From owner-svn-src-all@freebsd.org Sun Oct 9 03:20:59 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id BC09EAF7D05; Sun, 9 Oct 2016 03:20:59 +0000 (UTC) (envelope-from allanjude@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 8815C1A40; Sun, 9 Oct 2016 03:20:59 +0000 (UTC) (envelope-from allanjude@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u993KwZS008495; Sun, 9 Oct 2016 03:20:58 GMT (envelope-from allanjude@FreeBSD.org) Received: (from allanjude@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u993KwVD008493; Sun, 9 Oct 2016 03:20:58 GMT (envelope-from allanjude@FreeBSD.org) Message-Id: <201610090320.u993KwVD008493@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: allanjude set sender to allanjude@FreeBSD.org using -f From: Allan Jude Date: Sun, 9 Oct 2016 03:20:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r306896 - head/sbin/ifconfig X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 09 Oct 2016 03:20:59 -0000 Author: allanjude Date: Sun Oct 9 03:20:58 2016 New Revision: 306896 URL: https://svnweb.freebsd.org/changeset/base/306896 Log: Fix spurious white space introduced in r301059 r301059 accidently introduced a subtle change for point to point interfaces where an extra space is inserted before the netmask. This can cause issues for scripts that parse ifconfig output. Submitted by: Kevin Bowling Reviewed by: hiren MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D8199 Modified: head/sbin/ifconfig/af_inet.c head/sbin/ifconfig/af_inet6.c Modified: head/sbin/ifconfig/af_inet.c ============================================================================== --- head/sbin/ifconfig/af_inet.c Sun Oct 9 01:58:29 2016 (r306895) +++ head/sbin/ifconfig/af_inet.c Sun Oct 9 03:20:58 2016 (r306896) @@ -88,7 +88,7 @@ in_status(int s __unused, const struct i sin = (struct sockaddr_in *)ifa->ifa_dstaddr; if (sin == NULL) sin = &null_sin; - printf(" --> %s ", inet_ntoa(sin->sin_addr)); + printf(" --> %s", inet_ntoa(sin->sin_addr)); } sin = (struct sockaddr_in *)ifa->ifa_netmask; Modified: head/sbin/ifconfig/af_inet6.c ============================================================================== --- head/sbin/ifconfig/af_inet6.c Sun Oct 9 01:58:29 2016 (r306895) +++ head/sbin/ifconfig/af_inet6.c Sun Oct 9 03:20:58 2016 (r306896) @@ -237,7 +237,7 @@ in6_status(int s __unused, const struct if (error != 0) inet_ntop(AF_INET6, &sin->sin6_addr, addr_buf, sizeof(addr_buf)); - printf(" --> %s ", addr_buf); + printf(" --> %s", addr_buf); } } From owner-svn-src-all@freebsd.org Sun Oct 9 04:29:44 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 1298CC076A4; Sun, 9 Oct 2016 04:29:44 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id C7A89FE7; Sun, 9 Oct 2016 04:29:43 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u994TgPY031695; Sun, 9 Oct 2016 04:29:42 GMT (envelope-from gonzo@FreeBSD.org) Received: (from gonzo@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u994TgoR031694; Sun, 9 Oct 2016 04:29:42 GMT (envelope-from gonzo@FreeBSD.org) Message-Id: <201610090429.u994TgoR031694@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: gonzo set sender to gonzo@FreeBSD.org using -f From: Oleksandr Tymoshenko Date: Sun, 9 Oct 2016 04:29:42 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r306897 - head/sys/arm/nvidia X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 09 Oct 2016 04:29:44 -0000 Author: gonzo Date: Sun Oct 9 04:29:42 2016 New Revision: 306897 URL: https://svnweb.freebsd.org/changeset/base/306897 Log: Fix MSI allocation for NVidia Tegra - Fix range check - Due to checking found value in for(;;) condition irq after loop was always + 1 from actually found slot and wrong entry was marked as used which lead to returning slot 0 for all requests. Modified: head/sys/arm/nvidia/tegra_pcie.c Modified: head/sys/arm/nvidia/tegra_pcie.c ============================================================================== --- head/sys/arm/nvidia/tegra_pcie.c Sun Oct 9 03:20:58 2016 (r306896) +++ head/sys/arm/nvidia/tegra_pcie.c Sun Oct 9 04:29:42 2016 (r306897) @@ -710,7 +710,7 @@ tegra_pcib_msi_alloc_msi(device_t dev, d mtx_lock(&sc->mtx); found = false; - for (irq = 0; irq < TEGRA_PCIB_MAX_MSI && !found; irq++) { + for (irq = 0; (irq + count - 1) < TEGRA_PCIB_MAX_MSI; irq++) { /* Start on an aligned interrupt */ if ((irq & (maxcount - 1)) != 0) continue; @@ -719,20 +719,17 @@ tegra_pcib_msi_alloc_msi(device_t dev, d found = true; /* Check this range is valid */ - for (end_irq = irq; end_irq != irq + count - 1; end_irq++) { - /* No free interrupts */ - if (end_irq == (TEGRA_PCIB_MAX_MSI - 1)) { - found = false; - break; - } - + for (end_irq = irq; end_irq < irq + count; end_irq++) { /* This is already used */ - if ((sc->isrcs[irq].flags & TEGRA_FLAG_MSI_USED) == + if ((sc->isrcs[end_irq].flags & TEGRA_FLAG_MSI_USED) == TEGRA_FLAG_MSI_USED) { found = false; break; } } + + if (found) + break; } /* Not enough interrupts were found */ From owner-svn-src-all@freebsd.org Sun Oct 9 04:36:42 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 44133C0782D; Sun, 9 Oct 2016 04:36:42 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 0B14B785; Sun, 9 Oct 2016 04:36:41 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u994afge035455; Sun, 9 Oct 2016 04:36:41 GMT (envelope-from gonzo@FreeBSD.org) Received: (from gonzo@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u994afTR035454; Sun, 9 Oct 2016 04:36:41 GMT (envelope-from gonzo@FreeBSD.org) Message-Id: <201610090436.u994afTR035454@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: gonzo set sender to gonzo@FreeBSD.org using -f From: Oleksandr Tymoshenko Date: Sun, 9 Oct 2016 04:36:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r306898 - head/sys/arm/nvidia X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 09 Oct 2016 04:36:42 -0000 Author: gonzo Date: Sun Oct 9 04:36:40 2016 New Revision: 306898 URL: https://svnweb.freebsd.org/changeset/base/306898 Log: Fix release MSI method for NVidia Tegra PCI controller Modified: head/sys/arm/nvidia/tegra_pcie.c Modified: head/sys/arm/nvidia/tegra_pcie.c ============================================================================== --- head/sys/arm/nvidia/tegra_pcie.c Sun Oct 9 04:29:42 2016 (r306897) +++ head/sys/arm/nvidia/tegra_pcie.c Sun Oct 9 04:36:40 2016 (r306898) @@ -762,15 +762,15 @@ tegra_pcib_msi_release_msi(device_t dev, sc = device_get_softc(dev); mtx_lock(&sc->mtx); for (i = 0; i < count; i++) { - ti = (struct tegra_pcib_irqsrc *)isrc; + ti = (struct tegra_pcib_irqsrc *)isrc[i]; KASSERT((ti->flags & TEGRA_FLAG_MSI_USED) == TEGRA_FLAG_MSI_USED, ("%s: Trying to release an unused MSI-X interrupt", __func__)); ti->flags &= ~TEGRA_FLAG_MSI_USED; - mtx_unlock(&sc->mtx); } + mtx_unlock(&sc->mtx); return (0); } From owner-svn-src-all@freebsd.org Sun Oct 9 04:37:23 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 403D8C0787F; Sun, 9 Oct 2016 04:37:23 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 0FA88901; Sun, 9 Oct 2016 04:37:22 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u994bMFb035523; Sun, 9 Oct 2016 04:37:22 GMT (envelope-from gonzo@FreeBSD.org) Received: (from gonzo@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u994bMOP035522; Sun, 9 Oct 2016 04:37:22 GMT (envelope-from gonzo@FreeBSD.org) Message-Id: <201610090437.u994bMOP035522@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: gonzo set sender to gonzo@FreeBSD.org using -f From: Oleksandr Tymoshenko Date: Sun, 9 Oct 2016 04:37:22 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r306899 - head/sys/arm/arm X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 09 Oct 2016 04:37:23 -0000 Author: gonzo Date: Sun Oct 9 04:37:21 2016 New Revision: 306899 URL: https://svnweb.freebsd.org/changeset/base/306899 Log: Fix release MSI method for ARM GIC Modified: head/sys/arm/arm/gic.c Modified: head/sys/arm/arm/gic.c ============================================================================== --- head/sys/arm/arm/gic.c Sun Oct 9 04:36:40 2016 (r306898) +++ head/sys/arm/arm/gic.c Sun Oct 9 04:37:21 2016 (r306899) @@ -1474,15 +1474,15 @@ arm_gicv2m_release_msi(device_t dev, dev mtx_lock(&sc->sc_mutex); for (i = 0; i < count; i++) { - gi = (struct gic_irqsrc *)isrc; + gi = (struct gic_irqsrc *)isrc[i]; KASSERT((gi->gi_flags & GI_FLAG_MSI_USED) == GI_FLAG_MSI_USED, ("%s: Trying to release an unused MSI-X interrupt", __func__)); gi->gi_flags &= ~GI_FLAG_MSI_USED; - mtx_unlock(&sc->sc_mutex); } + mtx_unlock(&sc->sc_mutex); return (0); } From owner-svn-src-all@freebsd.org Sun Oct 9 10:21:29 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 6FD8FC07373; Sun, 9 Oct 2016 10:21:29 +0000 (UTC) (envelope-from avos@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 416C024C; Sun, 9 Oct 2016 10:21:29 +0000 (UTC) (envelope-from avos@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u99ALS0K066768; Sun, 9 Oct 2016 10:21:28 GMT (envelope-from avos@FreeBSD.org) Received: (from avos@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u99ALSDM066767; Sun, 9 Oct 2016 10:21:28 GMT (envelope-from avos@FreeBSD.org) Message-Id: <201610091021.u99ALSDM066767@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avos set sender to avos@FreeBSD.org using -f From: Andriy Voskoboinyk Date: Sun, 9 Oct 2016 10:21:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r306900 - head/sys/dev/iwm X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 09 Oct 2016 10:21:29 -0000 Author: avos Date: Sun Oct 9 10:21:28 2016 New Revision: 306900 URL: https://svnweb.freebsd.org/changeset/base/306900 Log: iwm: add missing 'Rx errors' counter incrementation. Modified: head/sys/dev/iwm/if_iwm.c Modified: head/sys/dev/iwm/if_iwm.c ============================================================================== --- head/sys/dev/iwm/if_iwm.c Sun Oct 9 04:37:21 2016 (r306899) +++ head/sys/dev/iwm/if_iwm.c Sun Oct 9 10:21:28 2016 (r306900) @@ -2918,14 +2918,14 @@ iwm_mvm_rx_rx_mpdu(struct iwm_softc *sc, device_printf(sc->sc_dev, "dsp size out of range [0,20]: %d\n", phy_info->cfg_phy_cnt); - return; + goto fail; } if (!(rx_pkt_status & IWM_RX_MPDU_RES_STATUS_CRC_OK) || !(rx_pkt_status & IWM_RX_MPDU_RES_STATUS_OVERRUN_OK)) { IWM_DPRINTF(sc, IWM_DEBUG_RECV, "Bad CRC or FIFO: 0x%08X.\n", rx_pkt_status); - return; /* drop */ + goto fail; } if (sc->sc_capaflags & IWM_UCODE_TLV_FLAGS_RX_ENERGY_API) { @@ -2947,7 +2947,7 @@ iwm_mvm_rx_rx_mpdu(struct iwm_softc *sc, if (iwm_rx_addbuf(sc, IWM_RBUF_SIZE, sc->rxq.cur) != 0) { device_printf(sc->sc_dev, "%s: unable to add more buffers\n", __func__); - return; + goto fail; } IWM_DPRINTF(sc, IWM_DEBUG_RECV, @@ -3020,6 +3020,10 @@ iwm_mvm_rx_rx_mpdu(struct iwm_softc *sc, ieee80211_input_mimo_all(ic, m, &rxs); } IWM_LOCK(sc); + + return; + +fail: counter_u64_add(ic->ic_ierrors, 1); } static int From owner-svn-src-all@freebsd.org Sun Oct 9 10:24:11 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A4817C074C5; Sun, 9 Oct 2016 10:24:11 +0000 (UTC) (envelope-from mmel@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 3EB386C2; Sun, 9 Oct 2016 10:24:11 +0000 (UTC) (envelope-from mmel@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u99AOAmK067510; Sun, 9 Oct 2016 10:24:10 GMT (envelope-from mmel@FreeBSD.org) Received: (from mmel@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u99AOAOC067506; Sun, 9 Oct 2016 10:24:10 GMT (envelope-from mmel@FreeBSD.org) Message-Id: <201610091024.u99AOAOC067506@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mmel set sender to mmel@FreeBSD.org using -f From: Michal Meloun Date: Sun, 9 Oct 2016 10:24:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r306901 - in head/sys: arm/arm arm/include conf X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 09 Oct 2016 10:24:11 -0000 Author: mmel Date: Sun Oct 9 10:24:10 2016 New Revision: 306901 URL: https://svnweb.freebsd.org/changeset/base/306901 Log: ARM: Split identify_arm_cpu() into ARMv4 and ARMv6 variant. On ARMv6, be more verbose about supported CPU features and/or optional instructions. Added: head/sys/arm/arm/identcpu-v4.c - copied, changed from r306899, head/sys/arm/arm/identcpu.c head/sys/arm/arm/identcpu-v6.c - copied, changed from r306900, head/sys/arm/arm/identcpu.c Deleted: head/sys/arm/arm/identcpu.c Modified: head/sys/arm/arm/cpuinfo.c head/sys/arm/include/cpuinfo.h head/sys/conf/files.arm Modified: head/sys/arm/arm/cpuinfo.c ============================================================================== --- head/sys/arm/arm/cpuinfo.c Sun Oct 9 10:21:28 2016 (r306900) +++ head/sys/arm/arm/cpuinfo.c Sun Oct 9 10:24:10 2016 (r306901) @@ -111,6 +111,10 @@ cpuinfo_init(void) /* Not yet - CBAR only exist on ARM SMP Cortex A CPUs cpuinfo.cbar = cp15_cbar_get(); */ + if (CPU_CT_FORMAT(cpuinfo.ctr) == CPU_CT_ARMV7) { + cpuinfo.ccsidr = cp15_ccsidr_get(); + cpuinfo.clidr = cp15_clidr_get(); + } /* Test if revidr is implemented */ if (cpuinfo.revidr == cpuinfo.midr) @@ -165,6 +169,7 @@ cpuinfo_get_actlr_modifier(uint32_t *act if (cpuinfo.implementer == CPU_IMPLEMENTER_ARM) { switch (cpuinfo.part_number) { + case CPU_ARCH_CORTEX_A73: case CPU_ARCH_CORTEX_A72: case CPU_ARCH_CORTEX_A57: case CPU_ARCH_CORTEX_A53: Copied and modified: head/sys/arm/arm/identcpu-v4.c (from r306899, head/sys/arm/arm/identcpu.c) ============================================================================== --- head/sys/arm/arm/identcpu.c Sun Oct 9 04:37:21 2016 (r306899, copy source) +++ head/sys/arm/arm/identcpu-v4.c Sun Oct 9 10:24:10 2016 (r306901) @@ -45,9 +45,6 @@ __FBSDID("$FreeBSD$"); #include #include -#include -#include -#include #include #include #include @@ -169,39 +166,6 @@ const struct cpuidtab cpuids[] = { { CPU_ID_ARM1026EJS, CPU_CLASS_ARM10EJ, "ARM1026EJ-S", generic_steppings }, - { CPU_ID_CORTEXA5, CPU_CLASS_CORTEXA, "Cortex A5", - generic_steppings }, - { CPU_ID_CORTEXA7, CPU_CLASS_CORTEXA, "Cortex A7", - generic_steppings }, - { CPU_ID_CORTEXA8R1, CPU_CLASS_CORTEXA, "Cortex A8-r1", - generic_steppings }, - { CPU_ID_CORTEXA8R2, CPU_CLASS_CORTEXA, "Cortex A8-r2", - generic_steppings }, - { CPU_ID_CORTEXA8R3, CPU_CLASS_CORTEXA, "Cortex A8-r3", - generic_steppings }, - { CPU_ID_CORTEXA9R1, CPU_CLASS_CORTEXA, "Cortex A9-r1", - generic_steppings }, - { CPU_ID_CORTEXA9R2, CPU_CLASS_CORTEXA, "Cortex A9-r2", - generic_steppings }, - { CPU_ID_CORTEXA9R3, CPU_CLASS_CORTEXA, "Cortex A9-r3", - generic_steppings }, - { CPU_ID_CORTEXA9R4, CPU_CLASS_CORTEXA, "Cortex A9-r4", - generic_steppings }, - { CPU_ID_CORTEXA12R0, CPU_CLASS_CORTEXA, "Cortex A12-r0", - generic_steppings }, - { CPU_ID_CORTEXA15R0, CPU_CLASS_CORTEXA, "Cortex A15-r0", - generic_steppings }, - { CPU_ID_CORTEXA15R1, CPU_CLASS_CORTEXA, "Cortex A15-r1", - generic_steppings }, - { CPU_ID_CORTEXA15R2, CPU_CLASS_CORTEXA, "Cortex A15-r2", - generic_steppings }, - { CPU_ID_CORTEXA15R3, CPU_CLASS_CORTEXA, "Cortex A15-r3", - generic_steppings }, - { CPU_ID_KRAIT300R0, CPU_CLASS_KRAIT, "Krait 300-r0", - generic_steppings }, - { CPU_ID_KRAIT300R1, CPU_CLASS_KRAIT, "Krait 300-r1", - generic_steppings }, - { CPU_ID_80200, CPU_CLASS_XSCALE, "i80200", xscale_steppings }, @@ -248,24 +212,11 @@ const struct cpuidtab cpuids[] = { { CPU_ID_IXP435, CPU_CLASS_XSCALE, "IXP435", ixp425_steppings }, - { CPU_ID_ARM1136JS, CPU_CLASS_ARM11J, "ARM1136J-S", - generic_steppings }, - { CPU_ID_ARM1136JSR1, CPU_CLASS_ARM11J, "ARM1136J-S R1", - generic_steppings }, - { CPU_ID_ARM1176JZS, CPU_CLASS_ARM11J, "ARM1176JZ-S", - generic_steppings }, - { CPU_ID_MV88FR131, CPU_CLASS_MARVELL, "Feroceon 88FR131", generic_steppings }, { CPU_ID_MV88FR571_VD, CPU_CLASS_MARVELL, "Feroceon 88FR571-VD", generic_steppings }, - { CPU_ID_MV88SV581X_V7, CPU_CLASS_MARVELL, "Sheeva 88SV581x", - generic_steppings }, - { CPU_ID_ARM_88SV581X_V7, CPU_CLASS_MARVELL, "Sheeva 88SV581x", - generic_steppings }, - { CPU_ID_MV88SV584X_V7, CPU_CLASS_MARVELL, "Sheeva 88SV584x", - generic_steppings }, { 0, CPU_CLASS_NONE, NULL, NULL } }; @@ -282,10 +233,7 @@ const struct cpu_classtab cpu_classes[] { "ARM9EJ-S", "CPU_ARM9E" }, /* CPU_CLASS_ARM9EJS */ { "ARM10E", "CPU_ARM10" }, /* CPU_CLASS_ARM10E */ { "ARM10EJ", "CPU_ARM10" }, /* CPU_CLASS_ARM10EJ */ - { "Cortex-A", "CPU_CORTEXA" }, /* CPU_CLASS_CORTEXA */ - { "Krait", "CPU_KRAIT" }, /* CPU_CLASS_KRAIT */ { "XScale", "CPU_XSCALE_..." }, /* CPU_CLASS_XSCALE */ - { "ARM11J", "CPU_ARM11" }, /* CPU_CLASS_ARM11J */ { "Marvell", "CPU_MARVELL" }, /* CPU_CLASS_MARVELL */ }; @@ -344,50 +292,11 @@ u_int cpu_pfr(int num) return (feat); } -static -void identify_armv7(void) -{ - u_int feature; - - printf("Supported features:"); - /* Get Processor Feature Register 0 */ - feature = cpu_pfr(0); - - if (feature & ARM_PFR0_ARM_ISA_MASK) - printf(" ARM_ISA"); - - if (feature & ARM_PFR0_THUMB2) - printf(" THUMB2"); - else if (feature & ARM_PFR0_THUMB) - printf(" THUMB"); - - if (feature & ARM_PFR0_JAZELLE_MASK) - printf(" JAZELLE"); - - if (feature & ARM_PFR0_THUMBEE_MASK) - printf(" THUMBEE"); - - - /* Get Processor Feature Register 1 */ - feature = cpu_pfr(1); - - if (feature & ARM_PFR1_ARMV4_MASK) - printf(" ARMv4"); - - if (feature & ARM_PFR1_SEC_EXT_MASK) - printf(" Security_Ext"); - - if (feature & ARM_PFR1_MICROCTRL_MASK) - printf(" M_profile"); - - printf("\n"); -} - void identify_arm_cpu(void) { - u_int cpuid, reg, size, sets, ways; - u_int8_t type, linesize, ctrl; + u_int cpuid; + u_int8_t ctrl; int i; ctrl = cpu_get_control(); @@ -413,43 +322,38 @@ identify_arm_cpu(void) printf(" "); - if ((cpuid & CPU_ID_ARCH_MASK) == CPU_ID_CPUID_SCHEME) { - identify_armv7(); - } else { - if (ctrl & CPU_CONTROL_BEND_ENABLE) - printf(" Big-endian"); - else - printf(" Little-endian"); - - switch (cpu_class) { - case CPU_CLASS_ARM9TDMI: - case CPU_CLASS_ARM9ES: - case CPU_CLASS_ARM9EJS: - case CPU_CLASS_ARM10E: - case CPU_CLASS_ARM10EJ: - case CPU_CLASS_XSCALE: - case CPU_CLASS_ARM11J: - case CPU_CLASS_MARVELL: - print_enadis(ctrl & CPU_CONTROL_DC_ENABLE, "DC"); - print_enadis(ctrl & CPU_CONTROL_IC_ENABLE, "IC"); + if (ctrl & CPU_CONTROL_BEND_ENABLE) + printf(" Big-endian"); + else + printf(" Little-endian"); + + switch (cpu_class) { + case CPU_CLASS_ARM9TDMI: + case CPU_CLASS_ARM9ES: + case CPU_CLASS_ARM9EJS: + case CPU_CLASS_ARM10E: + case CPU_CLASS_ARM10EJ: + case CPU_CLASS_XSCALE: + case CPU_CLASS_MARVELL: + print_enadis(ctrl & CPU_CONTROL_DC_ENABLE, "DC"); + print_enadis(ctrl & CPU_CONTROL_IC_ENABLE, "IC"); #ifdef CPU_XSCALE_81342 - print_enadis(ctrl & CPU_CONTROL_L2_ENABLE, "L2"); + print_enadis(ctrl & CPU_CONTROL_L2_ENABLE, "L2"); #endif #if defined(SOC_MV_KIRKWOOD) || defined(SOC_MV_DISCOVERY) - i = sheeva_control_ext(0, 0); - print_enadis(i & MV_WA_ENABLE, "WA"); - print_enadis(i & MV_DC_STREAM_ENABLE, "DC streaming"); - printf("\n "); - print_enadis((i & MV_BTB_DISABLE) == 0, "BTB"); - print_enadis(i & MV_L2_ENABLE, "L2"); - print_enadis((i & MV_L2_PREFETCH_DISABLE) == 0, - "L2 prefetch"); - printf("\n "); + i = sheeva_control_ext(0, 0); + print_enadis(i & MV_WA_ENABLE, "WA"); + print_enadis(i & MV_DC_STREAM_ENABLE, "DC streaming"); + printf("\n "); + print_enadis((i & MV_BTB_DISABLE) == 0, "BTB"); + print_enadis(i & MV_L2_ENABLE, "L2"); + print_enadis((i & MV_L2_PREFETCH_DISABLE) == 0, + "L2 prefetch"); + printf("\n "); #endif - break; - default: - break; - } + break; + default: + break; } print_enadis(ctrl & CPU_CONTROL_WBUF_ENABLE, "WB"); @@ -461,74 +365,22 @@ identify_arm_cpu(void) print_enadis(ctrl & CPU_CONTROL_BPRD_ENABLE, "branch prediction"); printf("\n"); - if (arm_cache_level) { - printf("LoUU:%d LoC:%d LoUIS:%d \n", CPU_CLIDR_LOUU(arm_cache_level) + 1, - arm_cache_loc + 1, CPU_CLIDR_LOUIS(arm_cache_level) + 1); - i = 0; - while (((type = CPU_CLIDR_CTYPE(arm_cache_level, i)) != 0) && i < 7) { - printf("Cache level %d: \n", i + 1); - if (type == CACHE_DCACHE || type == CACHE_UNI_CACHE || - type == CACHE_SEP_CACHE) { - reg = arm_cache_type[2 * i]; - ways = CPUV7_CT_xSIZE_ASSOC(reg) + 1; - sets = CPUV7_CT_xSIZE_SET(reg) + 1; - linesize = 1 << (CPUV7_CT_xSIZE_LEN(reg) + 4); - size = (ways * sets * linesize) / 1024; - - if (type == CACHE_UNI_CACHE) - printf(" %dKB/%dB %d-way unified cache", size, linesize,ways); - else - printf(" %dKB/%dB %d-way data cache", size, linesize, ways); - if (reg & CPUV7_CT_CTYPE_WT) - printf(" WT"); - if (reg & CPUV7_CT_CTYPE_WB) - printf(" WB"); - if (reg & CPUV7_CT_CTYPE_RA) - printf(" Read-Alloc"); - if (reg & CPUV7_CT_CTYPE_WA) - printf(" Write-Alloc"); - printf("\n"); - } - - if (type == CACHE_ICACHE || type == CACHE_SEP_CACHE) { - reg = arm_cache_type[(2 * i) + 1]; - - ways = CPUV7_CT_xSIZE_ASSOC(reg) + 1; - sets = CPUV7_CT_xSIZE_SET(reg) + 1; - linesize = 1 << (CPUV7_CT_xSIZE_LEN(reg) + 4); - size = (ways * sets * linesize) / 1024; - - printf(" %dKB/%dB %d-way instruction cache", size, linesize, ways); - if (reg & CPUV7_CT_CTYPE_WT) - printf(" WT"); - if (reg & CPUV7_CT_CTYPE_WB) - printf(" WB"); - if (reg & CPUV7_CT_CTYPE_RA) - printf(" Read-Alloc"); - if (reg & CPUV7_CT_CTYPE_WA) - printf(" Write-Alloc"); - printf("\n"); - } - i++; - } + /* Print cache info. */ + if (arm_picache_line_size == 0 && arm_pdcache_line_size == 0) + return; + + if (arm_pcache_unified) { + printf(" %dKB/%dB %d-way %s unified cache\n", + arm_pdcache_size / 1024, + arm_pdcache_line_size, arm_pdcache_ways, + wtnames[arm_pcache_type]); } else { - /* Print cache info. */ - if (arm_picache_line_size == 0 && arm_pdcache_line_size == 0) - return; - - if (arm_pcache_unified) { - printf(" %dKB/%dB %d-way %s unified cache\n", - arm_pdcache_size / 1024, - arm_pdcache_line_size, arm_pdcache_ways, - wtnames[arm_pcache_type]); - } else { - printf(" %dKB/%dB %d-way instruction cache\n", - arm_picache_size / 1024, - arm_picache_line_size, arm_picache_ways); - printf(" %dKB/%dB %d-way %s data cache\n", - arm_pdcache_size / 1024, - arm_pdcache_line_size, arm_pdcache_ways, - wtnames[arm_pcache_type]); - } + printf(" %dKB/%dB %d-way instruction cache\n", + arm_picache_size / 1024, + arm_picache_line_size, arm_picache_ways); + printf(" %dKB/%dB %d-way %s data cache\n", + arm_pdcache_size / 1024, + arm_pdcache_line_size, arm_pdcache_ways, + wtnames[arm_pcache_type]); } } Copied and modified: head/sys/arm/arm/identcpu-v6.c (from r306900, head/sys/arm/arm/identcpu.c) ============================================================================== --- head/sys/arm/arm/identcpu.c Sun Oct 9 10:21:28 2016 (r306900, copy source) +++ head/sys/arm/arm/identcpu-v6.c Sun Oct 9 10:24:10 2016 (r306901) @@ -45,16 +45,10 @@ __FBSDID("$FreeBSD$"); #include #include -#include -#include -#include #include #include #include #include -#include - -#include #include char machine[] = "arm"; @@ -62,473 +56,305 @@ char machine[] = "arm"; SYSCTL_STRING(_hw, HW_MACHINE, machine, CTLFLAG_RD, machine, 0, "Machine class"); -static const char * const generic_steppings[16] = { - "rev 0", "rev 1", "rev 2", "rev 3", - "rev 4", "rev 5", "rev 6", "rev 7", - "rev 8", "rev 9", "rev 10", "rev 11", - "rev 12", "rev 13", "rev 14", "rev 15", -}; - -static const char * const xscale_steppings[16] = { - "step A-0", "step A-1", "step B-0", "step C-0", - "step D-0", "rev 5", "rev 6", "rev 7", - "rev 8", "rev 9", "rev 10", "rev 11", - "rev 12", "rev 13", "rev 14", "rev 15", -}; - -static const char * const i80219_steppings[16] = { - "step A-0", "rev 1", "rev 2", "rev 3", - "rev 4", "rev 5", "rev 6", "rev 7", - "rev 8", "rev 9", "rev 10", "rev 11", - "rev 12", "rev 13", "rev 14", "rev 15", -}; - -static const char * const i80321_steppings[16] = { - "step A-0", "step B-0", "rev 2", "rev 3", - "rev 4", "rev 5", "rev 6", "rev 7", - "rev 8", "rev 9", "rev 10", "rev 11", - "rev 12", "rev 13", "rev 14", "rev 15", -}; - -static const char * const i81342_steppings[16] = { - "step A-0", "rev 1", "rev 2", "rev 3", - "rev 4", "rev 5", "rev 6", "rev 7", - "rev 8", "rev 9", "rev 10", "rev 11", - "rev 12", "rev 13", "rev 14", "rev 15", -}; +static char hw_buf[81]; +static int hw_buf_idx; +static bool hw_buf_newline; + +static struct { + int implementer; + int part_number; + char *impl_name; + char *core_name; +} cpu_names[] = { + {CPU_IMPLEMENTER_ARM, CPU_ARCH_ARM1176, "ARM", "ARM1176"}, + {CPU_IMPLEMENTER_ARM, CPU_ARCH_CORTEX_A5 , "ARM", "Cortex-A5"}, + {CPU_IMPLEMENTER_ARM, CPU_ARCH_CORTEX_A7 , "ARM", "Cortex-A7"}, + {CPU_IMPLEMENTER_ARM, CPU_ARCH_CORTEX_A8 , "ARM", "Cortex-A8"}, + {CPU_IMPLEMENTER_ARM, CPU_ARCH_CORTEX_A9 , "ARM", "Cortex-A9"}, + {CPU_IMPLEMENTER_ARM, CPU_ARCH_CORTEX_A12, "ARM", "Cortex-A12"}, + {CPU_IMPLEMENTER_ARM, CPU_ARCH_CORTEX_A15, "ARM", "Cortex-A15"}, + {CPU_IMPLEMENTER_ARM, CPU_ARCH_CORTEX_A17, "ARM", "Cortex-A17"}, + {CPU_IMPLEMENTER_ARM, CPU_ARCH_CORTEX_A53, "ARM", "Cortex-A53"}, + {CPU_IMPLEMENTER_ARM, CPU_ARCH_CORTEX_A57, "ARM", "Cortex-A57"}, + {CPU_IMPLEMENTER_ARM, CPU_ARCH_CORTEX_A72, "ARM", "Cortex-A72"}, + {CPU_IMPLEMENTER_ARM, CPU_ARCH_CORTEX_A73, "ARM", "Cortex-A73"}, -/* Steppings for PXA2[15]0 */ -static const char * const pxa2x0_steppings[16] = { - "step A-0", "step A-1", "step B-0", "step B-1", - "step B-2", "step C-0", "rev 6", "rev 7", - "rev 8", "rev 9", "rev 10", "rev 11", - "rev 12", "rev 13", "rev 14", "rev 15", -}; + {CPU_IMPLEMENTER_MRVL, CPU_ARCH_SHEEVA_581, "Marwell", "PJ4 v7"}, + {CPU_IMPLEMENTER_MRVL, CPU_ARCH_SHEEVA_584, "Marwell", "PJ4MP v7"}, -/* Steppings for PXA255/26x. - * rev 5: PXA26x B0, rev 6: PXA255 A0 - */ -static const char * const pxa255_steppings[16] = { - "rev 0", "rev 1", "rev 2", "step A-0", - "rev 4", "step B-0", "step A-0", "rev 7", - "rev 8", "rev 9", "rev 10", "rev 11", - "rev 12", "rev 13", "rev 14", "rev 15", + {CPU_IMPLEMENTER_QCOM, CPU_ARCH_KRAIT_300, "Qualcomm", "Krait 300"}, }; -/* Stepping for PXA27x */ -static const char * const pxa27x_steppings[16] = { - "step A-0", "step A-1", "step B-0", "step B-1", - "step C-0", "rev 5", "rev 6", "rev 7", - "rev 8", "rev 9", "rev 10", "rev 11", - "rev 12", "rev 13", "rev 14", "rev 15", -}; - -static const char * const ixp425_steppings[16] = { - "step 0 (A0)", "rev 1 (ARMv5TE)", "rev 2", "rev 3", - "rev 4", "rev 5", "rev 6", "rev 7", - "rev 8", "rev 9", "rev 10", "rev 11", - "rev 12", "rev 13", "rev 14", "rev 15", -}; - -struct cpuidtab { - u_int32_t cpuid; - enum cpu_class cpu_class; - const char *cpu_name; - const char * const *cpu_steppings; -}; - -const struct cpuidtab cpuids[] = { - { CPU_ID_ARM920T, CPU_CLASS_ARM9TDMI, "ARM920T", - generic_steppings }, - { CPU_ID_ARM920T_ALT, CPU_CLASS_ARM9TDMI, "ARM920T", - generic_steppings }, - { CPU_ID_ARM922T, CPU_CLASS_ARM9TDMI, "ARM922T", - generic_steppings }, - { CPU_ID_ARM926EJS, CPU_CLASS_ARM9EJS, "ARM926EJ-S", - generic_steppings }, - { CPU_ID_ARM940T, CPU_CLASS_ARM9TDMI, "ARM940T", - generic_steppings }, - { CPU_ID_ARM946ES, CPU_CLASS_ARM9ES, "ARM946E-S", - generic_steppings }, - { CPU_ID_ARM966ES, CPU_CLASS_ARM9ES, "ARM966E-S", - generic_steppings }, - { CPU_ID_ARM966ESR1, CPU_CLASS_ARM9ES, "ARM966E-S", - generic_steppings }, - { CPU_ID_FA526, CPU_CLASS_ARM9TDMI, "FA526", - generic_steppings }, - { CPU_ID_FA626TE, CPU_CLASS_ARM9ES, "FA626TE", - generic_steppings }, - - { CPU_ID_TI925T, CPU_CLASS_ARM9TDMI, "TI ARM925T", - generic_steppings }, - - { CPU_ID_ARM1020E, CPU_CLASS_ARM10E, "ARM1020E", - generic_steppings }, - { CPU_ID_ARM1022ES, CPU_CLASS_ARM10E, "ARM1022E-S", - generic_steppings }, - { CPU_ID_ARM1026EJS, CPU_CLASS_ARM10EJ, "ARM1026EJ-S", - generic_steppings }, - - { CPU_ID_CORTEXA5, CPU_CLASS_CORTEXA, "Cortex A5", - generic_steppings }, - { CPU_ID_CORTEXA7, CPU_CLASS_CORTEXA, "Cortex A7", - generic_steppings }, - { CPU_ID_CORTEXA8R1, CPU_CLASS_CORTEXA, "Cortex A8-r1", - generic_steppings }, - { CPU_ID_CORTEXA8R2, CPU_CLASS_CORTEXA, "Cortex A8-r2", - generic_steppings }, - { CPU_ID_CORTEXA8R3, CPU_CLASS_CORTEXA, "Cortex A8-r3", - generic_steppings }, - { CPU_ID_CORTEXA9R1, CPU_CLASS_CORTEXA, "Cortex A9-r1", - generic_steppings }, - { CPU_ID_CORTEXA9R2, CPU_CLASS_CORTEXA, "Cortex A9-r2", - generic_steppings }, - { CPU_ID_CORTEXA9R3, CPU_CLASS_CORTEXA, "Cortex A9-r3", - generic_steppings }, - { CPU_ID_CORTEXA9R4, CPU_CLASS_CORTEXA, "Cortex A9-r4", - generic_steppings }, - { CPU_ID_CORTEXA12R0, CPU_CLASS_CORTEXA, "Cortex A12-r0", - generic_steppings }, - { CPU_ID_CORTEXA15R0, CPU_CLASS_CORTEXA, "Cortex A15-r0", - generic_steppings }, - { CPU_ID_CORTEXA15R1, CPU_CLASS_CORTEXA, "Cortex A15-r1", - generic_steppings }, - { CPU_ID_CORTEXA15R2, CPU_CLASS_CORTEXA, "Cortex A15-r2", - generic_steppings }, - { CPU_ID_CORTEXA15R3, CPU_CLASS_CORTEXA, "Cortex A15-r3", - generic_steppings }, - { CPU_ID_KRAIT300R0, CPU_CLASS_KRAIT, "Krait 300-r0", - generic_steppings }, - { CPU_ID_KRAIT300R1, CPU_CLASS_KRAIT, "Krait 300-r1", - generic_steppings }, - - { CPU_ID_80200, CPU_CLASS_XSCALE, "i80200", - xscale_steppings }, - - { CPU_ID_80321_400, CPU_CLASS_XSCALE, "i80321 400MHz", - i80321_steppings }, - { CPU_ID_80321_600, CPU_CLASS_XSCALE, "i80321 600MHz", - i80321_steppings }, - { CPU_ID_80321_400_B0, CPU_CLASS_XSCALE, "i80321 400MHz", - i80321_steppings }, - { CPU_ID_80321_600_B0, CPU_CLASS_XSCALE, "i80321 600MHz", - i80321_steppings }, - - { CPU_ID_81342, CPU_CLASS_XSCALE, "i81342", - i81342_steppings }, - - { CPU_ID_80219_400, CPU_CLASS_XSCALE, "i80219 400MHz", - i80219_steppings }, - { CPU_ID_80219_600, CPU_CLASS_XSCALE, "i80219 600MHz", - i80219_steppings }, - - { CPU_ID_PXA27X, CPU_CLASS_XSCALE, "PXA27x", - pxa27x_steppings }, - { CPU_ID_PXA250A, CPU_CLASS_XSCALE, "PXA250", - pxa2x0_steppings }, - { CPU_ID_PXA210A, CPU_CLASS_XSCALE, "PXA210", - pxa2x0_steppings }, - { CPU_ID_PXA250B, CPU_CLASS_XSCALE, "PXA250", - pxa2x0_steppings }, - { CPU_ID_PXA210B, CPU_CLASS_XSCALE, "PXA210", - pxa2x0_steppings }, - { CPU_ID_PXA250C, CPU_CLASS_XSCALE, "PXA255", - pxa255_steppings }, - { CPU_ID_PXA210C, CPU_CLASS_XSCALE, "PXA210", - pxa2x0_steppings }, - - { CPU_ID_IXP425_533, CPU_CLASS_XSCALE, "IXP425 533MHz", - ixp425_steppings }, - { CPU_ID_IXP425_400, CPU_CLASS_XSCALE, "IXP425 400MHz", - ixp425_steppings }, - { CPU_ID_IXP425_266, CPU_CLASS_XSCALE, "IXP425 266MHz", - ixp425_steppings }, - - /* XXX ixp435 steppings? */ - { CPU_ID_IXP435, CPU_CLASS_XSCALE, "IXP435", - ixp425_steppings }, - - { CPU_ID_ARM1136JS, CPU_CLASS_ARM11J, "ARM1136J-S", - generic_steppings }, - { CPU_ID_ARM1136JSR1, CPU_CLASS_ARM11J, "ARM1136J-S R1", - generic_steppings }, - { CPU_ID_ARM1176JZS, CPU_CLASS_ARM11J, "ARM1176JZ-S", - generic_steppings }, - - { CPU_ID_MV88FR131, CPU_CLASS_MARVELL, "Feroceon 88FR131", - generic_steppings }, - - { CPU_ID_MV88FR571_VD, CPU_CLASS_MARVELL, "Feroceon 88FR571-VD", - generic_steppings }, - { CPU_ID_MV88SV581X_V7, CPU_CLASS_MARVELL, "Sheeva 88SV581x", - generic_steppings }, - { CPU_ID_ARM_88SV581X_V7, CPU_CLASS_MARVELL, "Sheeva 88SV581x", - generic_steppings }, - { CPU_ID_MV88SV584X_V7, CPU_CLASS_MARVELL, "Sheeva 88SV584x", - generic_steppings }, - - { 0, CPU_CLASS_NONE, NULL, NULL } -}; - -struct cpu_classtab { - const char *class_name; - const char *class_option; -}; - -const struct cpu_classtab cpu_classes[] = { - { "unknown", NULL }, /* CPU_CLASS_NONE */ - { "ARM9TDMI", "CPU_ARM9TDMI" }, /* CPU_CLASS_ARM9TDMI */ - { "ARM9E-S", "CPU_ARM9E" }, /* CPU_CLASS_ARM9ES */ - { "ARM9EJ-S", "CPU_ARM9E" }, /* CPU_CLASS_ARM9EJS */ - { "ARM10E", "CPU_ARM10" }, /* CPU_CLASS_ARM10E */ - { "ARM10EJ", "CPU_ARM10" }, /* CPU_CLASS_ARM10EJ */ - { "Cortex-A", "CPU_CORTEXA" }, /* CPU_CLASS_CORTEXA */ - { "Krait", "CPU_KRAIT" }, /* CPU_CLASS_KRAIT */ - { "XScale", "CPU_XSCALE_..." }, /* CPU_CLASS_XSCALE */ - { "ARM11J", "CPU_ARM11" }, /* CPU_CLASS_ARM11J */ - { "Marvell", "CPU_MARVELL" }, /* CPU_CLASS_MARVELL */ -}; - -/* - * Report the type of the specified arm processor. This uses the generic and - * arm specific information in the cpu structure to identify the processor. - * The remaining fields in the cpu structure are filled in appropriately. - */ - -static const char * const wtnames[] = { - "write-through", - "write-back", - "write-back", - "**unknown 3**", - "**unknown 4**", - "write-back-locking", /* XXX XScale-specific? */ - "write-back-locking-A", - "write-back-locking-B", - "**unknown 8**", - "**unknown 9**", - "**unknown 10**", - "**unknown 11**", - "**unknown 12**", - "**unknown 13**", - "write-back-locking-C", - "**unknown 15**", -}; static void -print_enadis(int enadis, char *s) +print_v5_cache(void) { + uint32_t isize, dsize; + uint32_t multiplier; + int pcache_type; + int pcache_unified; + int picache_size; + int picache_line_size; + int picache_ways; + int pdcache_size; + int pdcache_line_size; + int pdcache_ways; + + pcache_unified = 0; + picache_size = 0 ; + picache_line_size = 0 ; + picache_ways = 0 ; + pdcache_size = 0; + pdcache_line_size = 0; + pdcache_ways = 0; + + if ((cpuinfo.ctr & CPU_CT_S) == 0) + pcache_unified = 1; + + /* + * If you want to know how this code works, go read the ARM ARM. + */ + pcache_type = CPU_CT_CTYPE(cpuinfo.ctr); + + if (pcache_unified == 0) { + isize = CPU_CT_ISIZE(cpuinfo.ctr); + multiplier = (isize & CPU_CT_xSIZE_M) ? 3 : 2; + picache_line_size = 1U << (CPU_CT_xSIZE_LEN(isize) + 3); + if (CPU_CT_xSIZE_ASSOC(isize) == 0) { + if (isize & CPU_CT_xSIZE_M) + picache_line_size = 0; /* not present */ + else + picache_ways = 1; + } else { + picache_ways = multiplier << + (CPU_CT_xSIZE_ASSOC(isize) - 1); + } + picache_size = multiplier << (CPU_CT_xSIZE_SIZE(isize) + 8); + } - printf(" %s %sabled", s, (enadis == 0) ? "dis" : "en"); -} + dsize = CPU_CT_DSIZE(cpuinfo.ctr); + multiplier = (dsize & CPU_CT_xSIZE_M) ? 3 : 2; + pdcache_line_size = 1U << (CPU_CT_xSIZE_LEN(dsize) + 3); + if (CPU_CT_xSIZE_ASSOC(dsize) == 0) { + if (dsize & CPU_CT_xSIZE_M) + pdcache_line_size = 0; /* not present */ + else + pdcache_ways = 1; + } else { + pdcache_ways = multiplier << + (CPU_CT_xSIZE_ASSOC(dsize) - 1); + } + pdcache_size = multiplier << (CPU_CT_xSIZE_SIZE(dsize) + 8); -enum cpu_class cpu_class = CPU_CLASS_NONE; -u_int cpu_pfr(int num) -{ - u_int feat; + /* Print cache info. */ + if (picache_line_size == 0 && pdcache_line_size == 0) + return; - switch (num) { - case 0: - __asm __volatile("mrc p15, 0, %0, c0, c1, 0" - : "=r" (feat)); - break; - case 1: - __asm __volatile("mrc p15, 0, %0, c0, c1, 1" - : "=r" (feat)); - break; - default: - panic("Processor Feature Register %d not implemented", num); - break; + if (pcache_unified) { + printf(" %dKB/%dB %d-way %s unified cache\n", + pdcache_size / 1024, + pdcache_line_size, pdcache_ways, + pcache_type == 0 ? "WT" : "WB"); + } else { + printf(" %dKB/%dB %d-way instruction cache\n", + picache_size / 1024, + picache_line_size, picache_ways); + printf(" %dKB/%dB %d-way %s data cache\n", + pdcache_size / 1024, + pdcache_line_size, pdcache_ways, + pcache_type == 0 ? "WT" : "WB"); } - - return (feat); } -static -void identify_armv7(void) +static void +print_v7_cache(void ) { - u_int feature; - - printf("Supported features:"); - /* Get Processor Feature Register 0 */ - feature = cpu_pfr(0); - - if (feature & ARM_PFR0_ARM_ISA_MASK) - printf(" ARM_ISA"); - - if (feature & ARM_PFR0_THUMB2) - printf(" THUMB2"); - else if (feature & ARM_PFR0_THUMB) - printf(" THUMB"); - - if (feature & ARM_PFR0_JAZELLE_MASK) - printf(" JAZELLE"); + uint32_t type, val, size, sets, ways, linesize; + int i; - if (feature & ARM_PFR0_THUMBEE_MASK) - printf(" THUMBEE"); + printf("LoUU:%d LoC:%d LoUIS:%d \n", + CPU_CLIDR_LOUU(cpuinfo.clidr) + 1, + CPU_CLIDR_LOC(cpuinfo.clidr) + 1, + CPU_CLIDR_LOUIS(cpuinfo.clidr) + 1); + + for (i = 0; i < 7; i++) { + type = CPU_CLIDR_CTYPE(cpuinfo.clidr, i); + if (type == 0) + break; + printf("Cache level %d:\n", i + 1); + if (type == CACHE_DCACHE || type == CACHE_UNI_CACHE || + type == CACHE_SEP_CACHE) { + cp15_csselr_set(i << 1); + val = cp15_ccsidr_get(); + ways = CPUV7_CT_xSIZE_ASSOC(val) + 1; + sets = CPUV7_CT_xSIZE_SET(val) + 1; + linesize = 1 << (CPUV7_CT_xSIZE_LEN(val) + 4); + size = (ways * sets * linesize) / 1024; + + if (type == CACHE_UNI_CACHE) + printf(" %dKB/%dB %d-way unified cache", + size, linesize,ways); + else + printf(" %dKB/%dB %d-way data cache", + size, linesize, ways); + if (val & CPUV7_CT_CTYPE_WT) + printf(" WT"); + if (val & CPUV7_CT_CTYPE_WB) + printf(" WB"); + if (val & CPUV7_CT_CTYPE_RA) + printf(" Read-Alloc"); + if (val & CPUV7_CT_CTYPE_WA) + printf(" Write-Alloc"); + printf("\n"); + } + if (type == CACHE_ICACHE || type == CACHE_SEP_CACHE) { + cp15_csselr_set(i << 1 | 1); + val = cp15_ccsidr_get(); + ways = CPUV7_CT_xSIZE_ASSOC(val) + 1; + sets = CPUV7_CT_xSIZE_SET(val) + 1; + linesize = 1 << (CPUV7_CT_xSIZE_LEN(val) + 4); + size = (ways * sets * linesize) / 1024; + printf(" %dKB/%dB %d-way instruction cache", + size, linesize, ways); + if (val & CPUV7_CT_CTYPE_WT) + printf(" WT"); + if (val & CPUV7_CT_CTYPE_WB) + printf(" WB"); + if (val & CPUV7_CT_CTYPE_RA) + printf(" Read-Alloc"); + if (val & CPUV7_CT_CTYPE_WA) + printf(" Write-Alloc"); + printf("\n"); + } + } + cp15_csselr_set(0); +} - /* Get Processor Feature Register 1 */ - feature = cpu_pfr(1); +static void +add_cap(char *cap) +{ + int len; - if (feature & ARM_PFR1_ARMV4_MASK) - printf(" ARMv4"); + len = strlen(cap); - if (feature & ARM_PFR1_SEC_EXT_MASK) - printf(" Security_Ext"); + if ((hw_buf_idx + len + 2) >= 79) { + printf("%s,\n", hw_buf); + hw_buf_idx = 0; + hw_buf_newline = true; + } + if (hw_buf_newline) + hw_buf_idx += sprintf(hw_buf + hw_buf_idx, " "); + else + hw_buf_idx += sprintf(hw_buf + hw_buf_idx, ", "); + hw_buf_newline = false; - if (feature & ARM_PFR1_MICROCTRL_MASK) - printf(" M_profile"); - printf("\n"); + hw_buf_idx += sprintf(hw_buf + hw_buf_idx, "%s", cap); } void identify_arm_cpu(void) { - u_int cpuid, reg, size, sets, ways; - u_int8_t type, linesize, ctrl; int i; + u_int val; - ctrl = cpu_get_control(); - cpuid = cpu_ident(); - - if (cpuid == 0) { - printf("Processor failed probe - no CPU ID\n"); - return; - } - - for (i = 0; cpuids[i].cpuid != 0; i++) - if (cpuids[i].cpuid == (cpuid & CPU_ID_CPU_MASK)) { - cpu_class = cpuids[i].cpu_class; - printf("CPU: %s %s (%s core)\n", - cpuids[i].cpu_name, - cpuids[i].cpu_steppings[cpuid & - CPU_ID_REVISION_MASK], - cpu_classes[cpu_class].class_name); + /* + * CPU + */ + for(i = 0; i < nitems(cpu_names); i++) { + if (cpu_names[i].implementer == cpuinfo.implementer && + cpu_names[i].part_number == cpuinfo.part_number) { + printf("CPU: %s %s r%dp%d (ECO: 0x%08X)\n", + cpu_names[i].impl_name, cpu_names[i].core_name, + cpuinfo.revision, cpuinfo.patch, + cpuinfo.midr != cpuinfo.revidr ? + cpuinfo.revidr : 0); break; } - if (cpuids[i].cpuid == 0) - printf("unknown CPU (ID = 0x%x)\n", cpuid); - printf(" "); - - if ((cpuid & CPU_ID_ARCH_MASK) == CPU_ID_CPUID_SCHEME) { - identify_armv7(); - } else { - if (ctrl & CPU_CONTROL_BEND_ENABLE) - printf(" Big-endian"); - else - printf(" Little-endian"); + } + if (i >= nitems(cpu_names)) + printf("unknown CPU (ID = 0x%x)\n", cpuinfo.midr); - switch (cpu_class) { - case CPU_CLASS_ARM9TDMI: - case CPU_CLASS_ARM9ES: - case CPU_CLASS_ARM9EJS: - case CPU_CLASS_ARM10E: - case CPU_CLASS_ARM10EJ: - case CPU_CLASS_XSCALE: - case CPU_CLASS_ARM11J: - case CPU_CLASS_MARVELL: - print_enadis(ctrl & CPU_CONTROL_DC_ENABLE, "DC"); - print_enadis(ctrl & CPU_CONTROL_IC_ENABLE, "IC"); -#ifdef CPU_XSCALE_81342 - print_enadis(ctrl & CPU_CONTROL_L2_ENABLE, "L2"); -#endif -#if defined(SOC_MV_KIRKWOOD) || defined(SOC_MV_DISCOVERY) - i = sheeva_control_ext(0, 0); - print_enadis(i & MV_WA_ENABLE, "WA"); - print_enadis(i & MV_DC_STREAM_ENABLE, "DC streaming"); - printf("\n "); - print_enadis((i & MV_BTB_DISABLE) == 0, "BTB"); - print_enadis(i & MV_L2_ENABLE, "L2"); - print_enadis((i & MV_L2_PREFETCH_DISABLE) == 0, - "L2 prefetch"); - printf("\n "); -#endif - break; - default: - break; - } + printf("CPU Features: \n"); + hw_buf_idx = 0; + hw_buf_newline = true; + + val = (cpuinfo.mpidr >> 4)& 0xF; + if (cpuinfo.mpidr & (1 << 31U)) + add_cap("Multiprocessing"); + val = (cpuinfo.id_pfr0 >> 4)& 0xF; + if (val == 1) + add_cap("Thumb"); + else if (val == 3) + add_cap("Thumb2"); + + val = (cpuinfo.id_pfr1 >> 4)& 0xF; + if (val == 1 || val == 2) + add_cap("Security"); + + val = (cpuinfo.id_pfr1 >> 12)& 0xF; + if (val == 1) + add_cap("Virtualization"); + + val = (cpuinfo.id_pfr1 >> 16)& 0xF; + if (val == 1) + add_cap("Generic Timer"); + + val = (cpuinfo.id_mmfr0 >> 0)& 0xF; + if (val == 2) { + add_cap("VMSAv6"); + } else if (val >= 3) { + add_cap("VMSAv7"); + if (val >= 4) + add_cap("PXN"); + if (val >= 5) + add_cap("LPAE"); } - print_enadis(ctrl & CPU_CONTROL_WBUF_ENABLE, "WB"); - if (ctrl & CPU_CONTROL_LABT_ENABLE) - printf(" LABT"); + val = (cpuinfo.id_mmfr3 >> 20)& 0xF; + if (val == 1) + add_cap("Coherent Walk"); + + if (hw_buf_idx != 0) + printf("%s\n", hw_buf); + + printf("Optional instructions: \n"); + hw_buf_idx = 0; + hw_buf_newline = true; + val = (cpuinfo.id_isar0 >> 24)& 0xF; + if (val == 1) + add_cap("SDIV/UDIV (Thumb)"); + else if (val == 2) + add_cap("SDIV/UDIV"); + + val = (cpuinfo.id_isar2 >> 20)& 0xF; + if (val == 1 || val == 2) + add_cap("UMULL"); + + val = (cpuinfo.id_isar2 >> 16)& 0xF; + if (val == 1 || val == 2 || val == 3) + add_cap("SMULL"); + + val = (cpuinfo.id_isar2 >> 12)& 0xF; + if (val == 1) + add_cap("MLA"); + + val = (cpuinfo.id_isar3 >> 4)& 0xF; + if (val == 1) + add_cap("SIMD"); + else if (val == 3) + add_cap("SIMD(ext)"); + if (hw_buf_idx != 0) + printf("%s\n", hw_buf); + *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-all@freebsd.org Sun Oct 9 10:25:53 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 2A297C07538; Sun, 9 Oct 2016 10:25:53 +0000 (UTC) (envelope-from mmel@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id EA547897; Sun, 9 Oct 2016 10:25:52 +0000 (UTC) (envelope-from mmel@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u99APqhF067646; Sun, 9 Oct 2016 10:25:52 GMT (envelope-from mmel@FreeBSD.org) Received: (from mmel@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u99APl98067605; Sun, 9 Oct 2016 10:25:47 GMT (envelope-from mmel@FreeBSD.org) Message-Id: <201610091025.u99APl98067605@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mmel set sender to mmel@FreeBSD.org using -f From: Michal Meloun Date: Sun, 9 Oct 2016 10:25:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r306902 - in head/sys/arm: allwinner amlogic/aml8726 at91 broadcom/bcm2835 freescale/imx lpc mv rockchip ti ti/am335x ti/omap4 ti/twl xscale/i8134x xscale/ixp425 X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 09 Oct 2016 10:25:53 -0000 Author: mmel Date: Sun Oct 9 10:25:47 2016 New Revision: 306902 URL: https://svnweb.freebsd.org/changeset/base/306902 Log: ARM: Remove unused includes. MFC after: 1 week Modified: head/sys/arm/allwinner/a10_gpio.c head/sys/arm/allwinner/aw_wdog.c head/sys/arm/amlogic/aml8726/aml8726_machdep.c head/sys/arm/amlogic/aml8726/aml8726_wdt.c head/sys/arm/at91/at91_aic.c head/sys/arm/at91/at91_cfata.c head/sys/arm/at91/at91_mci.c head/sys/arm/at91/at91_pit.c head/sys/arm/at91/at91_pmc.c head/sys/arm/at91/at91_st.c head/sys/arm/broadcom/bcm2835/bcm2835_dma.c head/sys/arm/broadcom/bcm2835/bcm2835_spi.c head/sys/arm/broadcom/bcm2835/bcm2835_wdog.c head/sys/arm/freescale/imx/imx51_ipuv3.c head/sys/arm/freescale/imx/imx51_ipuv3_fbd.c head/sys/arm/lpc/lpc_fb.c head/sys/arm/lpc/lpc_gpio.c head/sys/arm/lpc/lpc_mmc.c head/sys/arm/lpc/lpc_spi.c head/sys/arm/mv/mpic.c head/sys/arm/rockchip/rk30xx_gpio.c head/sys/arm/rockchip/rk30xx_wdog.c head/sys/arm/ti/am335x/am335x_gpio.c head/sys/arm/ti/am335x/am335x_lcd_syscons.c head/sys/arm/ti/am335x/am335x_scm_padconf.c head/sys/arm/ti/omap4/omap4_prcm_clks.c head/sys/arm/ti/ti_cpuid.c head/sys/arm/ti/ti_pinmux.c head/sys/arm/ti/ti_prcm.c head/sys/arm/ti/ti_scm.c head/sys/arm/ti/twl/twl.c head/sys/arm/ti/twl/twl_clks.c head/sys/arm/ti/twl/twl_vreg.c head/sys/arm/xscale/i8134x/i80321_timer.c head/sys/arm/xscale/i8134x/i80321_wdog.c head/sys/arm/xscale/ixp425/avila_ata.c head/sys/arm/xscale/ixp425/ixp425_intr.h head/sys/arm/xscale/ixp425/ixp425_npe.c head/sys/arm/xscale/ixp425/ixp425_qmgr.c head/sys/arm/xscale/ixp425/ixp425_timer.c head/sys/arm/xscale/ixp425/ixp425_wdog.c Modified: head/sys/arm/allwinner/a10_gpio.c ============================================================================== --- head/sys/arm/allwinner/a10_gpio.c Sun Oct 9 10:24:10 2016 (r306901) +++ head/sys/arm/allwinner/a10_gpio.c Sun Oct 9 10:25:47 2016 (r306902) @@ -41,8 +41,6 @@ __FBSDID("$FreeBSD$"); #include #include -#include -#include #include #include Modified: head/sys/arm/allwinner/aw_wdog.c ============================================================================== --- head/sys/arm/allwinner/aw_wdog.c Sun Oct 9 10:24:10 2016 (r306901) +++ head/sys/arm/allwinner/aw_wdog.c Sun Oct 9 10:25:47 2016 (r306902) @@ -44,7 +44,6 @@ __FBSDID("$FreeBSD$"); #include #include -#include #include #include Modified: head/sys/arm/amlogic/aml8726/aml8726_machdep.c ============================================================================== --- head/sys/arm/amlogic/aml8726/aml8726_machdep.c Sun Oct 9 10:24:10 2016 (r306901) +++ head/sys/arm/amlogic/aml8726/aml8726_machdep.c Sun Oct 9 10:25:47 2016 (r306902) @@ -40,7 +40,6 @@ __FBSDID("$FreeBSD$"); #include #include -#include #include #include #include Modified: head/sys/arm/amlogic/aml8726/aml8726_wdt.c ============================================================================== --- head/sys/arm/amlogic/aml8726/aml8726_wdt.c Sun Oct 9 10:24:10 2016 (r306901) +++ head/sys/arm/amlogic/aml8726/aml8726_wdt.c Sun Oct 9 10:25:47 2016 (r306902) @@ -43,7 +43,6 @@ __FBSDID("$FreeBSD$"); #include #include -#include #include #include Modified: head/sys/arm/at91/at91_aic.c ============================================================================== --- head/sys/arm/at91/at91_aic.c Sun Oct 9 10:24:10 2016 (r306901) +++ head/sys/arm/at91/at91_aic.c Sun Oct 9 10:25:47 2016 (r306902) @@ -38,8 +38,6 @@ __FBSDID("$FreeBSD$"); #include #include -#include -#include #include #include #include Modified: head/sys/arm/at91/at91_cfata.c ============================================================================== --- head/sys/arm/at91/at91_cfata.c Sun Oct 9 10:24:10 2016 (r306901) +++ head/sys/arm/at91/at91_cfata.c Sun Oct 9 10:25:47 2016 (r306902) @@ -47,8 +47,6 @@ __FBSDID("$FreeBSD$"); #include #include -#include -#include #include #include Modified: head/sys/arm/at91/at91_mci.c ============================================================================== --- head/sys/arm/at91/at91_mci.c Sun Oct 9 10:24:10 2016 (r306901) +++ head/sys/arm/at91/at91_mci.c Sun Oct 9 10:25:47 2016 (r306902) @@ -51,8 +51,6 @@ __FBSDID("$FreeBSD$"); #include #include -#include -#include #include #include Modified: head/sys/arm/at91/at91_pit.c ============================================================================== --- head/sys/arm/at91/at91_pit.c Sun Oct 9 10:24:10 2016 (r306901) +++ head/sys/arm/at91/at91_pit.c Sun Oct 9 10:25:47 2016 (r306902) @@ -42,7 +42,6 @@ __FBSDID("$FreeBSD$"); #include #include -#include #include #include #include Modified: head/sys/arm/at91/at91_pmc.c ============================================================================== --- head/sys/arm/at91/at91_pmc.c Sun Oct 9 10:24:10 2016 (r306901) +++ head/sys/arm/at91/at91_pmc.c Sun Oct 9 10:25:47 2016 (r306902) @@ -41,8 +41,6 @@ __FBSDID("$FreeBSD$"); #include #include -#include -#include #include #include #include Modified: head/sys/arm/at91/at91_st.c ============================================================================== --- head/sys/arm/at91/at91_st.c Sun Oct 9 10:24:10 2016 (r306901) +++ head/sys/arm/at91/at91_st.c Sun Oct 9 10:25:47 2016 (r306902) @@ -39,7 +39,6 @@ __FBSDID("$FreeBSD$"); #include #include -#include #include #include #include Modified: head/sys/arm/broadcom/bcm2835/bcm2835_dma.c ============================================================================== --- head/sys/arm/broadcom/bcm2835/bcm2835_dma.c Sun Oct 9 10:24:10 2016 (r306901) +++ head/sys/arm/broadcom/bcm2835/bcm2835_dma.c Sun Oct 9 10:25:47 2016 (r306902) @@ -48,8 +48,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include -#include #include "bcm2835_dma.h" #include "bcm2835_vcbus.h" Modified: head/sys/arm/broadcom/bcm2835/bcm2835_spi.c ============================================================================== --- head/sys/arm/broadcom/bcm2835/bcm2835_spi.c Sun Oct 9 10:24:10 2016 (r306901) +++ head/sys/arm/broadcom/bcm2835/bcm2835_spi.c Sun Oct 9 10:25:47 2016 (r306902) @@ -40,8 +40,6 @@ __FBSDID("$FreeBSD$"); #include #include -#include -#include #include #include Modified: head/sys/arm/broadcom/bcm2835/bcm2835_wdog.c ============================================================================== --- head/sys/arm/broadcom/bcm2835/bcm2835_wdog.c Sun Oct 9 10:24:10 2016 (r306901) +++ head/sys/arm/broadcom/bcm2835/bcm2835_wdog.c Sun Oct 9 10:25:47 2016 (r306902) @@ -40,7 +40,6 @@ __FBSDID("$FreeBSD$"); #include #include -#include #include #include Modified: head/sys/arm/freescale/imx/imx51_ipuv3.c ============================================================================== --- head/sys/arm/freescale/imx/imx51_ipuv3.c Sun Oct 9 10:24:10 2016 (r306901) +++ head/sys/arm/freescale/imx/imx51_ipuv3.c Sun Oct 9 10:25:47 2016 (r306902) @@ -57,8 +57,6 @@ __FBSDID("$FreeBSD$"); #include #include -#include -#include #include #include #include Modified: head/sys/arm/freescale/imx/imx51_ipuv3_fbd.c ============================================================================== --- head/sys/arm/freescale/imx/imx51_ipuv3_fbd.c Sun Oct 9 10:24:10 2016 (r306901) +++ head/sys/arm/freescale/imx/imx51_ipuv3_fbd.c Sun Oct 9 10:25:47 2016 (r306902) @@ -55,8 +55,6 @@ __FBSDID("$FreeBSD$"); #include #include -#include -#include #include #include #include Modified: head/sys/arm/lpc/lpc_fb.c ============================================================================== --- head/sys/arm/lpc/lpc_fb.c Sun Oct 9 10:24:10 2016 (r306901) +++ head/sys/arm/lpc/lpc_fb.c Sun Oct 9 10:25:47 2016 (r306902) @@ -49,8 +49,6 @@ __FBSDID("$FreeBSD$"); #include #include -#include -#include #include #include Modified: head/sys/arm/lpc/lpc_gpio.c ============================================================================== --- head/sys/arm/lpc/lpc_gpio.c Sun Oct 9 10:24:10 2016 (r306901) +++ head/sys/arm/lpc/lpc_gpio.c Sun Oct 9 10:25:47 2016 (r306902) @@ -73,8 +73,6 @@ __FBSDID("$FreeBSD$"); #include #include -#include -#include #include #include #include Modified: head/sys/arm/lpc/lpc_mmc.c ============================================================================== --- head/sys/arm/lpc/lpc_mmc.c Sun Oct 9 10:24:10 2016 (r306901) +++ head/sys/arm/lpc/lpc_mmc.c Sun Oct 9 10:25:47 2016 (r306902) @@ -49,8 +49,6 @@ __FBSDID("$FreeBSD$"); #include #include -#include -#include #include #include Modified: head/sys/arm/lpc/lpc_spi.c ============================================================================== --- head/sys/arm/lpc/lpc_spi.c Sun Oct 9 10:24:10 2016 (r306901) +++ head/sys/arm/lpc/lpc_spi.c Sun Oct 9 10:25:47 2016 (r306902) @@ -47,8 +47,6 @@ __FBSDID("$FreeBSD$"); #include #include -#include -#include #include #include Modified: head/sys/arm/mv/mpic.c ============================================================================== --- head/sys/arm/mv/mpic.c Sun Oct 9 10:24:10 2016 (r306901) +++ head/sys/arm/mv/mpic.c Sun Oct 9 10:25:47 2016 (r306902) @@ -50,7 +50,6 @@ __FBSDID("$FreeBSD$"); #include #include -#include #include #include Modified: head/sys/arm/rockchip/rk30xx_gpio.c ============================================================================== --- head/sys/arm/rockchip/rk30xx_gpio.c Sun Oct 9 10:24:10 2016 (r306901) +++ head/sys/arm/rockchip/rk30xx_gpio.c Sun Oct 9 10:25:47 2016 (r306902) @@ -41,8 +41,6 @@ __FBSDID("$FreeBSD$"); #include #include -#include -#include #include #include Modified: head/sys/arm/rockchip/rk30xx_wdog.c ============================================================================== --- head/sys/arm/rockchip/rk30xx_wdog.c Sun Oct 9 10:24:10 2016 (r306901) +++ head/sys/arm/rockchip/rk30xx_wdog.c Sun Oct 9 10:25:47 2016 (r306902) @@ -42,7 +42,6 @@ __FBSDID("$FreeBSD$"); #include #include -#include #include #include Modified: head/sys/arm/ti/am335x/am335x_gpio.c ============================================================================== --- head/sys/arm/ti/am335x/am335x_gpio.c Sun Oct 9 10:24:10 2016 (r306901) +++ head/sys/arm/ti/am335x/am335x_gpio.c Sun Oct 9 10:25:47 2016 (r306902) @@ -39,8 +39,6 @@ __FBSDID("$FreeBSD$"); #include #include -#include -#include #include #include #include Modified: head/sys/arm/ti/am335x/am335x_lcd_syscons.c ============================================================================== --- head/sys/arm/ti/am335x/am335x_lcd_syscons.c Sun Oct 9 10:24:10 2016 (r306901) +++ head/sys/arm/ti/am335x/am335x_lcd_syscons.c Sun Oct 9 10:25:47 2016 (r306902) @@ -44,8 +44,6 @@ __FBSDID("$FreeBSD$"); #include #include -#include -#include #include #include Modified: head/sys/arm/ti/am335x/am335x_scm_padconf.c ============================================================================== --- head/sys/arm/ti/am335x/am335x_scm_padconf.c Sun Oct 9 10:24:10 2016 (r306901) +++ head/sys/arm/ti/am335x/am335x_scm_padconf.c Sun Oct 9 10:25:47 2016 (r306902) @@ -38,8 +38,6 @@ __FBSDID("$FreeBSD$"); #include #include -#include -#include #include #include #include Modified: head/sys/arm/ti/omap4/omap4_prcm_clks.c ============================================================================== --- head/sys/arm/ti/omap4/omap4_prcm_clks.c Sun Oct 9 10:24:10 2016 (r306901) +++ head/sys/arm/ti/omap4/omap4_prcm_clks.c Sun Oct 9 10:25:47 2016 (r306902) @@ -41,8 +41,6 @@ __FBSDID("$FreeBSD$"); #include #include -#include -#include #include #include Modified: head/sys/arm/ti/ti_cpuid.c ============================================================================== --- head/sys/arm/ti/ti_cpuid.c Sun Oct 9 10:24:10 2016 (r306901) +++ head/sys/arm/ti/ti_cpuid.c Sun Oct 9 10:25:47 2016 (r306902) @@ -40,8 +40,6 @@ __FBSDID("$FreeBSD$"); #include #include -#include -#include #include #include Modified: head/sys/arm/ti/ti_pinmux.c ============================================================================== --- head/sys/arm/ti/ti_pinmux.c Sun Oct 9 10:24:10 2016 (r306901) +++ head/sys/arm/ti/ti_pinmux.c Sun Oct 9 10:25:47 2016 (r306902) @@ -47,8 +47,6 @@ __FBSDID("$FreeBSD$"); #include #include -#include -#include #include #include Modified: head/sys/arm/ti/ti_prcm.c ============================================================================== --- head/sys/arm/ti/ti_prcm.c Sun Oct 9 10:24:10 2016 (r306901) +++ head/sys/arm/ti/ti_prcm.c Sun Oct 9 10:25:47 2016 (r306902) @@ -52,8 +52,6 @@ __FBSDID("$FreeBSD$"); #include #include -#include -#include #include #include Modified: head/sys/arm/ti/ti_scm.c ============================================================================== --- head/sys/arm/ti/ti_scm.c Sun Oct 9 10:24:10 2016 (r306901) +++ head/sys/arm/ti/ti_scm.c Sun Oct 9 10:25:47 2016 (r306902) @@ -59,8 +59,6 @@ __FBSDID("$FreeBSD$"); #include #include -#include -#include #include #include Modified: head/sys/arm/ti/twl/twl.c ============================================================================== --- head/sys/arm/ti/twl/twl.c Sun Oct 9 10:24:10 2016 (r306901) +++ head/sys/arm/ti/twl/twl.c Sun Oct 9 10:25:47 2016 (r306902) @@ -57,8 +57,6 @@ __FBSDID("$FreeBSD$"); #include #include -#include -#include #include #include Modified: head/sys/arm/ti/twl/twl_clks.c ============================================================================== --- head/sys/arm/ti/twl/twl_clks.c Sun Oct 9 10:24:10 2016 (r306901) +++ head/sys/arm/ti/twl/twl_clks.c Sun Oct 9 10:25:47 2016 (r306902) @@ -62,8 +62,6 @@ __FBSDID("$FreeBSD$"); #include #include -#include -#include #include #include Modified: head/sys/arm/ti/twl/twl_vreg.c ============================================================================== --- head/sys/arm/ti/twl/twl_vreg.c Sun Oct 9 10:24:10 2016 (r306901) +++ head/sys/arm/ti/twl/twl_vreg.c Sun Oct 9 10:25:47 2016 (r306902) @@ -63,8 +63,6 @@ __FBSDID("$FreeBSD$"); #include #include -#include -#include #include #include Modified: head/sys/arm/xscale/i8134x/i80321_timer.c ============================================================================== --- head/sys/arm/xscale/i8134x/i80321_timer.c Sun Oct 9 10:24:10 2016 (r306901) +++ head/sys/arm/xscale/i8134x/i80321_timer.c Sun Oct 9 10:25:47 2016 (r306902) @@ -55,7 +55,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #include #include #include Modified: head/sys/arm/xscale/i8134x/i80321_wdog.c ============================================================================== --- head/sys/arm/xscale/i8134x/i80321_wdog.c Sun Oct 9 10:24:10 2016 (r306901) +++ head/sys/arm/xscale/i8134x/i80321_wdog.c Sun Oct 9 10:25:47 2016 (r306902) @@ -51,7 +51,6 @@ __FBSDID("$FreeBSD$"); #include #include -#include #include #include Modified: head/sys/arm/xscale/ixp425/avila_ata.c ============================================================================== --- head/sys/arm/xscale/ixp425/avila_ata.c Sun Oct 9 10:24:10 2016 (r306901) +++ head/sys/arm/xscale/ixp425/avila_ata.c Sun Oct 9 10:25:47 2016 (r306902) @@ -53,8 +53,6 @@ __FBSDID("$FreeBSD$"); #include #include -#include -#include #include #include #include Modified: head/sys/arm/xscale/ixp425/ixp425_intr.h ============================================================================== --- head/sys/arm/xscale/ixp425/ixp425_intr.h Sun Oct 9 10:24:10 2016 (r306901) +++ head/sys/arm/xscale/ixp425/ixp425_intr.h Sun Oct 9 10:25:47 2016 (r306902) @@ -46,7 +46,6 @@ #ifndef _LOCORE #include -#include #include Modified: head/sys/arm/xscale/ixp425/ixp425_npe.c ============================================================================== --- head/sys/arm/xscale/ixp425/ixp425_npe.c Sun Oct 9 10:24:10 2016 (r306901) +++ head/sys/arm/xscale/ixp425/ixp425_npe.c Sun Oct 9 10:25:47 2016 (r306902) @@ -92,8 +92,6 @@ __FBSDID("$FreeBSD$"); #include #include -#include -#include #include #include #include Modified: head/sys/arm/xscale/ixp425/ixp425_qmgr.c ============================================================================== --- head/sys/arm/xscale/ixp425/ixp425_qmgr.c Sun Oct 9 10:24:10 2016 (r306901) +++ head/sys/arm/xscale/ixp425/ixp425_qmgr.c Sun Oct 9 10:25:47 2016 (r306902) @@ -84,8 +84,6 @@ __FBSDID("$FreeBSD$"); #include #include -#include -#include #include #include #include Modified: head/sys/arm/xscale/ixp425/ixp425_timer.c ============================================================================== --- head/sys/arm/xscale/ixp425/ixp425_timer.c Sun Oct 9 10:24:10 2016 (r306901) +++ head/sys/arm/xscale/ixp425/ixp425_timer.c Sun Oct 9 10:25:47 2016 (r306902) @@ -49,7 +49,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #include #include #include Modified: head/sys/arm/xscale/ixp425/ixp425_wdog.c ============================================================================== --- head/sys/arm/xscale/ixp425/ixp425_wdog.c Sun Oct 9 10:24:10 2016 (r306901) +++ head/sys/arm/xscale/ixp425/ixp425_wdog.c Sun Oct 9 10:25:47 2016 (r306902) @@ -38,8 +38,6 @@ __FBSDID("$FreeBSD$"); #include #include -#include -#include #include #include From owner-svn-src-all@freebsd.org Sun Oct 9 12:34:59 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 0ED73C06065; Sun, 9 Oct 2016 12:34:59 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id C400EEB0; Sun, 9 Oct 2016 12:34:58 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u99CYvWo018416; Sun, 9 Oct 2016 12:34:57 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u99CYv4x018407; Sun, 9 Oct 2016 12:34:57 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201610091234.u99CYv4x018407@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Sun, 9 Oct 2016 12:34:57 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r306905 - in stable/11: include lib/librt tests/sys/mqueue X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 09 Oct 2016 12:34:59 -0000 Author: kib Date: Sun Oct 9 12:34:56 2016 New Revision: 306905 URL: https://svnweb.freebsd.org/changeset/base/306905 Log: MFC r306588: Export the mq_getfd_np() and timer_oshandle_np() symbols from librt.so. Modified: stable/11/include/mqueue.h stable/11/include/time.h stable/11/lib/librt/Symbol.map stable/11/lib/librt/mq.c stable/11/lib/librt/timer.c stable/11/tests/sys/mqueue/Makefile stable/11/tests/sys/mqueue/mqtest3.c stable/11/tests/sys/mqueue/mqtest4.c Directory Properties: stable/11/ (props changed) Modified: stable/11/include/mqueue.h ============================================================================== --- stable/11/include/mqueue.h Sun Oct 9 11:44:33 2016 (r306904) +++ stable/11/include/mqueue.h Sun Oct 9 12:34:56 2016 (r306905) @@ -50,7 +50,9 @@ ssize_t mq_timedreceive(mqd_t, char *__r int mq_timedsend(mqd_t, const char *, size_t, unsigned, const struct timespec *); int mq_unlink(const char *); -int __mq_oshandle(mqd_t mqd); +#if __BSD_VISIBLE +int mq_getfd_np(mqd_t mqd); +#endif /* __BSD_VISIBLE */ __END_DECLS #endif Modified: stable/11/include/time.h ============================================================================== --- stable/11/include/time.h Sun Oct 9 11:44:33 2016 (r306904) +++ stable/11/include/time.h Sun Oct 9 12:34:56 2016 (r306905) @@ -194,6 +194,7 @@ char *timezone(int, int); /* XXX XSI con void tzsetwall(void); time_t timelocal(struct tm * const); time_t timegm(struct tm * const); +int timer_oshandle_np(timer_t timerid); #endif /* __BSD_VISIBLE */ #if __POSIX_VISIBLE >= 200809 || defined(_XLOCALE_H_) Modified: stable/11/lib/librt/Symbol.map ============================================================================== --- stable/11/lib/librt/Symbol.map Sun Oct 9 11:44:33 2016 (r306904) +++ stable/11/lib/librt/Symbol.map Sun Oct 9 12:34:56 2016 (r306905) @@ -25,6 +25,11 @@ FBSD_1.0 { timer_getoverrun; }; +FBSD_1.5 { + mq_getfd_np; + timer_oshandle_np; +}; + FBSDprivate_1.0 { _aio_read; _aio_write; Modified: stable/11/lib/librt/mq.c ============================================================================== --- stable/11/lib/librt/mq.c Sun Oct 9 11:44:33 2016 (r306904) +++ stable/11/lib/librt/mq.c Sun Oct 9 12:34:56 2016 (r306905) @@ -272,8 +272,9 @@ __mq_unlink(const char *path) return __sys_kmq_unlink(path); } +#pragma weak mq_getfd_np int -__mq_oshandle(mqd_t mqd) +mq_getfd_np(mqd_t mqd) { return (mqd->oshandle); Modified: stable/11/lib/librt/timer.c ============================================================================== --- stable/11/lib/librt/timer.c Sun Oct 9 11:44:33 2016 (r306904) +++ stable/11/lib/librt/timer.c Sun Oct 9 12:34:56 2016 (r306905) @@ -175,8 +175,9 @@ __timer_settime(timer_t timerid, int fla flags, value, ovalue); } +#pragma weak timer_oshandle_np int -__timer_oshandle(timer_t timerid) +timer_oshandle_np(timer_t timerid) { return (timerid->oshandle); Modified: stable/11/tests/sys/mqueue/Makefile ============================================================================== --- stable/11/tests/sys/mqueue/Makefile Sun Oct 9 11:44:33 2016 (r306904) +++ stable/11/tests/sys/mqueue/Makefile Sun Oct 9 12:34:56 2016 (r306905) @@ -10,8 +10,8 @@ CFLAGS+= -I${SRCTOP}/tests PROGS+= mqtest1 PROGS+= mqtest2 -#PROGS+= mqtest3 -#PROGS+= mqtest4 +PROGS+= mqtest3 +PROGS+= mqtest4 PROGS+= mqtest5 LIBADD+= rt Modified: stable/11/tests/sys/mqueue/mqtest3.c ============================================================================== --- stable/11/tests/sys/mqueue/mqtest3.c Sun Oct 9 11:44:33 2016 (r306904) +++ stable/11/tests/sys/mqueue/mqtest3.c Sun Oct 9 12:34:56 2016 (r306905) @@ -62,9 +62,10 @@ main(void) buf = malloc(attr.mq_msgsize); for (j = 0; j < LOOPS; ++j) { FD_ZERO(&set); - FD_SET(__mq_oshandle(mq), &set); + FD_SET(mq_getfd_np(mq), &set); alarm(3); - status = select(__mq_oshandle(mq)+1, &set, NULL, NULL, NULL); + status = select(mq_getfd_np(mq) + 1, &set, NULL, + NULL, NULL); if (status != 1) err(1, "child process: select()"); status = mq_receive(mq, buf, attr.mq_msgsize, &prio); @@ -94,8 +95,9 @@ main(void) } alarm(3); FD_ZERO(&set); - FD_SET(__mq_oshandle(mq), &set); - status = select(__mq_oshandle(mq)+1, NULL, &set, NULL, NULL); + FD_SET(mq_getfd_np(mq), &set); + status = select(mq_getfd_np(mq) + 1, NULL, &set, + NULL, NULL); if (status != 1) err(1, "select()"); status = mq_send(mq, buf, attr.mq_msgsize, PRIO); Modified: stable/11/tests/sys/mqueue/mqtest4.c ============================================================================== --- stable/11/tests/sys/mqueue/mqtest4.c Sun Oct 9 11:44:33 2016 (r306904) +++ stable/11/tests/sys/mqueue/mqtest4.c Sun Oct 9 12:34:56 2016 (r306905) @@ -57,7 +57,7 @@ main(void) mq = mq_open(MQNAME, O_RDWR); if (mq == (mqd_t)-1) err(1, "child: mq_open"); - EV_SET(&kev, __mq_oshandle(mq), EVFILT_READ, EV_ADD, 0, 0, 0); + EV_SET(&kev, mq_getfd_np(mq), EVFILT_READ, EV_ADD, 0, 0, 0); status = kevent(kq, &kev, 1, NULL, 0, NULL); if (status == -1) err(1, "child: kevent"); @@ -89,7 +89,7 @@ main(void) signal(SIGALRM, sighandler); kq = kqueue(); - EV_SET(&kev, __mq_oshandle(mq), EVFILT_WRITE, EV_ADD, 0, 0, 0); + EV_SET(&kev, mq_getfd_np(mq), EVFILT_WRITE, EV_ADD, 0, 0, 0); status = kevent(kq, &kev, 1, NULL, 0, NULL); if (status == -1) err(1, "kevent"); From owner-svn-src-all@freebsd.org Sun Oct 9 13:59:40 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 1B1BAC07439; Sun, 9 Oct 2016 13:59:40 +0000 (UTC) (envelope-from jmcneill@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id DDE012F3; Sun, 9 Oct 2016 13:59:39 +0000 (UTC) (envelope-from jmcneill@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u99Dxddc048992; Sun, 9 Oct 2016 13:59:39 GMT (envelope-from jmcneill@FreeBSD.org) Received: (from jmcneill@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u99DxcYb048991; Sun, 9 Oct 2016 13:59:38 GMT (envelope-from jmcneill@FreeBSD.org) Message-Id: <201610091359.u99DxcYb048991@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jmcneill set sender to jmcneill@FreeBSD.org using -f From: Jared McNeill Date: Sun, 9 Oct 2016 13:59:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r306907 - stable/11/sys/arm/arm X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 09 Oct 2016 13:59:40 -0000 Author: jmcneill Date: Sun Oct 9 13:59:38 2016 New Revision: 306907 URL: https://svnweb.freebsd.org/changeset/base/306907 Log: MFC r306658: Clear GT_CTRL_ENABLE to stop the timer. Modified: stable/11/sys/arm/arm/generic_timer.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/arm/arm/generic_timer.c ============================================================================== --- stable/11/sys/arm/arm/generic_timer.c Sun Oct 9 13:30:57 2016 (r306906) +++ stable/11/sys/arm/arm/generic_timer.c Sun Oct 9 13:59:38 2016 (r306907) @@ -259,7 +259,7 @@ arm_tmr_stop(struct eventtimer *et) sc = (struct arm_tmr_softc *)et->et_priv; ctrl = get_ctrl(sc->physical); - ctrl &= GT_CTRL_ENABLE; + ctrl &= ~GT_CTRL_ENABLE; set_ctrl(ctrl, sc->physical); return (0); From owner-svn-src-all@freebsd.org Sun Oct 9 19:57:22 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 76BD4C0B253; Sun, 9 Oct 2016 19:57:22 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 3864263B; Sun, 9 Oct 2016 19:57:22 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u99JvLI8086678; Sun, 9 Oct 2016 19:57:21 GMT (envelope-from pfg@FreeBSD.org) Received: (from pfg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u99JvLmP086675; Sun, 9 Oct 2016 19:57:21 GMT (envelope-from pfg@FreeBSD.org) Message-Id: <201610091957.u99JvLmP086675@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: pfg set sender to pfg@FreeBSD.org using -f From: "Pedro F. Giffuni" Date: Sun, 9 Oct 2016 19:57:20 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r306909 - stable/11/usr.sbin/fifolog/lib X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 09 Oct 2016 19:57:22 -0000 Author: pfg Date: Sun Oct 9 19:57:20 2016 New Revision: 306909 URL: https://svnweb.freebsd.org/changeset/base/306909 Log: MFC r305812: fifolog(1): invert order of calloc(3) arguments. The second argument to calloc(3) should be the size, make it so. While here be a little bit more cautious in fifolog_reader_open() to protect in the unlikely event of an overflowed allocation. Modified: stable/11/usr.sbin/fifolog/lib/fifolog_create.c stable/11/usr.sbin/fifolog/lib/fifolog_reader.c stable/11/usr.sbin/fifolog/lib/fifolog_write_poll.c stable/11/usr.sbin/fifolog/lib/miniobj.h Directory Properties: stable/11/ (props changed) Modified: stable/11/usr.sbin/fifolog/lib/fifolog_create.c ============================================================================== --- stable/11/usr.sbin/fifolog/lib/fifolog_create.c Sun Oct 9 18:39:13 2016 (r306908) +++ stable/11/usr.sbin/fifolog/lib/fifolog_create.c Sun Oct 9 19:57:20 2016 (r306909) @@ -97,7 +97,7 @@ fifolog_create(const char *fn, off_t siz if (S_ISREG(st.st_mode) && ftruncate(fd, size) < 0) return ("Could not ftrunc"); - buf = calloc(recsize, 1); + buf = calloc(1, recsize); if (buf == NULL) return ("Could not malloc"); Modified: stable/11/usr.sbin/fifolog/lib/fifolog_reader.c ============================================================================== --- stable/11/usr.sbin/fifolog/lib/fifolog_reader.c Sun Oct 9 18:39:13 2016 (r306908) +++ stable/11/usr.sbin/fifolog/lib/fifolog_reader.c Sun Oct 9 19:57:20 2016 (r306909) @@ -67,10 +67,10 @@ fifolog_reader_open(const char *fname) if (retval != NULL) err(1, "%s", retval); - fr->olen = fr->ff->recsize * 16; - fr->obuf = calloc(fr->olen, 1); + fr->obuf = calloc(16, fr->ff->recsize); if (fr->obuf == NULL) err(1, "Cannot malloc"); + fr->olen = fr->ff->recsize * 16; i = inflateInit(fr->ff->zs); assert(i == Z_OK); Modified: stable/11/usr.sbin/fifolog/lib/fifolog_write_poll.c ============================================================================== --- stable/11/usr.sbin/fifolog/lib/fifolog_write_poll.c Sun Oct 9 18:39:13 2016 (r306908) +++ stable/11/usr.sbin/fifolog/lib/fifolog_write_poll.c Sun Oct 9 19:57:20 2016 (r306909) @@ -45,7 +45,7 @@ static int fifolog_write_gzip(struct fifolog_writer *f, time_t now); #define ALLOC(ptr, size) do { \ - (*(ptr)) = calloc(size, 1); \ + (*(ptr)) = calloc(1, size); \ assert(*(ptr) != NULL); \ } while (0) Modified: stable/11/usr.sbin/fifolog/lib/miniobj.h ============================================================================== --- stable/11/usr.sbin/fifolog/lib/miniobj.h Sun Oct 9 18:39:13 2016 (r306908) +++ stable/11/usr.sbin/fifolog/lib/miniobj.h Sun Oct 9 19:57:20 2016 (r306909) @@ -28,7 +28,7 @@ #define ALLOC_OBJ(to, type_magic) \ do { \ - (to) = calloc(sizeof *(to), 1); \ + (to) = calloc(1, sizeof *(to)); \ if ((to) != NULL) \ (to)->magic = (type_magic); \ } while (0) From owner-svn-src-all@freebsd.org Sun Oct 9 19:58:28 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 9E295C0B2E6; Sun, 9 Oct 2016 19:58:28 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 6136E822; Sun, 9 Oct 2016 19:58:28 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u99JwRTm086763; Sun, 9 Oct 2016 19:58:27 GMT (envelope-from pfg@FreeBSD.org) Received: (from pfg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u99JwRJ5086759; Sun, 9 Oct 2016 19:58:27 GMT (envelope-from pfg@FreeBSD.org) Message-Id: <201610091958.u99JwRJ5086759@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: pfg set sender to pfg@FreeBSD.org using -f From: "Pedro F. Giffuni" Date: Sun, 9 Oct 2016 19:58:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r306910 - stable/10/usr.sbin/fifolog/lib X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 09 Oct 2016 19:58:28 -0000 Author: pfg Date: Sun Oct 9 19:58:27 2016 New Revision: 306910 URL: https://svnweb.freebsd.org/changeset/base/306910 Log: MFC r305812: fifolog(1): invert order of calloc(3) arguments. The second argument to calloc(3) should be the size, make it so. While here be a little bit more cautious in fifolog_reader_open() to protect in the unlikely event of an overflowed allocation. Modified: stable/10/usr.sbin/fifolog/lib/fifolog_create.c stable/10/usr.sbin/fifolog/lib/fifolog_reader.c stable/10/usr.sbin/fifolog/lib/fifolog_write_poll.c stable/10/usr.sbin/fifolog/lib/miniobj.h Directory Properties: stable/10/ (props changed) Modified: stable/10/usr.sbin/fifolog/lib/fifolog_create.c ============================================================================== --- stable/10/usr.sbin/fifolog/lib/fifolog_create.c Sun Oct 9 19:57:20 2016 (r306909) +++ stable/10/usr.sbin/fifolog/lib/fifolog_create.c Sun Oct 9 19:58:27 2016 (r306910) @@ -97,7 +97,7 @@ fifolog_create(const char *fn, off_t siz if (S_ISREG(st.st_mode) && ftruncate(fd, size) < 0) return ("Could not ftrunc"); - buf = calloc(recsize, 1); + buf = calloc(1, recsize); if (buf == NULL) return ("Could not malloc"); Modified: stable/10/usr.sbin/fifolog/lib/fifolog_reader.c ============================================================================== --- stable/10/usr.sbin/fifolog/lib/fifolog_reader.c Sun Oct 9 19:57:20 2016 (r306909) +++ stable/10/usr.sbin/fifolog/lib/fifolog_reader.c Sun Oct 9 19:58:27 2016 (r306910) @@ -67,10 +67,10 @@ fifolog_reader_open(const char *fname) if (retval != NULL) err(1, "%s", retval); - fr->olen = fr->ff->recsize * 16; - fr->obuf = calloc(fr->olen, 1); + fr->obuf = calloc(16, fr->ff->recsize); if (fr->obuf == NULL) err(1, "Cannot malloc"); + fr->olen = fr->ff->recsize * 16; i = inflateInit(fr->ff->zs); assert(i == Z_OK); Modified: stable/10/usr.sbin/fifolog/lib/fifolog_write_poll.c ============================================================================== --- stable/10/usr.sbin/fifolog/lib/fifolog_write_poll.c Sun Oct 9 19:57:20 2016 (r306909) +++ stable/10/usr.sbin/fifolog/lib/fifolog_write_poll.c Sun Oct 9 19:58:27 2016 (r306910) @@ -45,7 +45,7 @@ static int fifolog_write_gzip(struct fifolog_writer *f, time_t now); #define ALLOC(ptr, size) do { \ - (*(ptr)) = calloc(size, 1); \ + (*(ptr)) = calloc(1, size); \ assert(*(ptr) != NULL); \ } while (0) Modified: stable/10/usr.sbin/fifolog/lib/miniobj.h ============================================================================== --- stable/10/usr.sbin/fifolog/lib/miniobj.h Sun Oct 9 19:57:20 2016 (r306909) +++ stable/10/usr.sbin/fifolog/lib/miniobj.h Sun Oct 9 19:58:27 2016 (r306910) @@ -28,7 +28,7 @@ #define ALLOC_OBJ(to, type_magic) \ do { \ - (to) = calloc(sizeof *(to), 1); \ + (to) = calloc(1, sizeof *(to)); \ if ((to) != NULL) \ (to)->magic = (type_magic); \ } while (0) From owner-svn-src-all@freebsd.org Sun Oct 9 19:59:22 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 761ACC0B350; Sun, 9 Oct 2016 19:59:22 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 3844D98A; Sun, 9 Oct 2016 19:59:22 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u99JxL78086840; Sun, 9 Oct 2016 19:59:21 GMT (envelope-from pfg@FreeBSD.org) Received: (from pfg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u99JxKFG086836; Sun, 9 Oct 2016 19:59:20 GMT (envelope-from pfg@FreeBSD.org) Message-Id: <201610091959.u99JxKFG086836@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: pfg set sender to pfg@FreeBSD.org using -f From: "Pedro F. Giffuni" Date: Sun, 9 Oct 2016 19:59:20 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r306911 - stable/9/usr.sbin/fifolog/lib X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 09 Oct 2016 19:59:22 -0000 Author: pfg Date: Sun Oct 9 19:59:20 2016 New Revision: 306911 URL: https://svnweb.freebsd.org/changeset/base/306911 Log: MFC r305812: fifolog(1): invert order of calloc(3) arguments. The second argument to calloc(3) should be the size, make it so. While here be a little bit more cautious in fifolog_reader_open() to protect in the unlikely event of an overflowed allocation. Modified: stable/9/usr.sbin/fifolog/lib/fifolog_create.c stable/9/usr.sbin/fifolog/lib/fifolog_reader.c stable/9/usr.sbin/fifolog/lib/fifolog_write_poll.c stable/9/usr.sbin/fifolog/lib/miniobj.h Modified: stable/9/usr.sbin/fifolog/lib/fifolog_create.c ============================================================================== --- stable/9/usr.sbin/fifolog/lib/fifolog_create.c Sun Oct 9 19:58:27 2016 (r306910) +++ stable/9/usr.sbin/fifolog/lib/fifolog_create.c Sun Oct 9 19:59:20 2016 (r306911) @@ -97,7 +97,7 @@ fifolog_create(const char *fn, off_t siz if (S_ISREG(st.st_mode) && ftruncate(fd, size) < 0) return ("Could not ftrunc"); - buf = calloc(recsize, 1); + buf = calloc(1, recsize); if (buf == NULL) return ("Could not malloc"); Modified: stable/9/usr.sbin/fifolog/lib/fifolog_reader.c ============================================================================== --- stable/9/usr.sbin/fifolog/lib/fifolog_reader.c Sun Oct 9 19:58:27 2016 (r306910) +++ stable/9/usr.sbin/fifolog/lib/fifolog_reader.c Sun Oct 9 19:59:20 2016 (r306911) @@ -67,10 +67,10 @@ fifolog_reader_open(const char *fname) if (retval != NULL) err(1, "%s", retval); - fr->olen = fr->ff->recsize * 16; - fr->obuf = calloc(fr->olen, 1); + fr->obuf = calloc(16, fr->ff->recsize); if (fr->obuf == NULL) err(1, "Cannot malloc"); + fr->olen = fr->ff->recsize * 16; i = inflateInit(fr->ff->zs); assert(i == Z_OK); Modified: stable/9/usr.sbin/fifolog/lib/fifolog_write_poll.c ============================================================================== --- stable/9/usr.sbin/fifolog/lib/fifolog_write_poll.c Sun Oct 9 19:58:27 2016 (r306910) +++ stable/9/usr.sbin/fifolog/lib/fifolog_write_poll.c Sun Oct 9 19:59:20 2016 (r306911) @@ -45,7 +45,7 @@ static int fifolog_write_gzip(struct fifolog_writer *f, time_t now); #define ALLOC(ptr, size) do { \ - (*(ptr)) = calloc(size, 1); \ + (*(ptr)) = calloc(1, size); \ assert(*(ptr) != NULL); \ } while (0) Modified: stable/9/usr.sbin/fifolog/lib/miniobj.h ============================================================================== --- stable/9/usr.sbin/fifolog/lib/miniobj.h Sun Oct 9 19:58:27 2016 (r306910) +++ stable/9/usr.sbin/fifolog/lib/miniobj.h Sun Oct 9 19:59:20 2016 (r306911) @@ -28,7 +28,7 @@ #define ALLOC_OBJ(to, type_magic) \ do { \ - (to) = calloc(sizeof *(to), 1); \ + (to) = calloc(1, sizeof *(to)); \ if ((to) != NULL) \ (to)->magic = (type_magic); \ } while (0) From owner-svn-src-all@freebsd.org Sun Oct 9 20:07:03 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 0188EC0B534; Sun, 9 Oct 2016 20:07:03 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id C742DDC8; Sun, 9 Oct 2016 20:07:02 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u99K71fS090465; Sun, 9 Oct 2016 20:07:01 GMT (envelope-from pfg@FreeBSD.org) Received: (from pfg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u99K71vB090464; Sun, 9 Oct 2016 20:07:01 GMT (envelope-from pfg@FreeBSD.org) Message-Id: <201610092007.u99K71vB090464@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: pfg set sender to pfg@FreeBSD.org using -f From: "Pedro F. Giffuni" Date: Sun, 9 Oct 2016 20:07:01 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r306912 - stable/11/usr.bin/localedef X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 09 Oct 2016 20:07:03 -0000 Author: pfg Date: Sun Oct 9 20:07:01 2016 New Revision: 306912 URL: https://svnweb.freebsd.org/changeset/base/306912 Log: MFC r305813: localedef(1): make better use of calloc(3) arguments. The first argument of calloc(3) should be an ordinal type, and the second a size: split a multiplication to make better use of calloc(3) and detect overflows. Do some other re-ordering and style fixes while here. Modified: stable/11/usr.bin/localedef/collate.c Directory Properties: stable/11/ (props changed) Modified: stable/11/usr.bin/localedef/collate.c ============================================================================== --- stable/11/usr.bin/localedef/collate.c Sun Oct 9 19:59:20 2016 (r306911) +++ stable/11/usr.bin/localedef/collate.c Sun Oct 9 20:07:01 2016 (r306912) @@ -1204,7 +1204,7 @@ dump_collate(void) subst_t *temp; RB_COUNT(temp, substs, &substs[i], n); collinfo.subst_count[i] = n; - if ((st = calloc(sizeof (collate_subst_t) * n, 1)) == NULL) { + if ((st = calloc(n, sizeof(collate_subst_t))) == NULL) { fprintf(stderr, "out of memory"); return; } @@ -1233,7 +1233,7 @@ dump_collate(void) */ RB_NUMNODES(collelem_t, elem_by_expand, &elem_by_expand, collinfo.chain_count); - chain = calloc(sizeof (collate_chain_t), collinfo.chain_count); + chain = calloc(collinfo.chain_count, sizeof(collate_chain_t)); if (chain == NULL) { fprintf(stderr, "out of memory"); return; @@ -1253,7 +1253,7 @@ dump_collate(void) * Large (> UCHAR_MAX) character priorities */ RB_NUMNODES(collchar_t, collchars, &collchars, n); - large = calloc(n, sizeof (collate_large_t)); + large = calloc(n, sizeof(collate_large_t)); if (large == NULL) { fprintf(stderr, "out of memory"); return; From owner-svn-src-all@freebsd.org Sun Oct 9 20:13:00 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 1D08DC0B684; Sun, 9 Oct 2016 20:13:00 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id D887D1BB; Sun, 9 Oct 2016 20:12:59 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u99KCxZc094148; Sun, 9 Oct 2016 20:12:59 GMT (envelope-from pfg@FreeBSD.org) Received: (from pfg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u99KCxDK094147; Sun, 9 Oct 2016 20:12:59 GMT (envelope-from pfg@FreeBSD.org) Message-Id: <201610092012.u99KCxDK094147@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: pfg set sender to pfg@FreeBSD.org using -f From: "Pedro F. Giffuni" Date: Sun, 9 Oct 2016 20:12:59 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r306913 - stable/11/usr.bin/patch X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 09 Oct 2016 20:13:00 -0000 Author: pfg Date: Sun Oct 9 20:12:58 2016 New Revision: 306913 URL: https://svnweb.freebsd.org/changeset/base/306913 Log: MFC r306560, r306561: patch(1): make some macros look boolean. Minor cleanup inspired by a new patch(1) variant in schily tools. For reference: https://sourceforge.net/p/schillix-on/ Modified: stable/11/usr.bin/patch/common.h Directory Properties: stable/11/ (props changed) Modified: stable/11/usr.bin/patch/common.h ============================================================================== --- stable/11/usr.bin/patch/common.h Sun Oct 9 20:07:01 2016 (r306912) +++ stable/11/usr.bin/patch/common.h Sun Oct 9 20:12:58 2016 (r306913) @@ -47,10 +47,9 @@ /* handy definitions */ -#define strNE(s1,s2) (strcmp(s1, s2)) -#define strEQ(s1,s2) (!strcmp(s1, s2)) -#define strnNE(s1,s2,l) (strncmp(s1, s2, l)) -#define strnEQ(s1,s2,l) (!strncmp(s1, s2, l)) +#define strEQ(s1,s2) (strcmp(s1, s2) == 0) +#define strnNE(s1,s2,l) (strncmp(s1, s2, l) != 0) +#define strnEQ(s1,s2,l) (strncmp(s1, s2, l) == 0) /* typedefs */ From owner-svn-src-all@freebsd.org Sun Oct 9 20:13:54 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B8245C0B6DF; Sun, 9 Oct 2016 20:13:54 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 874F1338; Sun, 9 Oct 2016 20:13:54 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u99KDrjT094227; Sun, 9 Oct 2016 20:13:53 GMT (envelope-from pfg@FreeBSD.org) Received: (from pfg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u99KDrE2094226; Sun, 9 Oct 2016 20:13:53 GMT (envelope-from pfg@FreeBSD.org) Message-Id: <201610092013.u99KDrE2094226@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: pfg set sender to pfg@FreeBSD.org using -f From: "Pedro F. Giffuni" Date: Sun, 9 Oct 2016 20:13:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r306914 - stable/10/usr.bin/patch X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 09 Oct 2016 20:13:54 -0000 Author: pfg Date: Sun Oct 9 20:13:53 2016 New Revision: 306914 URL: https://svnweb.freebsd.org/changeset/base/306914 Log: MFC r306560, r306561: patch(1): make some macros look boolean. Minor cleanup inspired by a new patch(1) variant in schily tools. For reference: https://sourceforge.net/p/schillix-on/ Modified: stable/10/usr.bin/patch/common.h Directory Properties: stable/10/ (props changed) Modified: stable/10/usr.bin/patch/common.h ============================================================================== --- stable/10/usr.bin/patch/common.h Sun Oct 9 20:12:58 2016 (r306913) +++ stable/10/usr.bin/patch/common.h Sun Oct 9 20:13:53 2016 (r306914) @@ -53,10 +53,9 @@ /* handy definitions */ -#define strNE(s1,s2) (strcmp(s1, s2)) -#define strEQ(s1,s2) (!strcmp(s1, s2)) -#define strnNE(s1,s2,l) (strncmp(s1, s2, l)) -#define strnEQ(s1,s2,l) (!strncmp(s1, s2, l)) +#define strEQ(s1,s2) (strcmp(s1, s2) == 0) +#define strnNE(s1,s2,l) (strncmp(s1, s2, l) != 0) +#define strnEQ(s1,s2,l) (strncmp(s1, s2, l) == 0) /* typedefs */ From owner-svn-src-all@freebsd.org Sun Oct 9 21:02:35 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 129F3C07918; Sun, 9 Oct 2016 21:02:35 +0000 (UTC) (envelope-from jch@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id D473ED2C; Sun, 9 Oct 2016 21:02:34 +0000 (UTC) (envelope-from jch@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u99L2YHD013353; Sun, 9 Oct 2016 21:02:34 GMT (envelope-from jch@FreeBSD.org) Received: (from jch@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u99L2YBN013352; Sun, 9 Oct 2016 21:02:34 GMT (envelope-from jch@FreeBSD.org) Message-Id: <201610092102.u99L2YBN013352@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jch set sender to jch@FreeBSD.org using -f From: Julien Charbon Date: Sun, 9 Oct 2016 21:02:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r306922 - stable/11/sys/netinet X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 09 Oct 2016 21:02:35 -0000 Author: jch Date: Sun Oct 9 21:02:33 2016 New Revision: 306922 URL: https://svnweb.freebsd.org/changeset/base/306922 Log: MFC r306443: Fix an issue with accept_filter introduced with r261242: As a side effect of r261242 when using accept_filter the first call to soisconnected() is done earlier in tcp_input() instead of tcp_do_segment() context. Restore the expected behaviour. Note: This call to soisconnected() seems to be extraneous in all cases (with or without accept_filter). Will be addressed in a separate commit. PR: 212920 Reported by: Alexey Tested by: Alexey, jch Sponsored by: Verisign, Inc. Modified: stable/11/sys/netinet/tcp_syncache.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/netinet/tcp_syncache.c ============================================================================== --- stable/11/sys/netinet/tcp_syncache.c Sun Oct 9 21:00:49 2016 (r306921) +++ stable/11/sys/netinet/tcp_syncache.c Sun Oct 9 21:02:33 2016 (r306922) @@ -918,7 +918,9 @@ syncache_socket(struct syncache *sc, str tp->t_keepcnt = sototcpcb(lso)->t_keepcnt; tcp_timer_activate(tp, TT_KEEP, TP_KEEPINIT(tp)); - soisconnected(so); + if ((so->so_options & SO_ACCEPTFILTER) == 0) { + soisconnected(so); + } TCPSTAT_INC(tcps_accepts); return (so); From owner-svn-src-all@freebsd.org Sun Oct 9 21:28:57 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id CA0D3C0B0B6; Sun, 9 Oct 2016 21:28:57 +0000 (UTC) (envelope-from jilles@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 90BBAA96; Sun, 9 Oct 2016 21:28:57 +0000 (UTC) (envelope-from jilles@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u99LSuvV021308; Sun, 9 Oct 2016 21:28:56 GMT (envelope-from jilles@FreeBSD.org) Received: (from jilles@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u99LSuJj021307; Sun, 9 Oct 2016 21:28:56 GMT (envelope-from jilles@FreeBSD.org) Message-Id: <201610092128.u99LSuJj021307@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jilles set sender to jilles@FreeBSD.org using -f From: Jilles Tjoelker Date: Sun, 9 Oct 2016 21:28:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r306924 - stable/10/etc/rc.d X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 09 Oct 2016 21:28:57 -0000 Author: jilles Date: Sun Oct 9 21:28:56 2016 New Revision: 306924 URL: https://svnweb.freebsd.org/changeset/base/306924 Log: MFC r297314: rc.d: Make msgs a proper rc.d script. PR: 207149 Reported by: Jonathan de Boyne Pollard Modified: stable/10/etc/rc.d/msgs Directory Properties: stable/10/ (props changed) Modified: stable/10/etc/rc.d/msgs ============================================================================== --- stable/10/etc/rc.d/msgs Sun Oct 9 21:05:19 2016 (r306923) +++ stable/10/etc/rc.d/msgs Sun Oct 9 21:28:56 2016 (r306924) @@ -6,8 +6,20 @@ # PROVIDE: msgs # REQUIRE: LOGIN -# Make a bounds file for msgs(1) if there isn't one already -# -if [ -d /var/msgs -a ! -f /var/msgs/bounds -a ! -L /var/msgs/bounds ]; then - echo 0 > /var/msgs/bounds -fi +. /etc/rc.subr + +name="msgs" +start_cmd="msgs_start" +stop_cmd=":" + +msgs_start() +{ + # Make a bounds file for msgs(1) if there isn't one already + # + if [ -d /var/msgs -a ! -f /var/msgs/bounds -a ! -L /var/msgs/bounds ]; then + echo 0 > /var/msgs/bounds + fi +} + +load_rc_config $name +run_rc_command "$1" From owner-svn-src-all@freebsd.org Sun Oct 9 21:35:13 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B2114C0B208; Sun, 9 Oct 2016 21:35:13 +0000 (UTC) (envelope-from jch@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 8196CE64; Sun, 9 Oct 2016 21:35:13 +0000 (UTC) (envelope-from jch@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u99LZCm6024907; Sun, 9 Oct 2016 21:35:12 GMT (envelope-from jch@FreeBSD.org) Received: (from jch@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u99LZCTR024906; Sun, 9 Oct 2016 21:35:12 GMT (envelope-from jch@FreeBSD.org) Message-Id: <201610092135.u99LZCTR024906@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jch set sender to jch@FreeBSD.org using -f From: Julien Charbon Date: Sun, 9 Oct 2016 21:35:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r306925 - stable/10/sys/netinet X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 09 Oct 2016 21:35:13 -0000 Author: jch Date: Sun Oct 9 21:35:12 2016 New Revision: 306925 URL: https://svnweb.freebsd.org/changeset/base/306925 Log: MFC r306443: Fix an issue with accept_filter introduced with r261242: As a side effect of r261242 when using accept_filter the first call to soisconnected() is done earlier in tcp_input() instead of tcp_do_segment() context. Restore the expected behaviour. Note: This call to soisconnected() seems to be extraneous in all cases (with or without accept_filter). Will be addressed in a separate commit. PR: 212920 Reported by: Alexey Tested by: Alexey, jch Sponsored by: Verisign, Inc. Modified: stable/10/sys/netinet/tcp_syncache.c Modified: stable/10/sys/netinet/tcp_syncache.c ============================================================================== --- stable/10/sys/netinet/tcp_syncache.c Sun Oct 9 21:28:56 2016 (r306924) +++ stable/10/sys/netinet/tcp_syncache.c Sun Oct 9 21:35:12 2016 (r306925) @@ -922,7 +922,9 @@ syncache_socket(struct syncache *sc, str INP_WUNLOCK(inp); - soisconnected(so); + if ((so->so_options & SO_ACCEPTFILTER) == 0) { + soisconnected(so); + } TCPSTAT_INC(tcps_accepts); return (so); From owner-svn-src-all@freebsd.org Sun Oct 9 21:47:22 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 519DAC0B52F; Sun, 9 Oct 2016 21:47:22 +0000 (UTC) (envelope-from andrew@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 1647F82C; Sun, 9 Oct 2016 21:47:22 +0000 (UTC) (envelope-from andrew@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u99LlL2p029085; Sun, 9 Oct 2016 21:47:21 GMT (envelope-from andrew@FreeBSD.org) Received: (from andrew@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u99LlLun029084; Sun, 9 Oct 2016 21:47:21 GMT (envelope-from andrew@FreeBSD.org) Message-Id: <201610092147.u99LlLun029084@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: andrew set sender to andrew@FreeBSD.org using -f From: Andrew Turner Date: Sun, 9 Oct 2016 21:47:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r306928 - head/sys/conf X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 09 Oct 2016 21:47:22 -0000 Author: andrew Date: Sun Oct 9 21:47:20 2016 New Revision: 306928 URL: https://svnweb.freebsd.org/changeset/base/306928 Log: Set INLINE_LIMIT in the aarch64 case for gcc. Submitted by: andreast MFC after: 1 week Modified: head/sys/conf/kern.mk Modified: head/sys/conf/kern.mk ============================================================================== --- head/sys/conf/kern.mk Sun Oct 9 21:39:51 2016 (r306927) +++ head/sys/conf/kern.mk Sun Oct 9 21:47:20 2016 (r306928) @@ -114,6 +114,7 @@ INLINE_LIMIT?= 8000 CFLAGS += -mgeneral-regs-only # Reserve x18 for pcpu data CFLAGS += -ffixed-x18 +INLINE_LIMIT?= 8000 .endif .if ${MACHINE_CPUARCH} == "riscv" From owner-svn-src-all@freebsd.org Mon Oct 10 03:21:12 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 154C5C07CD9; Mon, 10 Oct 2016 03:21:12 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mail106.syd.optusnet.com.au (mail106.syd.optusnet.com.au [211.29.132.42]) by mx1.freebsd.org (Postfix) with ESMTP id 5F72FED8; Mon, 10 Oct 2016 03:21:10 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from c122-106-149-109.carlnfd1.nsw.optusnet.com.au (c122-106-149-109.carlnfd1.nsw.optusnet.com.au [122.106.149.109]) by mail106.syd.optusnet.com.au (Postfix) with ESMTPS id A53BB3C2A48; Mon, 10 Oct 2016 14:21:08 +1100 (AEDT) Date: Mon, 10 Oct 2016 14:21:07 +1100 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: Michal Meloun cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r306902 - in head/sys/arm: allwinner amlogic/aml8726 at91 broadcom/bcm2835 freescale/imx lpc mv rockchip ti ti/am335x ti/omap4 ti/twl xscale/i8134x xscale/ixp425 In-Reply-To: <201610091025.u99APl98067605@repo.freebsd.org> Message-ID: <20161010140648.Y1935@besplex.bde.org> References: <201610091025.u99APl98067605@repo.freebsd.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.1 cv=VIkg5I7X c=1 sm=1 tr=0 a=R/f3m204ZbWUO/0rwPSMPw==:117 a=L9H7d07YOLsA:10 a=9cW_t1CCXrUA:10 a=s5jvgZ67dGcA:10 a=kj9zAlcOel0A:10 a=M87QekrunEUvCcydvxMA:9 a=CjuIK1q_8ugA:10 a=chvjmp5bT-K0Np4W8Gpx:22 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 Oct 2016 03:21:12 -0000 On Sun, 9 Oct 2016, Michal Meloun wrote: > Log: > ARM: Remove unused includes. > > MFC after: 1 week > ... > Modified: head/sys/arm/allwinner/a10_gpio.c > ============================================================================== > --- head/sys/arm/allwinner/a10_gpio.c Sun Oct 9 10:24:10 2016 (r306901) > +++ head/sys/arm/allwinner/a10_gpio.c Sun Oct 9 10:25:47 2016 (r306902) > @@ -41,8 +41,6 @@ __FBSDID("$FreeBSD$"); > #include > > #include > -#include > -#include > #include > #include > ... It is correct to remove them, but are they really unused? machine/cpufunc.h is my invention for holding miscellaneous 1-lime asms on i386. It is apparently something completely different (much larger and uglier) on arm. On i386, it is considered as an extension of likbern so it is included in . It is included there for all arches, and it is a style bug to not depend on that. Including sys/libkern.h is another style bug. machine/cpu.h is for holding MD definitions of MI APIs like TRAPF_USERMODE() and not much else. Almost nothing needs these APIs so almost nothing should include this header. But the header has lots of namespace pollution and might provide other APIs accidentally. On arm, it isn't much larger than on i386, but has a few definitions like struct arm_boot_params that are completely unrelated to MI APIs. get_cyclecount() is misimplemented on most arches, and arm is no exception. It is an MI API, but not worth inlining unless it is 1 fast instruction. Bruce From owner-svn-src-all@freebsd.org Mon Oct 10 04:53:16 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 61FBEC0B1CF; Mon, 10 Oct 2016 04:53:16 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 31408D5F; Mon, 10 Oct 2016 04:53:16 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9A4rFow092758; Mon, 10 Oct 2016 04:53:15 GMT (envelope-from manu@FreeBSD.org) Received: (from manu@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9A4rFqC092757; Mon, 10 Oct 2016 04:53:15 GMT (envelope-from manu@FreeBSD.org) Message-Id: <201610100453.u9A4rFqC092757@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: manu set sender to manu@FreeBSD.org using -f From: Emmanuel Vadot Date: Mon, 10 Oct 2016 04:53:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r306934 - head/sys/modules/dtb/allwinner X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 Oct 2016 04:53:16 -0000 Author: manu Date: Mon Oct 10 04:53:15 2016 New Revision: 306934 URL: https://svnweb.freebsd.org/changeset/base/306934 Log: Add CHIP dts into the build Modified: head/sys/modules/dtb/allwinner/Makefile Modified: head/sys/modules/dtb/allwinner/Makefile ============================================================================== --- head/sys/modules/dtb/allwinner/Makefile Sun Oct 9 23:27:08 2016 (r306933) +++ head/sys/modules/dtb/allwinner/Makefile Mon Oct 10 04:53:15 2016 (r306934) @@ -9,6 +9,7 @@ DTS= \ olinuxino-lime.dts \ pcduino3.dts \ sinovoip-bpi-m3.dts \ - sun5i-a13-olinuxino.dts + sun5i-a13-olinuxino.dts \ + sun5i-r8-chip.dts .include From owner-svn-src-all@freebsd.org Mon Oct 10 04:57:34 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D0890C0B360; Mon, 10 Oct 2016 04:57:34 +0000 (UTC) (envelope-from julian@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id A01D62B; Mon, 10 Oct 2016 04:57:34 +0000 (UTC) (envelope-from julian@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9A4vXAM092951; Mon, 10 Oct 2016 04:57:33 GMT (envelope-from julian@FreeBSD.org) Received: (from julian@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9A4vXlI092950; Mon, 10 Oct 2016 04:57:33 GMT (envelope-from julian@FreeBSD.org) Message-Id: <201610100457.u9A4vXlI092950@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: julian set sender to julian@FreeBSD.org using -f From: Julian Elischer Date: Mon, 10 Oct 2016 04:57:33 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r306935 - stable/10/sys/kern X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 Oct 2016 04:57:34 -0000 Author: julian Date: Mon Oct 10 04:57:33 2016 New Revision: 306935 URL: https://svnweb.freebsd.org/changeset/base/306935 Log: While the thread is sleeping in taskqueue_drain_all() it is posible that the queue entry it is looking at is removed from the queue, but we make no effort to account for this. when we wake up we need to check it's still there. PR: 209580 Sponsored by: Panzura inc Differential Revision: D8160 Modified: stable/10/sys/kern/subr_taskqueue.c Modified: stable/10/sys/kern/subr_taskqueue.c ============================================================================== --- stable/10/sys/kern/subr_taskqueue.c Mon Oct 10 04:53:15 2016 (r306934) +++ stable/10/sys/kern/subr_taskqueue.c Mon Oct 10 04:57:33 2016 (r306935) @@ -454,9 +454,26 @@ taskqueue_drain_all(struct taskqueue *qu TQ_LOCK(queue); task = STAILQ_LAST(&queue->tq_queue, task, ta_link); - if (task != NULL) - while (task->ta_pending != 0) - TQ_SLEEP(queue, task, &queue->tq_mutex, PWAIT, "-", 0); + while (task != NULL && task->ta_pending != 0) { + struct task *oldtask; + TQ_SLEEP(queue, task, &queue->tq_mutex, PWAIT, "-", 0); + /* + * While we were asleeep the last entry may have been freed. + * We need to check if it's still even in the queue. + * Not perfect, but it's better than referencing bad memory. + * first guess is the current 'end of queue' but if a new + * item has been added we need to take the expensive path + * Better fix in 11. + */ + oldtask = task; + if (oldtask != + (task = STAILQ_LAST(&queue->tq_queue, task, ta_link))) { + STAILQ_FOREACH(task, &queue->tq_queue, ta_link) { + if (task == oldtask) + break; + } + } + } taskqueue_drain_running(queue); KASSERT(STAILQ_EMPTY(&queue->tq_queue), ("taskqueue queue is not empty after draining")); From owner-svn-src-all@freebsd.org Mon Oct 10 05:41:40 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id EB846C0B08C; Mon, 10 Oct 2016 05:41:40 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id B73FEDBA; Mon, 10 Oct 2016 05:41:40 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9A5fdUP011128; Mon, 10 Oct 2016 05:41:39 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9A5fd2C011125; Mon, 10 Oct 2016 05:41:39 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610100541.u9A5fd2C011125@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Mon, 10 Oct 2016 05:41:39 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r306936 - in head/sys: dev/hyperv/netvsc net X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 Oct 2016 05:41:41 -0000 Author: sephe Date: Mon Oct 10 05:41:39 2016 New Revision: 306936 URL: https://svnweb.freebsd.org/changeset/base/306936 Log: hyperv/hn: Fix checksum offload settings The _correct_ way to identify the supported checksum offloading and TSO parameters is to query OID_TCP_OFFLOAD_HARDWARE_CAPABILITIES. MFC after: 1 week Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8088 Modified: head/sys/dev/hyperv/netvsc/hv_rndis_filter.c head/sys/dev/hyperv/netvsc/ndis.h head/sys/net/rndis.h Modified: head/sys/dev/hyperv/netvsc/hv_rndis_filter.c ============================================================================== --- head/sys/dev/hyperv/netvsc/hv_rndis_filter.c Mon Oct 10 04:57:33 2016 (r306935) +++ head/sys/dev/hyperv/netvsc/hv_rndis_filter.c Mon Oct 10 05:41:39 2016 (r306936) @@ -68,6 +68,16 @@ __FBSDID("$FreeBSD$"); #define HN_RNDIS_XFER_SIZE 2048 +#define HN_NDIS_TXCSUM_CAP_IP4 \ + (NDIS_TXCSUM_CAP_IP4 | NDIS_TXCSUM_CAP_IP4OPT) +#define HN_NDIS_TXCSUM_CAP_TCP4 \ + (NDIS_TXCSUM_CAP_TCP4 | NDIS_TXCSUM_CAP_TCP4OPT) +#define HN_NDIS_TXCSUM_CAP_TCP6 \ + (NDIS_TXCSUM_CAP_TCP6 | NDIS_TXCSUM_CAP_TCP6OPT | \ + NDIS_TXCSUM_CAP_IP6EXT) +#define HN_NDIS_TXCSUM_CAP_UDP6 \ + (NDIS_TXCSUM_CAP_UDP6 | NDIS_TXCSUM_CAP_IP6EXT) + /* * Forward declarations */ @@ -78,9 +88,14 @@ static void hv_rf_receive_data(struct hn static int hn_rndis_query(struct hn_softc *sc, uint32_t oid, const void *idata, size_t idlen, void *odata, size_t *odlen0); +static int hn_rndis_query2(struct hn_softc *sc, uint32_t oid, + const void *idata, size_t idlen, void *odata, size_t *odlen0, + size_t min_odlen); static int hn_rndis_set(struct hn_softc *sc, uint32_t oid, const void *data, size_t dlen); static int hn_rndis_conf_offload(struct hn_softc *sc); +static int hn_rndis_query_hwcaps(struct hn_softc *sc, + struct ndis_offload *caps); static __inline uint32_t hn_rndis_rid(struct hn_softc *sc) @@ -624,6 +639,15 @@ static int hn_rndis_query(struct hn_softc *sc, uint32_t oid, const void *idata, size_t idlen, void *odata, size_t *odlen0) { + + return (hn_rndis_query2(sc, oid, idata, idlen, odata, odlen0, *odlen0)); +} + +static int +hn_rndis_query2(struct hn_softc *sc, uint32_t oid, + const void *idata, size_t idlen, void *odata, size_t *odlen0, + size_t min_odlen) +{ struct rndis_query_req *req; const struct rndis_query_comp *comp; struct vmbus_xact *xact; @@ -661,7 +685,7 @@ hn_rndis_query(struct hn_softc *sc, uint memcpy(req + 1, idata, idlen); } - comp_len = sizeof(*comp) + odlen; + comp_len = sizeof(*comp) + min_odlen; comp = hn_rndis_xact_execute(sc, xact, rid, reqlen, &comp_len, REMOTE_NDIS_QUERY_CMPLT); if (comp == NULL) { @@ -808,11 +832,18 @@ done: static int hn_rndis_conf_offload(struct hn_softc *sc) { + struct ndis_offload hwcaps; struct ndis_offload_params params; - uint32_t caps; + uint32_t caps = 0; size_t paramsz; int error; + error = hn_rndis_query_hwcaps(sc, &hwcaps); + if (error) { + if_printf(sc->hn_ifp, "hwcaps query failed: %d\n", error); + return (error); + } + /* NOTE: 0 means "no change" */ memset(¶ms, 0, sizeof(params)); @@ -826,18 +857,96 @@ hn_rndis_conf_offload(struct hn_softc *s } params.ndis_hdr.ndis_size = paramsz; - caps = HN_CAP_IPCS | HN_CAP_TCP4CS | HN_CAP_TCP6CS; - params.ndis_ip4csum = NDIS_OFFLOAD_PARAM_TXRX; - params.ndis_tcp4csum = NDIS_OFFLOAD_PARAM_TXRX; - params.ndis_tcp6csum = NDIS_OFFLOAD_PARAM_TXRX; - if (sc->hn_ndis_ver >= HN_NDIS_VERSION_6_30) { - caps |= HN_CAP_UDP4CS | HN_CAP_UDP6CS; - params.ndis_udp4csum = NDIS_OFFLOAD_PARAM_TXRX; - params.ndis_udp6csum = NDIS_OFFLOAD_PARAM_TXRX; - } - caps |= HN_CAP_TSO4; - params.ndis_lsov2_ip4 = NDIS_OFFLOAD_LSOV2_ON; - /* XXX ndis_lsov2_ip6 = NDIS_OFFLOAD_LSOV2_ON */ + /* TSO */ + if (hwcaps.ndis_lsov2.ndis_ip4_encap & NDIS_OFFLOAD_ENCAP_8023) { + caps |= HN_CAP_TSO4; + params.ndis_lsov2_ip4 = NDIS_OFFLOAD_LSOV2_ON; + /* TODO: tso_max */ + } + if (hwcaps.ndis_lsov2.ndis_ip6_encap & NDIS_OFFLOAD_ENCAP_8023) { +#ifdef notyet + caps |= HN_CAP_TSO6; + params.ndis_lsov2_ip6 = NDIS_OFFLOAD_LSOV2_ON; +#endif + /* TODO: tso_max */ + } + + /* IPv4 checksum */ + if ((hwcaps.ndis_csum.ndis_ip4_txcsum & HN_NDIS_TXCSUM_CAP_IP4) == + HN_NDIS_TXCSUM_CAP_IP4) { + caps |= HN_CAP_IPCS; + params.ndis_ip4csum = NDIS_OFFLOAD_PARAM_TX; + } + if (hwcaps.ndis_csum.ndis_ip4_rxcsum & NDIS_RXCSUM_CAP_IP4) { + if (params.ndis_ip4csum == NDIS_OFFLOAD_PARAM_TX) + params.ndis_ip4csum = NDIS_OFFLOAD_PARAM_TXRX; + else + params.ndis_ip4csum = NDIS_OFFLOAD_PARAM_RX; + } + + /* TCP4 checksum */ + if ((hwcaps.ndis_csum.ndis_ip4_txcsum & HN_NDIS_TXCSUM_CAP_TCP4) == + HN_NDIS_TXCSUM_CAP_TCP4) { + caps |= HN_CAP_TCP4CS; + params.ndis_tcp4csum = NDIS_OFFLOAD_PARAM_TX; + } + if (hwcaps.ndis_csum.ndis_ip4_rxcsum & NDIS_RXCSUM_CAP_TCP4) { + if (params.ndis_tcp4csum == NDIS_OFFLOAD_PARAM_TX) + params.ndis_tcp4csum = NDIS_OFFLOAD_PARAM_TXRX; + else + params.ndis_tcp4csum = NDIS_OFFLOAD_PARAM_RX; + } + + /* UDP4 checksum */ + if (hwcaps.ndis_csum.ndis_ip4_txcsum & NDIS_TXCSUM_CAP_UDP4) { + caps |= HN_CAP_UDP4CS; + params.ndis_udp4csum = NDIS_OFFLOAD_PARAM_TX; + } + if (hwcaps.ndis_csum.ndis_ip4_rxcsum & NDIS_RXCSUM_CAP_UDP4) { + if (params.ndis_udp4csum == NDIS_OFFLOAD_PARAM_TX) + params.ndis_udp4csum = NDIS_OFFLOAD_PARAM_TXRX; + else + params.ndis_udp4csum = NDIS_OFFLOAD_PARAM_RX; + } + + /* TCP6 checksum */ + if ((hwcaps.ndis_csum.ndis_ip6_txcsum & HN_NDIS_TXCSUM_CAP_TCP6) == + HN_NDIS_TXCSUM_CAP_TCP6) { + caps |= HN_CAP_TCP6CS; + params.ndis_tcp6csum = NDIS_OFFLOAD_PARAM_TX; + } + if (hwcaps.ndis_csum.ndis_ip6_rxcsum & NDIS_RXCSUM_CAP_TCP6) { + if (params.ndis_tcp6csum == NDIS_OFFLOAD_PARAM_TX) + params.ndis_tcp6csum = NDIS_OFFLOAD_PARAM_TXRX; + else + params.ndis_tcp6csum = NDIS_OFFLOAD_PARAM_RX; + } + + /* UDP6 checksum */ + if ((hwcaps.ndis_csum.ndis_ip6_txcsum & HN_NDIS_TXCSUM_CAP_UDP6) == + HN_NDIS_TXCSUM_CAP_UDP6) { + caps |= HN_CAP_UDP6CS; + params.ndis_udp6csum = NDIS_OFFLOAD_PARAM_TX; + } + if (hwcaps.ndis_csum.ndis_ip6_rxcsum & NDIS_RXCSUM_CAP_UDP6) { + if (params.ndis_udp6csum == NDIS_OFFLOAD_PARAM_TX) + params.ndis_udp6csum = NDIS_OFFLOAD_PARAM_TXRX; + else + params.ndis_udp6csum = NDIS_OFFLOAD_PARAM_RX; + } + + if (bootverbose) { + if_printf(sc->hn_ifp, "offload csum: " + "ip4 %u, tcp4 %u, udp4 %u, tcp6 %u, udp6 %u\n", + params.ndis_ip4csum, + params.ndis_tcp4csum, + params.ndis_udp4csum, + params.ndis_tcp6csum, + params.ndis_udp6csum); + if_printf(sc->hn_ifp, "offload lsov2: ip4 %u, ip6 %u\n", + params.ndis_lsov2_ip4, + params.ndis_lsov2_ip6); + } error = hn_rndis_set(sc, OID_TCP_OFFLOAD_PARAMETERS, ¶ms, paramsz); if (error) { @@ -994,6 +1103,88 @@ hn_rndis_halt(struct hn_softc *sc) return (0); } +static int +hn_rndis_query_hwcaps(struct hn_softc *sc, struct ndis_offload *caps) +{ + struct ndis_offload in; + size_t caps_len, size; + int error; + + memset(&in, 0, sizeof(in)); + in.ndis_hdr.ndis_type = NDIS_OBJTYPE_OFFLOAD; + if (sc->hn_ndis_ver >= HN_NDIS_VERSION_6_30) { + in.ndis_hdr.ndis_rev = NDIS_OFFLOAD_REV_3; + size = NDIS_OFFLOAD_SIZE; + } else if (sc->hn_ndis_ver >= HN_NDIS_VERSION_6_1) { + in.ndis_hdr.ndis_rev = NDIS_OFFLOAD_REV_2; + size = NDIS_OFFLOAD_SIZE_2; + } else { + in.ndis_hdr.ndis_rev = NDIS_OFFLOAD_REV_1; + size = NDIS_OFFLOAD_SIZE_1; + } + in.ndis_hdr.ndis_size = size; + + caps_len = NDIS_OFFLOAD_SIZE; + error = hn_rndis_query2(sc, OID_TCP_OFFLOAD_HARDWARE_CAPABILITIES, + &in, size, caps, &caps_len, NDIS_OFFLOAD_SIZE_1); + if (error) + return (error); + + /* + * Preliminary verification. + */ + if (caps->ndis_hdr.ndis_type != NDIS_OBJTYPE_OFFLOAD) { + if_printf(sc->hn_ifp, "invalid NDIS objtype 0x%02x\n", + caps->ndis_hdr.ndis_type); + return (EINVAL); + } + if (caps->ndis_hdr.ndis_rev < NDIS_OFFLOAD_REV_1) { + if_printf(sc->hn_ifp, "invalid NDIS objrev 0x%02x\n", + caps->ndis_hdr.ndis_rev); + return (EINVAL); + } + if (caps->ndis_hdr.ndis_size > caps_len) { + if_printf(sc->hn_ifp, "invalid NDIS objsize %u, " + "data size %zu\n", caps->ndis_hdr.ndis_size, caps_len); + return (EINVAL); + } else if (caps->ndis_hdr.ndis_size < NDIS_OFFLOAD_SIZE_1) { + if_printf(sc->hn_ifp, "invalid NDIS objsize %u\n", + caps->ndis_hdr.ndis_size); + return (EINVAL); + } + + if (bootverbose) { + /* + * Fields for NDIS 6.0 are accessable. + */ + if_printf(sc->hn_ifp, "hwcaps rev %u\n", + caps->ndis_hdr.ndis_rev); + + if_printf(sc->hn_ifp, "hwcaps csum: " + "ip4 tx 0x%x/0x%x rx 0x%x/0x%x, " + "ip6 tx 0x%x/0x%x rx 0x%x/0x%x\n", + caps->ndis_csum.ndis_ip4_txcsum, + caps->ndis_csum.ndis_ip4_txenc, + caps->ndis_csum.ndis_ip4_rxcsum, + caps->ndis_csum.ndis_ip4_rxenc, + caps->ndis_csum.ndis_ip6_txcsum, + caps->ndis_csum.ndis_ip6_txenc, + caps->ndis_csum.ndis_ip6_rxcsum, + caps->ndis_csum.ndis_ip6_rxenc); + if_printf(sc->hn_ifp, "hwcaps lsov2: " + "ip4 maxsz %u minsg %u encap 0x%x, " + "ip6 maxsz %u minsg %u encap 0x%x opts 0x%x\n", + caps->ndis_lsov2.ndis_ip4_maxsz, + caps->ndis_lsov2.ndis_ip4_minsg, + caps->ndis_lsov2.ndis_ip4_encap, + caps->ndis_lsov2.ndis_ip6_maxsz, + caps->ndis_lsov2.ndis_ip6_minsg, + caps->ndis_lsov2.ndis_ip6_encap, + caps->ndis_lsov2.ndis_ip6_opts); + } + return (0); +} + int hn_rndis_attach(struct hn_softc *sc) { Modified: head/sys/dev/hyperv/netvsc/ndis.h ============================================================================== --- head/sys/dev/hyperv/netvsc/ndis.h Mon Oct 10 04:57:33 2016 (r306935) +++ head/sys/dev/hyperv/netvsc/ndis.h Mon Oct 10 05:41:39 2016 (r306936) @@ -59,6 +59,7 @@ #define NDIS_OBJTYPE_DEFAULT 0x80 #define NDIS_OBJTYPE_RSS_CAPS 0x88 #define NDIS_OBJTYPE_RSS_PARAMS 0x89 +#define NDIS_OBJTYPE_OFFLOAD 0xa7 struct ndis_object_hdr { uint8_t ndis_type; /* NDIS_OBJTYPE_ */ @@ -205,6 +206,129 @@ struct ndis_rssprm_toeplitz { }; /* + * OID_TCP_OFFLOAD_HARDWARE_CAPABILITIES + * ndis_type: NDIS_OBJTYPE_OFFLOAD + */ + +#define NDIS_OFFLOAD_ENCAP_NONE 0x0000 +#define NDIS_OFFLOAD_ENCAP_NULL 0x0001 +#define NDIS_OFFLOAD_ENCAP_8023 0x0002 +#define NDIS_OFFLOAD_ENCAP_8023PQ 0x0004 +#define NDIS_OFFLOAD_ENCAP_8023PQ_OOB 0x0008 +#define NDIS_OFFLOAD_ENCAP_RFC1483 0x0010 + +struct ndis_csum_offload { + uint32_t ndis_ip4_txenc; /*NDIS_OFFLOAD_ENCAP_*/ + uint32_t ndis_ip4_txcsum; +#define NDIS_TXCSUM_CAP_IP4OPT 0x001 +#define NDIS_TXCSUM_CAP_TCP4OPT 0x004 +#define NDIS_TXCSUM_CAP_TCP4 0x010 +#define NDIS_TXCSUM_CAP_UDP4 0x040 +#define NDIS_TXCSUM_CAP_IP4 0x100 + uint32_t ndis_ip4_rxenc; /*NDIS_OFFLOAD_ENCAP_*/ + uint32_t ndis_ip4_rxcsum; +#define NDIS_RXCSUM_CAP_IP4OPT 0x001 +#define NDIS_RXCSUM_CAP_TCP4OPT 0x004 +#define NDIS_RXCSUM_CAP_TCP4 0x010 +#define NDIS_RXCSUM_CAP_UDP4 0x040 +#define NDIS_RXCSUM_CAP_IP4 0x100 + uint32_t ndis_ip6_txenc; /*NDIS_OFFLOAD_ENCAP_*/ + uint32_t ndis_ip6_txcsum; +#define NDIS_TXCSUM_CAP_IP6EXT 0x001 +#define NDIS_TXCSUM_CAP_TCP6OPT 0x004 +#define NDIS_TXCSUM_CAP_TCP6 0x010 +#define NDIS_TXCSUM_CAP_UDP6 0x040 + uint32_t ndis_ip6_rxenc; /*NDIS_OFFLOAD_ENCAP_*/ + uint32_t ndis_ip6_rxcsum; +#define NDIS_RXCSUM_CAP_IP6EXT 0x001 +#define NDIS_RXCSUM_CAP_TCP6OPT 0x004 +#define NDIS_RXCSUM_CAP_TCP6 0x010 +#define NDIS_RXCSUM_CAP_UDP6 0x040 +}; + +struct ndis_lsov1_offload { + uint32_t ndis_encap; /*NDIS_OFFLOAD_ENCAP_*/ + uint32_t ndis_maxsize; + uint32_t ndis_minsegs; + uint32_t ndis_opts; +}; + +struct ndis_ipsecv1_offload { + uint32_t ndis_encap; /*NDIS_OFFLOAD_ENCAP_*/ + uint32_t ndis_ah_esp; + uint32_t ndis_xport_tun; + uint32_t ndis_ip4_opts; + uint32_t ndis_flags; + uint32_t ndis_ip4_ah; + uint32_t ndis_ip4_esp; +}; + +struct ndis_lsov2_offload { + uint32_t ndis_ip4_encap; /*NDIS_OFFLOAD_ENCAP_*/ + uint32_t ndis_ip4_maxsz; + uint32_t ndis_ip4_minsg; + uint32_t ndis_ip6_encap; /*NDIS_OFFLOAD_ENCAP_*/ + uint32_t ndis_ip6_maxsz; + uint32_t ndis_ip6_minsg; + uint32_t ndis_ip6_opts; +#define NDIS_LSOV2_CAP_IP6EXT 0x001 +#define NDIS_LSOV2_CAP_TCP6OPT 0x004 +}; + +struct ndis_ipsecv2_offload { + uint32_t ndis_encap; /*NDIS_OFFLOAD_ENCAP_*/ + uint16_t ndis_ip6; + uint16_t ndis_ip4opt; + uint16_t ndis_ip6ext; + uint16_t ndis_ah; + uint16_t ndis_esp; + uint16_t ndis_ah_esp; + uint16_t ndis_xport; + uint16_t ndis_tun; + uint16_t ndis_xport_tun; + uint16_t ndis_lso; + uint16_t ndis_extseq; + uint32_t ndis_udp_esp; + uint32_t ndis_auth; + uint32_t ndis_crypto; + uint32_t ndis_sa_caps; +}; + +struct ndis_rsc_offload { + uint16_t ndis_ip4; + uint16_t ndis_ip6; +}; + +struct ndis_encap_offload { + uint32_t ndis_flags; + uint32_t ndis_maxhdr; +}; + +struct ndis_offload { + struct ndis_object_hdr ndis_hdr; + struct ndis_csum_offload ndis_csum; + struct ndis_lsov1_offload ndis_lsov1; + struct ndis_ipsecv1_offload ndis_ipsecv1; + struct ndis_lsov2_offload ndis_lsov2; + uint32_t ndis_flags; + /* NDIS >= 6.1 */ + struct ndis_ipsecv2_offload ndis_ipsecv2; + /* NDIS >= 6.30 */ + struct ndis_rsc_offload ndis_rsc; + struct ndis_encap_offload ndis_encap_gre; +}; + +#define NDIS_OFFLOAD_SIZE sizeof(struct ndis_offload) +#define NDIS_OFFLOAD_SIZE_1 \ + __offsetof(struct ndis_offload, ndis_ipsecv2) +#define NDIS_OFFLOAD_SIZE_2 \ + __offsetof(struct ndis_offload, ndis_rsc) + +#define NDIS_OFFLOAD_REV_1 1 /* NDIS 6.0 */ +#define NDIS_OFFLOAD_REV_2 2 /* NDIS 6.1 */ +#define NDIS_OFFLOAD_REV_3 3 /* NDIS 6.30 */ + +/* * Per-packet-info */ Modified: head/sys/net/rndis.h ============================================================================== --- head/sys/net/rndis.h Mon Oct 10 04:57:33 2016 (r306935) +++ head/sys/net/rndis.h Mon Oct 10 05:41:39 2016 (r306936) @@ -87,6 +87,7 @@ #define OID_802_3_XMIT_LATE_COLLISIONS 0x01020207 #define OID_TCP_OFFLOAD_PARAMETERS 0xFC01020C +#define OID_TCP_OFFLOAD_HARDWARE_CAPABILITIES 0xFC01020D #define RNDIS_MEDIUM_802_3 0x00000000 From owner-svn-src-all@freebsd.org Mon Oct 10 05:50:03 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 45C88C0B33A; Mon, 10 Oct 2016 05:50:03 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 2282015A; Mon, 10 Oct 2016 05:50:03 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9A5o2kA012153; Mon, 10 Oct 2016 05:50:02 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9A5o1qg012149; Mon, 10 Oct 2016 05:50:01 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610100550.u9A5o1qg012149@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Mon, 10 Oct 2016 05:50:01 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r306937 - head/sys/dev/hyperv/netvsc X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 Oct 2016 05:50:03 -0000 Author: sephe Date: Mon Oct 10 05:50:01 2016 New Revision: 306937 URL: https://svnweb.freebsd.org/changeset/base/306937 Log: hyperv/hn: Fix if_hw_tsomax setup. MFC after: 1 week Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8089 Modified: head/sys/dev/hyperv/netvsc/hv_net_vsc.h head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c head/sys/dev/hyperv/netvsc/hv_rndis_filter.c head/sys/dev/hyperv/netvsc/if_hnvar.h Modified: head/sys/dev/hyperv/netvsc/hv_net_vsc.h ============================================================================== --- head/sys/dev/hyperv/netvsc/hv_net_vsc.h Mon Oct 10 05:41:39 2016 (r306936) +++ head/sys/dev/hyperv/netvsc/hv_net_vsc.h Mon Oct 10 05:50:01 2016 (r306937) @@ -244,6 +244,8 @@ struct hn_softc { uint32_t hn_rndis_rid; uint32_t hn_ndis_ver; + int hn_ndis_tso_szmax; + int hn_ndis_tso_sgmin; struct ndis_rssprm_toeplitz hn_rss; }; Modified: head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c ============================================================================== --- head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Mon Oct 10 05:41:39 2016 (r306936) +++ head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Mon Oct 10 05:50:01 2016 (r306937) @@ -230,7 +230,7 @@ SYSCTL_INT(_hw_hn, OID_AUTO, trust_hosti "when csum info is missing (global setting)"); /* Limit TSO burst size */ -static int hn_tso_maxlen = 0; +static int hn_tso_maxlen = IP_MAXPACKET; SYSCTL_INT(_hw_hn, OID_AUTO, tso_maxlen, CTLFLAG_RDTUN, &hn_tso_maxlen, 0, "TSO burst limit"); @@ -338,6 +338,7 @@ static int hn_encap(struct hn_tx_ring *, static int hn_create_rx_data(struct hn_softc *sc, int); static void hn_destroy_rx_data(struct hn_softc *sc); static void hn_set_chim_size(struct hn_softc *, int); +static void hn_set_tso_maxsize(struct hn_softc *, int, int); static int hn_chan_attach(struct hn_softc *, struct vmbus_channel *); static void hn_chan_detach(struct hn_softc *, struct vmbus_channel *); static int hn_attach_subchans(struct hn_softc *); @@ -520,7 +521,6 @@ netvsc_attach(device_t dev) uint32_t link_status; struct ifnet *ifp = NULL; int error, ring_cnt, tx_ring_cnt; - int tso_maxlen; sc->hn_dev = dev; sc->hn_prichan = vmbus_get_channel(dev); @@ -720,18 +720,16 @@ netvsc_attach(device_t dev) /* Enable all available capabilities by default. */ ifp->if_capenable = ifp->if_capabilities; - tso_maxlen = hn_tso_maxlen; - if (tso_maxlen <= 0 || tso_maxlen > IP_MAXPACKET) - tso_maxlen = IP_MAXPACKET; - ifp->if_hw_tsomaxsegcount = HN_TX_DATA_SEGCNT_MAX; - ifp->if_hw_tsomaxsegsize = PAGE_SIZE; - ifp->if_hw_tsomax = tso_maxlen - - (ETHER_HDR_LEN + ETHER_VLAN_ENCAP_LEN); + if (ifp->if_capabilities & (IFCAP_TSO6 | IFCAP_TSO4)) { + hn_set_tso_maxsize(sc, hn_tso_maxlen, ETHERMTU); + ifp->if_hw_tsomaxsegcount = HN_TX_DATA_SEGCNT_MAX; + ifp->if_hw_tsomaxsegsize = PAGE_SIZE; + } ether_ifattach(ifp, eaddr); - if (bootverbose) { - if_printf(ifp, "TSO: %u/%u/%u\n", ifp->if_hw_tsomax, + if ((ifp->if_capabilities & (IFCAP_TSO6 | IFCAP_TSO4)) && bootverbose) { + if_printf(ifp, "TSO segcnt %u segsz %u\n", ifp->if_hw_tsomaxsegcount, ifp->if_hw_tsomaxsegsize); } @@ -1672,6 +1670,7 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, if (sc->hn_tx_ring[0].hn_chim_size > sc->hn_chim_szmax) hn_set_chim_size(sc, sc->hn_chim_szmax); + hn_set_tso_maxsize(sc, hn_tso_maxlen, ifr->ifr_mtu); /* All done! Resume now. */ if (ifp->if_drv_flags & IFF_DRV_RUNNING) @@ -2919,6 +2918,34 @@ hn_set_chim_size(struct hn_softc *sc, in } static void +hn_set_tso_maxsize(struct hn_softc *sc, int tso_maxlen, int mtu) +{ + struct ifnet *ifp = sc->hn_ifp; + int tso_minlen; + + if ((ifp->if_capabilities & (IFCAP_TSO4 | IFCAP_TSO6)) == 0) + return; + + KASSERT(sc->hn_ndis_tso_sgmin >= 2, + ("invalid NDIS tso sgmin %d", sc->hn_ndis_tso_sgmin)); + tso_minlen = sc->hn_ndis_tso_sgmin * mtu; + + KASSERT(sc->hn_ndis_tso_szmax >= tso_minlen && + sc->hn_ndis_tso_szmax <= IP_MAXPACKET, + ("invalid NDIS tso szmax %d", sc->hn_ndis_tso_szmax)); + + if (tso_maxlen < tso_minlen) + tso_maxlen = tso_minlen; + else if (tso_maxlen > IP_MAXPACKET) + tso_maxlen = IP_MAXPACKET; + if (tso_maxlen > sc->hn_ndis_tso_szmax) + tso_maxlen = sc->hn_ndis_tso_szmax; + ifp->if_hw_tsomax = tso_maxlen - (ETHER_HDR_LEN + ETHER_VLAN_ENCAP_LEN); + if (bootverbose) + if_printf(ifp, "TSO size max %u\n", ifp->if_hw_tsomax); +} + +static void hn_fixup_tx_data(struct hn_softc *sc) { uint64_t csum_assist; @@ -3424,7 +3451,7 @@ hn_synth_attach(struct hn_softc *sc, int /* * Attach RNDIS _after_ NVS is attached. */ - error = hn_rndis_attach(sc); + error = hn_rndis_attach(sc, mtu); if (error) return (error); Modified: head/sys/dev/hyperv/netvsc/hv_rndis_filter.c ============================================================================== --- head/sys/dev/hyperv/netvsc/hv_rndis_filter.c Mon Oct 10 05:41:39 2016 (r306936) +++ head/sys/dev/hyperv/netvsc/hv_rndis_filter.c Mon Oct 10 05:50:01 2016 (r306937) @@ -39,6 +39,8 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include +#include #include #include #include @@ -77,6 +79,8 @@ __FBSDID("$FreeBSD$"); NDIS_TXCSUM_CAP_IP6EXT) #define HN_NDIS_TXCSUM_CAP_UDP6 \ (NDIS_TXCSUM_CAP_UDP6 | NDIS_TXCSUM_CAP_IP6EXT) +#define HN_NDIS_LSOV2_CAP_IP6 \ + (NDIS_LSOV2_CAP_IP6EXT | NDIS_LSOV2_CAP_TCP6OPT) /* * Forward declarations @@ -93,7 +97,7 @@ static int hn_rndis_query2(struct hn_sof size_t min_odlen); static int hn_rndis_set(struct hn_softc *sc, uint32_t oid, const void *data, size_t dlen); -static int hn_rndis_conf_offload(struct hn_softc *sc); +static int hn_rndis_conf_offload(struct hn_softc *sc, int mtu); static int hn_rndis_query_hwcaps(struct hn_softc *sc, struct ndis_offload *caps); @@ -830,13 +834,13 @@ done: } static int -hn_rndis_conf_offload(struct hn_softc *sc) +hn_rndis_conf_offload(struct hn_softc *sc, int mtu) { struct ndis_offload hwcaps; struct ndis_offload_params params; uint32_t caps = 0; size_t paramsz; - int error; + int error, tso_maxsz, tso_minsg; error = hn_rndis_query_hwcaps(sc, &hwcaps); if (error) { @@ -857,18 +861,58 @@ hn_rndis_conf_offload(struct hn_softc *s } params.ndis_hdr.ndis_size = paramsz; - /* TSO */ + /* + * TSO4/TSO6 setup. + */ + tso_maxsz = IP_MAXPACKET; + tso_minsg = 2; if (hwcaps.ndis_lsov2.ndis_ip4_encap & NDIS_OFFLOAD_ENCAP_8023) { caps |= HN_CAP_TSO4; params.ndis_lsov2_ip4 = NDIS_OFFLOAD_LSOV2_ON; - /* TODO: tso_max */ - } - if (hwcaps.ndis_lsov2.ndis_ip6_encap & NDIS_OFFLOAD_ENCAP_8023) { + + if (hwcaps.ndis_lsov2.ndis_ip4_maxsz < tso_maxsz) + tso_maxsz = hwcaps.ndis_lsov2.ndis_ip4_maxsz; + if (hwcaps.ndis_lsov2.ndis_ip4_minsg > tso_minsg) + tso_minsg = hwcaps.ndis_lsov2.ndis_ip4_minsg; + } + if ((hwcaps.ndis_lsov2.ndis_ip6_encap & NDIS_OFFLOAD_ENCAP_8023) && + (hwcaps.ndis_lsov2.ndis_ip6_opts & HN_NDIS_LSOV2_CAP_IP6) == + HN_NDIS_LSOV2_CAP_IP6) { #ifdef notyet caps |= HN_CAP_TSO6; params.ndis_lsov2_ip6 = NDIS_OFFLOAD_LSOV2_ON; + + if (hwcaps.ndis_lsov2.ndis_ip6_maxsz < tso_maxsz) + tso_maxsz = hwcaps.ndis_lsov2.ndis_ip6_maxsz; + if (hwcaps.ndis_lsov2.ndis_ip6_minsg > tso_minsg) + tso_minsg = hwcaps.ndis_lsov2.ndis_ip6_minsg; #endif - /* TODO: tso_max */ + } + sc->hn_ndis_tso_szmax = 0; + sc->hn_ndis_tso_sgmin = 0; + if (caps & (HN_CAP_TSO4 | HN_CAP_TSO6)) { + KASSERT(tso_maxsz <= IP_MAXPACKET, + ("invalid NDIS TSO maxsz %d", tso_maxsz)); + KASSERT(tso_minsg >= 2, + ("invalid NDIS TSO minsg %d", tso_minsg)); + if (tso_maxsz < tso_minsg * mtu) { + if_printf(sc->hn_ifp, "invalid NDIS TSO config: " + "maxsz %d, minsg %d, mtu %d; " + "disable TSO4 and TSO6\n", + tso_maxsz, tso_minsg, mtu); + caps &= ~(HN_CAP_TSO4 | HN_CAP_TSO6); + params.ndis_lsov2_ip4 = NDIS_OFFLOAD_LSOV2_OFF; + params.ndis_lsov2_ip6 = NDIS_OFFLOAD_LSOV2_OFF; + } else { + sc->hn_ndis_tso_szmax = tso_maxsz; + sc->hn_ndis_tso_sgmin = tso_minsg; + if (bootverbose) { + if_printf(sc->hn_ifp, "NDIS TSO " + "szmax %d sgmin %d\n", + sc->hn_ndis_tso_szmax, + sc->hn_ndis_tso_sgmin); + } + } } /* IPv4 checksum */ @@ -1186,7 +1230,7 @@ hn_rndis_query_hwcaps(struct hn_softc *s } int -hn_rndis_attach(struct hn_softc *sc) +hn_rndis_attach(struct hn_softc *sc, int mtu) { int error; @@ -1201,7 +1245,7 @@ hn_rndis_attach(struct hn_softc *sc) * Configure NDIS offload settings. * XXX no offloading, if error happened? */ - hn_rndis_conf_offload(sc); + hn_rndis_conf_offload(sc, mtu); return (0); } Modified: head/sys/dev/hyperv/netvsc/if_hnvar.h ============================================================================== --- head/sys/dev/hyperv/netvsc/if_hnvar.h Mon Oct 10 05:41:39 2016 (r306936) +++ head/sys/dev/hyperv/netvsc/if_hnvar.h Mon Oct 10 05:50:01 2016 (r306937) @@ -117,7 +117,7 @@ struct rndis_packet_msg; uint32_t hn_chim_alloc(struct hn_softc *sc); void hn_chim_free(struct hn_softc *sc, uint32_t chim_idx); -int hn_rndis_attach(struct hn_softc *sc); +int hn_rndis_attach(struct hn_softc *sc, int mtu); void hn_rndis_detach(struct hn_softc *sc); int hn_rndis_conf_rss(struct hn_softc *sc, uint16_t flags); void *hn_rndis_pktinfo_append(struct rndis_packet_msg *, From owner-svn-src-all@freebsd.org Mon Oct 10 05:59:32 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 31ECFC0B4C2; Mon, 10 Oct 2016 05:59:32 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id E3CA87F4; Mon, 10 Oct 2016 05:59:31 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9A5xUYV015967; Mon, 10 Oct 2016 05:59:30 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9A5xUkL015966; Mon, 10 Oct 2016 05:59:30 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610100559.u9A5xUkL015966@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Mon, 10 Oct 2016 05:59:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r306938 - head/sys/dev/hyperv/netvsc X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 Oct 2016 05:59:32 -0000 Author: sephe Date: Mon Oct 10 05:59:30 2016 New Revision: 306938 URL: https://svnweb.freebsd.org/changeset/base/306938 Log: hyperv/hn: Generalize RSS capabilities query. - Support NDIS < 6.30. - Stringent response checks. MFC after: 1 week Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8090 Modified: head/sys/dev/hyperv/netvsc/hv_rndis_filter.c Modified: head/sys/dev/hyperv/netvsc/hv_rndis_filter.c ============================================================================== --- head/sys/dev/hyperv/netvsc/hv_rndis_filter.c Mon Oct 10 05:50:01 2016 (r306937) +++ head/sys/dev/hyperv/netvsc/hv_rndis_filter.c Mon Oct 10 05:59:30 2016 (r306938) @@ -745,26 +745,44 @@ hn_rndis_get_rsscaps(struct hn_softc *sc size_t caps_len; int error; - /* - * Only NDIS 6.30+ is supported. - */ - KASSERT(sc->hn_ndis_ver >= HN_NDIS_VERSION_6_30, - ("NDIS 6.30+ is required, NDIS version 0x%08x", sc->hn_ndis_ver)); *rxr_cnt = 0; memset(&in, 0, sizeof(in)); in.ndis_hdr.ndis_type = NDIS_OBJTYPE_RSS_CAPS; - in.ndis_hdr.ndis_rev = NDIS_RSS_CAPS_REV_2; - in.ndis_hdr.ndis_size = NDIS_RSS_CAPS_SIZE; + if (sc->hn_ndis_ver < HN_NDIS_VERSION_6_30) { + in.ndis_hdr.ndis_rev = NDIS_RSS_CAPS_REV_1; + in.ndis_hdr.ndis_size = NDIS_RSS_CAPS_SIZE_6_0; + } else { + in.ndis_hdr.ndis_rev = NDIS_RSS_CAPS_REV_2; + in.ndis_hdr.ndis_size = NDIS_RSS_CAPS_SIZE; + } caps_len = NDIS_RSS_CAPS_SIZE; - error = hn_rndis_query(sc, OID_GEN_RECEIVE_SCALE_CAPABILITIES, - &in, NDIS_RSS_CAPS_SIZE, &caps, &caps_len); + error = hn_rndis_query2(sc, OID_GEN_RECEIVE_SCALE_CAPABILITIES, + &in, NDIS_RSS_CAPS_SIZE, &caps, &caps_len, NDIS_RSS_CAPS_SIZE_6_0); if (error) return (error); - if (caps_len < NDIS_RSS_CAPS_SIZE_6_0) { - if_printf(sc->hn_ifp, "invalid NDIS RSS caps len %zu", - caps_len); + + /* + * Preliminary verification. + */ + if (caps.ndis_hdr.ndis_type != NDIS_OBJTYPE_RSS_CAPS) { + if_printf(sc->hn_ifp, "invalid NDIS objtype 0x%02x\n", + caps.ndis_hdr.ndis_type); + return (EINVAL); + } + if (caps.ndis_hdr.ndis_rev < NDIS_RSS_CAPS_REV_1) { + if_printf(sc->hn_ifp, "invalid NDIS objrev 0x%02x\n", + caps.ndis_hdr.ndis_rev); + return (EINVAL); + } + if (caps.ndis_hdr.ndis_size > caps_len) { + if_printf(sc->hn_ifp, "invalid NDIS objsize %u, " + "data size %zu\n", caps.ndis_hdr.ndis_size, caps_len); + return (EINVAL); + } else if (caps.ndis_hdr.ndis_size < NDIS_RSS_CAPS_SIZE_6_0) { + if_printf(sc->hn_ifp, "invalid NDIS objsize %u\n", + caps.ndis_hdr.ndis_size); return (EINVAL); } @@ -774,7 +792,7 @@ hn_rndis_get_rsscaps(struct hn_softc *sc } *rxr_cnt = caps.ndis_nrxr; - if (caps_len == NDIS_RSS_CAPS_SIZE) { + if (caps.ndis_hdr.ndis_size == NDIS_RSS_CAPS_SIZE) { if (bootverbose) { if_printf(sc->hn_ifp, "RSS indirect table size %u\n", caps.ndis_nind); From owner-svn-src-all@freebsd.org Mon Oct 10 06:14:40 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 32783C0B868; Mon, 10 Oct 2016 06:14:40 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id D1CC7FF8; Mon, 10 Oct 2016 06:14:39 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9A6Ec3Y023201; Mon, 10 Oct 2016 06:14:38 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9A6Ecm6023198; Mon, 10 Oct 2016 06:14:38 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610100614.u9A6Ecm6023198@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Mon, 10 Oct 2016 06:14:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r306939 - head/sys/dev/hyperv/netvsc X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 Oct 2016 06:14:40 -0000 Author: sephe Date: Mon Oct 10 06:14:38 2016 New Revision: 306939 URL: https://svnweb.freebsd.org/changeset/base/306939 Log: hyperv/hn: Suffix NDIS offload size with NDIS version. MFC after: 1 week Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8091 Modified: head/sys/dev/hyperv/netvsc/hv_rndis_filter.c head/sys/dev/hyperv/netvsc/ndis.h Modified: head/sys/dev/hyperv/netvsc/hv_rndis_filter.c ============================================================================== --- head/sys/dev/hyperv/netvsc/hv_rndis_filter.c Mon Oct 10 05:59:30 2016 (r306938) +++ head/sys/dev/hyperv/netvsc/hv_rndis_filter.c Mon Oct 10 06:14:38 2016 (r306939) @@ -1179,16 +1179,16 @@ hn_rndis_query_hwcaps(struct hn_softc *s size = NDIS_OFFLOAD_SIZE; } else if (sc->hn_ndis_ver >= HN_NDIS_VERSION_6_1) { in.ndis_hdr.ndis_rev = NDIS_OFFLOAD_REV_2; - size = NDIS_OFFLOAD_SIZE_2; + size = NDIS_OFFLOAD_SIZE_6_1; } else { in.ndis_hdr.ndis_rev = NDIS_OFFLOAD_REV_1; - size = NDIS_OFFLOAD_SIZE_1; + size = NDIS_OFFLOAD_SIZE_6_0; } in.ndis_hdr.ndis_size = size; caps_len = NDIS_OFFLOAD_SIZE; error = hn_rndis_query2(sc, OID_TCP_OFFLOAD_HARDWARE_CAPABILITIES, - &in, size, caps, &caps_len, NDIS_OFFLOAD_SIZE_1); + &in, size, caps, &caps_len, NDIS_OFFLOAD_SIZE_6_0); if (error) return (error); @@ -1209,7 +1209,7 @@ hn_rndis_query_hwcaps(struct hn_softc *s if_printf(sc->hn_ifp, "invalid NDIS objsize %u, " "data size %zu\n", caps->ndis_hdr.ndis_size, caps_len); return (EINVAL); - } else if (caps->ndis_hdr.ndis_size < NDIS_OFFLOAD_SIZE_1) { + } else if (caps->ndis_hdr.ndis_size < NDIS_OFFLOAD_SIZE_6_0) { if_printf(sc->hn_ifp, "invalid NDIS objsize %u\n", caps->ndis_hdr.ndis_size); return (EINVAL); @@ -1217,7 +1217,9 @@ hn_rndis_query_hwcaps(struct hn_softc *s if (bootverbose) { /* - * Fields for NDIS 6.0 are accessable. + * NOTE: + * caps->ndis_hdr.ndis_size MUST be checked before accessing + * NDIS 6.1+ specific fields. */ if_printf(sc->hn_ifp, "hwcaps rev %u\n", caps->ndis_hdr.ndis_rev); Modified: head/sys/dev/hyperv/netvsc/ndis.h ============================================================================== --- head/sys/dev/hyperv/netvsc/ndis.h Mon Oct 10 05:59:30 2016 (r306938) +++ head/sys/dev/hyperv/netvsc/ndis.h Mon Oct 10 06:14:38 2016 (r306939) @@ -319,9 +319,9 @@ struct ndis_offload { }; #define NDIS_OFFLOAD_SIZE sizeof(struct ndis_offload) -#define NDIS_OFFLOAD_SIZE_1 \ +#define NDIS_OFFLOAD_SIZE_6_0 \ __offsetof(struct ndis_offload, ndis_ipsecv2) -#define NDIS_OFFLOAD_SIZE_2 \ +#define NDIS_OFFLOAD_SIZE_6_1 \ __offsetof(struct ndis_offload, ndis_rsc) #define NDIS_OFFLOAD_REV_1 1 /* NDIS 6.0 */ From owner-svn-src-all@freebsd.org Mon Oct 10 07:18:56 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 3FF16AF755D; Mon, 10 Oct 2016 07:18:56 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id D701CEB2; Mon, 10 Oct 2016 07:18:55 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9A7Itow045986; Mon, 10 Oct 2016 07:18:55 GMT (envelope-from delphij@FreeBSD.org) Received: (from delphij@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9A7Is0K045977; Mon, 10 Oct 2016 07:18:54 GMT (envelope-from delphij@FreeBSD.org) Message-Id: <201610100718.u9A7Is0K045977@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: delphij set sender to delphij@FreeBSD.org using -f From: Xin LI Date: Mon, 10 Oct 2016 07:18:54 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-releng@freebsd.org Subject: svn commit: r306941 - in releng: 10.1 10.1/contrib/libarchive/libarchive 10.1/contrib/libarchive/libarchive/test 10.1/lib/libarchive/test 10.1/sys/conf 10.1/usr.bin/bsdiff/bspatch 10.1/usr.sbin/por... X-SVN-Group: releng MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 Oct 2016 07:18:56 -0000 Author: delphij Date: Mon Oct 10 07:18:54 2016 New Revision: 306941 URL: https://svnweb.freebsd.org/changeset/base/306941 Log: Fix bspatch heap overflow vulnerability. [SA-16:29] Fix multiple portsnap vulnerabilities. [SA-16:30] Fix multiple libarchive vulnerabilities. [SA-16:31] Approved by: so Added: releng/10.1/contrib/libarchive/libarchive/test/test_write_disk_secure744.c (contents, props changed) releng/10.1/contrib/libarchive/libarchive/test/test_write_disk_secure745.c (contents, props changed) releng/10.1/contrib/libarchive/libarchive/test/test_write_disk_secure746.c (contents, props changed) releng/10.2/contrib/libarchive/libarchive/test/test_write_disk_secure744.c (contents, props changed) releng/10.2/contrib/libarchive/libarchive/test/test_write_disk_secure745.c (contents, props changed) releng/10.2/contrib/libarchive/libarchive/test/test_write_disk_secure746.c (contents, props changed) releng/10.3/contrib/libarchive/libarchive/test/test_write_disk_secure744.c (contents, props changed) releng/10.3/contrib/libarchive/libarchive/test/test_write_disk_secure745.c (contents, props changed) releng/10.3/contrib/libarchive/libarchive/test/test_write_disk_secure746.c (contents, props changed) Modified: releng/10.1/UPDATING releng/10.1/contrib/libarchive/libarchive/archive_read_disk_entry_from_file.c releng/10.1/contrib/libarchive/libarchive/archive_read_support_format_tar.c releng/10.1/contrib/libarchive/libarchive/archive_write_disk_acl.c releng/10.1/contrib/libarchive/libarchive/archive_write_disk_posix.c releng/10.1/contrib/libarchive/libarchive/test/main.c releng/10.1/contrib/libarchive/libarchive/test/test.h releng/10.1/lib/libarchive/test/Makefile releng/10.1/sys/conf/newvers.sh releng/10.1/usr.bin/bsdiff/bspatch/bspatch.c releng/10.1/usr.sbin/portsnap/portsnap/portsnap.sh releng/10.2/UPDATING releng/10.2/contrib/libarchive/libarchive/archive_read_disk_entry_from_file.c releng/10.2/contrib/libarchive/libarchive/archive_read_support_format_tar.c releng/10.2/contrib/libarchive/libarchive/archive_write_disk_acl.c releng/10.2/contrib/libarchive/libarchive/archive_write_disk_posix.c releng/10.2/contrib/libarchive/libarchive/test/main.c releng/10.2/contrib/libarchive/libarchive/test/test.h releng/10.2/lib/libarchive/test/Makefile releng/10.2/sys/conf/newvers.sh releng/10.2/usr.bin/bsdiff/bspatch/bspatch.c releng/10.2/usr.sbin/portsnap/portsnap/portsnap.sh releng/10.3/UPDATING releng/10.3/contrib/libarchive/libarchive/archive_read_disk_entry_from_file.c releng/10.3/contrib/libarchive/libarchive/archive_read_support_format_tar.c releng/10.3/contrib/libarchive/libarchive/archive_write_disk_acl.c releng/10.3/contrib/libarchive/libarchive/archive_write_disk_posix.c releng/10.3/contrib/libarchive/libarchive/test/main.c releng/10.3/contrib/libarchive/libarchive/test/test.h releng/10.3/lib/libarchive/tests/Makefile releng/10.3/sys/conf/newvers.sh releng/10.3/usr.bin/bsdiff/bspatch/bspatch.c releng/10.3/usr.sbin/portsnap/portsnap/portsnap.sh Modified: releng/10.1/UPDATING ============================================================================== --- releng/10.1/UPDATING Mon Oct 10 06:58:32 2016 (r306940) +++ releng/10.1/UPDATING Mon Oct 10 07:18:54 2016 (r306941) @@ -16,7 +16,17 @@ from older versions of FreeBSD, try WITH stable/10, and then rebuild without this option. The bootstrap process from older version of current is a bit fragile. -20160926 p29 FreeBSD-SA-16:26.openssl [revised] +20161010 p40 FreeBSD-SA-16:29.bspatch + FreeBSD-SA-16:30.portsnap + FreeBSD-SA-16:31.libarchive + + Fix bspatch heap overflow vulnerability. [SA-16:29] + + Fix multiple portsnap vulnerabilities. [SA-16:30] + + Fix multiple libarchive vulnerabilities. [SA-16:31] + +20160926 p39 FreeBSD-SA-16:26.openssl [revised] Fix OpenSSL regression introduced in SA-16:26. Modified: releng/10.1/contrib/libarchive/libarchive/archive_read_disk_entry_from_file.c ============================================================================== --- releng/10.1/contrib/libarchive/libarchive/archive_read_disk_entry_from_file.c Mon Oct 10 06:58:32 2016 (r306940) +++ releng/10.1/contrib/libarchive/libarchive/archive_read_disk_entry_from_file.c Mon Oct 10 07:18:54 2016 (r306941) @@ -409,9 +409,7 @@ setup_acls(struct archive_read_disk *a, { const char *accpath; acl_t acl; -#if HAVE_ACL_IS_TRIVIAL_NP int r; -#endif accpath = archive_entry_sourcepath(entry); if (accpath == NULL) @@ -443,9 +441,13 @@ setup_acls(struct archive_read_disk *a, } #endif if (acl != NULL) { - translate_acl(a, entry, acl, ARCHIVE_ENTRY_ACL_TYPE_NFS4); + r = translate_acl(a, entry, acl, ARCHIVE_ENTRY_ACL_TYPE_NFS4); acl_free(acl); - return (ARCHIVE_OK); + if (r != ARCHIVE_OK) { + archive_set_error(&a->archive, errno, + "Couldn't translate NFSv4 ACLs: %s", accpath); + } + return (r); } /* Retrieve access ACL from file. */ @@ -464,18 +466,29 @@ setup_acls(struct archive_read_disk *a, else acl = acl_get_file(accpath, ACL_TYPE_ACCESS); if (acl != NULL) { - translate_acl(a, entry, acl, + r = translate_acl(a, entry, acl, ARCHIVE_ENTRY_ACL_TYPE_ACCESS); acl_free(acl); + if (r != ARCHIVE_OK) { + archive_set_error(&a->archive, errno, + "Couldn't translate access ACLs: %s", accpath); + return (r); + } } /* Only directories can have default ACLs. */ if (S_ISDIR(archive_entry_mode(entry))) { acl = acl_get_file(accpath, ACL_TYPE_DEFAULT); if (acl != NULL) { - translate_acl(a, entry, acl, + r = translate_acl(a, entry, acl, ARCHIVE_ENTRY_ACL_TYPE_DEFAULT); acl_free(acl); + if (r != ARCHIVE_OK) { + archive_set_error(&a->archive, errno, + "Couldn't translate default ACLs: %s", + accpath); + return (r); + } } } return (ARCHIVE_OK); @@ -536,7 +549,11 @@ translate_acl(struct archive_read_disk * // FreeBSD "brands" ACLs as POSIX.1e or NFSv4 // Make sure the "brand" on this ACL is consistent // with the default_entry_acl_type bits provided. - acl_get_brand_np(acl, &brand); + if (acl_get_brand_np(acl, &brand) != 0) { + archive_set_error(&a->archive, errno, + "Failed to read ACL brand"); + return (ARCHIVE_WARN); + } switch (brand) { case ACL_BRAND_POSIX: switch (default_entry_acl_type) { @@ -544,30 +561,42 @@ translate_acl(struct archive_read_disk * case ARCHIVE_ENTRY_ACL_TYPE_DEFAULT: break; default: - // XXX set warning message? - return ARCHIVE_FAILED; + archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC, + "Invalid ACL entry type for POSIX.1e ACL"); + return (ARCHIVE_WARN); } break; case ACL_BRAND_NFS4: if (default_entry_acl_type & ~ARCHIVE_ENTRY_ACL_TYPE_NFS4) { - // XXX set warning message? - return ARCHIVE_FAILED; + archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC, + "Invalid ACL entry type for NFSv4 ACL"); + return (ARCHIVE_WARN); } break; default: - // XXX set warning message? - return ARCHIVE_FAILED; + archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC, + "Unknown ACL brand"); + return (ARCHIVE_WARN); break; } s = acl_get_entry(acl, ACL_FIRST_ENTRY, &acl_entry); + if (s == -1) { + archive_set_error(&a->archive, errno, + "Failed to get first ACL entry"); + return (ARCHIVE_WARN); + } while (s == 1) { ae_id = -1; ae_name = NULL; ae_perm = 0; - acl_get_tag_type(acl_entry, &acl_tag); + if (acl_get_tag_type(acl_entry, &acl_tag) != 0) { + archive_set_error(&a->archive, errno, + "Failed to get ACL tag type"); + return (ARCHIVE_WARN); + } switch (acl_tag) { case ACL_USER: ae_id = (int)*(uid_t *)acl_get_qualifier(acl_entry); @@ -600,12 +629,17 @@ translate_acl(struct archive_read_disk * continue; } - // XXX acl type maps to allow/deny/audit/YYYY bits - // XXX acl_get_entry_type_np on FreeBSD returns EINVAL for - // non-NFSv4 ACLs + // XXX acl_type maps to allow/deny/audit/YYYY bits entry_acl_type = default_entry_acl_type; - r = acl_get_entry_type_np(acl_entry, &acl_type); - if (r == 0) { + if (default_entry_acl_type & ARCHIVE_ENTRY_ACL_TYPE_NFS4) { + /* + * acl_get_entry_type_np() falis with non-NFSv4 ACLs + */ + if (acl_get_entry_type_np(acl_entry, &acl_type) != 0) { + archive_set_error(&a->archive, errno, "Failed " + "to get ACL type from a NFSv4 ACL entry"); + return (ARCHIVE_WARN); + } switch (acl_type) { case ACL_ENTRY_TYPE_ALLOW: entry_acl_type = ARCHIVE_ENTRY_ACL_TYPE_ALLOW; @@ -619,28 +653,52 @@ translate_acl(struct archive_read_disk * case ACL_ENTRY_TYPE_ALARM: entry_acl_type = ARCHIVE_ENTRY_ACL_TYPE_ALARM; break; + default: + archive_set_error(&a->archive, errno, + "Invalid NFSv4 ACL entry type"); + return (ARCHIVE_WARN); } - } - - /* - * Libarchive stores "flag" (NFSv4 inheritance bits) - * in the ae_perm bitmap. - */ - acl_get_flagset_np(acl_entry, &acl_flagset); - for (i = 0; i < (int)(sizeof(acl_inherit_map) / sizeof(acl_inherit_map[0])); ++i) { - if (acl_get_flag_np(acl_flagset, - acl_inherit_map[i].platform_inherit)) - ae_perm |= acl_inherit_map[i].archive_inherit; - } + /* + * Libarchive stores "flag" (NFSv4 inheritance bits) + * in the ae_perm bitmap. + * + * acl_get_flagset_np() fails with non-NFSv4 ACLs + */ + if (acl_get_flagset_np(acl_entry, &acl_flagset) != 0) { + archive_set_error(&a->archive, errno, + "Failed to get flagset from a NFSv4 ACL entry"); + return (ARCHIVE_WARN); + } + for (i = 0; i < (int)(sizeof(acl_inherit_map) / sizeof(acl_inherit_map[0])); ++i) { + r = acl_get_flag_np(acl_flagset, + acl_inherit_map[i].platform_inherit); + if (r == -1) { + archive_set_error(&a->archive, errno, + "Failed to check flag in a NFSv4 " + "ACL flagset"); + return (ARCHIVE_WARN); + } else if (r) + ae_perm |= acl_inherit_map[i].archive_inherit; + } + } - acl_get_permset(acl_entry, &acl_permset); - for (i = 0; i < (int)(sizeof(acl_perm_map) / sizeof(acl_perm_map[0])); ++i) { + if (acl_get_permset(acl_entry, &acl_permset) != 0) { + archive_set_error(&a->archive, errno, + "Failed to get ACL permission set"); + return (ARCHIVE_WARN); + } + for (i = 0; i < (int)(sizeof(acl_perm_map) / sizeof(acl_perm_map[0])); ++i) { /* * acl_get_perm() is spelled differently on different * platforms; see above. */ - if (ACL_GET_PERM(acl_permset, acl_perm_map[i].platform_perm)) + r = ACL_GET_PERM(acl_permset, acl_perm_map[i].platform_perm); + if (r == -1) { + archive_set_error(&a->archive, errno, + "Failed to check permission in an ACL permission set"); + return (ARCHIVE_WARN); + } else if (r) ae_perm |= acl_perm_map[i].archive_perm; } @@ -649,6 +707,11 @@ translate_acl(struct archive_read_disk * ae_id, ae_name); s = acl_get_entry(acl, ACL_NEXT_ENTRY, &acl_entry); + if (s == -1) { + archive_set_error(&a->archive, errno, + "Failed to get next ACL entry"); + return (ARCHIVE_WARN); + } } return (ARCHIVE_OK); } Modified: releng/10.1/contrib/libarchive/libarchive/archive_read_support_format_tar.c ============================================================================== --- releng/10.1/contrib/libarchive/libarchive/archive_read_support_format_tar.c Mon Oct 10 06:58:32 2016 (r306940) +++ releng/10.1/contrib/libarchive/libarchive/archive_read_support_format_tar.c Mon Oct 10 07:18:54 2016 (r306941) @@ -136,6 +136,7 @@ struct tar { int64_t entry_padding; int64_t entry_bytes_unconsumed; int64_t realsize; + int sparse_allowed; struct sparse_block *sparse_list; struct sparse_block *sparse_last; int64_t sparse_offset; @@ -1216,6 +1217,14 @@ header_common(struct archive_read *a, st * sparse information in the extended area. */ /* FALLTHROUGH */ + case '0': + /* + * Enable sparse file "read" support only for regular + * files and explicit GNU sparse files. However, we + * don't allow non-standard file types to be sparse. + */ + tar->sparse_allowed = 1; + /* FALLTHROUGH */ default: /* Regular file and non-standard types */ /* * Per POSIX: non-recognized types should always be @@ -1675,6 +1684,14 @@ pax_attribute(struct archive_read *a, st #endif switch (key[0]) { case 'G': + /* Reject GNU.sparse.* headers on non-regular files. */ + if (strncmp(key, "GNU.sparse", 10) == 0 && + !tar->sparse_allowed) { + archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC, + "Non-regular file cannot be sparse"); + return (ARCHIVE_FATAL); + } + /* GNU "0.0" sparse pax format. */ if (strcmp(key, "GNU.sparse.numblocks") == 0) { tar->sparse_offset = -1; Modified: releng/10.1/contrib/libarchive/libarchive/archive_write_disk_acl.c ============================================================================== --- releng/10.1/contrib/libarchive/libarchive/archive_write_disk_acl.c Mon Oct 10 06:58:32 2016 (r306940) +++ releng/10.1/contrib/libarchive/libarchive/archive_write_disk_acl.c Mon Oct 10 07:18:54 2016 (r306941) @@ -131,6 +131,7 @@ set_acl(struct archive *a, int fd, const acl_entry_t acl_entry; acl_permset_t acl_permset; acl_flagset_t acl_flagset; + int r; int ret; int ae_type, ae_permset, ae_tag, ae_id; uid_t ae_uid; @@ -144,9 +145,19 @@ set_acl(struct archive *a, int fd, const if (entries == 0) return (ARCHIVE_OK); acl = acl_init(entries); + if (acl == (acl_t)NULL) { + archive_set_error(a, errno, + "Failed to initialize ACL working storage"); + return (ARCHIVE_FAILED); + } while (archive_acl_next(a, abstract_acl, ae_requested_type, &ae_type, &ae_permset, &ae_tag, &ae_id, &ae_name) == ARCHIVE_OK) { - acl_create_entry(&acl, &acl_entry); + if (acl_create_entry(&acl, &acl_entry) != 0) { + archive_set_error(a, errno, + "Failed to create a new ACL entry"); + ret = ARCHIVE_FAILED; + goto exit_free; + } switch (ae_tag) { case ARCHIVE_ENTRY_ACL_USER: @@ -175,47 +186,95 @@ set_acl(struct archive *a, int fd, const acl_set_tag_type(acl_entry, ACL_EVERYONE); break; default: - /* XXX */ - break; + archive_set_error(a, ARCHIVE_ERRNO_MISC, + "Unknown ACL tag"); + ret = ARCHIVE_FAILED; + goto exit_free; } + r = 0; switch (ae_type) { case ARCHIVE_ENTRY_ACL_TYPE_ALLOW: - acl_set_entry_type_np(acl_entry, ACL_ENTRY_TYPE_ALLOW); + r = acl_set_entry_type_np(acl_entry, ACL_ENTRY_TYPE_ALLOW); break; case ARCHIVE_ENTRY_ACL_TYPE_DENY: - acl_set_entry_type_np(acl_entry, ACL_ENTRY_TYPE_DENY); + r = acl_set_entry_type_np(acl_entry, ACL_ENTRY_TYPE_DENY); break; case ARCHIVE_ENTRY_ACL_TYPE_AUDIT: - acl_set_entry_type_np(acl_entry, ACL_ENTRY_TYPE_AUDIT); + r = acl_set_entry_type_np(acl_entry, ACL_ENTRY_TYPE_AUDIT); break; case ARCHIVE_ENTRY_ACL_TYPE_ALARM: - acl_set_entry_type_np(acl_entry, ACL_ENTRY_TYPE_ALARM); + r = acl_set_entry_type_np(acl_entry, ACL_ENTRY_TYPE_ALARM); break; case ARCHIVE_ENTRY_ACL_TYPE_ACCESS: case ARCHIVE_ENTRY_ACL_TYPE_DEFAULT: // These don't translate directly into the system ACL. break; default: - // XXX error handling here. - break; + archive_set_error(a, ARCHIVE_ERRNO_MISC, + "Unknown ACL entry type"); + ret = ARCHIVE_FAILED; + goto exit_free; + } + if (r != 0) { + archive_set_error(a, errno, + "Failed to set ACL entry type"); + ret = ARCHIVE_FAILED; + goto exit_free; } - acl_get_permset(acl_entry, &acl_permset); - acl_clear_perms(acl_permset); + if (acl_get_permset(acl_entry, &acl_permset) != 0) { + archive_set_error(a, errno, + "Failed to get ACL permission set"); + ret = ARCHIVE_FAILED; + goto exit_free; + } + if (acl_clear_perms(acl_permset) != 0) { + archive_set_error(a, errno, + "Failed to clear ACL permissions"); + ret = ARCHIVE_FAILED; + goto exit_free; + } for (i = 0; i < (int)(sizeof(acl_perm_map) / sizeof(acl_perm_map[0])); ++i) { if (ae_permset & acl_perm_map[i].archive_perm) - acl_add_perm(acl_permset, - acl_perm_map[i].platform_perm); + if (acl_add_perm(acl_permset, + acl_perm_map[i].platform_perm) != 0) { + archive_set_error(a, errno, + "Failed to add ACL permission"); + ret = ARCHIVE_FAILED; + goto exit_free; + } } acl_get_flagset_np(acl_entry, &acl_flagset); - acl_clear_flags_np(acl_flagset); - for (i = 0; i < (int)(sizeof(acl_inherit_map) / sizeof(acl_inherit_map[0])); ++i) { - if (ae_permset & acl_inherit_map[i].archive_inherit) - acl_add_flag_np(acl_flagset, - acl_inherit_map[i].platform_inherit); + if (acl_type == ACL_TYPE_NFS4) { + /* + * acl_get_flagset_np() fails with non-NFSv4 ACLs + */ + if (acl_get_flagset_np(acl_entry, &acl_flagset) != 0) { + archive_set_error(a, errno, + "Failed to get flagset from an NFSv4 ACL entry"); + ret = ARCHIVE_FAILED; + goto exit_free; + } + if (acl_clear_flags_np(acl_flagset) != 0) { + archive_set_error(a, errno, + "Failed to clear flags from an NFSv4 ACL flagset"); + ret = ARCHIVE_FAILED; + goto exit_free; + } + for (i = 0; i < (int)(sizeof(acl_inherit_map) / sizeof(acl_inherit_map[0])); ++i) { + if (ae_permset & acl_inherit_map[i].archive_inherit) { + if (acl_add_flag_np(acl_flagset, + acl_inherit_map[i].platform_inherit) != 0) { + archive_set_error(a, errno, + "Failed to add flag to NFSv4 ACL flagset"); + ret = ARCHIVE_FAILED; + goto exit_free; + } + } + } } } @@ -243,6 +302,7 @@ set_acl(struct archive *a, int fd, const ret = ARCHIVE_WARN; } #endif +exit_free: acl_free(acl); return (ret); } Modified: releng/10.1/contrib/libarchive/libarchive/archive_write_disk_posix.c ============================================================================== --- releng/10.1/contrib/libarchive/libarchive/archive_write_disk_posix.c Mon Oct 10 06:58:32 2016 (r306940) +++ releng/10.1/contrib/libarchive/libarchive/archive_write_disk_posix.c Mon Oct 10 07:18:54 2016 (r306941) @@ -140,7 +140,17 @@ __FBSDID("$FreeBSD$"); #define O_BINARY 0 #endif #ifndef O_CLOEXEC -#define O_CLOEXEC 0 +#define O_CLOEXEC 0 +#endif + +/* Ignore non-int O_NOFOLLOW constant. */ +/* gnulib's fcntl.h does this on AIX, but it seems practical everywhere */ +#if defined O_NOFOLLOW && !(INT_MIN <= O_NOFOLLOW && O_NOFOLLOW <= INT_MAX) +#undef O_NOFOLLOW +#endif + +#ifndef O_NOFOLLOW +#define O_NOFOLLOW 0 #endif struct fixup_entry { @@ -326,12 +336,14 @@ struct archive_write_disk { #define HFS_BLOCKS(s) ((s) >> 12) +static int check_symlinks_fsobj(char *path, int *error_number, struct archive_string *error_string, int flags); static int check_symlinks(struct archive_write_disk *); static int create_filesystem_object(struct archive_write_disk *); static struct fixup_entry *current_fixup(struct archive_write_disk *, const char *pathname); #if defined(HAVE_FCHDIR) && defined(PATH_MAX) static void edit_deep_directories(struct archive_write_disk *ad); #endif +static int cleanup_pathname_fsobj(char *path, int *error_number, struct archive_string *error_string, int flags); static int cleanup_pathname(struct archive_write_disk *); static int create_dir(struct archive_write_disk *, char *); static int create_parent_dir(struct archive_write_disk *, char *); @@ -1791,7 +1803,7 @@ edit_deep_directories(struct archive_wri char *tail = a->name; /* If path is short, avoid the open() below. */ - if (strlen(tail) <= PATH_MAX) + if (strlen(tail) < PATH_MAX) return; /* Try to record our starting dir. */ @@ -1801,7 +1813,7 @@ edit_deep_directories(struct archive_wri return; /* As long as the path is too long... */ - while (strlen(tail) > PATH_MAX) { + while (strlen(tail) >= PATH_MAX) { /* Locate a dir prefix shorter than PATH_MAX. */ tail += PATH_MAX - 8; while (tail > a->name && *tail != '/') @@ -1996,6 +2008,10 @@ create_filesystem_object(struct archive_ const char *linkname; mode_t final_mode, mode; int r; + /* these for check_symlinks_fsobj */ + char *linkname_copy; /* non-const copy of linkname */ + struct archive_string error_string; + int error_number; /* We identify hard/symlinks according to the link names. */ /* Since link(2) and symlink(2) don't handle modes, we're done here. */ @@ -2004,6 +2020,27 @@ create_filesystem_object(struct archive_ #if !HAVE_LINK return (EPERM); #else + archive_string_init(&error_string); + linkname_copy = strdup(linkname); + if (linkname_copy == NULL) { + return (EPERM); + } + /* TODO: consider using the cleaned-up path as the link target? */ + r = cleanup_pathname_fsobj(linkname_copy, &error_number, &error_string, a->flags); + if (r != ARCHIVE_OK) { + archive_set_error(&a->archive, error_number, "%s", error_string.s); + free(linkname_copy); + /* EPERM is more appropriate than error_number for our callers */ + return (EPERM); + } + r = check_symlinks_fsobj(linkname_copy, &error_number, &error_string, a->flags); + if (r != ARCHIVE_OK) { + archive_set_error(&a->archive, error_number, "%s", error_string.s); + free(linkname_copy); + /* EPERM is more appropriate than error_number for our callers */ + return (EPERM); + } + free(linkname_copy); r = link(linkname, a->name) ? errno : 0; /* * New cpio and pax formats allow hardlink entries @@ -2022,7 +2059,7 @@ create_filesystem_object(struct archive_ a->deferred = 0; } else if (r == 0 && a->filesize > 0) { a->fd = open(a->name, - O_WRONLY | O_TRUNC | O_BINARY | O_CLOEXEC); + O_WRONLY | O_TRUNC | O_BINARY | O_CLOEXEC | O_NOFOLLOW); __archive_ensure_cloexec_flag(a->fd); if (a->fd < 0) r = errno; @@ -2332,110 +2369,233 @@ current_fixup(struct archive_write_disk return (a->current_fixup); } -/* TODO: Make this work. */ -/* - * TODO: The deep-directory support bypasses this; disable deep directory - * support if we're doing symlink checks. - */ /* * TODO: Someday, integrate this with the deep dir support; they both * scan the path and both can be optimized by comparing against other * recent paths. */ /* TODO: Extend this to support symlinks on Windows Vista and later. */ + +/* + * Checks the given path to see if any elements along it are symlinks. Returns + * ARCHIVE_OK if there are none, otherwise puts an error in errmsg. + */ static int -check_symlinks(struct archive_write_disk *a) +check_symlinks_fsobj(char *path, int *error_number, struct archive_string *error_string, int flags) { #if !defined(HAVE_LSTAT) /* Platform doesn't have lstat, so we can't look for symlinks. */ - (void)a; /* UNUSED */ + (void)path; /* UNUSED */ + (void)error_number; /* UNUSED */ + (void)error_string; /* UNUSED */ + (void)flags; /* UNUSED */ return (ARCHIVE_OK); #else - char *pn; + int res = ARCHIVE_OK; + char *tail; + char *head; + int last; char c; int r; struct stat st; + int restore_pwd; + + /* Nothing to do here if name is empty */ + if(path[0] == '\0') + return (ARCHIVE_OK); /* * Guard against symlink tricks. Reject any archive entry whose * destination would be altered by a symlink. - */ - /* Whatever we checked last time doesn't need to be re-checked. */ - pn = a->name; - if (archive_strlen(&(a->path_safe)) > 0) { - char *p = a->path_safe.s; - while ((*pn != '\0') && (*p == *pn)) - ++p, ++pn; - } - c = pn[0]; - /* Keep going until we've checked the entire name. */ - while (pn[0] != '\0' && (pn[0] != '/' || pn[1] != '\0')) { + * + * Walk the filename in chunks separated by '/'. For each segment: + * - if it doesn't exist, continue + * - if it's symlink, abort or remove it + * - if it's a directory and it's not the last chunk, cd into it + * As we go: + * head points to the current (relative) path + * tail points to the temporary \0 terminating the segment we're currently examining + * c holds what used to be in *tail + * last is 1 if this is the last tail + */ + restore_pwd = open(".", O_RDONLY | O_BINARY | O_CLOEXEC); + __archive_ensure_cloexec_flag(restore_pwd); + if (restore_pwd < 0) + return (ARCHIVE_FATAL); + head = path; + tail = path; + last = 0; + /* TODO: reintroduce a safe cache here? */ + /* Skip the root directory if the path is absolute. */ + if(tail == path && tail[0] == '/') + ++tail; + /* Keep going until we've checked the entire name. + * head, tail, path all alias the same string, which is + * temporarily zeroed at tail, so be careful restoring the + * stashed (c=tail[0]) for error messages. + * Exiting the loop with break is okay; continue is not. + */ + while (!last) { + /* Skip the separator we just consumed, plus any adjacent ones */ + while (*tail == '/') + ++tail; /* Skip the next path element. */ - while (*pn != '\0' && *pn != '/') - ++pn; - c = pn[0]; - pn[0] = '\0'; + while (*tail != '\0' && *tail != '/') + ++tail; + /* is this the last path component? */ + last = (tail[0] == '\0') || (tail[0] == '/' && tail[1] == '\0'); + /* temporarily truncate the string here */ + c = tail[0]; + tail[0] = '\0'; /* Check that we haven't hit a symlink. */ - r = lstat(a->name, &st); + r = lstat(head, &st); if (r != 0) { + tail[0] = c; /* We've hit a dir that doesn't exist; stop now. */ - if (errno == ENOENT) + if (errno == ENOENT) { + break; + } else { + /* Treat any other error as fatal - best to be paranoid here + * Note: This effectively disables deep directory + * support when security checks are enabled. + * Otherwise, very long pathnames that trigger + * an error here could evade the sandbox. + * TODO: We could do better, but it would probably + * require merging the symlink checks with the + * deep-directory editing. */ + if (error_number) *error_number = errno; + if (error_string) + archive_string_sprintf(error_string, + "Could not stat %s", + path); + res = ARCHIVE_FAILED; break; + } + } else if (S_ISDIR(st.st_mode)) { + if (!last) { + if (chdir(head) != 0) { + tail[0] = c; + if (error_number) *error_number = errno; + if (error_string) + archive_string_sprintf(error_string, + "Could not chdir %s", + path); + res = (ARCHIVE_FATAL); + break; + } + /* Our view is now from inside this dir: */ + head = tail + 1; + } } else if (S_ISLNK(st.st_mode)) { - if (c == '\0') { + if (last) { /* * Last element is symlink; remove it * so we can overwrite it with the * item being extracted. */ - if (unlink(a->name)) { - archive_set_error(&a->archive, errno, - "Could not remove symlink %s", - a->name); - pn[0] = c; - return (ARCHIVE_FAILED); + if (unlink(head)) { + tail[0] = c; + if (error_number) *error_number = errno; + if (error_string) + archive_string_sprintf(error_string, + "Could not remove symlink %s", + path); + res = ARCHIVE_FAILED; + break; } - a->pst = NULL; /* * Even if we did remove it, a warning * is in order. The warning is silly, * though, if we're just replacing one * symlink with another symlink. */ - if (!S_ISLNK(a->mode)) { - archive_set_error(&a->archive, 0, - "Removing symlink %s", - a->name); + tail[0] = c; + /* FIXME: not sure how important this is to restore + if (!S_ISLNK(path)) { + if (error_number) *error_number = 0; + if (error_string) + archive_string_sprintf(error_string, + "Removing symlink %s", + path); } + */ /* Symlink gone. No more problem! */ - pn[0] = c; - return (0); - } else if (a->flags & ARCHIVE_EXTRACT_UNLINK) { + res = ARCHIVE_OK; + break; + } else if (flags & ARCHIVE_EXTRACT_UNLINK) { /* User asked us to remove problems. */ - if (unlink(a->name) != 0) { - archive_set_error(&a->archive, 0, - "Cannot remove intervening symlink %s", - a->name); - pn[0] = c; - return (ARCHIVE_FAILED); + if (unlink(head) != 0) { + tail[0] = c; + if (error_number) *error_number = 0; + if (error_string) + archive_string_sprintf(error_string, + "Cannot remove intervening symlink %s", + path); + res = ARCHIVE_FAILED; + break; } - a->pst = NULL; + tail[0] = c; } else { - archive_set_error(&a->archive, 0, - "Cannot extract through symlink %s", - a->name); - pn[0] = c; - return (ARCHIVE_FAILED); + tail[0] = c; + if (error_number) *error_number = 0; + if (error_string) + archive_string_sprintf(error_string, + "Cannot extract through symlink %s", + path); + res = ARCHIVE_FAILED; + break; } } + /* be sure to always maintain this */ + tail[0] = c; + if (tail[0] != '\0') + tail++; /* Advance to the next segment. */ + } + /* Catches loop exits via break */ + tail[0] = c; +#ifdef HAVE_FCHDIR + /* If we changed directory above, restore it here. */ + if (restore_pwd >= 0) { + r = fchdir(restore_pwd); + if (r != 0) { + if(error_number) *error_number = errno; + if(error_string) + archive_string_sprintf(error_string, + "chdir() failure"); + } + close(restore_pwd); + restore_pwd = -1; + if (r != 0) { + res = (ARCHIVE_FATAL); + } } - pn[0] = c; - /* We've checked and/or cleaned the whole path, so remember it. */ - archive_strcpy(&a->path_safe, a->name); - return (ARCHIVE_OK); +#endif + /* TODO: reintroduce a safe cache here? */ + return res; #endif } +/* + * Check a->name for symlinks, returning ARCHIVE_OK if its clean, otherwise + * calls archive_set_error and returns ARCHIVE_{FATAL,FAILED} + */ +static int +check_symlinks(struct archive_write_disk *a) +{ + struct archive_string error_string; + int error_number; + int rc; + archive_string_init(&error_string); + rc = check_symlinks_fsobj(a->name, &error_number, &error_string, a->flags); + if (rc != ARCHIVE_OK) { + archive_set_error(&a->archive, error_number, "%s", error_string.s); + } + archive_string_free(&error_string); + a->pst = NULL; /* to be safe */ + return rc; +} + + #if defined(__CYGWIN__) /* * 1. Convert a path separator from '\' to '/' . @@ -2509,15 +2669,17 @@ cleanup_pathname_win(struct archive_writ * is set) if the path is absolute. */ static int -cleanup_pathname(struct archive_write_disk *a) +cleanup_pathname_fsobj(char *path, int *error_number, struct archive_string *error_string, int flags) { char *dest, *src; char separator = '\0'; - dest = src = a->name; + dest = src = path; if (*src == '\0') { - archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC, - "Invalid empty pathname"); + if (error_number) *error_number = ARCHIVE_ERRNO_MISC; + if (error_string) + archive_string_sprintf(error_string, + "Invalid empty pathname"); return (ARCHIVE_FAILED); } @@ -2526,9 +2688,11 @@ cleanup_pathname(struct archive_write_di #endif /* Skip leading '/'. */ if (*src == '/') { - if (a->flags & ARCHIVE_EXTRACT_SECURE_NOABSOLUTEPATHS) { - archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC, - "Path is absolute"); + if (flags & ARCHIVE_EXTRACT_SECURE_NOABSOLUTEPATHS) { + if (error_number) *error_number = ARCHIVE_ERRNO_MISC; + if (error_string) + archive_string_sprintf(error_string, + "Path is absolute"); return (ARCHIVE_FAILED); } @@ -2555,10 +2719,11 @@ cleanup_pathname(struct archive_write_di } else if (src[1] == '.') { if (src[2] == '/' || src[2] == '\0') { /* Conditionally warn about '..' */ - if (a->flags & ARCHIVE_EXTRACT_SECURE_NODOTDOT) { - archive_set_error(&a->archive, - ARCHIVE_ERRNO_MISC, - "Path contains '..'"); + if (flags & ARCHIVE_EXTRACT_SECURE_NODOTDOT) { + if (error_number) *error_number = ARCHIVE_ERRNO_MISC; + if (error_string) + archive_string_sprintf(error_string, + "Path contains '..'"); return (ARCHIVE_FAILED); } } @@ -2589,7 +2754,7 @@ cleanup_pathname(struct archive_write_di * We've just copied zero or more path elements, not including the * final '/'. */ - if (dest == a->name) { + if (dest == path) { /* * Nothing got copied. The path must have been something * like '.' or '/' or './' or '/././././/./'. @@ -2604,6 +2769,21 @@ cleanup_pathname(struct archive_write_di return (ARCHIVE_OK); } +static int +cleanup_pathname(struct archive_write_disk *a) +{ + struct archive_string error_string; + int error_number; + int rc; + archive_string_init(&error_string); + rc = cleanup_pathname_fsobj(a->name, &error_number, &error_string, a->flags); + if (rc != ARCHIVE_OK) { + archive_set_error(&a->archive, error_number, "%s", error_string.s); + } + archive_string_free(&error_string); + return rc; +} + /* * Create the parent directory of the specified path, assuming path * is already in mutable storage. Modified: releng/10.1/contrib/libarchive/libarchive/test/main.c ============================================================================== --- releng/10.1/contrib/libarchive/libarchive/test/main.c Mon Oct 10 06:58:32 2016 (r306940) +++ releng/10.1/contrib/libarchive/libarchive/test/main.c Mon Oct 10 07:18:54 2016 (r306941) @@ -1396,6 +1396,31 @@ assertion_file_size(const char *file, in return (0); } +/* Verify mode of 'pathname'. */ +int +assertion_file_mode(const char *file, int line, const char *pathname, int expected_mode) +{ + int mode; + int r; + + assertion_count(file, line); +#if defined(_WIN32) && !defined(__CYGWIN__) + failure_start(file, line, "assertFileMode not yet implemented for Windows"); +#else + { + struct stat st; + r = lstat(pathname, &st); + mode = (int)(st.st_mode & 0777); + } + if (r == 0 && mode == expected_mode) + return (1); + failure_start(file, line, "File %s has mode %o, expected %o", + pathname, mode, expected_mode); +#endif + failure_finish(NULL); + return (0); +} + /* Assert that 'pathname' is a dir. If mode >= 0, verify that too. */ int assertion_is_dir(const char *file, int line, const char *pathname, int mode) Modified: releng/10.1/contrib/libarchive/libarchive/test/test.h ============================================================================== --- releng/10.1/contrib/libarchive/libarchive/test/test.h Mon Oct 10 06:58:32 2016 (r306940) +++ releng/10.1/contrib/libarchive/libarchive/test/test.h Mon Oct 10 07:18:54 2016 (r306941) @@ -176,6 +176,8 @@ assertion_file_nlinks(__FILE__, __LINE__, pathname, nlinks) #define assertFileSize(pathname, size) \ assertion_file_size(__FILE__, __LINE__, pathname, size) +#define assertFileMode(pathname, mode) \ + assertion_file_mode(__FILE__, __LINE__, pathname, mode) #define assertTextFileContents(text, pathname) \ assertion_text_file_contents(__FILE__, __LINE__, text, pathname) #define assertFileContainsLinesAnyOrder(pathname, lines) \ @@ -239,6 +241,7 @@ int assertion_file_mtime_recent(const ch int assertion_file_nlinks(const char *, int, const char *, int); int assertion_file_not_exists(const char *, int, const char *); int assertion_file_size(const char *, int, const char *, long); +int assertion_file_mode(const char *, int, const char *, int); int assertion_is_dir(const char *, int, const char *, int); int assertion_is_hardlink(const char *, int, const char *, const char *); int assertion_is_not_hardlink(const char *, int, const char *, const char *); Added: releng/10.1/contrib/libarchive/libarchive/test/test_write_disk_secure744.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ releng/10.1/contrib/libarchive/libarchive/test/test_write_disk_secure744.c Mon Oct 10 07:18:54 2016 (r306941) @@ -0,0 +1,95 @@ +/*- + * Copyright (c) 2003-2007,2016 Tim Kientzle + * 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(S) ``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(S) BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#include "test.h" +__FBSDID("$FreeBSD$"); + +#define UMASK 022 + *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-all@freebsd.org Mon Oct 10 07:19:18 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 8E1A9AF7696; Mon, 10 Oct 2016 07:19:18 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 56B196B; Mon, 10 Oct 2016 07:19:18 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9A7JHeW046049; Mon, 10 Oct 2016 07:19:17 GMT (envelope-from delphij@FreeBSD.org) Received: (from delphij@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9A7JHGO046044; Mon, 10 Oct 2016 07:19:17 GMT (envelope-from delphij@FreeBSD.org) Message-Id: <201610100719.u9A7JHGO046044@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: delphij set sender to delphij@FreeBSD.org using -f From: Xin LI Date: Mon, 10 Oct 2016 07:19:17 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-releng@freebsd.org Subject: svn commit: r306942 - in releng/9.3: . contrib/bind9/lib/dns sys/conf usr.bin/bsdiff/bspatch usr.sbin/portsnap/portsnap X-SVN-Group: releng MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 Oct 2016 07:19:18 -0000 Author: delphij Date: Mon Oct 10 07:19:16 2016 New Revision: 306942 URL: https://svnweb.freebsd.org/changeset/base/306942 Log: Fix BIND remote Denial of Service vulnerability. [SA-16:28] Fix bspatch heap overflow vulnerability. [SA-16:29] Fix multiple portsnap vulnerabilities. [SA-16:30] Approved by: so Modified: releng/9.3/UPDATING releng/9.3/contrib/bind9/lib/dns/message.c releng/9.3/sys/conf/newvers.sh releng/9.3/usr.bin/bsdiff/bspatch/bspatch.c releng/9.3/usr.sbin/portsnap/portsnap/portsnap.sh Modified: releng/9.3/UPDATING ============================================================================== --- releng/9.3/UPDATING Mon Oct 10 07:18:54 2016 (r306941) +++ releng/9.3/UPDATING Mon Oct 10 07:19:16 2016 (r306942) @@ -11,6 +11,16 @@ handbook: Items affecting the ports and packages system can be found in /usr/ports/UPDATING. Please read that file before running portupgrade. +20161010 p48 FreeBSD-SA-16:28.bind + FreeBSD-SA-16:29.bspatch + FreeBSD-SA-16:30.portsnap + + Fix BIND remote Denial of Service vulnerability. [SA-16:28] + + Fix bspatch heap overflow vulnerability. [SA-16:29] + + Fix multiple portsnap vulnerabilities. [SA-16:30] + 20160926 p47 FreeBSD-SA-16:26.openssl [revised] Fix OpenSSL regression introduced in SA-16:26. Modified: releng/9.3/contrib/bind9/lib/dns/message.c ============================================================================== --- releng/9.3/contrib/bind9/lib/dns/message.c Mon Oct 10 07:18:54 2016 (r306941) +++ releng/9.3/contrib/bind9/lib/dns/message.c Mon Oct 10 07:19:16 2016 (r306942) @@ -1736,7 +1736,7 @@ dns_message_renderbegin(dns_message_t *m if (r.length < DNS_MESSAGE_HEADERLEN) return (ISC_R_NOSPACE); - if (r.length < msg->reserved) + if (r.length - DNS_MESSAGE_HEADERLEN < msg->reserved) return (ISC_R_NOSPACE); /* @@ -1863,8 +1863,29 @@ norender_rdataset(const dns_rdataset_t * return (ISC_TRUE); } - #endif + +static isc_result_t +renderset(dns_rdataset_t *rdataset, dns_name_t *owner_name, + dns_compress_t *cctx, isc_buffer_t *target, + unsigned int reserved, unsigned int options, unsigned int *countp) +{ + isc_result_t result; + + /* + * Shrink the space in the buffer by the reserved amount. + */ + if (target->length - target->used < reserved) + return (ISC_R_NOSPACE); + + target->length -= reserved; + result = dns_rdataset_towire(rdataset, owner_name, + cctx, target, options, countp); + target->length += reserved; + + return (result); +} + isc_result_t dns_message_rendersection(dns_message_t *msg, dns_section_t sectionid, unsigned int options) @@ -1907,6 +1928,8 @@ dns_message_rendersection(dns_message_t /* * Shrink the space in the buffer by the reserved amount. */ + if (msg->buffer->length - msg->buffer->used < msg->reserved) + return (ISC_R_NOSPACE); msg->buffer->length -= msg->reserved; total = 0; @@ -2183,9 +2206,8 @@ dns_message_renderend(dns_message_t *msg * Render. */ count = 0; - result = dns_rdataset_towire(msg->opt, dns_rootname, - msg->cctx, msg->buffer, 0, - &count); + result = renderset(msg->opt, dns_rootname, msg->cctx, + msg->buffer, msg->reserved, 0, &count); msg->counts[DNS_SECTION_ADDITIONAL] += count; if (result != ISC_R_SUCCESS) return (result); @@ -2201,9 +2223,8 @@ dns_message_renderend(dns_message_t *msg if (result != ISC_R_SUCCESS) return (result); count = 0; - result = dns_rdataset_towire(msg->tsig, msg->tsigname, - msg->cctx, msg->buffer, 0, - &count); + result = renderset(msg->tsig, msg->tsigname, msg->cctx, + msg->buffer, msg->reserved, 0, &count); msg->counts[DNS_SECTION_ADDITIONAL] += count; if (result != ISC_R_SUCCESS) return (result); @@ -2224,9 +2245,8 @@ dns_message_renderend(dns_message_t *msg * the owner name of a SIG(0) is irrelevant, and will not * be set in a message being rendered. */ - result = dns_rdataset_towire(msg->sig0, dns_rootname, - msg->cctx, msg->buffer, 0, - &count); + result = renderset(msg->sig0, dns_rootname, msg->cctx, + msg->buffer, msg->reserved, 0, &count); msg->counts[DNS_SECTION_ADDITIONAL] += count; if (result != ISC_R_SUCCESS) return (result); Modified: releng/9.3/sys/conf/newvers.sh ============================================================================== --- releng/9.3/sys/conf/newvers.sh Mon Oct 10 07:18:54 2016 (r306941) +++ releng/9.3/sys/conf/newvers.sh Mon Oct 10 07:19:16 2016 (r306942) @@ -32,7 +32,7 @@ TYPE="FreeBSD" REVISION="9.3" -BRANCH="RELEASE-p47" +BRANCH="RELEASE-p48" if [ "X${BRANCH_OVERRIDE}" != "X" ]; then BRANCH=${BRANCH_OVERRIDE} fi Modified: releng/9.3/usr.bin/bsdiff/bspatch/bspatch.c ============================================================================== --- releng/9.3/usr.bin/bsdiff/bspatch/bspatch.c Mon Oct 10 07:18:54 2016 (r306941) +++ releng/9.3/usr.bin/bsdiff/bspatch/bspatch.c Mon Oct 10 07:19:16 2016 (r306942) @@ -27,56 +27,133 @@ #include __FBSDID("$FreeBSD$"); +#if defined(__FreeBSD__) +#include +#if __FreeBSD_version >= 1001511 +#include +#define HAVE_CAPSICUM +#endif +#endif + #include -#include +#include +#include +#include +#include +#include +#include #include +#include #include -#include #include -#include #ifndef O_BINARY #define O_BINARY 0 #endif +#define HEADER_SIZE 32 + +static char *newfile; +static int dirfd = -1; + +static void +exit_cleanup(void) +{ + + if (dirfd != -1 && newfile != NULL) + if (unlinkat(dirfd, newfile, 0)) + warn("unlinkat"); +} static off_t offtin(u_char *buf) { off_t y; - y=buf[7]&0x7F; - y=y*256;y+=buf[6]; - y=y*256;y+=buf[5]; - y=y*256;y+=buf[4]; - y=y*256;y+=buf[3]; - y=y*256;y+=buf[2]; - y=y*256;y+=buf[1]; - y=y*256;y+=buf[0]; + y = buf[7] & 0x7F; + y = y * 256; y += buf[6]; + y = y * 256; y += buf[5]; + y = y * 256; y += buf[4]; + y = y * 256; y += buf[3]; + y = y * 256; y += buf[2]; + y = y * 256; y += buf[1]; + y = y * 256; y += buf[0]; - if(buf[7]&0x80) y=-y; + if (buf[7] & 0x80) + y = -y; - return y; + return (y); } -int main(int argc,char * argv[]) +int main(int argc, char *argv[]) { - FILE * f, * cpf, * dpf, * epf; - BZFILE * cpfbz2, * dpfbz2, * epfbz2; + FILE *f, *cpf, *dpf, *epf; + BZFILE *cpfbz2, *dpfbz2, *epfbz2; + char *directory, *namebuf; int cbz2err, dbz2err, ebz2err; - int fd; - ssize_t oldsize,newsize; - ssize_t bzctrllen,bzdatalen; - u_char header[32],buf[8]; + int newfd, oldfd; + off_t oldsize, newsize; + off_t bzctrllen, bzdatalen; + u_char header[HEADER_SIZE], buf[8]; u_char *old, *new; - off_t oldpos,newpos; + off_t oldpos, newpos; off_t ctrl[3]; - off_t lenread; - off_t i; + off_t i, lenread, offset; +#ifdef HAVE_CAPSICUM + cap_rights_t rights_dir, rights_ro, rights_wr; +#endif if(argc!=4) errx(1,"usage: %s oldfile newfile patchfile\n",argv[0]); /* Open patch file */ if ((f = fopen(argv[3], "rb")) == NULL) err(1, "fopen(%s)", argv[3]); + /* Open patch file for control block */ + if ((cpf = fopen(argv[3], "rb")) == NULL) + err(1, "fopen(%s)", argv[3]); + /* open patch file for diff block */ + if ((dpf = fopen(argv[3], "rb")) == NULL) + err(1, "fopen(%s)", argv[3]); + /* open patch file for extra block */ + if ((epf = fopen(argv[3], "rb")) == NULL) + err(1, "fopen(%s)", argv[3]); + /* open oldfile */ + if ((oldfd = open(argv[1], O_RDONLY | O_BINARY, 0)) < 0) + err(1, "open(%s)", argv[1]); + /* open directory where we'll write newfile */ + if ((namebuf = strdup(argv[2])) == NULL || + (directory = dirname(namebuf)) == NULL || + (dirfd = open(directory, O_DIRECTORY)) < 0) + err(1, "open %s", argv[2]); + free(namebuf); + if ((newfile = basename(argv[2])) == NULL) + err(1, "basename"); + /* open newfile */ + if ((newfd = openat(dirfd, newfile, + O_CREAT | O_TRUNC | O_WRONLY | O_BINARY, 0666)) < 0) + err(1, "open(%s)", argv[2]); + atexit(exit_cleanup); + +#ifdef HAVE_CAPSICUM + if (cap_enter() < 0) { + /* Failed to sandbox, fatal if CAPABILITY_MODE enabled */ + if (errno != ENOSYS) + err(1, "failed to enter security sandbox"); + } else { + /* Capsicum Available */ + cap_rights_init(&rights_ro, CAP_READ, CAP_FSTAT, CAP_SEEK); + cap_rights_init(&rights_wr, CAP_WRITE); + cap_rights_init(&rights_dir, CAP_UNLINKAT); + + if (cap_rights_limit(fileno(f), &rights_ro) < 0 || + cap_rights_limit(fileno(cpf), &rights_ro) < 0 || + cap_rights_limit(fileno(dpf), &rights_ro) < 0 || + cap_rights_limit(fileno(epf), &rights_ro) < 0 || + cap_rights_limit(oldfd, &rights_ro) < 0 || + cap_rights_limit(newfd, &rights_wr) < 0 || + cap_rights_limit(dirfd, &rights_dir) < 0) + err(1, "cap_rights_limit() failed, could not restrict" + " capabilities"); + } +#endif /* File format: @@ -93,99 +170,99 @@ int main(int argc,char * argv[]) */ /* Read header */ - if (fread(header, 1, 32, f) < 32) { + if (fread(header, 1, HEADER_SIZE, f) < HEADER_SIZE) { if (feof(f)) - errx(1, "Corrupt patch\n"); + errx(1, "Corrupt patch"); err(1, "fread(%s)", argv[3]); } /* Check for appropriate magic */ if (memcmp(header, "BSDIFF40", 8) != 0) - errx(1, "Corrupt patch\n"); + errx(1, "Corrupt patch"); /* Read lengths from header */ - bzctrllen=offtin(header+8); - bzdatalen=offtin(header+16); - newsize=offtin(header+24); - if((bzctrllen<0) || (bzdatalen<0) || (newsize<0)) - errx(1,"Corrupt patch\n"); + bzctrllen = offtin(header + 8); + bzdatalen = offtin(header + 16); + newsize = offtin(header + 24); + if (bzctrllen < 0 || bzctrllen > OFF_MAX - HEADER_SIZE || + bzdatalen < 0 || bzctrllen + HEADER_SIZE > OFF_MAX - bzdatalen || + newsize < 0 || newsize > SSIZE_MAX) + errx(1, "Corrupt patch"); /* Close patch file and re-open it via libbzip2 at the right places */ if (fclose(f)) err(1, "fclose(%s)", argv[3]); - if ((cpf = fopen(argv[3], "rb")) == NULL) - err(1, "fopen(%s)", argv[3]); - if (fseeko(cpf, 32, SEEK_SET)) - err(1, "fseeko(%s, %lld)", argv[3], - (long long)32); + offset = HEADER_SIZE; + if (fseeko(cpf, offset, SEEK_SET)) + err(1, "fseeko(%s, %jd)", argv[3], (intmax_t)offset); if ((cpfbz2 = BZ2_bzReadOpen(&cbz2err, cpf, 0, 0, NULL, 0)) == NULL) errx(1, "BZ2_bzReadOpen, bz2err = %d", cbz2err); - if ((dpf = fopen(argv[3], "rb")) == NULL) - err(1, "fopen(%s)", argv[3]); - if (fseeko(dpf, 32 + bzctrllen, SEEK_SET)) - err(1, "fseeko(%s, %lld)", argv[3], - (long long)(32 + bzctrllen)); + offset += bzctrllen; + if (fseeko(dpf, offset, SEEK_SET)) + err(1, "fseeko(%s, %jd)", argv[3], (intmax_t)offset); if ((dpfbz2 = BZ2_bzReadOpen(&dbz2err, dpf, 0, 0, NULL, 0)) == NULL) errx(1, "BZ2_bzReadOpen, bz2err = %d", dbz2err); - if ((epf = fopen(argv[3], "rb")) == NULL) - err(1, "fopen(%s)", argv[3]); - if (fseeko(epf, 32 + bzctrllen + bzdatalen, SEEK_SET)) - err(1, "fseeko(%s, %lld)", argv[3], - (long long)(32 + bzctrllen + bzdatalen)); + offset += bzdatalen; + if (fseeko(epf, offset, SEEK_SET)) + err(1, "fseeko(%s, %jd)", argv[3], (intmax_t)offset); if ((epfbz2 = BZ2_bzReadOpen(&ebz2err, epf, 0, 0, NULL, 0)) == NULL) errx(1, "BZ2_bzReadOpen, bz2err = %d", ebz2err); - if(((fd=open(argv[1],O_RDONLY|O_BINARY,0))<0) || - ((oldsize=lseek(fd,0,SEEK_END))==-1) || - ((old=malloc(oldsize+1))==NULL) || - (lseek(fd,0,SEEK_SET)!=0) || - (read(fd,old,oldsize)!=oldsize) || - (close(fd)==-1)) err(1,"%s",argv[1]); - if((new=malloc(newsize+1))==NULL) err(1,NULL); - - oldpos=0;newpos=0; - while(newpos SSIZE_MAX || + (old = malloc(oldsize)) == NULL || + lseek(oldfd, 0, SEEK_SET) != 0 || + read(oldfd, old, oldsize) != oldsize || + close(oldfd) == -1) + err(1, "%s", argv[1]); + if ((new = malloc(newsize)) == NULL) + err(1, NULL); + + oldpos = 0; + newpos = 0; + while (newpos < newsize) { /* Read control data */ - for(i=0;i<=2;i++) { + for (i = 0; i <= 2; i++) { lenread = BZ2_bzRead(&cbz2err, cpfbz2, buf, 8); if ((lenread < 8) || ((cbz2err != BZ_OK) && (cbz2err != BZ_STREAM_END))) - errx(1, "Corrupt patch\n"); - ctrl[i]=offtin(buf); + errx(1, "Corrupt patch"); + ctrl[i] = offtin(buf); }; /* Sanity-check */ - if ((ctrl[0] < 0) || (ctrl[1] < 0)) - errx(1,"Corrupt patch\n"); + if (ctrl[0] < 0 || ctrl[0] > INT_MAX || + ctrl[1] < 0 || ctrl[1] > INT_MAX) + errx(1, "Corrupt patch"); /* Sanity-check */ - if(newpos+ctrl[0]>newsize) - errx(1,"Corrupt patch\n"); + if (newpos + ctrl[0] > newsize) + errx(1, "Corrupt patch"); /* Read diff string */ lenread = BZ2_bzRead(&dbz2err, dpfbz2, new + newpos, ctrl[0]); if ((lenread < ctrl[0]) || ((dbz2err != BZ_OK) && (dbz2err != BZ_STREAM_END))) - errx(1, "Corrupt patch\n"); + errx(1, "Corrupt patch"); /* Add old data to diff string */ - for(i=0;i=0) && (oldpos+i= 0) && (oldpos + i < oldsize)) + new[newpos + i] += old[oldpos + i]; /* Adjust pointers */ - newpos+=ctrl[0]; - oldpos+=ctrl[0]; + newpos += ctrl[0]; + oldpos += ctrl[0]; /* Sanity-check */ - if(newpos+ctrl[1]>newsize) - errx(1,"Corrupt patch\n"); + if (newpos + ctrl[1] > newsize) + errx(1, "Corrupt patch"); /* Read extra string */ lenread = BZ2_bzRead(&ebz2err, epfbz2, new + newpos, ctrl[1]); if ((lenread < ctrl[1]) || ((ebz2err != BZ_OK) && (ebz2err != BZ_STREAM_END))) - errx(1, "Corrupt patch\n"); + errx(1, "Corrupt patch"); /* Adjust pointers */ newpos+=ctrl[1]; @@ -200,12 +277,13 @@ int main(int argc,char * argv[]) err(1, "fclose(%s)", argv[3]); /* Write the new file */ - if(((fd=open(argv[2],O_CREAT|O_TRUNC|O_WRONLY|O_BINARY,0666))<0) || - (write(fd,new,newsize)!=newsize) || (close(fd)==-1)) - err(1,"%s",argv[2]); + if (write(newfd, new, newsize) != newsize || close(newfd) == -1) + err(1, "%s", argv[2]); + /* Disable atexit cleanup */ + newfile = NULL; free(new); free(old); - return 0; + return (0); } Modified: releng/9.3/usr.sbin/portsnap/portsnap/portsnap.sh ============================================================================== --- releng/9.3/usr.sbin/portsnap/portsnap/portsnap.sh Mon Oct 10 07:18:54 2016 (r306941) +++ releng/9.3/usr.sbin/portsnap/portsnap/portsnap.sh Mon Oct 10 07:19:16 2016 (r306942) @@ -609,7 +609,7 @@ fetch_index_sanity() { # Verify a list of files fetch_snapshot_verify() { while read F; do - if [ "`gunzip -c snap/${F} | ${SHA256} -q`" != ${F} ]; then + if [ "`gunzip -c < snap/${F}.gz | ${SHA256} -q`" != ${F} ]; then echo "snapshot corrupt." return 1 fi @@ -644,11 +644,18 @@ fetch_snapshot() { cut -f 2 -d '|' tINDEX.new | fetch_snapshot_verify || return 1 # Extract the index rm -f INDEX.new - gunzip -c snap/`look INDEX tINDEX.new | + gunzip -c < snap/`look INDEX tINDEX.new | cut -f 2 -d '|'`.gz > INDEX.new fetch_index_sanity || return 1 # Verify the snapshot contents cut -f 2 -d '|' INDEX.new | fetch_snapshot_verify || return 1 + cut -f 2 -d '|' tINDEX.new INDEX.new | sort -u > files.expected + find snap -mindepth 1 | sed -E 's^snap/(.*)\.gz^\1^' | sort > files.snap + if ! cmp -s files.expected files.snap; then + echo "unexpected files in snapshot." + return 1 + fi + rm files.expected files.snap echo "done." # Move files into their proper locations @@ -737,7 +744,7 @@ fetch_update() { echo "done." # Extract the index - gunzip -c files/`look INDEX tINDEX.new | + gunzip -c < files/`look INDEX tINDEX.new | cut -f 2 -d '|'`.gz > INDEX.new fetch_index_sanity || return 1 @@ -842,7 +849,7 @@ extract_make_index() { echo -n "$1 not provided by portsnap server; " echo "$2 not being generated." else - gunzip -c "${WORKDIR}/files/`look $1 ${WORKDIR}/tINDEX | + gunzip -c < "${WORKDIR}/files/`look $1 ${WORKDIR}/tINDEX | cut -f 2 -d '|'`.gz" | cat - ${LOCALDESC} | ${MKINDEX} /dev/stdin > ${PORTSDIR}/$2 From owner-svn-src-all@freebsd.org Mon Oct 10 09:54:02 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id F1EA2C063CA; Mon, 10 Oct 2016 09:54:02 +0000 (UTC) (envelope-from arybchik@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id B28FE785; Mon, 10 Oct 2016 09:54:02 +0000 (UTC) (envelope-from arybchik@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9A9s12t005786; Mon, 10 Oct 2016 09:54:01 GMT (envelope-from arybchik@FreeBSD.org) Received: (from arybchik@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9A9s1vh005784; Mon, 10 Oct 2016 09:54:01 GMT (envelope-from arybchik@FreeBSD.org) Message-Id: <201610100954.u9A9s1vh005784@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: arybchik set sender to arybchik@FreeBSD.org using -f From: Andrew Rybchenko Date: Mon, 10 Oct 2016 09:54:01 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r306944 - head/sys/dev/sfxge/common X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 Oct 2016 09:54:03 -0000 Author: arybchik Date: Mon Oct 10 09:54:01 2016 New Revision: 306944 URL: https://svnweb.freebsd.org/changeset/base/306944 Log: sfxge(4): sync tlv_layout.h with firmwaresrc and update port-mode definition use It fixes driver attach issue to a new firmware which reports a new port-modes. Reviewed by: gnn Submitted by: Tom Millington Sponsored by: Solarflare Communications, Inc. MFC after: 2 days Differential Revision: https://reviews.freebsd.org/D8203 Modified: head/sys/dev/sfxge/common/ef10_nic.c head/sys/dev/sfxge/common/ef10_tlv_layout.h Modified: head/sys/dev/sfxge/common/ef10_nic.c ============================================================================== --- head/sys/dev/sfxge/common/ef10_nic.c Mon Oct 10 08:46:26 2016 (r306943) +++ head/sys/dev/sfxge/common/ef10_nic.c Mon Oct 10 09:54:01 2016 (r306944) @@ -164,6 +164,7 @@ ef10_nic_get_port_mode_bandwidth( break; case TLV_PORT_MODE_10G_10G_10G_10G: case TLV_PORT_MODE_10G_10G_10G_10G_Q: + case TLV_PORT_MODE_10G_10G_10G_10G_Q1_Q2: case TLV_PORT_MODE_10G_10G_10G_10G_Q2: bandwidth = 10000 * 4; break; @@ -1122,8 +1123,7 @@ static struct { { EFX_FAMILY_MEDFORD, (1 << TLV_PORT_MODE_10G) | - (1 << TLV_PORT_MODE_10G_10G) | - (1 << TLV_PORT_MODE_10G_10G_10G_10G), + (1 << TLV_PORT_MODE_10G_10G), 1 }, /* Supported modes requiring 2 outputs per port */ @@ -1140,13 +1140,15 @@ static struct { (1 << TLV_PORT_MODE_40G) | (1 << TLV_PORT_MODE_40G_40G) | (1 << TLV_PORT_MODE_40G_10G_10G) | - (1 << TLV_PORT_MODE_10G_10G_40G), + (1 << TLV_PORT_MODE_10G_10G_40G) | + (1 << TLV_PORT_MODE_10G_10G_10G_10G_Q1_Q2), 2 }, /* Supported modes requiring 4 outputs per port */ { EFX_FAMILY_MEDFORD, (1 << TLV_PORT_MODE_10G_10G_10G_10G_Q) | + (1 << TLV_PORT_MODE_10G_10G_10G_10G_Q1) | (1 << TLV_PORT_MODE_10G_10G_10G_10G_Q2), 4 }, Modified: head/sys/dev/sfxge/common/ef10_tlv_layout.h ============================================================================== --- head/sys/dev/sfxge/common/ef10_tlv_layout.h Mon Oct 10 08:46:26 2016 (r306943) +++ head/sys/dev/sfxge/common/ef10_tlv_layout.h Mon Oct 10 09:54:01 2016 (r306944) @@ -553,12 +553,14 @@ struct tlv_global_port_mode { #define TLV_PORT_MODE_40G (1) /* 40G, single QSFP/40G-KR */ #define TLV_PORT_MODE_10G_10G (2) /* 2x10G, dual SFP/10G-KR or single QSFP */ #define TLV_PORT_MODE_40G_40G (3) /* 40G + 40G, dual QSFP/40G-KR (Greenport, Medford) */ -#define TLV_PORT_MODE_10G_10G_10G_10G (4) /* 2x10G + 2x10G, quad SFP/10G-KR or dual QSFP (Greenport, Medford) */ -#define TLV_PORT_MODE_10G_10G_10G_10G_Q (5) /* 4x10G, single QSFP, cage 0 (Medford) */ +#define TLV_PORT_MODE_10G_10G_10G_10G (4) /* 2x10G + 2x10G, quad SFP/10G-KR or dual QSFP (Greenport) */ +#define TLV_PORT_MODE_10G_10G_10G_10G_Q1 (4) /* 4x10G, single QSFP, cage 0 (Medford) */ +#define TLV_PORT_MODE_10G_10G_10G_10G_Q (5) /* 4x10G, single QSFP, cage 0 (Medford) OBSOLETE DO NOT USE */ #define TLV_PORT_MODE_40G_10G_10G (6) /* 1x40G + 2x10G, dual QSFP (Greenport, Medford) */ #define TLV_PORT_MODE_10G_10G_40G (7) /* 2x10G + 1x40G, dual QSFP (Greenport, Medford) */ #define TLV_PORT_MODE_10G_10G_10G_10G_Q2 (8) /* 4x10G, single QSFP, cage 1 (Medford) */ -#define TLV_PORT_MODE_MAX TLV_PORT_MODE_10G_10G_10G_10G_Q2 +#define TLV_PORT_MODE_10G_10G_10G_10G_Q1_Q2 (9) /* 2x10G + 2x10G, dual QSFP (Medford) */ +#define TLV_PORT_MODE_MAX TLV_PORT_MODE_10G_10G_10G_10G_Q1_Q2 }; /* Type of the v-switch created implicitly by the firmware */ @@ -765,8 +767,8 @@ struct tlv_rx_event_merging_config { #define TLV_RX_EVENT_MERGING_CONFIG_MAX_EVENTS_MAX ((1 << 4) - 1) uint32_t timeout_ns; }; -#define TLV_RX_EVENT_MERGING_MAX_EVENTS_DEFAULT 7 -#define TLV_RX_EVENT_MERGING_TIMEOUT_NS_DEFAULT 8740 +#define TLV_RX_EVENT_MERGING_MAX_EVENTS_DEFAULT (0xffffffff) +#define TLV_RX_EVENT_MERGING_TIMEOUT_NS_DEFAULT (0xffffffff) #define TLV_TAG_PCIE_LINK_SETTINGS (0x101f0000) struct tlv_pcie_link_settings { @@ -791,9 +793,9 @@ struct tlv_tx_event_merging_config { uint32_t timeout_ns; uint32_t qempty_timeout_ns; /* Medford only */ }; -#define TLV_TX_EVENT_MERGING_MAX_EVENTS_DEFAULT 7 -#define TLV_TX_EVENT_MERGING_TIMEOUT_NS_DEFAULT 1400 -#define TLV_TX_EVENT_MERGING_QEMPTY_TIMEOUT_NS_DEFAULT 700 +#define TLV_TX_EVENT_MERGING_MAX_EVENTS_DEFAULT (0xffffffff) +#define TLV_TX_EVENT_MERGING_TIMEOUT_NS_DEFAULT (0xffffffff) +#define TLV_TX_EVENT_MERGING_QEMPTY_TIMEOUT_NS_DEFAULT (0xffffffff) /* Tx vFIFO Low latency configuration * @@ -809,6 +811,20 @@ struct tlv_tx_vfifo_ull_mode { #define TLV_TX_VFIFO_ULL_MODE_DEFAULT 0 }; +/* BIU mode + * + * Medford2 tag for selecting VI window decode (see values below) + */ +#define TLV_TAG_BIU_VI_WINDOW_MODE (0x10280000) +struct tlv_biu_vi_window_mode { + uint32_t tag; + uint32_t length; + uint8_t mode; +#define TLV_BIU_VI_WINDOW_MODE_8K 0 /* 8k per VI, CTPIO not mapped, medford/hunt compatible */ +#define TLV_BIU_VI_WINDOW_MODE_16K 1 /* 16k per VI, CTPIO mapped */ +#define TLV_BIU_VI_WINDOW_MODE_64K 2 /* 64k per VI, CTPIO mapped, POWER-friendly */ +}; + #define TLV_TAG_LICENSE (0x30800000) typedef struct tlv_license { From owner-svn-src-all@freebsd.org Mon Oct 10 11:09:10 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 1C38BC07B4A; Mon, 10 Oct 2016 11:09:10 +0000 (UTC) (envelope-from slw@zxy.spb.ru) Received: from zxy.spb.ru (zxy.spb.ru [195.70.199.98]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id CEEE9F29; Mon, 10 Oct 2016 11:09:09 +0000 (UTC) (envelope-from slw@zxy.spb.ru) Received: from slw by zxy.spb.ru with local (Exim 4.86 (FreeBSD)) (envelope-from ) id 1btYS5-0006oU-Ca; Mon, 10 Oct 2016 14:09:01 +0300 Date: Mon, 10 Oct 2016 14:09:01 +0300 From: Slawa Olhovchenkov To: John Baldwin Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: Re: svn commit: r306661 - in stable/11/sys/dev/cxgbe: . tom Message-ID: <20161010110901.GH6177@zxy.spb.ru> References: <201610032315.u93NFiHE057529@repo.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <201610032315.u93NFiHE057529@repo.freebsd.org> User-Agent: Mutt/1.5.24 (2015-08-30) X-SA-Exim-Connect-IP: X-SA-Exim-Mail-From: slw@zxy.spb.ru X-SA-Exim-Scanned: No (on zxy.spb.ru); SAEximRunCond expanded to false X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 Oct 2016 11:09:10 -0000 On Mon, Oct 03, 2016 at 11:15:44PM +0000, John Baldwin wrote: > Author: jhb > Date: Mon Oct 3 23:15:44 2016 > New Revision: 306661 > URL: https://svnweb.freebsd.org/changeset/base/306661 > > Log: > MFC 303405: Add support for zero-copy aio_write() on TOE sockets. > > AIO write requests for a TOE socket on a Chelsio T4+ adapter can now > DMA directly from the user-supplied buffer. This is implemented by > wiring the pages backing the user-supplied buffer and queueing special > mbufs backed by raw VM pages to the socket buffer. The TOE code > recognizes these special mbufs and builds a sglist from the VM page > array associated with the mbuf when queueing a work request to the TOE. > > Because these mbufs do not have an associated virtual address, m_data > is not valid. Thus, the AIO handler does not invoke sosend() directly > for these mbufs but instead inlines portions of sosend_generic() and > tcp_usr_send(). > > An aiotx_buffer structure is used to describe the user buffer (e.g. > it holds the array of VM pages and a reference to the AIO job). The > special mbufs reference this structure via m_ext. Note that a single > job might be split across multiple mbufs (e.g. if it is larger than > the socket buffer size). The 'ext_arg2' member of each mbuf gives an > offset relative to the backing aiotx_buffer. The AIO job associated > with an aiotx_buffer structure is completed when the last reference to > the structure is released. > > Zero-copy aio_write()'s for connections associated with a given > adapter can be enabled/disabled at runtime via the > 'dev.t[45]nex.N.toe.tx_zcopy' sysctl. > > Sponsored by: Chelsio Communications Do you have any public available application patches for support this? May be nginx? From owner-svn-src-all@freebsd.org Mon Oct 10 11:22:13 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 3A71AC0B11F; Mon, 10 Oct 2016 11:22:13 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id F054CB14; Mon, 10 Oct 2016 11:22:12 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9ABMCNw040488; Mon, 10 Oct 2016 11:22:12 GMT (envelope-from hselasky@FreeBSD.org) Received: (from hselasky@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9ABMBMQ040486; Mon, 10 Oct 2016 11:22:11 GMT (envelope-from hselasky@FreeBSD.org) Message-Id: <201610101122.u9ABMBMQ040486@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hselasky set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky Date: Mon, 10 Oct 2016 11:22:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r306946 - in stable/11: share/man/man9 sys/kern X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 Oct 2016 11:22:13 -0000 Author: hselasky Date: Mon Oct 10 11:22:11 2016 New Revision: 306946 URL: https://svnweb.freebsd.org/changeset/base/306946 Log: MFC r306441 and r306634: While draining a timeout task prevent the taskqueue_enqueue_timeout() function from restarting the timer. Commonly taskqueue_enqueue_timeout() is called from within the task function itself without any checks for teardown. Then it can happen the timer stays active after the return of taskqueue_drain_timeout(), because the timeout and task is drained separately. This patch factors out the teardown flag into the timeout task itself, allowing existing code to stay as-is instead of applying a teardown flag to each and every of the timeout task consumers. Add assert to taskqueue_drain_timeout() which prevents parallel execution on the same timeout task. Update manual page documenting the return value of taskqueue_enqueue_timeout(). Differential Revision: https://reviews.freebsd.org/D8012 Reviewed by: kib, trasz Modified: stable/11/share/man/man9/taskqueue.9 stable/11/sys/kern/subr_taskqueue.c Directory Properties: stable/11/ (props changed) Modified: stable/11/share/man/man9/taskqueue.9 ============================================================================== --- stable/11/share/man/man9/taskqueue.9 Mon Oct 10 10:58:18 2016 (r306945) +++ stable/11/share/man/man9/taskqueue.9 Mon Oct 10 11:22:11 2016 (r306946) @@ -223,6 +223,8 @@ Otherwise, the task is scheduled for enq after the absolute value of .Va ticks is passed. +This function returns -1 if the task is being drained. +Otherwise, the number of pending calls is returned. .Pp The .Fn taskqueue_cancel Modified: stable/11/sys/kern/subr_taskqueue.c ============================================================================== --- stable/11/sys/kern/subr_taskqueue.c Mon Oct 10 10:58:18 2016 (r306945) +++ stable/11/sys/kern/subr_taskqueue.c Mon Oct 10 11:22:11 2016 (r306946) @@ -81,6 +81,7 @@ struct taskqueue { #define TQ_FLAGS_UNLOCKED_ENQUEUE (1 << 2) #define DT_CALLOUT_ARMED (1 << 0) +#define DT_DRAIN_IN_PROGRESS (1 << 1) #define TQ_LOCK(tq) \ do { \ @@ -299,7 +300,11 @@ taskqueue_enqueue_timeout(struct taskque KASSERT(!queue->tq_spin, ("Timeout for spin-queue")); timeout_task->q = queue; res = timeout_task->t.ta_pending; - if (ticks == 0) { + if (timeout_task->f & DT_DRAIN_IN_PROGRESS) { + /* Do nothing */ + TQ_UNLOCK(queue); + res = -1; + } else if (ticks == 0) { taskqueue_enqueue_locked(queue, &timeout_task->t); /* The lock is released inside. */ } else { @@ -559,8 +564,24 @@ taskqueue_drain_timeout(struct taskqueue struct timeout_task *timeout_task) { + /* + * Set flag to prevent timer from re-starting during drain: + */ + TQ_LOCK(queue); + KASSERT((timeout_task->f & DT_DRAIN_IN_PROGRESS) == 0, + ("Drain already in progress")); + timeout_task->f |= DT_DRAIN_IN_PROGRESS; + TQ_UNLOCK(queue); + callout_drain(&timeout_task->c); taskqueue_drain(queue, &timeout_task->t); + + /* + * Clear flag to allow timer to re-start: + */ + TQ_LOCK(queue); + timeout_task->f &= ~DT_DRAIN_IN_PROGRESS; + TQ_UNLOCK(queue); } static void From owner-svn-src-all@freebsd.org Mon Oct 10 11:25:13 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 563FEC0B1B3; Mon, 10 Oct 2016 11:25:13 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 17AD3CCD; Mon, 10 Oct 2016 11:25:13 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9ABPCnR040649; Mon, 10 Oct 2016 11:25:12 GMT (envelope-from hselasky@FreeBSD.org) Received: (from hselasky@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9ABPCAT040647; Mon, 10 Oct 2016 11:25:12 GMT (envelope-from hselasky@FreeBSD.org) Message-Id: <201610101125.u9ABPCAT040647@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hselasky set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky Date: Mon, 10 Oct 2016 11:25:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r306947 - in stable/10: share/man/man9 sys/kern X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 Oct 2016 11:25:13 -0000 Author: hselasky Date: Mon Oct 10 11:25:11 2016 New Revision: 306947 URL: https://svnweb.freebsd.org/changeset/base/306947 Log: MFC r306441 and r306634: While draining a timeout task prevent the taskqueue_enqueue_timeout() function from restarting the timer. Commonly taskqueue_enqueue_timeout() is called from within the task function itself without any checks for teardown. Then it can happen the timer stays active after the return of taskqueue_drain_timeout(), because the timeout and task is drained separately. This patch factors out the teardown flag into the timeout task itself, allowing existing code to stay as-is instead of applying a teardown flag to each and every of the timeout task consumers. Add assert to taskqueue_drain_timeout() which prevents parallel execution on the same timeout task. Update manual page documenting the return value of taskqueue_enqueue_timeout(). Differential Revision: https://reviews.freebsd.org/D8012 Reviewed by: kib, trasz Modified: stable/10/share/man/man9/taskqueue.9 stable/10/sys/kern/subr_taskqueue.c Directory Properties: stable/10/ (props changed) Modified: stable/10/share/man/man9/taskqueue.9 ============================================================================== --- stable/10/share/man/man9/taskqueue.9 Mon Oct 10 11:22:11 2016 (r306946) +++ stable/10/share/man/man9/taskqueue.9 Mon Oct 10 11:25:11 2016 (r306947) @@ -221,6 +221,8 @@ Otherwise, the task is scheduled for enq after the absolute value of .Va ticks is passed. +This function returns -1 if the task is being drained. +Otherwise, the number of pending calls is returned. .Pp The .Fn taskqueue_cancel Modified: stable/10/sys/kern/subr_taskqueue.c ============================================================================== --- stable/10/sys/kern/subr_taskqueue.c Mon Oct 10 11:22:11 2016 (r306946) +++ stable/10/sys/kern/subr_taskqueue.c Mon Oct 10 11:25:11 2016 (r306947) @@ -75,6 +75,7 @@ struct taskqueue { #define TQ_FLAGS_UNLOCKED_ENQUEUE (1 << 2) #define DT_CALLOUT_ARMED (1 << 0) +#define DT_DRAIN_IN_PROGRESS (1 << 1) #define TQ_LOCK(tq) \ do { \ @@ -279,7 +280,11 @@ taskqueue_enqueue_timeout(struct taskque KASSERT(!queue->tq_spin, ("Timeout for spin-queue")); timeout_task->q = queue; res = timeout_task->t.ta_pending; - if (ticks == 0) { + if (timeout_task->f & DT_DRAIN_IN_PROGRESS) { + /* Do nothing */ + TQ_UNLOCK(queue); + res = -1; + } else if (ticks == 0) { taskqueue_enqueue_locked(queue, &timeout_task->t); /* The lock is released inside. */ } else { @@ -485,8 +490,24 @@ taskqueue_drain_timeout(struct taskqueue struct timeout_task *timeout_task) { + /* + * Set flag to prevent timer from re-starting during drain: + */ + TQ_LOCK(queue); + KASSERT((timeout_task->f & DT_DRAIN_IN_PROGRESS) == 0, + ("Drain already in progress")); + timeout_task->f |= DT_DRAIN_IN_PROGRESS; + TQ_UNLOCK(queue); + callout_drain(&timeout_task->c); taskqueue_drain(queue, &timeout_task->t); + + /* + * Clear flag to allow timer to re-start: + */ + TQ_LOCK(queue); + timeout_task->f &= ~DT_DRAIN_IN_PROGRESS; + TQ_UNLOCK(queue); } static void From owner-svn-src-all@freebsd.org Mon Oct 10 11:28:00 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C2DB7C0B427; Mon, 10 Oct 2016 11:28:00 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 9D3FC11E; Mon, 10 Oct 2016 11:28:00 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9ABRxou040800; Mon, 10 Oct 2016 11:27:59 GMT (envelope-from hselasky@FreeBSD.org) Received: (from hselasky@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9ABRxSp040798; Mon, 10 Oct 2016 11:27:59 GMT (envelope-from hselasky@FreeBSD.org) Message-Id: <201610101127.u9ABRxSp040798@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hselasky set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky Date: Mon, 10 Oct 2016 11:27:59 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r306948 - in stable/9: share/man/man9 sys/kern X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 Oct 2016 11:28:00 -0000 Author: hselasky Date: Mon Oct 10 11:27:59 2016 New Revision: 306948 URL: https://svnweb.freebsd.org/changeset/base/306948 Log: MFC r306441 and r306634: While draining a timeout task prevent the taskqueue_enqueue_timeout() function from restarting the timer. Commonly taskqueue_enqueue_timeout() is called from within the task function itself without any checks for teardown. Then it can happen the timer stays active after the return of taskqueue_drain_timeout(), because the timeout and task is drained separately. This patch factors out the teardown flag into the timeout task itself, allowing existing code to stay as-is instead of applying a teardown flag to each and every of the timeout task consumers. Add assert to taskqueue_drain_timeout() which prevents parallel execution on the same timeout task. Update manual page documenting the return value of taskqueue_enqueue_timeout(). Differential Revision: https://reviews.freebsd.org/D8012 Reviewed by: kib, trasz Modified: stable/9/share/man/man9/taskqueue.9 stable/9/sys/kern/subr_taskqueue.c Directory Properties: stable/9/share/ (props changed) stable/9/share/man/ (props changed) stable/9/share/man/man9/ (props changed) stable/9/sys/ (props changed) Modified: stable/9/share/man/man9/taskqueue.9 ============================================================================== --- stable/9/share/man/man9/taskqueue.9 Mon Oct 10 11:25:11 2016 (r306947) +++ stable/9/share/man/man9/taskqueue.9 Mon Oct 10 11:27:59 2016 (r306948) @@ -193,6 +193,8 @@ Otherwise, the task is scheduled for enq after the absolute value of .Va ticks is passed. +This function returns -1 if the task is being drained. +Otherwise, the number of pending calls is returned. .Pp The .Fn taskqueue_cancel Modified: stable/9/sys/kern/subr_taskqueue.c ============================================================================== --- stable/9/sys/kern/subr_taskqueue.c Mon Oct 10 11:25:11 2016 (r306947) +++ stable/9/sys/kern/subr_taskqueue.c Mon Oct 10 11:27:59 2016 (r306948) @@ -70,6 +70,7 @@ struct taskqueue { #define TQ_FLAGS_PENDING (1 << 2) #define DT_CALLOUT_ARMED (1 << 0) +#define DT_DRAIN_IN_PROGRESS (1 << 1) #define TQ_LOCK(tq) \ do { \ @@ -244,7 +245,11 @@ taskqueue_enqueue_timeout(struct taskque KASSERT(!queue->tq_spin, ("Timeout for spin-queue")); timeout_task->q = queue; res = timeout_task->t.ta_pending; - if (ticks == 0) { + if (timeout_task->f & DT_DRAIN_IN_PROGRESS) { + /* Do nothing */ + TQ_UNLOCK(queue); + res = -1; + } else if (ticks == 0) { taskqueue_enqueue_locked(queue, &timeout_task->t); } else { if ((timeout_task->f & DT_CALLOUT_ARMED) != 0) { @@ -434,8 +439,24 @@ taskqueue_drain_timeout(struct taskqueue struct timeout_task *timeout_task) { + /* + * Set flag to prevent timer from re-starting during drain: + */ + TQ_LOCK(queue); + KASSERT((timeout_task->f & DT_DRAIN_IN_PROGRESS) == 0, + ("Drain already in progress")); + timeout_task->f |= DT_DRAIN_IN_PROGRESS; + TQ_UNLOCK(queue); + callout_drain(&timeout_task->c); taskqueue_drain(queue, &timeout_task->t); + + /* + * Clear flag to allow timer to re-start: + */ + TQ_LOCK(queue); + timeout_task->f &= ~DT_DRAIN_IN_PROGRESS; + TQ_UNLOCK(queue); } static void From owner-svn-src-all@freebsd.org Mon Oct 10 11:30:37 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 00285C0B4E0; Mon, 10 Oct 2016 11:30:36 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id A7F15305; Mon, 10 Oct 2016 11:30:36 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9ABUZSf040960; Mon, 10 Oct 2016 11:30:35 GMT (envelope-from hselasky@FreeBSD.org) Received: (from hselasky@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9ABUZRh040959; Mon, 10 Oct 2016 11:30:35 GMT (envelope-from hselasky@FreeBSD.org) Message-Id: <201610101130.u9ABUZRh040959@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hselasky set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky Date: Mon, 10 Oct 2016 11:30:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r306949 - stable/11/sys/compat/linuxkpi/common/include/linux X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 Oct 2016 11:30:37 -0000 Author: hselasky Date: Mon Oct 10 11:30:35 2016 New Revision: 306949 URL: https://svnweb.freebsd.org/changeset/base/306949 Log: MFC r306451: The IORESOURCE_XXX defines should resemble a bitmask while SYS_RES_XXX are not bitmasks. Fix return value of pci_resource_flags() to reflect this change. Sponsored by: Mellanox Technologies Modified: stable/11/sys/compat/linuxkpi/common/include/linux/pci.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/compat/linuxkpi/common/include/linux/pci.h ============================================================================== --- stable/11/sys/compat/linuxkpi/common/include/linux/pci.h Mon Oct 10 11:27:59 2016 (r306948) +++ stable/11/sys/compat/linuxkpi/common/include/linux/pci.h Mon Oct 10 11:30:35 2016 (r306949) @@ -2,7 +2,7 @@ * Copyright (c) 2010 Isilon Systems, Inc. * Copyright (c) 2010 iX Systems, Inc. * Copyright (c) 2010 Panasas, Inc. - * Copyright (c) 2013, 2014 Mellanox Technologies, Ltd. + * Copyright (c) 2013-2016 Mellanox Technologies, Ltd. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -121,9 +121,9 @@ struct pci_device_id { #define PCI_EXP_LNKCAP2_SLS_5_0GB 0x04 /* Supported Link Speed 5.0GT/s */ #define PCI_EXP_LNKCAP2_SLS_8_0GB 0x08 /* Supported Link Speed 8.0GT/s */ -#define IORESOURCE_MEM SYS_RES_MEMORY -#define IORESOURCE_IO SYS_RES_IOPORT -#define IORESOURCE_IRQ SYS_RES_IRQ +#define IORESOURCE_MEM (1 << SYS_RES_MEMORY) +#define IORESOURCE_IO (1 << SYS_RES_IOPORT) +#define IORESOURCE_IRQ (1 << SYS_RES_IRQ) enum pci_bus_speed { PCI_SPEED_UNKNOWN = -1, @@ -230,17 +230,28 @@ pci_resource_len(struct pci_dev *pdev, i return rle->count; } +static inline int +pci_resource_type(struct pci_dev *pdev, int bar) +{ + struct resource_list_entry *rle; + + if ((rle = _pci_get_bar(pdev, bar)) == NULL) + return (-1); + return (rle->type); +} + /* * All drivers just seem to want to inspect the type not flags. */ static inline int pci_resource_flags(struct pci_dev *pdev, int bar) { - struct resource_list_entry *rle; + int type; - if ((rle = _pci_get_bar(pdev, bar)) == NULL) + type = pci_resource_type(pdev, bar); + if (type < 0) return (0); - return rle->type; + return (1 << type); } static inline const char * @@ -300,8 +311,8 @@ pci_request_region(struct pci_dev *pdev, int rid; int type; - type = pci_resource_flags(pdev, bar); - if (type == 0) + type = pci_resource_type(pdev, bar); + if (type < 0) return (-ENODEV); rid = PCIR_BAR(bar); if (bus_alloc_resource_any(pdev->dev.bsddev, type, &rid, From owner-svn-src-all@freebsd.org Mon Oct 10 11:34:52 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 9FD8BC0B796; Mon, 10 Oct 2016 11:34:52 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 54AF2A7D; Mon, 10 Oct 2016 11:34:52 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9ABYp0d044451; Mon, 10 Oct 2016 11:34:51 GMT (envelope-from hselasky@FreeBSD.org) Received: (from hselasky@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9ABYpAk044450; Mon, 10 Oct 2016 11:34:51 GMT (envelope-from hselasky@FreeBSD.org) Message-Id: <201610101134.u9ABYpAk044450@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hselasky set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky Date: Mon, 10 Oct 2016 11:34:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r306950 - stable/10/sys/ofed/include/linux X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 Oct 2016 11:34:52 -0000 Author: hselasky Date: Mon Oct 10 11:34:51 2016 New Revision: 306950 URL: https://svnweb.freebsd.org/changeset/base/306950 Log: MFC r306451: The IORESOURCE_XXX defines should resemble a bitmask while SYS_RES_XXX are not bitmasks. Fix return value of pci_resource_flags() to reflect this change. Sponsored by: Mellanox Technologies Modified: stable/10/sys/ofed/include/linux/pci.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/ofed/include/linux/pci.h ============================================================================== --- stable/10/sys/ofed/include/linux/pci.h Mon Oct 10 11:30:35 2016 (r306949) +++ stable/10/sys/ofed/include/linux/pci.h Mon Oct 10 11:34:51 2016 (r306950) @@ -2,7 +2,7 @@ * Copyright (c) 2010 Isilon Systems, Inc. * Copyright (c) 2010 iX Systems, Inc. * Copyright (c) 2010 Panasas, Inc. - * Copyright (c) 2013, 2014 Mellanox Technologies, Ltd. + * Copyright (c) 2013-2016 Mellanox Technologies, Ltd. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -115,9 +115,9 @@ struct pci_device_id { #define PCI_EXP_TYPE_RC_EC PCIEM_TYPE_ROOT_EC /* Root Complex Event Collector */ -#define IORESOURCE_MEM SYS_RES_MEMORY -#define IORESOURCE_IO SYS_RES_IOPORT -#define IORESOURCE_IRQ SYS_RES_IRQ +#define IORESOURCE_MEM (1 << SYS_RES_MEMORY) +#define IORESOURCE_IO (1 << SYS_RES_IOPORT) +#define IORESOURCE_IRQ (1 << SYS_RES_IRQ) struct pci_dev; @@ -213,17 +213,28 @@ pci_resource_len(struct pci_dev *pdev, i return rle->count; } +static inline int +pci_resource_type(struct pci_dev *pdev, int bar) +{ + struct resource_list_entry *rle; + + if ((rle = _pci_get_bar(pdev, bar)) == NULL) + return (-1); + return (rle->type); +} + /* * All drivers just seem to want to inspect the type not flags. */ static inline int pci_resource_flags(struct pci_dev *pdev, int bar) { - struct resource_list_entry *rle; + int type; - if ((rle = _pci_get_bar(pdev, bar)) == NULL) + type = pci_resource_type(pdev, bar); + if (type < 0) return (0); - return rle->type; + return (1 << type); } static inline const char * @@ -283,8 +294,8 @@ pci_request_region(struct pci_dev *pdev, int rid; int type; - type = pci_resource_flags(pdev, bar); - if (type == 0) + type = pci_resource_type(pdev, bar); + if (type < 0) return (-ENODEV); rid = PCIR_BAR(bar); if (bus_alloc_resource_any(pdev->dev.bsddev, type, &rid, From owner-svn-src-all@freebsd.org Mon Oct 10 11:36:45 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 2DDF5C0B86F; Mon, 10 Oct 2016 11:36:45 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id D97F4D43; Mon, 10 Oct 2016 11:36:44 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9ABaiJY044581; Mon, 10 Oct 2016 11:36:44 GMT (envelope-from hselasky@FreeBSD.org) Received: (from hselasky@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9ABaieE044580; Mon, 10 Oct 2016 11:36:44 GMT (envelope-from hselasky@FreeBSD.org) Message-Id: <201610101136.u9ABaieE044580@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hselasky set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky Date: Mon, 10 Oct 2016 11:36:44 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r306951 - stable/9/sys/ofed/include/linux X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 Oct 2016 11:36:45 -0000 Author: hselasky Date: Mon Oct 10 11:36:43 2016 New Revision: 306951 URL: https://svnweb.freebsd.org/changeset/base/306951 Log: MFC r306451: The IORESOURCE_XXX defines should resemble a bitmask while SYS_RES_XXX are not bitmasks. Fix return value of pci_resource_flags() to reflect this change. Sponsored by: Mellanox Technologies Modified: stable/9/sys/ofed/include/linux/pci.h Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/ofed/include/linux/pci.h ============================================================================== --- stable/9/sys/ofed/include/linux/pci.h Mon Oct 10 11:34:51 2016 (r306950) +++ stable/9/sys/ofed/include/linux/pci.h Mon Oct 10 11:36:43 2016 (r306951) @@ -2,7 +2,7 @@ * Copyright (c) 2010 Isilon Systems, Inc. * Copyright (c) 2010 iX Systems, Inc. * Copyright (c) 2010 Panasas, Inc. - * Copyright (c) 2013, 2014 Mellanox Technologies, Ltd. + * Copyright (c) 2013-2016 Mellanox Technologies, Ltd. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -115,9 +115,9 @@ struct pci_device_id { #define PCI_EXP_TYPE_RC_EC PCIEM_TYPE_ROOT_EC /* Root Complex Event Collector */ -#define IORESOURCE_MEM SYS_RES_MEMORY -#define IORESOURCE_IO SYS_RES_IOPORT -#define IORESOURCE_IRQ SYS_RES_IRQ +#define IORESOURCE_MEM (1 << SYS_RES_MEMORY) +#define IORESOURCE_IO (1 << SYS_RES_IOPORT) +#define IORESOURCE_IRQ (1 << SYS_RES_IRQ) struct pci_dev; @@ -213,17 +213,28 @@ pci_resource_len(struct pci_dev *pdev, i return rle->count; } +static inline int +pci_resource_type(struct pci_dev *pdev, int bar) +{ + struct resource_list_entry *rle; + + if ((rle = _pci_get_bar(pdev, bar)) == NULL) + return (-1); + return (rle->type); +} + /* * All drivers just seem to want to inspect the type not flags. */ static inline int pci_resource_flags(struct pci_dev *pdev, int bar) { - struct resource_list_entry *rle; + int type; - if ((rle = _pci_get_bar(pdev, bar)) == NULL) + type = pci_resource_type(pdev, bar); + if (type < 0) return (0); - return rle->type; + return (1 << type); } static inline const char * @@ -283,8 +294,8 @@ pci_request_region(struct pci_dev *pdev, int rid; int type; - type = pci_resource_flags(pdev, bar); - if (type == 0) + type = pci_resource_type(pdev, bar); + if (type < 0) return (-ENODEV); rid = PCIR_BAR(bar); if (bus_alloc_resource_any(pdev->dev.bsddev, type, &rid, From owner-svn-src-all@freebsd.org Mon Oct 10 11:38:56 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B0F2EC0BAE3; Mon, 10 Oct 2016 11:38:56 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 7E999FE6; Mon, 10 Oct 2016 11:38:56 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9ABctNj044709; Mon, 10 Oct 2016 11:38:55 GMT (envelope-from hselasky@FreeBSD.org) Received: (from hselasky@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9ABctto044708; Mon, 10 Oct 2016 11:38:55 GMT (envelope-from hselasky@FreeBSD.org) Message-Id: <201610101138.u9ABctto044708@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hselasky set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky Date: Mon, 10 Oct 2016 11:38:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r306952 - stable/11/sys/dev/mlx5/mlx5_en X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 Oct 2016 11:38:56 -0000 Author: hselasky Date: Mon Oct 10 11:38:55 2016 New Revision: 306952 URL: https://svnweb.freebsd.org/changeset/base/306952 Log: MFC r306453: Set hardware stats flag to avoid double counting the number of incoming bytes. Found by: Ben RUBSON Modified: stable/11/sys/dev/mlx5/mlx5_en/mlx5_en_main.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/mlx5/mlx5_en/mlx5_en_main.c ============================================================================== --- stable/11/sys/dev/mlx5/mlx5_en/mlx5_en_main.c Mon Oct 10 11:36:43 2016 (r306951) +++ stable/11/sys/dev/mlx5/mlx5_en/mlx5_en_main.c Mon Oct 10 11:38:55 2016 (r306952) @@ -2903,6 +2903,7 @@ mlx5e_create_ifp(struct mlx5_core_dev *m ifp->if_capabilities |= IFCAP_LINKSTATE | IFCAP_JUMBO_MTU; ifp->if_capabilities |= IFCAP_LRO; ifp->if_capabilities |= IFCAP_TSO | IFCAP_VLAN_HWTSO; + ifp->if_capabilities |= IFCAP_HWSTATS; /* set TSO limits so that we don't have to drop TX packets */ ifp->if_hw_tsomax = MLX5E_MAX_TX_PAYLOAD_SIZE - (ETHER_HDR_LEN + ETHER_VLAN_ENCAP_LEN); From owner-svn-src-all@freebsd.org Mon Oct 10 11:40:53 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B708DC0BB7A; Mon, 10 Oct 2016 11:40:53 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 881C4207; Mon, 10 Oct 2016 11:40:53 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9ABeqx1044860; Mon, 10 Oct 2016 11:40:52 GMT (envelope-from hselasky@FreeBSD.org) Received: (from hselasky@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9ABeqIU044859; Mon, 10 Oct 2016 11:40:52 GMT (envelope-from hselasky@FreeBSD.org) Message-Id: <201610101140.u9ABeqIU044859@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hselasky set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky Date: Mon, 10 Oct 2016 11:40:52 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r306953 - stable/10/sys/dev/mlx5/mlx5_en X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 Oct 2016 11:40:53 -0000 Author: hselasky Date: Mon Oct 10 11:40:52 2016 New Revision: 306953 URL: https://svnweb.freebsd.org/changeset/base/306953 Log: MFC r306453: Set hardware stats flag to avoid double counting the number of incoming bytes. Found by: Ben RUBSON Sponsored by: Mellanox Technologies Modified: stable/10/sys/dev/mlx5/mlx5_en/mlx5_en_main.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/mlx5/mlx5_en/mlx5_en_main.c ============================================================================== --- stable/10/sys/dev/mlx5/mlx5_en/mlx5_en_main.c Mon Oct 10 11:38:55 2016 (r306952) +++ stable/10/sys/dev/mlx5/mlx5_en/mlx5_en_main.c Mon Oct 10 11:40:52 2016 (r306953) @@ -2909,6 +2909,7 @@ mlx5e_create_ifp(struct mlx5_core_dev *m ifp->if_capabilities |= IFCAP_LINKSTATE | IFCAP_JUMBO_MTU; ifp->if_capabilities |= IFCAP_LRO; ifp->if_capabilities |= IFCAP_TSO | IFCAP_VLAN_HWTSO; + ifp->if_capabilities |= IFCAP_HWSTATS; /* set TSO limits so that we don't have to drop TX packets */ ifp->if_hw_tsomax = MLX5E_MAX_TX_PAYLOAD_SIZE - (ETHER_HDR_LEN + ETHER_VLAN_ENCAP_LEN); From owner-svn-src-all@freebsd.org Mon Oct 10 11:42:27 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 39952C0BD0E; Mon, 10 Oct 2016 11:42:27 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 0930E9BD; Mon, 10 Oct 2016 11:42:26 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9ABgQ0J048747; Mon, 10 Oct 2016 11:42:26 GMT (envelope-from hselasky@FreeBSD.org) Received: (from hselasky@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9ABgQrQ048746; Mon, 10 Oct 2016 11:42:26 GMT (envelope-from hselasky@FreeBSD.org) Message-Id: <201610101142.u9ABgQrQ048746@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hselasky set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky Date: Mon, 10 Oct 2016 11:42:26 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r306954 - stable/11/sys/ofed/drivers/net/mlx4 X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 Oct 2016 11:42:27 -0000 Author: hselasky Date: Mon Oct 10 11:42:25 2016 New Revision: 306954 URL: https://svnweb.freebsd.org/changeset/base/306954 Log: MFC r306454: Set hardware stats flag to avoid double counting the number of incoming bytes. Found by: Ben RUBSON Sponsored by: Mellanox Technologies Modified: stable/11/sys/ofed/drivers/net/mlx4/en_netdev.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/ofed/drivers/net/mlx4/en_netdev.c ============================================================================== --- stable/11/sys/ofed/drivers/net/mlx4/en_netdev.c Mon Oct 10 11:40:52 2016 (r306953) +++ stable/11/sys/ofed/drivers/net/mlx4/en_netdev.c Mon Oct 10 11:42:25 2016 (r306954) @@ -2165,6 +2165,7 @@ int mlx4_en_init_netdev(struct mlx4_en_d dev->if_capabilities |= IFCAP_VLAN_HWCSUM | IFCAP_VLAN_HWFILTER; dev->if_capabilities |= IFCAP_LINKSTATE | IFCAP_JUMBO_MTU; dev->if_capabilities |= IFCAP_LRO; + dev->if_capabilities |= IFCAP_HWSTATS; if (mdev->LSO_support) dev->if_capabilities |= IFCAP_TSO4 | IFCAP_TSO6 | IFCAP_VLAN_HWTSO; From owner-svn-src-all@freebsd.org Mon Oct 10 11:43:56 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B268AC0BD7A; Mon, 10 Oct 2016 11:43:56 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 83A75B71; Mon, 10 Oct 2016 11:43:56 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9ABhtuW048853; Mon, 10 Oct 2016 11:43:55 GMT (envelope-from hselasky@FreeBSD.org) Received: (from hselasky@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9ABhtFj048852; Mon, 10 Oct 2016 11:43:55 GMT (envelope-from hselasky@FreeBSD.org) Message-Id: <201610101143.u9ABhtFj048852@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hselasky set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky Date: Mon, 10 Oct 2016 11:43:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r306955 - stable/10/sys/ofed/drivers/net/mlx4 X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 Oct 2016 11:43:56 -0000 Author: hselasky Date: Mon Oct 10 11:43:55 2016 New Revision: 306955 URL: https://svnweb.freebsd.org/changeset/base/306955 Log: MFC r306454: Set hardware stats flag to avoid double counting the number of incoming bytes. Found by: Ben RUBSON Sponsored by: Mellanox Technologies Modified: stable/10/sys/ofed/drivers/net/mlx4/en_netdev.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/ofed/drivers/net/mlx4/en_netdev.c ============================================================================== --- stable/10/sys/ofed/drivers/net/mlx4/en_netdev.c Mon Oct 10 11:42:25 2016 (r306954) +++ stable/10/sys/ofed/drivers/net/mlx4/en_netdev.c Mon Oct 10 11:43:55 2016 (r306955) @@ -2166,6 +2166,7 @@ int mlx4_en_init_netdev(struct mlx4_en_d dev->if_capabilities |= IFCAP_VLAN_HWCSUM | IFCAP_VLAN_HWFILTER; dev->if_capabilities |= IFCAP_LINKSTATE | IFCAP_JUMBO_MTU; dev->if_capabilities |= IFCAP_LRO; + dev->if_capabilities |= IFCAP_HWSTATS; if (mdev->LSO_support) dev->if_capabilities |= IFCAP_TSO4 | IFCAP_TSO6 | IFCAP_VLAN_HWTSO; From owner-svn-src-all@freebsd.org Mon Oct 10 11:46:09 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 57EBEC0BDF1; Mon, 10 Oct 2016 11:46:09 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 33FD0D02; Mon, 10 Oct 2016 11:46:09 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9ABk8Fc049022; Mon, 10 Oct 2016 11:46:08 GMT (envelope-from hselasky@FreeBSD.org) Received: (from hselasky@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9ABk8mw049020; Mon, 10 Oct 2016 11:46:08 GMT (envelope-from hselasky@FreeBSD.org) Message-Id: <201610101146.u9ABk8mw049020@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hselasky set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky Date: Mon, 10 Oct 2016 11:46:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r306956 - in stable/11/sys/dev/usb: . serial X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 Oct 2016 11:46:09 -0000 Author: hselasky Date: Mon Oct 10 11:46:08 2016 New Revision: 306956 URL: https://svnweb.freebsd.org/changeset/base/306956 Log: MFC r306478: Add new USB ID. While at it remove some whitespaces. Submitted by: Jose Luis Duran PR: 213110 Modified: stable/11/sys/dev/usb/serial/u3g.c stable/11/sys/dev/usb/usbdevs Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/usb/serial/u3g.c ============================================================================== --- stable/11/sys/dev/usb/serial/u3g.c Mon Oct 10 11:43:55 2016 (r306955) +++ stable/11/sys/dev/usb/serial/u3g.c Mon Oct 10 11:46:08 2016 (r306956) @@ -522,6 +522,7 @@ static const STRUCT_USB_HOST_ID u3g_devs U3G_DEV(SIERRA, MC5728, 0), U3G_DEV(SIERRA, MC7354, 0), U3G_DEV(SIERRA, MC7355, 0), + U3G_DEV(SIERRA, MC7430, 0), U3G_DEV(SIERRA, MC8700, 0), U3G_DEV(SIERRA, MC8755, 0), U3G_DEV(SIERRA, MC8755_2, 0), @@ -631,7 +632,7 @@ u3g_sael_m460_init(struct usb_device *ud static const uint8_t setup[][24] = { { 0x41, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, { 0x41, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00 }, - { 0x41, 0x13, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, + { 0x41, 0x13, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, { 0xc1, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x40, 0x02 }, @@ -643,7 +644,7 @@ u3g_sael_m460_init(struct usb_device *ud { 0x41, 0x03, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00 }, { 0x41, 0x19, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x13 }, - { 0x41, 0x13, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, + { 0x41, 0x13, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00 }, { 0x41, 0x12, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00 }, @@ -653,7 +654,7 @@ u3g_sael_m460_init(struct usb_device *ud { 0x41, 0x19, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x13 }, { 0x41, 0x13, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, - 0x09, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, + 0x09, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00 }, { 0x41, 0x07, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00 }, }; @@ -687,7 +688,7 @@ u3g_sael_m460_init(struct usb_device *ud DPRINTFN(0, "too small buffer\n"); continue; } - err = usbd_do_request(udev, NULL, &req, + err = usbd_do_request(udev, NULL, &req, __DECONST(uint8_t *, &setup[n][8])); } if (err) { @@ -863,7 +864,7 @@ u3g_attach(device_t dev) } /* copy in USB config */ - for (n = 0; n != U3G_N_TRANSFER; n++) + for (n = 0; n != U3G_N_TRANSFER; n++) u3g_config_tmp[n] = u3g_config[n]; device_set_usb_desc(dev); Modified: stable/11/sys/dev/usb/usbdevs ============================================================================== --- stable/11/sys/dev/usb/usbdevs Mon Oct 10 11:43:55 2016 (r306955) +++ stable/11/sys/dev/usb/usbdevs Mon Oct 10 11:46:08 2016 (r306956) @@ -4083,6 +4083,7 @@ product SIERRA E6893 0x6893 E6893 product SIERRA MC8700 0x68A3 MC8700 product SIERRA MC7354 0x68C0 MC7354 product SIERRA MC7355 0x9041 MC7355 +product SIERRA MC7430 0x9071 Sierra Wireless MC7430 Qualcomm Snapdragon X7 LTE-A product SIERRA AC313U 0x68aa Sierra Wireless AirCard 313U product SIERRA TRUINSTALL 0x0fff Aircard Tru Installer From owner-svn-src-all@freebsd.org Mon Oct 10 11:47:30 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B32B7C0BF45; Mon, 10 Oct 2016 11:47:30 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 8AAA3FD3; Mon, 10 Oct 2016 11:47:30 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9ABlTa4049139; Mon, 10 Oct 2016 11:47:29 GMT (envelope-from hselasky@FreeBSD.org) Received: (from hselasky@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9ABlTW1049137; Mon, 10 Oct 2016 11:47:29 GMT (envelope-from hselasky@FreeBSD.org) Message-Id: <201610101147.u9ABlTW1049137@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hselasky set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky Date: Mon, 10 Oct 2016 11:47:29 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r306957 - in stable/10/sys/dev/usb: . serial X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 Oct 2016 11:47:30 -0000 Author: hselasky Date: Mon Oct 10 11:47:29 2016 New Revision: 306957 URL: https://svnweb.freebsd.org/changeset/base/306957 Log: MFC r306478: Add new USB ID. While at it remove some whitespaces. Submitted by: Jose Luis Duran PR: 213110 Modified: stable/10/sys/dev/usb/serial/u3g.c stable/10/sys/dev/usb/usbdevs Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/usb/serial/u3g.c ============================================================================== --- stable/10/sys/dev/usb/serial/u3g.c Mon Oct 10 11:46:08 2016 (r306956) +++ stable/10/sys/dev/usb/serial/u3g.c Mon Oct 10 11:47:29 2016 (r306957) @@ -525,6 +525,7 @@ static const STRUCT_USB_HOST_ID u3g_devs U3G_DEV(SIERRA, MC5728, 0), U3G_DEV(SIERRA, MC7354, 0), U3G_DEV(SIERRA, MC7355, 0), + U3G_DEV(SIERRA, MC7430, 0), U3G_DEV(SIERRA, MC8700, 0), U3G_DEV(SIERRA, MC8755, 0), U3G_DEV(SIERRA, MC8755_2, 0), @@ -628,7 +629,7 @@ u3g_sael_m460_init(struct usb_device *ud static const uint8_t setup[][24] = { { 0x41, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, { 0x41, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00 }, - { 0x41, 0x13, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, + { 0x41, 0x13, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, { 0xc1, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x40, 0x02 }, @@ -640,7 +641,7 @@ u3g_sael_m460_init(struct usb_device *ud { 0x41, 0x03, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00 }, { 0x41, 0x19, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x13 }, - { 0x41, 0x13, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, + { 0x41, 0x13, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00 }, { 0x41, 0x12, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00 }, @@ -650,7 +651,7 @@ u3g_sael_m460_init(struct usb_device *ud { 0x41, 0x19, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x13 }, { 0x41, 0x13, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, - 0x09, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, + 0x09, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00 }, { 0x41, 0x07, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00 }, }; @@ -684,7 +685,7 @@ u3g_sael_m460_init(struct usb_device *ud DPRINTFN(0, "too small buffer\n"); continue; } - err = usbd_do_request(udev, NULL, &req, + err = usbd_do_request(udev, NULL, &req, __DECONST(uint8_t *, &setup[n][8])); } if (err) { @@ -859,7 +860,7 @@ u3g_attach(device_t dev) } /* copy in USB config */ - for (n = 0; n != U3G_N_TRANSFER; n++) + for (n = 0; n != U3G_N_TRANSFER; n++) u3g_config_tmp[n] = u3g_config[n]; device_set_usb_desc(dev); Modified: stable/10/sys/dev/usb/usbdevs ============================================================================== --- stable/10/sys/dev/usb/usbdevs Mon Oct 10 11:46:08 2016 (r306956) +++ stable/10/sys/dev/usb/usbdevs Mon Oct 10 11:47:29 2016 (r306957) @@ -4079,6 +4079,7 @@ product SIERRA E6893 0x6893 E6893 product SIERRA MC8700 0x68A3 MC8700 product SIERRA MC7354 0x68C0 MC7354 product SIERRA MC7355 0x9041 MC7355 +product SIERRA MC7430 0x9071 Sierra Wireless MC7430 Qualcomm Snapdragon X7 LTE-A product SIERRA AC313U 0x68aa Sierra Wireless AirCard 313U product SIERRA TRUINSTALL 0x0fff Aircard Tru Installer From owner-svn-src-all@freebsd.org Mon Oct 10 11:48:25 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 0EBD4C0B015; Mon, 10 Oct 2016 11:48:25 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id D98951CC; Mon, 10 Oct 2016 11:48:24 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9ABmNSJ049236; Mon, 10 Oct 2016 11:48:23 GMT (envelope-from hselasky@FreeBSD.org) Received: (from hselasky@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9ABmN1q049234; Mon, 10 Oct 2016 11:48:23 GMT (envelope-from hselasky@FreeBSD.org) Message-Id: <201610101148.u9ABmN1q049234@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hselasky set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky Date: Mon, 10 Oct 2016 11:48:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r306958 - in stable/9/sys/dev/usb: . serial X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 Oct 2016 11:48:25 -0000 Author: hselasky Date: Mon Oct 10 11:48:23 2016 New Revision: 306958 URL: https://svnweb.freebsd.org/changeset/base/306958 Log: MFC r306478: Add new USB ID. While at it remove some whitespaces. Submitted by: Jose Luis Duran PR: 213110 Modified: stable/9/sys/dev/usb/serial/u3g.c stable/9/sys/dev/usb/usbdevs Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/dev/usb/serial/u3g.c ============================================================================== --- stable/9/sys/dev/usb/serial/u3g.c Mon Oct 10 11:47:29 2016 (r306957) +++ stable/9/sys/dev/usb/serial/u3g.c Mon Oct 10 11:48:23 2016 (r306958) @@ -523,6 +523,7 @@ static const STRUCT_USB_HOST_ID u3g_devs U3G_DEV(SIERRA, MC5727, 0), U3G_DEV(SIERRA, MC5727_2, 0), U3G_DEV(SIERRA, MC5728, 0), + U3G_DEV(SIERRA, MC7430, 0), U3G_DEV(SIERRA, MC8700, 0), U3G_DEV(SIERRA, MC8755, 0), U3G_DEV(SIERRA, MC8755_2, 0), @@ -626,7 +627,7 @@ u3g_sael_m460_init(struct usb_device *ud static const uint8_t setup[][24] = { { 0x41, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, { 0x41, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00 }, - { 0x41, 0x13, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, + { 0x41, 0x13, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, { 0xc1, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x40, 0x02 }, @@ -638,7 +639,7 @@ u3g_sael_m460_init(struct usb_device *ud { 0x41, 0x03, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00 }, { 0x41, 0x19, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x13 }, - { 0x41, 0x13, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, + { 0x41, 0x13, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00 }, { 0x41, 0x12, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00 }, @@ -648,7 +649,7 @@ u3g_sael_m460_init(struct usb_device *ud { 0x41, 0x19, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x13 }, { 0x41, 0x13, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, - 0x09, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, + 0x09, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00 }, { 0x41, 0x07, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00 }, }; @@ -682,7 +683,7 @@ u3g_sael_m460_init(struct usb_device *ud DPRINTFN(0, "too small buffer\n"); continue; } - err = usbd_do_request(udev, NULL, &req, + err = usbd_do_request(udev, NULL, &req, __DECONST(uint8_t *, &setup[n][8])); } if (err) { @@ -857,7 +858,7 @@ u3g_attach(device_t dev) } /* copy in USB config */ - for (n = 0; n != U3G_N_TRANSFER; n++) + for (n = 0; n != U3G_N_TRANSFER; n++) u3g_config_tmp[n] = u3g_config[n]; device_set_usb_desc(dev); Modified: stable/9/sys/dev/usb/usbdevs ============================================================================== --- stable/9/sys/dev/usb/usbdevs Mon Oct 10 11:47:29 2016 (r306957) +++ stable/9/sys/dev/usb/usbdevs Mon Oct 10 11:48:23 2016 (r306958) @@ -4078,6 +4078,7 @@ product SIERRA E6893 0x6893 E6893 product SIERRA MC8700 0x68A3 MC8700 product SIERRA MC7354 0x68C0 MC7354 product SIERRA MC7355 0x9041 MC7355 +product SIERRA MC7430 0x9071 Sierra Wireless MC7430 Qualcomm Snapdragon X7 LTE-A product SIERRA AC313U 0x68aa Sierra Wireless AirCard 313U product SIERRA TRUINSTALL 0x0fff Aircard Tru Installer From owner-svn-src-all@freebsd.org Mon Oct 10 11:49:45 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 2F5D8C0B0CE; Mon, 10 Oct 2016 11:49:45 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 0AAC23B9; Mon, 10 Oct 2016 11:49:44 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9ABniga049350; Mon, 10 Oct 2016 11:49:44 GMT (envelope-from hselasky@FreeBSD.org) Received: (from hselasky@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9ABniXP049348; Mon, 10 Oct 2016 11:49:44 GMT (envelope-from hselasky@FreeBSD.org) Message-Id: <201610101149.u9ABniXP049348@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hselasky set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky Date: Mon, 10 Oct 2016 11:49:44 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org Subject: svn commit: r306959 - in stable/8/sys/dev/usb: . serial X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 Oct 2016 11:49:45 -0000 Author: hselasky Date: Mon Oct 10 11:49:43 2016 New Revision: 306959 URL: https://svnweb.freebsd.org/changeset/base/306959 Log: MFC r306478: Add new USB ID. While at it remove some whitespaces. Submitted by: Jose Luis Duran PR: 213110 Modified: stable/8/sys/dev/usb/serial/u3g.c stable/8/sys/dev/usb/usbdevs Directory Properties: stable/8/sys/ (props changed) stable/8/sys/dev/ (props changed) stable/8/sys/dev/usb/ (props changed) Modified: stable/8/sys/dev/usb/serial/u3g.c ============================================================================== --- stable/8/sys/dev/usb/serial/u3g.c Mon Oct 10 11:48:23 2016 (r306958) +++ stable/8/sys/dev/usb/serial/u3g.c Mon Oct 10 11:49:43 2016 (r306959) @@ -509,6 +509,7 @@ static const STRUCT_USB_HOST_ID u3g_devs U3G_DEV(SIERRA, MC5727, 0), U3G_DEV(SIERRA, MC5727_2, 0), U3G_DEV(SIERRA, MC5728, 0), + U3G_DEV(SIERRA, MC7430, 0), U3G_DEV(SIERRA, MC8700, 0), U3G_DEV(SIERRA, MC8755, 0), U3G_DEV(SIERRA, MC8755_2, 0), @@ -612,7 +613,7 @@ u3g_sael_m460_init(struct usb_device *ud static const uint8_t setup[][24] = { { 0x41, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, { 0x41, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00 }, - { 0x41, 0x13, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, + { 0x41, 0x13, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, { 0xc1, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x40, 0x02 }, @@ -624,7 +625,7 @@ u3g_sael_m460_init(struct usb_device *ud { 0x41, 0x03, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00 }, { 0x41, 0x19, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x13 }, - { 0x41, 0x13, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, + { 0x41, 0x13, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00 }, { 0x41, 0x12, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00 }, @@ -634,7 +635,7 @@ u3g_sael_m460_init(struct usb_device *ud { 0x41, 0x19, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x13 }, { 0x41, 0x13, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, - 0x09, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, + 0x09, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00 }, { 0x41, 0x07, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00 }, }; @@ -668,7 +669,7 @@ u3g_sael_m460_init(struct usb_device *ud DPRINTFN(0, "too small buffer\n"); continue; } - err = usbd_do_request(udev, NULL, &req, + err = usbd_do_request(udev, NULL, &req, __DECONST(uint8_t *, &setup[n][8])); } if (err) { @@ -838,7 +839,7 @@ u3g_attach(device_t dev) } /* copy in USB config */ - for (n = 0; n != U3G_N_TRANSFER; n++) + for (n = 0; n != U3G_N_TRANSFER; n++) u3g_config_tmp[n] = u3g_config[n]; device_set_usb_desc(dev); Modified: stable/8/sys/dev/usb/usbdevs ============================================================================== --- stable/8/sys/dev/usb/usbdevs Mon Oct 10 11:48:23 2016 (r306958) +++ stable/8/sys/dev/usb/usbdevs Mon Oct 10 11:49:43 2016 (r306959) @@ -3968,6 +3968,7 @@ product SIERRA E6892 0x6892 E6892 product SIERRA E6893 0x6893 E6893 product SIERRA MC8700 0x68A3 MC8700 product SIERRA AIRCARD875 0x6820 Aircard 875 HSDPA +product SIERRA MC7430 0x9071 Sierra Wireless MC7430 Qualcomm Snapdragon X7 LTE-A product SIERRA AC313U 0x68aa Sierra Wireless AirCard 313U product SIERRA TRUINSTALL 0x0fff Aircard Tru Installer From owner-svn-src-all@freebsd.org Mon Oct 10 11:51:48 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B54D5C0B2AB; Mon, 10 Oct 2016 11:51:48 +0000 (UTC) (envelope-from tijl@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 8361E986; Mon, 10 Oct 2016 11:51:48 +0000 (UTC) (envelope-from tijl@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9ABplmb052789; Mon, 10 Oct 2016 11:51:47 GMT (envelope-from tijl@FreeBSD.org) Received: (from tijl@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9ABplsw052788; Mon, 10 Oct 2016 11:51:47 GMT (envelope-from tijl@FreeBSD.org) Message-Id: <201610101151.u9ABplsw052788@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: tijl set sender to tijl@FreeBSD.org using -f From: Tijl Coosemans Date: Mon, 10 Oct 2016 11:51:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r306960 - stable/11/sys/i386/i386 X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 Oct 2016 11:51:48 -0000 Author: tijl Date: Mon Oct 10 11:51:47 2016 New Revision: 306960 URL: https://svnweb.freebsd.org/changeset/base/306960 Log: MFC: r306318 Allocate a zeroed LDT. Failing to do this might result in the LDT appearing to run out of free descriptors because of random junk in the descriptor's 'sd_type' field. http://lists.freebsd.org/pipermail/freebsd-amd64/2014-May/016088.html PR: 212639 Submitted by: wheelcomplex@gmail.com Modified: stable/11/sys/i386/i386/sys_machdep.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/i386/i386/sys_machdep.c ============================================================================== --- stable/11/sys/i386/i386/sys_machdep.c Mon Oct 10 11:49:43 2016 (r306959) +++ stable/11/sys/i386/i386/sys_machdep.c Mon Oct 10 11:51:47 2016 (r306960) @@ -438,7 +438,7 @@ user_ldt_alloc(struct mdproc *mdp, int l new_ldt->ldt_len = len = NEW_MAX_LD(len); new_ldt->ldt_base = (caddr_t)kmem_malloc(kernel_arena, - len * sizeof(union descriptor), M_WAITOK); + len * sizeof(union descriptor), M_WAITOK | M_ZERO); new_ldt->ldt_refcnt = 1; new_ldt->ldt_active = 0; From owner-svn-src-all@freebsd.org Mon Oct 10 11:53:55 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 469EDC0B3CB; Mon, 10 Oct 2016 11:53:55 +0000 (UTC) (envelope-from tijl@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 182A4BBF; Mon, 10 Oct 2016 11:53:55 +0000 (UTC) (envelope-from tijl@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9ABrsMD052917; Mon, 10 Oct 2016 11:53:54 GMT (envelope-from tijl@FreeBSD.org) Received: (from tijl@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9ABrsb0052916; Mon, 10 Oct 2016 11:53:54 GMT (envelope-from tijl@FreeBSD.org) Message-Id: <201610101153.u9ABrsb0052916@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: tijl set sender to tijl@FreeBSD.org using -f From: Tijl Coosemans Date: Mon, 10 Oct 2016 11:53:54 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r306961 - stable/10/sys/i386/i386 X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 Oct 2016 11:53:55 -0000 Author: tijl Date: Mon Oct 10 11:53:54 2016 New Revision: 306961 URL: https://svnweb.freebsd.org/changeset/base/306961 Log: MFC: r306318 Allocate a zeroed LDT. Failing to do this might result in the LDT appearing to run out of free descriptors because of random junk in the descriptor's 'sd_type' field. http://lists.freebsd.org/pipermail/freebsd-amd64/2014-May/016088.html PR: 212639 Submitted by: wheelcomplex@gmail.com Modified: stable/10/sys/i386/i386/sys_machdep.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/i386/i386/sys_machdep.c ============================================================================== --- stable/10/sys/i386/i386/sys_machdep.c Mon Oct 10 11:51:47 2016 (r306960) +++ stable/10/sys/i386/i386/sys_machdep.c Mon Oct 10 11:53:54 2016 (r306961) @@ -509,7 +509,7 @@ user_ldt_alloc(struct mdproc *mdp, int l new_ldt->ldt_len = len = NEW_MAX_LD(len); new_ldt->ldt_base = (caddr_t)kmem_malloc(kernel_arena, - len * sizeof(union descriptor), M_WAITOK); + len * sizeof(union descriptor), M_WAITOK | M_ZERO); new_ldt->ldt_refcnt = 1; new_ldt->ldt_active = 0; From owner-svn-src-all@freebsd.org Mon Oct 10 13:40:06 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id AC752C072F2; Mon, 10 Oct 2016 13:40:06 +0000 (UTC) (envelope-from br@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 7BF027A; Mon, 10 Oct 2016 13:40:06 +0000 (UTC) (envelope-from br@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9ADe5Qu093069; Mon, 10 Oct 2016 13:40:05 GMT (envelope-from br@FreeBSD.org) Received: (from br@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9ADe5XW093068; Mon, 10 Oct 2016 13:40:05 GMT (envelope-from br@FreeBSD.org) Message-Id: <201610101340.u9ADe5XW093068@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: br set sender to br@FreeBSD.org using -f From: Ruslan Bukin Date: Mon, 10 Oct 2016 13:40:05 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r306962 - head/tests/sys/kern/pipe X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 Oct 2016 13:40:06 -0000 Author: br Date: Mon Oct 10 13:40:05 2016 New Revision: 306962 URL: https://svnweb.freebsd.org/changeset/base/306962 Log: Ensure data in pipe is available to read. Useful for latest (5th, direct mode) test only. Sponsored by: DARPA, AFRL Sponsored by: HEIF5 Modified: head/tests/sys/kern/pipe/pipe_fstat_bug_test.c Modified: head/tests/sys/kern/pipe/pipe_fstat_bug_test.c ============================================================================== --- head/tests/sys/kern/pipe/pipe_fstat_bug_test.c Mon Oct 10 11:53:54 2016 (r306961) +++ head/tests/sys/kern/pipe/pipe_fstat_bug_test.c Mon Oct 10 13:40:05 2016 (r306962) @@ -26,6 +26,7 @@ SUCH DAMAGE. #include #include #include +#include #include #include #include @@ -49,10 +50,12 @@ main(void) { char buffer[32768], buffer2[32768], go[] = "go", go2[] = "go2"; int desc[2], ipc_coord[2]; + struct kevent event, ke; ssize_t error; int successes = 0; struct stat status; pid_t new_pid; + int kq; error = pipe(desc); if (error == -1) @@ -118,9 +121,24 @@ main(void) _exit(0); } + kq = kqueue(); + if (kq == -1) + _exit(1); + + EV_SET(&ke, desc[0], EVFILT_READ, EV_ADD, 0, 0, NULL); + + /* Attach event to the kqueue. */ + if (kevent(kq, &ke, 1, NULL, 0, NULL) != 0) + _exit(2); + while (successes < 5) { SYNC_W(1, go); SYNC_R(1, go2); + + /* Ensure data is available to read */ + if (kevent(kq, NULL, 0, &event, 1, NULL) != 1) + _exit(3); + fstat(desc[0], &status); error = read(desc[0], &buffer2, sizeof(buffer2)); From owner-svn-src-all@freebsd.org Mon Oct 10 14:21:22 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 87377C07F33; Mon, 10 Oct 2016 14:21:22 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 539DDABD; Mon, 10 Oct 2016 14:21:22 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9AELLEv010800; Mon, 10 Oct 2016 14:21:21 GMT (envelope-from emaste@FreeBSD.org) Received: (from emaste@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9AELLim010799; Mon, 10 Oct 2016 14:21:21 GMT (envelope-from emaste@FreeBSD.org) Message-Id: <201610101421.u9AELLim010799@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: emaste set sender to emaste@FreeBSD.org using -f From: Ed Maste Date: Mon, 10 Oct 2016 14:21:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r306963 - head/usr.sbin/chown X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 Oct 2016 14:21:22 -0000 Author: emaste Date: Mon Oct 10 14:21:21 2016 New Revision: 306963 URL: https://svnweb.freebsd.org/changeset/base/306963 Log: chown: use NULL instead of 0 for null pointer Modified: head/usr.sbin/chown/chown.c Modified: head/usr.sbin/chown/chown.c ============================================================================== --- head/usr.sbin/chown/chown.c Mon Oct 10 13:40:05 2016 (r306962) +++ head/usr.sbin/chown/chown.c Mon Oct 10 14:21:21 2016 (r306963) @@ -159,7 +159,7 @@ main(int argc, char **argv) } else a_gid(*argv); - if ((ftsp = fts_open(++argv, fts_options, 0)) == NULL) + if ((ftsp = fts_open(++argv, fts_options, NULL)) == NULL) err(1, NULL); for (rval = 0; (p = fts_read(ftsp)) != NULL;) { From owner-svn-src-all@freebsd.org Mon Oct 10 14:21:42 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 2F1B7C07FAA; Mon, 10 Oct 2016 14:21:42 +0000 (UTC) (envelope-from br@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 0128CC72; Mon, 10 Oct 2016 14:21:41 +0000 (UTC) (envelope-from br@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9AELfmQ012118; Mon, 10 Oct 2016 14:21:41 GMT (envelope-from br@FreeBSD.org) Received: (from br@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9AELfwG012117; Mon, 10 Oct 2016 14:21:41 GMT (envelope-from br@FreeBSD.org) Message-Id: <201610101421.u9AELfwG012117@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: br set sender to br@FreeBSD.org using -f From: Ruslan Bukin Date: Mon, 10 Oct 2016 14:21:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r306964 - head/tests/sys/kern X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 Oct 2016 14:21:42 -0000 Author: br Date: Mon Oct 10 14:21:40 2016 New Revision: 306964 URL: https://svnweb.freebsd.org/changeset/base/306964 Log: Skip test on MIPS as we don't have shared page implemented yet. Sponsored by: DARPA, AFRL Sponsored by: HEIF5 Modified: head/tests/sys/kern/kern_copyin.c Modified: head/tests/sys/kern/kern_copyin.c ============================================================================== --- head/tests/sys/kern/kern_copyin.c Mon Oct 10 14:21:21 2016 (r306963) +++ head/tests/sys/kern/kern_copyin.c Mon Oct 10 14:21:40 2016 (r306964) @@ -59,6 +59,11 @@ ATF_TC_BODY(kern_copyin, tc) { char template[] = "copyin.XXXXXX"; +#ifdef __mips__ + /* MIPS has no shared page implemented yet. */ + atf_tc_skip("Platform is not supported."); +#endif + scratch_file = mkstemp(template); ATF_REQUIRE(scratch_file != -1); unlink(template); From owner-svn-src-all@freebsd.org Mon Oct 10 15:30:00 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 789E0C07BCC; Mon, 10 Oct 2016 15:30:00 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 453EF385; Mon, 10 Oct 2016 15:30:00 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9AFTxB6034970; Mon, 10 Oct 2016 15:29:59 GMT (envelope-from emaste@FreeBSD.org) Received: (from emaste@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9AFTxvJ034969; Mon, 10 Oct 2016 15:29:59 GMT (envelope-from emaste@FreeBSD.org) Message-Id: <201610101529.u9AFTxvJ034969@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: emaste set sender to emaste@FreeBSD.org using -f From: Ed Maste Date: Mon, 10 Oct 2016 15:29:59 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r306965 - head/tools/build/mk X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 Oct 2016 15:30:00 -0000 Author: emaste Date: Mon Oct 10 15:29:59 2016 New Revision: 306965 URL: https://svnweb.freebsd.org/changeset/base/306965 Log: Remove old makewhatis(1) man page when using mandoc mandoc installs makewhatis(8) Modified: head/tools/build/mk/OptionalObsoleteFiles.inc Modified: head/tools/build/mk/OptionalObsoleteFiles.inc ============================================================================== --- head/tools/build/mk/OptionalObsoleteFiles.inc Mon Oct 10 14:21:40 2016 (r306964) +++ head/tools/build/mk/OptionalObsoleteFiles.inc Mon Oct 10 15:29:59 2016 (r306965) @@ -6014,6 +6014,10 @@ OLD_FILES+=usr/share/man/whatis OLD_FILES+=usr/share/openssl/man/whatis .endif +.if ${MK_MANDOCDB} != no +OLD_FILES+=usr/share/man/man1/makewhatis.1.gz +.endif + .if ${MK_NDIS} == no OLD_FILES+=usr/sbin/ndiscvt OLD_FILES+=usr/sbin/ndisgen From owner-svn-src-all@freebsd.org Mon Oct 10 15:35:00 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id CF021C07E1D; Mon, 10 Oct 2016 15:35:00 +0000 (UTC) (envelope-from cse.cem@gmail.com) Received: from mail-io0-f175.google.com (mail-io0-f175.google.com [209.85.223.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 5CDD4AF1; Mon, 10 Oct 2016 15:35:00 +0000 (UTC) (envelope-from cse.cem@gmail.com) Received: by mail-io0-f175.google.com with SMTP id i202so114290809ioi.2; Mon, 10 Oct 2016 08:35:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:reply-to:in-reply-to:references :from:date:message-id:subject:to:cc; bh=+LDSNEmS0Ut98gJ0QU25qfYN8c4DnbRfO21d5AIXJY4=; b=QGpmVLLf98c+bbnxvyHlKnjS9zkHxAMIzB9+l4HxtbPbawVcw9EajRH4S7YL+nDInU ZNW3JDA6AsfSDGD9V8Oy9onm3KZbF9JdSst2qIQBjZ+dWkfF1ONlIgS+8pIHX9UaF0OG oGHl7e3maNedNZl6csh5Vh4Ia3VnLffeeuB8kJtUero8Z3ad7sFz0vNZQqcYPxxgXUMd 3B/Bd65j/Ty6v5eGNVJ39S0LNsPI+ER8m643qJ5q1X/53RFNurtxrLiAuGZ7W1FIvEOj x+nM1N+3RYEwN/U938jPT1vwP6gKotN37HGN2qRGQsOejuaLpHeN+dGcQCShZMcqkMlw DxIw== X-Gm-Message-State: AA6/9RmkQv6M0fj4OhdMRSjL6P3XOS45Gyg/QvaOw3wlmLBlrtTiNVzUD5iNfIL9u0naVQ== X-Received: by 10.107.29.21 with SMTP id d21mr18784589iod.10.1476111885721; Mon, 10 Oct 2016 08:04:45 -0700 (PDT) Received: from mail-io0-f177.google.com (mail-io0-f177.google.com. [209.85.223.177]) by smtp.gmail.com with ESMTPSA id a192sm6897434itc.8.2016.10.10.08.04.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 10 Oct 2016 08:04:45 -0700 (PDT) Received: by mail-io0-f177.google.com with SMTP id i202so113270486ioi.2; Mon, 10 Oct 2016 08:04:45 -0700 (PDT) X-Received: by 10.107.168.96 with SMTP id r93mr31796675ioe.31.1476111884796; Mon, 10 Oct 2016 08:04:44 -0700 (PDT) MIME-Version: 1.0 Reply-To: cem@freebsd.org Received: by 10.36.220.129 with HTTP; Mon, 10 Oct 2016 08:04:44 -0700 (PDT) In-Reply-To: <201610101340.u9ADe5XW093068@repo.freebsd.org> References: <201610101340.u9ADe5XW093068@repo.freebsd.org> From: Conrad Meyer Date: Mon, 10 Oct 2016 08:04:44 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: svn commit: r306962 - head/tests/sys/kern/pipe To: Ruslan Bukin Cc: src-committers , svn-src-all@freebsd.org, svn-src-head@freebsd.org Content-Type: text/plain; charset=UTF-8 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 Oct 2016 15:35:00 -0000 We also observed this test was broken, but I think the right fix is much smaller: --- a/tests/sys/kern/pipe/pipe_fstat_bug_test.c +++ b/tests/sys/kern/pipe/pipe_fstat_bug_test.c @@ -108,7 +108,6 @@ main(void) SYNC_W(0, go2); SYNC_R(0, go); - SYNC_W(0, go2); /* XXX: why is this required? */ WRITE(8192); SYNC_W(0, go2); (That line breaks the synchronization mechanism that is the only guarantee the test passes.) Best, Conrad On Mon, Oct 10, 2016 at 6:40 AM, Ruslan Bukin wrote: > Author: br > Date: Mon Oct 10 13:40:05 2016 > New Revision: 306962 > URL: https://svnweb.freebsd.org/changeset/base/306962 > > Log: > Ensure data in pipe is available to read. > Useful for latest (5th, direct mode) test only. > > Sponsored by: DARPA, AFRL > Sponsored by: HEIF5 > > Modified: > head/tests/sys/kern/pipe/pipe_fstat_bug_test.c > > Modified: head/tests/sys/kern/pipe/pipe_fstat_bug_test.c > ============================================================================== > --- head/tests/sys/kern/pipe/pipe_fstat_bug_test.c Mon Oct 10 11:53:54 2016 (r306961) > +++ head/tests/sys/kern/pipe/pipe_fstat_bug_test.c Mon Oct 10 13:40:05 2016 (r306962) > @@ -26,6 +26,7 @@ SUCH DAMAGE. > #include > #include > #include > +#include > #include > #include > #include > @@ -49,10 +50,12 @@ main(void) > { > char buffer[32768], buffer2[32768], go[] = "go", go2[] = "go2"; > int desc[2], ipc_coord[2]; > + struct kevent event, ke; > ssize_t error; > int successes = 0; > struct stat status; > pid_t new_pid; > + int kq; > > error = pipe(desc); > if (error == -1) > @@ -118,9 +121,24 @@ main(void) > _exit(0); > } > > + kq = kqueue(); > + if (kq == -1) > + _exit(1); > + > + EV_SET(&ke, desc[0], EVFILT_READ, EV_ADD, 0, 0, NULL); > + > + /* Attach event to the kqueue. */ > + if (kevent(kq, &ke, 1, NULL, 0, NULL) != 0) > + _exit(2); > + > while (successes < 5) { > SYNC_W(1, go); > SYNC_R(1, go2); > + > + /* Ensure data is available to read */ > + if (kevent(kq, NULL, 0, &event, 1, NULL) != 1) > + _exit(3); > + > fstat(desc[0], &status); > error = read(desc[0], &buffer2, sizeof(buffer2)); > > From owner-svn-src-all@freebsd.org Mon Oct 10 15:40:09 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E8799C07EB4; Mon, 10 Oct 2016 15:40:09 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id B4C00CF5; Mon, 10 Oct 2016 15:40:09 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9AFe82l039249; Mon, 10 Oct 2016 15:40:08 GMT (envelope-from emaste@FreeBSD.org) Received: (from emaste@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9AFe8X4039248; Mon, 10 Oct 2016 15:40:08 GMT (envelope-from emaste@FreeBSD.org) Message-Id: <201610101540.u9AFe8X4039248@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: emaste set sender to emaste@FreeBSD.org using -f From: Ed Maste Date: Mon, 10 Oct 2016 15:40:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r306966 - head/tools/build/options X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 Oct 2016 15:40:10 -0000 Author: emaste Date: Mon Oct 10 15:40:08 2016 New Revision: 306966 URL: https://svnweb.freebsd.org/changeset/base/306966 Log: Correct sense of WITHOUT_MANDOCDB knob WITHOUT_MANDOCDB *disables* the use of mandoc's makewhatis. Modified: head/tools/build/options/WITHOUT_MANDOCDB Modified: head/tools/build/options/WITHOUT_MANDOCDB ============================================================================== --- head/tools/build/options/WITHOUT_MANDOCDB Mon Oct 10 15:29:59 2016 (r306965) +++ head/tools/build/options/WITHOUT_MANDOCDB Mon Oct 10 15:40:08 2016 (r306966) @@ -1,6 +1,9 @@ .\" $FreeBSD$ -Use the -.Xr mandoc 1 -version of +Use the version of +.Xr makewhatis 1 +introduced in +.Fx 2.1 , +instead of the .Xr makewhatis 8 -database and utilities. +database and utilities from +.Xr mandoc 1 . From owner-svn-src-all@freebsd.org Mon Oct 10 15:42:52 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 22047C0C01C; Mon, 10 Oct 2016 15:42:52 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id D9EF4F2; Mon, 10 Oct 2016 15:42:51 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9AFgoCF042640; Mon, 10 Oct 2016 15:42:50 GMT (envelope-from sevan@FreeBSD.org) Received: (from sevan@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9AFgoKh042639; Mon, 10 Oct 2016 15:42:50 GMT (envelope-from sevan@FreeBSD.org) Message-Id: <201610101542.u9AFgoKh042639@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sevan set sender to sevan@FreeBSD.org using -f From: Sevan Janiyan Date: Mon, 10 Oct 2016 15:42:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r306967 - stable/11/bin/chio X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 Oct 2016 15:42:52 -0000 Author: sevan (doc committer) Date: Mon Oct 10 15:42:50 2016 New Revision: 306967 URL: https://svnweb.freebsd.org/changeset/base/306967 Log: MFC r306584: Move the description of CHANGER variable to ENVIRONMENT section rather than in the DESCRIPTION section. From OpenBSD src/bin/chio/chio.1 r1.23 PR: 212158 Approved by: bjk Obtained from: OpenBSD Differential Revision: https://reviews.freebsd.org/D8117 Modified: stable/11/bin/chio/chio.1 Directory Properties: stable/11/ (props changed) Modified: stable/11/bin/chio/chio.1 ============================================================================== --- stable/11/bin/chio/chio.1 Mon Oct 10 15:40:08 2016 (r306966) +++ stable/11/bin/chio/chio.1 Mon Oct 10 15:42:50 2016 (r306967) @@ -32,7 +32,7 @@ .\" .\" $FreeBSD$ .\" -.Dd May 14, 1998 +.Dd October 2, 2016 .Dt CHIO 1 .Os .Sh NAME @@ -61,10 +61,6 @@ rather than the default device .Pa /dev/ch0 . .El .Pp -The default changer may be overridden by setting the environment variable -.Ev CHANGER -to the desired changer device. -.Pp A medium changer apparatus is made up of .Em elements . There are five element types: @@ -265,6 +261,12 @@ Element supports passing media (exportin .It INENAB Element supports receiving media (importing) from an outside human operator. .El +.Sh ENVIRONMENT +.Bl -tag -width CHANGER +.It Ev CHANGER +The default changer may be overridden by setting this environmental +variable to the desired changer device. +.El .Sh FILES .Bl -tag -width /dev/ch0 -compact .It Pa /dev/ch0 From owner-svn-src-all@freebsd.org Mon Oct 10 15:44:44 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 2075EC0C07F; Mon, 10 Oct 2016 15:44:44 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id E32F4275; Mon, 10 Oct 2016 15:44:43 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9AFihgX042778; Mon, 10 Oct 2016 15:44:43 GMT (envelope-from sevan@FreeBSD.org) Received: (from sevan@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9AFihDm042777; Mon, 10 Oct 2016 15:44:43 GMT (envelope-from sevan@FreeBSD.org) Message-Id: <201610101544.u9AFihDm042777@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sevan set sender to sevan@FreeBSD.org using -f From: Sevan Janiyan Date: Mon, 10 Oct 2016 15:44:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r306968 - stable/10/bin/chio X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 Oct 2016 15:44:44 -0000 Author: sevan (doc committer) Date: Mon Oct 10 15:44:42 2016 New Revision: 306968 URL: https://svnweb.freebsd.org/changeset/base/306968 Log: MFC r306584: Move the description of CHANGER variable to ENVIRONMENT section rather than in the DESCRIPTION section. From OpenBSD src/bin/chio/chio.1 r1.23 PR: 212158 Approved by: bjk Obtained from: OpenBSD Differential Revision: https://reviews.freebsd.org/D8117 Modified: stable/10/bin/chio/chio.1 Directory Properties: stable/10/ (props changed) Modified: stable/10/bin/chio/chio.1 ============================================================================== --- stable/10/bin/chio/chio.1 Mon Oct 10 15:42:50 2016 (r306967) +++ stable/10/bin/chio/chio.1 Mon Oct 10 15:44:42 2016 (r306968) @@ -32,7 +32,7 @@ .\" .\" $FreeBSD$ .\" -.Dd May 14, 1998 +.Dd October 2, 2016 .Dt CHIO 1 .Os .Sh NAME @@ -61,10 +61,6 @@ rather than the default device .Pa /dev/ch0 . .El .Pp -The default changer may be overridden by setting the environment variable -.Ev CHANGER -to the desired changer device. -.Pp A medium changer apparatus is made up of .Em elements . There are five element types: @@ -267,6 +263,12 @@ Element supports passing media (exportin .It INENAB Element supports receiving media (importing) from an outside human operator. .El +.Sh ENVIRONMENT +.Bl -tag -width CHANGER +.It Ev CHANGER +The default changer may be overridden by setting this environmental +variable to the desired changer device. +.El .Sh FILES .Bl -tag -width /dev/ch0 -compact .It Pa /dev/ch0 From owner-svn-src-all@freebsd.org Mon Oct 10 15:47:31 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 5AB11C0C0EF; Mon, 10 Oct 2016 15:47:31 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 269A867D; Mon, 10 Oct 2016 15:47:31 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9AFlUZ0042952; Mon, 10 Oct 2016 15:47:30 GMT (envelope-from emaste@FreeBSD.org) Received: (from emaste@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9AFlUFv042951; Mon, 10 Oct 2016 15:47:30 GMT (envelope-from emaste@FreeBSD.org) Message-Id: <201610101547.u9AFlUFv042951@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: emaste set sender to emaste@FreeBSD.org using -f From: Ed Maste Date: Mon, 10 Oct 2016 15:47:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r306969 - head/share/man/man5 X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 Oct 2016 15:47:31 -0000 Author: emaste Date: Mon Oct 10 15:47:30 2016 New Revision: 306969 URL: https://svnweb.freebsd.org/changeset/base/306969 Log: src.conf.5: regen after r306965 Modified: head/share/man/man5/src.conf.5 Modified: head/share/man/man5/src.conf.5 ============================================================================== --- head/share/man/man5/src.conf.5 Mon Oct 10 15:44:42 2016 (r306968) +++ head/share/man/man5/src.conf.5 Mon Oct 10 15:47:30 2016 (r306969) @@ -1,7 +1,7 @@ .\" DO NOT EDIT-- this file is automatically generated. .\" from FreeBSD: head/tools/build/options/makeman 306729 2016-10-05 20:12:00Z emaste .\" $FreeBSD$ -.Dd October 5, 2016 +.Dd October 10, 2016 .Dt SRC.CONF 5 .Os .Sh NAME @@ -1075,12 +1075,15 @@ is set explicitly) Set to not to install compressed man pages. Only the uncompressed versions will be installed. .It Va WITHOUT_MANDOCDB -.\" from FreeBSD: head/tools/build/options/WITHOUT_MANDOCDB 283777 2015-05-30 17:41:37Z bapt -Use the -.Xr mandoc 1 -version of +.\" from FreeBSD: head/tools/build/options/WITHOUT_MANDOCDB 306966 2016-10-10 15:40:08Z emaste +Use the version of +.Xr makewhatis 1 +introduced in +.Fx 2.1 , +instead of the .Xr makewhatis 8 -database and utilities. +database and utilities from +.Xr mandoc 1 . .It Va WITHOUT_MAN_UTILS .\" from FreeBSD: head/tools/build/options/WITHOUT_MAN_UTILS 208322 2010-05-20 00:07:21Z jkim Set to not build utilities for manual pages, From owner-svn-src-all@freebsd.org Mon Oct 10 15:47:41 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 4EFB4C0C118; Mon, 10 Oct 2016 15:47:41 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 1B6DA82E; Mon, 10 Oct 2016 15:47:41 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9AFle9T043002; Mon, 10 Oct 2016 15:47:40 GMT (envelope-from sevan@FreeBSD.org) Received: (from sevan@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9AFleMN043001; Mon, 10 Oct 2016 15:47:40 GMT (envelope-from sevan@FreeBSD.org) Message-Id: <201610101547.u9AFleMN043001@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sevan set sender to sevan@FreeBSD.org using -f From: Sevan Janiyan Date: Mon, 10 Oct 2016 15:47:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r306970 - stable/11/bin/chio X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 Oct 2016 15:47:41 -0000 Author: sevan (doc committer) Date: Mon Oct 10 15:47:39 2016 New Revision: 306970 URL: https://svnweb.freebsd.org/changeset/base/306970 Log: MFC r306714: Document where chio(1) originated from & which version of FreeBSD first included it. PR: 211776 Approved by: bcr (mentor) Differential Revision: https://reviews.freebsd.org/D8104 Modified: stable/11/bin/chio/chio.1 Directory Properties: stable/11/ (props changed) Modified: stable/11/bin/chio/chio.1 ============================================================================== --- stable/11/bin/chio/chio.1 Mon Oct 10 15:47:30 2016 (r306969) +++ stable/11/bin/chio/chio.1 Mon Oct 10 15:47:39 2016 (r306970) @@ -32,7 +32,7 @@ .\" .\" $FreeBSD$ .\" -.Dd October 2, 2016 +.Dd October 5, 2016 .Dt CHIO 1 .Os .Sh NAME @@ -287,6 +287,14 @@ Configure the changer to use picker 2 (t .Sh SEE ALSO .Xr mt 1 , .Xr mount 8 +.Sh HISTORY +A +.Nm +utility appeared in +.Nx 1.3 . +.Nm +first appeared in +.Fx 2.2 . .Sh AUTHORS .An -nosplit The From owner-svn-src-all@freebsd.org Mon Oct 10 15:48:41 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 7EE26C0C195; Mon, 10 Oct 2016 15:48:41 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4B04E9B7; Mon, 10 Oct 2016 15:48:41 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9AFmeqe043102; Mon, 10 Oct 2016 15:48:40 GMT (envelope-from sevan@FreeBSD.org) Received: (from sevan@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9AFmeuo043101; Mon, 10 Oct 2016 15:48:40 GMT (envelope-from sevan@FreeBSD.org) Message-Id: <201610101548.u9AFmeuo043101@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sevan set sender to sevan@FreeBSD.org using -f From: Sevan Janiyan Date: Mon, 10 Oct 2016 15:48:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r306971 - stable/10/bin/chio X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 Oct 2016 15:48:41 -0000 Author: sevan (doc committer) Date: Mon Oct 10 15:48:40 2016 New Revision: 306971 URL: https://svnweb.freebsd.org/changeset/base/306971 Log: MFC r306714: Document where chio(1) originated from & which version of FreeBSD first included it. PR: 211776 Approved by: bcr (mentor) Differential Revision: https://reviews.freebsd.org/D8104 Modified: stable/10/bin/chio/chio.1 Directory Properties: stable/10/ (props changed) Modified: stable/10/bin/chio/chio.1 ============================================================================== --- stable/10/bin/chio/chio.1 Mon Oct 10 15:47:39 2016 (r306970) +++ stable/10/bin/chio/chio.1 Mon Oct 10 15:48:40 2016 (r306971) @@ -32,7 +32,7 @@ .\" .\" $FreeBSD$ .\" -.Dd October 2, 2016 +.Dd October 5, 2016 .Dt CHIO 1 .Os .Sh NAME @@ -289,6 +289,14 @@ Configure the changer to use picker 2 (t .Sh SEE ALSO .Xr mt 1 , .Xr mount 8 +.Sh HISTORY +A +.Nm +utility appeared in +.Nx 1.3 . +.Nm +first appeared in +.Fx 2.2 . .Sh AUTHORS .An -nosplit The From owner-svn-src-all@freebsd.org Mon Oct 10 15:49:50 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 971DAC0C299; Mon, 10 Oct 2016 15:49:50 +0000 (UTC) (envelope-from gjb@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 55E5FB9A; Mon, 10 Oct 2016 15:49:50 +0000 (UTC) (envelope-from gjb@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9AFnnAM043198; Mon, 10 Oct 2016 15:49:49 GMT (envelope-from gjb@FreeBSD.org) Received: (from gjb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9AFnndj043196; Mon, 10 Oct 2016 15:49:49 GMT (envelope-from gjb@FreeBSD.org) Message-Id: <201610101549.u9AFnndj043196@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: gjb set sender to gjb@FreeBSD.org using -f From: Glen Barber Date: Mon, 10 Oct 2016 15:49:49 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r306972 - in stable/11/release/doc: en_US.ISO8859-1/errata share/xml X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 Oct 2016 15:49:50 -0000 Author: gjb Date: Mon Oct 10 15:49:49 2016 New Revision: 306972 URL: https://svnweb.freebsd.org/changeset/base/306972 Log: - Add known-issue entries for 11.0-RELEASE errata.html. - Bump version numbers in release.ent. - Bump the copyright year for the errata file. Sponsored by: The FreeBSD Foundation Modified: stable/11/release/doc/en_US.ISO8859-1/errata/article.xml stable/11/release/doc/share/xml/release.ent Modified: stable/11/release/doc/en_US.ISO8859-1/errata/article.xml ============================================================================== --- stable/11/release/doc/en_US.ISO8859-1/errata/article.xml Mon Oct 10 15:48:40 2016 (r306971) +++ stable/11/release/doc/en_US.ISO8859-1/errata/article.xml Mon Oct 10 15:49:49 2016 (r306972) @@ -19,7 +19,7 @@ $FreeBSD$ - 2015 + 2016 The &os; Documentation Project @@ -89,7 +89,79 @@ Open Issues - No open issues. + + + An issue was discovered with Amazon® EC2™ + images which would cause the virtual machine to hang during + boot when upgrading from previous FreeBSD versions. New + EC2™ installations are not affected, but exisiting + installations running earlier releases are advised to wait + until the issue is resolved in an Errata Notice before + upgrading. An Errata Notice to address this is planned + following the release. + + + + &os;/&arch.i386; installed on ZFS may crash during boot + when the ZFS pool mount is attempted while booting an + unmodified GENERIC kernel. + + A system tunable has been added as of revision + r286584 to make the + kern.kstack_pages tunable configurable + without recompiling the kernel. + + To mitigate system crashes with such configurations, + chose Escape to loader prompt in the boot + menu and enter the following lines from &man.loader.8; + prompt, after an OK: + + set kern.kstack_pages=4 +boot + + Add this line to + /boot/loader.conf for the change to + persist across reboots: + + kern.kstack_pages=4 + + + + A bug was diagnosed in interaction of the + pmap_activate() function and + TLB shootdown IPI + handler on amd64 systems which have PCID + features but do not implement the INVPCID + instruction. On such machines, such as SandyBridge™ + and IvyBridge™ microarchitectures, set the loader + tunable vm.pmap.pcid_enabled=0 during + boot: + + set vm.pmap.pcid_enabled=0 +boot + + Add this line to + /boot/loader.conf for the change to + persist across reboots: + + To check if the system is affected, check + &man.dmesg.8; for PCID listed in the + "Features2", and absence of + INVPCID in the "Structured Extended + Features". If the PCID feature is + not present, or INVPCID is present, + system is not affected. + + vm.pmap.pcid_enabled=0 + + + + The Release Notes errorneously states the + WITH_SYSTEM_COMPILER &man.src.conf.5; + option is enabled by default, however this was disabled + prior to the final release build. + + Modified: stable/11/release/doc/share/xml/release.ent ============================================================================== --- stable/11/release/doc/share/xml/release.ent Mon Oct 10 15:48:40 2016 (r306971) +++ stable/11/release/doc/share/xml/release.ent Mon Oct 10 15:49:49 2016 (r306972) @@ -11,15 +11,15 @@ - + - + - + @@ -39,8 +39,8 @@ doc.relnotes.mk when updating this --> - - + + @@ -58,7 +58,7 @@ - + From owner-svn-src-all@freebsd.org Mon Oct 10 15:53:57 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 7EE80C0C44D; Mon, 10 Oct 2016 15:53:57 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4DCAB75; Mon, 10 Oct 2016 15:53:57 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9AFru9I046883; Mon, 10 Oct 2016 15:53:56 GMT (envelope-from sevan@FreeBSD.org) Received: (from sevan@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9AFrumB046882; Mon, 10 Oct 2016 15:53:56 GMT (envelope-from sevan@FreeBSD.org) Message-Id: <201610101553.u9AFrumB046882@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sevan set sender to sevan@FreeBSD.org using -f From: Sevan Janiyan Date: Mon, 10 Oct 2016 15:53:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r306973 - stable/11/bin/ed X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 Oct 2016 15:53:57 -0000 Author: sevan (doc committer) Date: Mon Oct 10 15:53:56 2016 New Revision: 306973 URL: https://svnweb.freebsd.org/changeset/base/306973 Log: MFC r306581: Use .At macro instead of specifying AT&T UNIX literaly. PR: 212034 Approved by: bcr (mentor) Differential Revision: https://reviews.freebsd.org/D8114 Modified: stable/11/bin/ed/ed.1 Directory Properties: stable/11/ (props changed) Modified: stable/11/bin/ed/ed.1 ============================================================================== --- stable/11/bin/ed/ed.1 Mon Oct 10 15:49:49 2016 (r306972) +++ stable/11/bin/ed/ed.1 Mon Oct 10 15:53:56 2016 (r306973) @@ -1,5 +1,5 @@ .\" $FreeBSD$ -.Dd July 3, 2004 +.Dd October 2, 2016 .Dt ED 1 .Os .Sh NAME @@ -998,7 +998,7 @@ per line overhead: 4 ints An .Nm command appeared in -Version 1 AT&T UNIX. +.At v1 . .Sh BUGS The .Nm From owner-svn-src-all@freebsd.org Mon Oct 10 15:54:33 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id CA486C0C49C; Mon, 10 Oct 2016 15:54:33 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 9BAB81F4; Mon, 10 Oct 2016 15:54:33 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9AFsWIY046968; Mon, 10 Oct 2016 15:54:32 GMT (envelope-from sevan@FreeBSD.org) Received: (from sevan@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9AFsWUl046967; Mon, 10 Oct 2016 15:54:32 GMT (envelope-from sevan@FreeBSD.org) Message-Id: <201610101554.u9AFsWUl046967@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sevan set sender to sevan@FreeBSD.org using -f From: Sevan Janiyan Date: Mon, 10 Oct 2016 15:54:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r306974 - stable/10/bin/ed X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 Oct 2016 15:54:33 -0000 Author: sevan (doc committer) Date: Mon Oct 10 15:54:32 2016 New Revision: 306974 URL: https://svnweb.freebsd.org/changeset/base/306974 Log: MFC r306581: Use .At macro instead of specifying AT&T UNIX literaly. PR: 212034 Approved by: bcr (mentor) Differential Revision: https://reviews.freebsd.org/D8114 Modified: stable/10/bin/ed/ed.1 Directory Properties: stable/10/ (props changed) Modified: stable/10/bin/ed/ed.1 ============================================================================== --- stable/10/bin/ed/ed.1 Mon Oct 10 15:53:56 2016 (r306973) +++ stable/10/bin/ed/ed.1 Mon Oct 10 15:54:32 2016 (r306974) @@ -1,5 +1,5 @@ .\" $FreeBSD$ -.Dd July 3, 2004 +.Dd October 2, 2016 .Dt ED 1 .Os .Sh NAME @@ -998,7 +998,7 @@ per line overhead: 4 ints An .Nm command appeared in -Version 1 AT&T UNIX. +.At v1 . .Sh BUGS The .Nm From owner-svn-src-all@freebsd.org Mon Oct 10 16:01:25 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C53EAC0C6F0; Mon, 10 Oct 2016 16:01:25 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 404FEB24; Mon, 10 Oct 2016 16:01:25 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from tom.home (kib@localhost [127.0.0.1]) by kib.kiev.ua (8.15.2/8.15.2) with ESMTPS id u9AG1EB5025167 (version=TLSv1 cipher=DHE-RSA-CAMELLIA256-SHA bits=256 verify=NO); Mon, 10 Oct 2016 19:01:15 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua u9AG1EB5025167 Received: (from kostik@localhost) by tom.home (8.15.2/8.15.2/Submit) id u9AG1Enc025166; Mon, 10 Oct 2016 19:01:14 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Mon, 10 Oct 2016 19:01:14 +0300 From: Konstantin Belousov To: Ruslan Bukin Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r306964 - head/tests/sys/kern Message-ID: <20161010160114.GL68202@kib.kiev.ua> References: <201610101421.u9AELfwG012117@repo.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <201610101421.u9AELfwG012117@repo.freebsd.org> User-Agent: Mutt/1.7.0 (2016-08-17) X-Spam-Status: No, score=-2.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on tom.home X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 Oct 2016 16:01:25 -0000 On Mon, Oct 10, 2016 at 02:21:41PM +0000, Ruslan Bukin wrote: > Author: br > Date: Mon Oct 10 14:21:40 2016 > New Revision: 306964 > URL: https://svnweb.freebsd.org/changeset/base/306964 > > Log: > Skip test on MIPS as we don't have shared page implemented yet. > > Sponsored by: DARPA, AFRL > Sponsored by: HEIF5 > > Modified: > head/tests/sys/kern/kern_copyin.c > > Modified: head/tests/sys/kern/kern_copyin.c > ============================================================================== > --- head/tests/sys/kern/kern_copyin.c Mon Oct 10 14:21:21 2016 (r306963) > +++ head/tests/sys/kern/kern_copyin.c Mon Oct 10 14:21:40 2016 (r306964) > @@ -59,6 +59,11 @@ ATF_TC_BODY(kern_copyin, tc) > { > char template[] = "copyin.XXXXXX"; > > +#ifdef __mips__ > + /* MIPS has no shared page implemented yet. */ > + atf_tc_skip("Platform is not supported."); > +#endif > + > scratch_file = mkstemp(template); > ATF_REQUIRE(scratch_file != -1); > unlink(template); Shared page does not have much to do with the test failure. The cause is that the UVA map on mips ends the highest mapped entry at the VM_MAXUSER_ADDRESS - PAGE_SIZE, while all other arches map either stack or shared page up to the VM_MAXUSER_ADDRESS. >From the comment in mips/include/vmparam.h it is not clear whether the test could be fixed by mapping a page at VM_MAXUSER_ADDRESS - PAGE_SIZE. From owner-svn-src-all@freebsd.org Mon Oct 10 16:06:56 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 9C476C0C8B2; Mon, 10 Oct 2016 16:06:56 +0000 (UTC) (envelope-from gjb@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 6B442E76; Mon, 10 Oct 2016 16:06:56 +0000 (UTC) (envelope-from gjb@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9AG6ti4051152; Mon, 10 Oct 2016 16:06:55 GMT (envelope-from gjb@FreeBSD.org) Received: (from gjb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9AG6ta1051151; Mon, 10 Oct 2016 16:06:55 GMT (envelope-from gjb@FreeBSD.org) Message-Id: <201610101606.u9AG6ta1051151@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: gjb set sender to gjb@FreeBSD.org using -f From: Glen Barber Date: Mon, 10 Oct 2016 16:06:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r306975 - stable/11/release/doc/en_US.ISO8859-1/errata X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 Oct 2016 16:06:56 -0000 Author: gjb Date: Mon Oct 10 16:06:55 2016 New Revision: 306975 URL: https://svnweb.freebsd.org/changeset/base/306975 Log: Fix a typo. Spotted by: lidl Sponsored by: The FreeBSD Foundation Modified: stable/11/release/doc/en_US.ISO8859-1/errata/article.xml Modified: stable/11/release/doc/en_US.ISO8859-1/errata/article.xml ============================================================================== --- stable/11/release/doc/en_US.ISO8859-1/errata/article.xml Mon Oct 10 15:54:32 2016 (r306974) +++ stable/11/release/doc/en_US.ISO8859-1/errata/article.xml Mon Oct 10 16:06:55 2016 (r306975) @@ -156,7 +156,7 @@ boot - The Release Notes errorneously states the + The Release Notes erroneously states the WITH_SYSTEM_COMPILER &man.src.conf.5; option is enabled by default, however this was disabled prior to the final release build. From owner-svn-src-all@freebsd.org Mon Oct 10 16:07:24 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 5A93FC0C8FD; Mon, 10 Oct 2016 16:07:24 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 2C203FCE; Mon, 10 Oct 2016 16:07:24 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9AG7N7t051222; Mon, 10 Oct 2016 16:07:23 GMT (envelope-from sevan@FreeBSD.org) Received: (from sevan@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9AG7N9b051221; Mon, 10 Oct 2016 16:07:23 GMT (envelope-from sevan@FreeBSD.org) Message-Id: <201610101607.u9AG7N9b051221@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sevan set sender to sevan@FreeBSD.org using -f From: Sevan Janiyan Date: Mon, 10 Oct 2016 16:07:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r306976 - stable/10/bin/chmod X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 Oct 2016 16:07:24 -0000 Author: sevan (doc committer) Date: Mon Oct 10 16:07:23 2016 New Revision: 306976 URL: https://svnweb.freebsd.org/changeset/base/306976 Log: MFC r306582: "POSIX doesn't specify -h." - r1.27 from NetBSD http://man.openbsd.org/?query=chmod&apropos=0&sec=0&arch=default&manpath=POSIX-2013 PR: 212337 Approved by: bcr (mentor) Obtained from: NetBSD Differential Revision: https://reviews.freebsd.org/D8118 Modified: stable/10/bin/chmod/chmod.c Directory Properties: stable/10/ (props changed) Modified: stable/10/bin/chmod/chmod.c ============================================================================== --- stable/10/bin/chmod/chmod.c Mon Oct 10 16:06:55 2016 (r306975) +++ stable/10/bin/chmod/chmod.c Mon Oct 10 16:07:23 2016 (r306976) @@ -91,12 +91,11 @@ main(int argc, char *argv[]) break; case 'h': /* - * In System V (and probably POSIX.2) the -h option - * causes chmod to change the mode of the symbolic - * link. 4.4BSD's symbolic links didn't have modes, - * so it was an undocumented noop. In FreeBSD 3.0, - * lchmod(2) is introduced and this option does real - * work. + * In System V the -h option causes chmod to change + * the mode of the symbolic link. 4.4BSD's symbolic + * links didn't have modes, so it was an undocumented + * noop. In FreeBSD 3.0, lchmod(2) is introduced and + * this option does real work. */ hflag = 1; break; From owner-svn-src-all@freebsd.org Mon Oct 10 16:08:30 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 84AC9C0C987; Mon, 10 Oct 2016 16:08:30 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 50BA720F; Mon, 10 Oct 2016 16:08:30 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9AG8Tq1051376; Mon, 10 Oct 2016 16:08:29 GMT (envelope-from sevan@FreeBSD.org) Received: (from sevan@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9AG8T9N051375; Mon, 10 Oct 2016 16:08:29 GMT (envelope-from sevan@FreeBSD.org) Message-Id: <201610101608.u9AG8T9N051375@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sevan set sender to sevan@FreeBSD.org using -f From: Sevan Janiyan Date: Mon, 10 Oct 2016 16:08:29 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r306977 - stable/11/bin/chmod X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 Oct 2016 16:08:30 -0000 Author: sevan (doc committer) Date: Mon Oct 10 16:08:29 2016 New Revision: 306977 URL: https://svnweb.freebsd.org/changeset/base/306977 Log: MFC r306582: "POSIX doesn't specify -h." - r1.27 from NetBSD http://man.openbsd.org/?query=chmod&apropos=0&sec=0&arch=default&manpath=POSIX-2013 PR: 212337 Approved by: bcr (mentor) Obtained from: NetBSD Differential Revision: https://reviews.freebsd.org/D8118 Modified: stable/11/bin/chmod/chmod.c Directory Properties: stable/11/ (props changed) Modified: stable/11/bin/chmod/chmod.c ============================================================================== --- stable/11/bin/chmod/chmod.c Mon Oct 10 16:07:23 2016 (r306976) +++ stable/11/bin/chmod/chmod.c Mon Oct 10 16:08:29 2016 (r306977) @@ -91,12 +91,11 @@ main(int argc, char *argv[]) break; case 'h': /* - * In System V (and probably POSIX.2) the -h option - * causes chmod to change the mode of the symbolic - * link. 4.4BSD's symbolic links didn't have modes, - * so it was an undocumented noop. In FreeBSD 3.0, - * lchmod(2) is introduced and this option does real - * work. + * In System V the -h option causes chmod to change + * the mode of the symbolic link. 4.4BSD's symbolic + * links didn't have modes, so it was an undocumented + * noop. In FreeBSD 3.0, lchmod(2) is introduced and + * this option does real work. */ hflag = 1; break; From owner-svn-src-all@freebsd.org Mon Oct 10 16:11:03 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 74807C0CAAB; Mon, 10 Oct 2016 16:11:03 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 40C0276D; Mon, 10 Oct 2016 16:11:03 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9AGB24i053764; Mon, 10 Oct 2016 16:11:02 GMT (envelope-from sevan@FreeBSD.org) Received: (from sevan@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9AGB2Tn053763; Mon, 10 Oct 2016 16:11:02 GMT (envelope-from sevan@FreeBSD.org) Message-Id: <201610101611.u9AGB2Tn053763@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sevan set sender to sevan@FreeBSD.org using -f From: Sevan Janiyan Date: Mon, 10 Oct 2016 16:11:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r306978 - stable/11/sbin/ccdconfig X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 Oct 2016 16:11:03 -0000 Author: sevan (doc committer) Date: Mon Oct 10 16:11:02 2016 New Revision: 306978 URL: https://svnweb.freebsd.org/changeset/base/306978 Log: MFC r306598 ccdconfig first appeared in NetBSD 1.1 From NetBSD man page, confirmed with repo tags in CVS [1] (there was also no 1.0a release according to [2]) [1] http://cvsweb.netbsd.org/bsdweb.cgi/src/sbin/ccdconfig/ccdconfig.c [2] http://netbsd.org/releases/formal.html#history PR: 212437 Approved by: bcr (mentor) Obtained from: NetBSD Differential Revision: https://reviews.freebsd.org/D8105 Modified: stable/11/sbin/ccdconfig/ccdconfig.8 Directory Properties: stable/11/ (props changed) Modified: stable/11/sbin/ccdconfig/ccdconfig.8 ============================================================================== --- stable/11/sbin/ccdconfig/ccdconfig.8 Mon Oct 10 16:08:29 2016 (r306977) +++ stable/11/sbin/ccdconfig/ccdconfig.8 Mon Oct 10 16:11:02 2016 (r306978) @@ -28,7 +28,7 @@ .\" .\" $FreeBSD$ .\" -.Dd October 1, 2013 +.Dd October 3, 2016 .Dt CCDCONFIG 8 .Os .Sh NAME @@ -159,7 +159,7 @@ It reads as a two disk stripe of da4 and to a two disk stripe of da6 and da7. The last example is a simple mirror. -The 2nd slice of /dev/da8 is mirrored with the 3rd slice of /dev/da9 +The second slice of /dev/da8 is mirrored with the third slice of /dev/da9 and assigned to ccd0. .Bd -literal # ccdconfig ccd0 64 none /dev/da0s1 /dev/da1s1 /dev/da2s1 /dev/da3s1 @@ -246,7 +246,7 @@ and The .Nm utility first appeared in -.Nx 1.0a . +.Nx 1.1 . .Sh BUGS The initial disklabel returned by .Xr ccd 4 From owner-svn-src-all@freebsd.org Mon Oct 10 16:11:53 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id F407DC0CB04; Mon, 10 Oct 2016 16:11:52 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id C58F696F; Mon, 10 Oct 2016 16:11:52 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9AGBpLw055116; Mon, 10 Oct 2016 16:11:51 GMT (envelope-from sevan@FreeBSD.org) Received: (from sevan@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9AGBp3W055115; Mon, 10 Oct 2016 16:11:51 GMT (envelope-from sevan@FreeBSD.org) Message-Id: <201610101611.u9AGBp3W055115@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sevan set sender to sevan@FreeBSD.org using -f From: Sevan Janiyan Date: Mon, 10 Oct 2016 16:11:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r306979 - stable/10/sbin/ccdconfig X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 Oct 2016 16:11:53 -0000 Author: sevan (doc committer) Date: Mon Oct 10 16:11:51 2016 New Revision: 306979 URL: https://svnweb.freebsd.org/changeset/base/306979 Log: MFC r306598 ccdconfig first appeared in NetBSD 1.1 From NetBSD man page, confirmed with repo tags in CVS [1] (there was also no 1.0a release according to [2]) [1] http://cvsweb.netbsd.org/bsdweb.cgi/src/sbin/ccdconfig/ccdconfig.c [2] http://netbsd.org/releases/formal.html#history PR: 212437 Approved by: bcr (mentor) Obtained from: NetBSD Differential Revision: https://reviews.freebsd.org/D8105 Modified: stable/10/sbin/ccdconfig/ccdconfig.8 Directory Properties: stable/10/ (props changed) Modified: stable/10/sbin/ccdconfig/ccdconfig.8 ============================================================================== --- stable/10/sbin/ccdconfig/ccdconfig.8 Mon Oct 10 16:11:02 2016 (r306978) +++ stable/10/sbin/ccdconfig/ccdconfig.8 Mon Oct 10 16:11:51 2016 (r306979) @@ -28,7 +28,7 @@ .\" .\" $FreeBSD$ .\" -.Dd October 1, 2013 +.Dd October 3, 2016 .Dt CCDCONFIG 8 .Os .Sh NAME @@ -159,7 +159,7 @@ It reads as a two disk stripe of da4 and to a two disk stripe of da6 and da7. The last example is a simple mirror. -The 2nd slice of /dev/da8 is mirrored with the 3rd slice of /dev/da9 +The second slice of /dev/da8 is mirrored with the third slice of /dev/da9 and assigned to ccd0. .Bd -literal # ccdconfig ccd0 64 none /dev/da0s1 /dev/da1s1 /dev/da2s1 /dev/da3s1 @@ -246,7 +246,7 @@ and The .Nm utility first appeared in -.Nx 1.0a . +.Nx 1.1 . .Sh BUGS The initial disklabel returned by .Xr ccd 4 From owner-svn-src-all@freebsd.org Mon Oct 10 16:14:01 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 608B8C0CB96; Mon, 10 Oct 2016 16:14:01 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 2C91DB95; Mon, 10 Oct 2016 16:14:01 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9AGE0LE055258; Mon, 10 Oct 2016 16:14:00 GMT (envelope-from sevan@FreeBSD.org) Received: (from sevan@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9AGE0PT055257; Mon, 10 Oct 2016 16:14:00 GMT (envelope-from sevan@FreeBSD.org) Message-Id: <201610101614.u9AGE0PT055257@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sevan set sender to sevan@FreeBSD.org using -f From: Sevan Janiyan Date: Mon, 10 Oct 2016 16:14:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r306980 - stable/10/sbin/dump X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 Oct 2016 16:14:01 -0000 Author: sevan (doc committer) Date: Mon Oct 10 16:14:00 2016 New Revision: 306980 URL: https://svnweb.freebsd.org/changeset/base/306980 Log: MFC r306600: dump(8) first appeared in V4 UNIX http://minnie.tuhs.org/cgi-bin/utree.pl?file=V4/man/man8 PR: 212444 Approved by: bcr (mentor) Obtained from: TUHS Differential Revision: https://reviews.freebsd.org/D8105 Modified: stable/10/sbin/dump/dump.8 Directory Properties: stable/10/ (props changed) Modified: stable/10/sbin/dump/dump.8 ============================================================================== --- stable/10/sbin/dump/dump.8 Mon Oct 10 16:11:51 2016 (r306979) +++ stable/10/sbin/dump/dump.8 Mon Oct 10 16:14:00 2016 (r306980) @@ -29,7 +29,7 @@ .\" @(#)dump.8 8.3 (Berkeley) 5/1/95 .\" $FreeBSD$ .\" -.Dd February 24, 2006 +.Dd October 3, 2016 .Dt DUMP 8 .Os .Sh NAME @@ -514,7 +514,7 @@ Many, and verbose. A .Nm utility appeared in -.At v6 . +.At v4 . .Sh BUGS Fewer than 32 read errors on the file system are ignored, though all errors will generate a warning message. From owner-svn-src-all@freebsd.org Mon Oct 10 16:14:50 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id EF085C0CC17; Mon, 10 Oct 2016 16:14:50 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id C0A29D3E; Mon, 10 Oct 2016 16:14:50 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9AGEngj055351; Mon, 10 Oct 2016 16:14:49 GMT (envelope-from sevan@FreeBSD.org) Received: (from sevan@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9AGEnit055350; Mon, 10 Oct 2016 16:14:49 GMT (envelope-from sevan@FreeBSD.org) Message-Id: <201610101614.u9AGEnit055350@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sevan set sender to sevan@FreeBSD.org using -f From: Sevan Janiyan Date: Mon, 10 Oct 2016 16:14:49 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r306981 - stable/11/sbin/dump X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 Oct 2016 16:14:51 -0000 Author: sevan (doc committer) Date: Mon Oct 10 16:14:49 2016 New Revision: 306981 URL: https://svnweb.freebsd.org/changeset/base/306981 Log: MFC r306600: dump(8) first appeared in V4 UNIX http://minnie.tuhs.org/cgi-bin/utree.pl?file=V4/man/man8 PR: 212444 Approved by: bcr (mentor) Obtained from: TUHS Differential Revision: https://reviews.freebsd.org/D8105 Modified: stable/11/sbin/dump/dump.8 Directory Properties: stable/11/ (props changed) Modified: stable/11/sbin/dump/dump.8 ============================================================================== --- stable/11/sbin/dump/dump.8 Mon Oct 10 16:14:00 2016 (r306980) +++ stable/11/sbin/dump/dump.8 Mon Oct 10 16:14:49 2016 (r306981) @@ -29,7 +29,7 @@ .\" @(#)dump.8 8.3 (Berkeley) 5/1/95 .\" $FreeBSD$ .\" -.Dd February 24, 2006 +.Dd October 3, 2016 .Dt DUMP 8 .Os .Sh NAME @@ -514,7 +514,7 @@ Many, and verbose. A .Nm utility appeared in -.At v6 . +.At v4 . .Sh BUGS Fewer than 32 read errors on the file system are ignored, though all errors will generate a warning message. From owner-svn-src-all@freebsd.org Mon Oct 10 16:16:27 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 7DBE6C0CCD1; Mon, 10 Oct 2016 16:16:27 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4CB59FBF; Mon, 10 Oct 2016 16:16:27 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9AGGQqE055833; Mon, 10 Oct 2016 16:16:26 GMT (envelope-from sevan@FreeBSD.org) Received: (from sevan@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9AGGQbJ055832; Mon, 10 Oct 2016 16:16:26 GMT (envelope-from sevan@FreeBSD.org) Message-Id: <201610101616.u9AGGQbJ055832@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sevan set sender to sevan@FreeBSD.org using -f From: Sevan Janiyan Date: Mon, 10 Oct 2016 16:16:26 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r306982 - stable/11/sbin/dumpon X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 Oct 2016 16:16:27 -0000 Author: sevan (doc committer) Date: Mon Oct 10 16:16:26 2016 New Revision: 306982 URL: https://svnweb.freebsd.org/changeset/base/306982 Log: MFC r306601: dumpon(8) appears to be present in FreeBSD 2.0.5, despite initial import of man page listed FreeBSD 2.1. PR: 212445 Approved by: bcr (mentor) Differential Revision: https://reviews.freebsd.org/D8105 Modified: stable/11/sbin/dumpon/dumpon.8 Directory Properties: stable/11/ (props changed) Modified: stable/11/sbin/dumpon/dumpon.8 ============================================================================== --- stable/11/sbin/dumpon/dumpon.8 Mon Oct 10 16:14:49 2016 (r306981) +++ stable/11/sbin/dumpon/dumpon.8 Mon Oct 10 16:16:26 2016 (r306982) @@ -28,7 +28,7 @@ .\" From: @(#)swapon.8 8.1 (Berkeley) 6/5/93 .\" $FreeBSD$ .\" -.Dd October 8, 2014 +.Dd October 3, 2016 .Dt DUMPON 8 .Os .Sh NAME @@ -154,7 +154,7 @@ boot-time system configuration The .Nm utility appeared in -.Fx 2.1 . +.Fx 2.0.5 . .Sh BUGS Because the file system layer is already dead by the time a crash dump is taken, it is not possible to send crash dumps directly to a file. From owner-svn-src-all@freebsd.org Mon Oct 10 16:17:16 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 0552EC0CD30; Mon, 10 Oct 2016 16:17:16 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id CAB9B185; Mon, 10 Oct 2016 16:17:15 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9AGHEXA055940; Mon, 10 Oct 2016 16:17:14 GMT (envelope-from sevan@FreeBSD.org) Received: (from sevan@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9AGHE9J055939; Mon, 10 Oct 2016 16:17:14 GMT (envelope-from sevan@FreeBSD.org) Message-Id: <201610101617.u9AGHE9J055939@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sevan set sender to sevan@FreeBSD.org using -f From: Sevan Janiyan Date: Mon, 10 Oct 2016 16:17:14 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r306983 - stable/10/sbin/dumpon X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 Oct 2016 16:17:16 -0000 Author: sevan (doc committer) Date: Mon Oct 10 16:17:14 2016 New Revision: 306983 URL: https://svnweb.freebsd.org/changeset/base/306983 Log: MFC r306601: dumpon(8) appears to be present in FreeBSD 2.0.5, despite initial import of man page listed FreeBSD 2.1. PR: 212445 Approved by: bcr (mentor) Differential Revision: https://reviews.freebsd.org/D8105 Modified: stable/10/sbin/dumpon/dumpon.8 Directory Properties: stable/10/ (props changed) Modified: stable/10/sbin/dumpon/dumpon.8 ============================================================================== --- stable/10/sbin/dumpon/dumpon.8 Mon Oct 10 16:16:26 2016 (r306982) +++ stable/10/sbin/dumpon/dumpon.8 Mon Oct 10 16:17:14 2016 (r306983) @@ -28,7 +28,7 @@ .\" From: @(#)swapon.8 8.1 (Berkeley) 6/5/93 .\" $FreeBSD$ .\" -.Dd October 8, 2014 +.Dd October 3, 2016 .Dt DUMPON 8 .Os .Sh NAME @@ -154,7 +154,7 @@ boot-time system configuration The .Nm utility appeared in -.Fx 2.1 . +.Fx 2.0.5 . .Sh BUGS Because the file system layer is already dead by the time a crash dump is taken, it is not possible to send crash dumps directly to a file. From owner-svn-src-all@freebsd.org Mon Oct 10 16:21:35 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 5523BC0CE19; Mon, 10 Oct 2016 16:21:35 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 2334D86F; Mon, 10 Oct 2016 16:21:35 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9AGLYTX056962; Mon, 10 Oct 2016 16:21:34 GMT (envelope-from sevan@FreeBSD.org) Received: (from sevan@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9AGLYrf056961; Mon, 10 Oct 2016 16:21:34 GMT (envelope-from sevan@FreeBSD.org) Message-Id: <201610101621.u9AGLYrf056961@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sevan set sender to sevan@FreeBSD.org using -f From: Sevan Janiyan Date: Mon, 10 Oct 2016 16:21:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r306984 - stable/10/sbin/fsck_msdosfs X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 Oct 2016 16:21:35 -0000 Author: sevan (doc committer) Date: Mon Oct 10 16:21:34 2016 New Revision: 306984 URL: https://svnweb.freebsd.org/changeset/base/306984 Log: MFC r306602: Mention the version of NetBSD the utility originated from. PR: 212476 Approved by: bcr (mentor) Differential Revision: https://reviews.freebsd.org/D8105 Modified: stable/10/sbin/fsck_msdosfs/fsck_msdosfs.8 Directory Properties: stable/10/ (props changed) Modified: stable/10/sbin/fsck_msdosfs/fsck_msdosfs.8 ============================================================================== --- stable/10/sbin/fsck_msdosfs/fsck_msdosfs.8 Mon Oct 10 16:17:14 2016 (r306983) +++ stable/10/sbin/fsck_msdosfs/fsck_msdosfs.8 Mon Oct 10 16:21:34 2016 (r306984) @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd June 4, 2009 +.Dd October 3, 2016 .Dt FSCK_MSDOSFS 8 .Os .Sh NAME @@ -114,7 +114,10 @@ as the answer to all operator questions. .Sh HISTORY The .Nm -utility first appeared in +utility appeared in +.Nx 1.2 . +.Nm +first appeared in .Fx 4.4 . .Sh BUGS The From owner-svn-src-all@freebsd.org Mon Oct 10 16:22:36 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 1C345C0CF7F; Mon, 10 Oct 2016 16:22:36 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id DCBFAD02; Mon, 10 Oct 2016 16:22:35 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9AGMY9I060053; Mon, 10 Oct 2016 16:22:34 GMT (envelope-from sevan@FreeBSD.org) Received: (from sevan@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9AGMYlm060052; Mon, 10 Oct 2016 16:22:34 GMT (envelope-from sevan@FreeBSD.org) Message-Id: <201610101622.u9AGMYlm060052@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sevan set sender to sevan@FreeBSD.org using -f From: Sevan Janiyan Date: Mon, 10 Oct 2016 16:22:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r306985 - stable/11/sbin/fsck_msdosfs X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 Oct 2016 16:22:36 -0000 Author: sevan (doc committer) Date: Mon Oct 10 16:22:34 2016 New Revision: 306985 URL: https://svnweb.freebsd.org/changeset/base/306985 Log: MFC r306602: Mention the version of NetBSD the utility originated from. PR: 212476 Approved by: bcr (mentor) Differential Revision: https://reviews.freebsd.org/D8105 Modified: stable/11/sbin/fsck_msdosfs/fsck_msdosfs.8 Directory Properties: stable/11/ (props changed) Modified: stable/11/sbin/fsck_msdosfs/fsck_msdosfs.8 ============================================================================== --- stable/11/sbin/fsck_msdosfs/fsck_msdosfs.8 Mon Oct 10 16:21:34 2016 (r306984) +++ stable/11/sbin/fsck_msdosfs/fsck_msdosfs.8 Mon Oct 10 16:22:34 2016 (r306985) @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd June 4, 2009 +.Dd October 3, 2016 .Dt FSCK_MSDOSFS 8 .Os .Sh NAME @@ -114,7 +114,10 @@ as the answer to all operator questions. .Sh HISTORY The .Nm -utility first appeared in +utility appeared in +.Nx 1.2 . +.Nm +first appeared in .Fx 4.4 . .Sh BUGS The From owner-svn-src-all@freebsd.org Mon Oct 10 16:24:06 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C9A64C0B0C5; Mon, 10 Oct 2016 16:24:06 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 9B20FF94; Mon, 10 Oct 2016 16:24:06 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9AGO51b060171; Mon, 10 Oct 2016 16:24:05 GMT (envelope-from sevan@FreeBSD.org) Received: (from sevan@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9AGO5uW060170; Mon, 10 Oct 2016 16:24:05 GMT (envelope-from sevan@FreeBSD.org) Message-Id: <201610101624.u9AGO5uW060170@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sevan set sender to sevan@FreeBSD.org using -f From: Sevan Janiyan Date: Mon, 10 Oct 2016 16:24:05 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r306986 - stable/11/sbin/fsdb X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 Oct 2016 16:24:06 -0000 Author: sevan (doc committer) Date: Mon Oct 10 16:24:05 2016 New Revision: 306986 URL: https://svnweb.freebsd.org/changeset/base/306986 Log: MFC r306603: Document which version of BSD first showed up in and add the version info for NetBSD & FreeBSD. PR: 212477 Approved by: bcr (mentor) Differential Revision: https://reviews.freebsd.org/D8105 Modified: stable/11/sbin/fsdb/fsdb.8 Directory Properties: stable/11/ (props changed) Modified: stable/11/sbin/fsdb/fsdb.8 ============================================================================== --- stable/11/sbin/fsdb/fsdb.8 Mon Oct 10 16:22:34 2016 (r306985) +++ stable/11/sbin/fsdb/fsdb.8 Mon Oct 10 16:24:05 2016 (r306986) @@ -28,7 +28,7 @@ .\" .\" $FreeBSD$ .\" -.Dd August 24, 2006 +.Dd October 3, 2016 .Dt FSDB 8 .Os .Sh NAME @@ -239,19 +239,20 @@ Exit the program. .Sh HISTORY The .Nm -utility uses the source code for +utility appeared in +.Bx 4.3 Tahoe . +It used the source code for .Xr fsck 8 to implement most of the file system manipulation code. The remainder of .Nm -first appeared in -.Nx , +appeared in +.Nx 1.1 written by .An John T. Kohl . -.Pp -.An Peter Wemm -ported it to -.Fx . +It first appeared in +.Fx 2.1.5 +ported by Peter Wemm. .Sh BUGS Manipulation of ``short'' symlinks has no effect. In particular, one should not From owner-svn-src-all@freebsd.org Mon Oct 10 16:25:06 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id BF9E2C0B14F; Mon, 10 Oct 2016 16:25:06 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 8E89215D; Mon, 10 Oct 2016 16:25:06 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9AGP5Km060287; Mon, 10 Oct 2016 16:25:05 GMT (envelope-from sevan@FreeBSD.org) Received: (from sevan@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9AGP56R060286; Mon, 10 Oct 2016 16:25:05 GMT (envelope-from sevan@FreeBSD.org) Message-Id: <201610101625.u9AGP56R060286@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sevan set sender to sevan@FreeBSD.org using -f From: Sevan Janiyan Date: Mon, 10 Oct 2016 16:25:05 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r306987 - stable/10/sbin/fsdb X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 Oct 2016 16:25:06 -0000 Author: sevan (doc committer) Date: Mon Oct 10 16:25:05 2016 New Revision: 306987 URL: https://svnweb.freebsd.org/changeset/base/306987 Log: MFC r306603: Document which version of BSD first showed up in and add the version info for NetBSD & FreeBSD. PR: 212477 Approved by: bcr (mentor) Differential Revision: https://reviews.freebsd.org/D8105 Modified: stable/10/sbin/fsdb/fsdb.8 Directory Properties: stable/10/ (props changed) Modified: stable/10/sbin/fsdb/fsdb.8 ============================================================================== --- stable/10/sbin/fsdb/fsdb.8 Mon Oct 10 16:24:05 2016 (r306986) +++ stable/10/sbin/fsdb/fsdb.8 Mon Oct 10 16:25:05 2016 (r306987) @@ -28,7 +28,7 @@ .\" .\" $FreeBSD$ .\" -.Dd August 24, 2006 +.Dd October 3, 2016 .Dt FSDB 8 .Os .Sh NAME @@ -239,19 +239,20 @@ Exit the program. .Sh HISTORY The .Nm -utility uses the source code for +utility appeared in +.Bx 4.3 Tahoe . +It used the source code for .Xr fsck 8 to implement most of the file system manipulation code. The remainder of .Nm -first appeared in -.Nx , +appeared in +.Nx 1.1 written by .An John T. Kohl . -.Pp -.An Peter Wemm -ported it to -.Fx . +It first appeared in +.Fx 2.1.5 +ported by Peter Wemm. .Sh BUGS Manipulation of ``short'' symlinks has no effect. In particular, one should not From owner-svn-src-all@freebsd.org Mon Oct 10 16:26:39 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 4E3E0C0B1DC; Mon, 10 Oct 2016 16:26:39 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 1D55032B; Mon, 10 Oct 2016 16:26:39 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9AGQcO0060401; Mon, 10 Oct 2016 16:26:38 GMT (envelope-from sevan@FreeBSD.org) Received: (from sevan@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9AGQcHQ060400; Mon, 10 Oct 2016 16:26:38 GMT (envelope-from sevan@FreeBSD.org) Message-Id: <201610101626.u9AGQcHQ060400@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sevan set sender to sevan@FreeBSD.org using -f From: Sevan Janiyan Date: Mon, 10 Oct 2016 16:26:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r306988 - stable/10/sbin/gbde X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 Oct 2016 16:26:39 -0000 Author: sevan (doc committer) Date: Mon Oct 10 16:26:38 2016 New Revision: 306988 URL: https://svnweb.freebsd.org/changeset/base/306988 Log: MFC r306604: gbde first appeared in FreeBSD 5.0 PR: 212478 Approved by: brc (mentor) Differential Revision: https://reviews.freebsd.org/D8105 Modified: stable/10/sbin/gbde/gbde.8 Directory Properties: stable/10/ (props changed) Modified: stable/10/sbin/gbde/gbde.8 ============================================================================== --- stable/10/sbin/gbde/gbde.8 Mon Oct 10 16:25:05 2016 (r306987) +++ stable/10/sbin/gbde/gbde.8 Mon Oct 10 16:26:38 2016 (r306988) @@ -31,7 +31,7 @@ .\" .\" $FreeBSD$ .\" -.Dd August 27, 2014 +.Dd October 3, 2016 .Dt GBDE 8 .Os .Sh NAME @@ -249,6 +249,9 @@ under DARPA/SPAWAR contract N66001-01-C- .Pq Dq CBOSS , as part of the DARPA CHATS research program. +.Nm +first appeared in +.Fx 5.0 . .Sh AUTHORS .An "Poul-Henning Kamp" Aq phk@FreeBSD.org .Sh BUGS From owner-svn-src-all@freebsd.org Mon Oct 10 16:27:33 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 65475C0B25D; Mon, 10 Oct 2016 16:27:33 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 364B36C1; Mon, 10 Oct 2016 16:27:33 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9AGRW1Y060508; Mon, 10 Oct 2016 16:27:32 GMT (envelope-from sevan@FreeBSD.org) Received: (from sevan@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9AGRWns060507; Mon, 10 Oct 2016 16:27:32 GMT (envelope-from sevan@FreeBSD.org) Message-Id: <201610101627.u9AGRWns060507@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sevan set sender to sevan@FreeBSD.org using -f From: Sevan Janiyan Date: Mon, 10 Oct 2016 16:27:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r306989 - stable/11/sbin/gbde X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 Oct 2016 16:27:33 -0000 Author: sevan (doc committer) Date: Mon Oct 10 16:27:32 2016 New Revision: 306989 URL: https://svnweb.freebsd.org/changeset/base/306989 Log: MFC r306604: gbde first appeared in FreeBSD 5.0 PR: 212478 Approved by: brc (mentor) Differential Revision: https://reviews.freebsd.org/D8105 Modified: stable/11/sbin/gbde/gbde.8 Directory Properties: stable/11/ (props changed) Modified: stable/11/sbin/gbde/gbde.8 ============================================================================== --- stable/11/sbin/gbde/gbde.8 Mon Oct 10 16:26:38 2016 (r306988) +++ stable/11/sbin/gbde/gbde.8 Mon Oct 10 16:27:32 2016 (r306989) @@ -31,7 +31,7 @@ .\" .\" $FreeBSD$ .\" -.Dd August 27, 2014 +.Dd October 3, 2016 .Dt GBDE 8 .Os .Sh NAME @@ -263,6 +263,9 @@ under DARPA/SPAWAR contract N66001-01-C- .Pq Dq CBOSS , as part of the DARPA CHATS research program. +.Nm +first appeared in +.Fx 5.0 . .Sh AUTHORS .An Poul-Henning Kamp Aq Mt phk@FreeBSD.org .Sh BUGS From owner-svn-src-all@freebsd.org Mon Oct 10 16:29:15 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E9DA2C0B2DC; Mon, 10 Oct 2016 16:29:15 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id B8EEC8AB; Mon, 10 Oct 2016 16:29:15 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9AGTEfu060629; Mon, 10 Oct 2016 16:29:14 GMT (envelope-from sevan@FreeBSD.org) Received: (from sevan@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9AGTEmg060628; Mon, 10 Oct 2016 16:29:14 GMT (envelope-from sevan@FreeBSD.org) Message-Id: <201610101629.u9AGTEmg060628@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sevan set sender to sevan@FreeBSD.org using -f From: Sevan Janiyan Date: Mon, 10 Oct 2016 16:29:14 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r306990 - stable/11/sbin/init X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 Oct 2016 16:29:16 -0000 Author: sevan (doc committer) Date: Mon Oct 10 16:29:14 2016 New Revision: 306990 URL: https://svnweb.freebsd.org/changeset/base/306990 Log: MFC r306605: init was there in UNIX from V1 http://minnie.tuhs.org/cgi-bin/utree.pl?file=V1/init.s PR: 212503 Approved by: bcr (mentor) Differential Revision: https://reviews.freebsd.org/D8105 Modified: stable/11/sbin/init/init.8 Directory Properties: stable/11/ (props changed) Modified: stable/11/sbin/init/init.8 ============================================================================== --- stable/11/sbin/init/init.8 Mon Oct 10 16:27:32 2016 (r306989) +++ stable/11/sbin/init/init.8 Mon Oct 10 16:29:14 2016 (r306990) @@ -31,7 +31,7 @@ .\" @(#)init.8 8.3 (Berkeley) 4/18/94 .\" $FreeBSD$ .\" -.Dd July 24, 2015 +.Dd October 3, 2016 .Dt INIT 8 .Os .Sh NAME @@ -345,7 +345,7 @@ a persistent device error condition. An .Nm utility appeared in -.At v6 . +.At v1 . .Sh CAVEATS Systems without .Xr sysctl 8 From owner-svn-src-all@freebsd.org Mon Oct 10 16:30:02 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 4CEBAC0B355; Mon, 10 Oct 2016 16:30:02 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 1BF6DA18; Mon, 10 Oct 2016 16:30:02 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9AGU1DQ060749; Mon, 10 Oct 2016 16:30:01 GMT (envelope-from sevan@FreeBSD.org) Received: (from sevan@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9AGU1C6060748; Mon, 10 Oct 2016 16:30:01 GMT (envelope-from sevan@FreeBSD.org) Message-Id: <201610101630.u9AGU1C6060748@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sevan set sender to sevan@FreeBSD.org using -f From: Sevan Janiyan Date: Mon, 10 Oct 2016 16:30:01 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r306991 - stable/10/sbin/init X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 Oct 2016 16:30:02 -0000 Author: sevan (doc committer) Date: Mon Oct 10 16:30:01 2016 New Revision: 306991 URL: https://svnweb.freebsd.org/changeset/base/306991 Log: MFC r306605: init was there in UNIX from V1 http://minnie.tuhs.org/cgi-bin/utree.pl?file=V1/init.s PR: 212503 Approved by: bcr (mentor) Differential Revision: https://reviews.freebsd.org/D8105 Modified: stable/10/sbin/init/init.8 Directory Properties: stable/10/ (props changed) Modified: stable/10/sbin/init/init.8 ============================================================================== --- stable/10/sbin/init/init.8 Mon Oct 10 16:29:14 2016 (r306990) +++ stable/10/sbin/init/init.8 Mon Oct 10 16:30:01 2016 (r306991) @@ -31,7 +31,7 @@ .\" @(#)init.8 8.3 (Berkeley) 4/18/94 .\" $FreeBSD$ .\" -.Dd July 24, 2015 +.Dd October 3, 2016 .Dt INIT 8 .Os .Sh NAME @@ -345,7 +345,7 @@ a persistent device error condition. An .Nm utility appeared in -.At v6 . +.At v1 . .Sh CAVEATS Systems without .Xr sysctl 8 From owner-svn-src-all@freebsd.org Mon Oct 10 16:32:57 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 2ACC3C0B54C; Mon, 10 Oct 2016 16:32:57 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id ED0B3F20; Mon, 10 Oct 2016 16:32:56 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9AGWuYe064284; Mon, 10 Oct 2016 16:32:56 GMT (envelope-from sevan@FreeBSD.org) Received: (from sevan@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9AGWuxO064283; Mon, 10 Oct 2016 16:32:56 GMT (envelope-from sevan@FreeBSD.org) Message-Id: <201610101632.u9AGWuxO064283@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sevan set sender to sevan@FreeBSD.org using -f From: Sevan Janiyan Date: Mon, 10 Oct 2016 16:32:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r306992 - stable/10/sbin/mknod X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 Oct 2016 16:32:57 -0000 Author: sevan (doc committer) Date: Mon Oct 10 16:32:55 2016 New Revision: 306992 URL: https://svnweb.freebsd.org/changeset/base/306992 Log: MFC r306606: mknod appeared in V4 UNIX http://minnie.tuhs.org/cgi-bin/utree.pl?file=V4/man/man8/mknod.8 PR: 212509 Approved by: bcr (mentor) Differential Revision: https://reviews.freebsd.org/D8105 Modified: stable/10/sbin/mknod/mknod.8 Directory Properties: stable/10/ (props changed) Modified: stable/10/sbin/mknod/mknod.8 ============================================================================== --- stable/10/sbin/mknod/mknod.8 Mon Oct 10 16:30:01 2016 (r306991) +++ stable/10/sbin/mknod/mknod.8 Mon Oct 10 16:32:55 2016 (r306992) @@ -28,7 +28,7 @@ .\" @(#)mknod.8 8.2 (Berkeley) 12/11/93 .\" $FreeBSD$ .\" -.Dd January 31, 2010 +.Dd October 3, 2016 .Dt MKNOD 8 .Os .Sh NAME @@ -149,4 +149,4 @@ nodes cannot be used to access devices. A .Nm utility appeared in -.At v6 . +.At v4 . From owner-svn-src-all@freebsd.org Mon Oct 10 16:33:45 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C3D18C0B5FB; Mon, 10 Oct 2016 16:33:45 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 9060A11E; Mon, 10 Oct 2016 16:33:45 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9AGXiL1064407; Mon, 10 Oct 2016 16:33:44 GMT (envelope-from sevan@FreeBSD.org) Received: (from sevan@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9AGXiqw064406; Mon, 10 Oct 2016 16:33:44 GMT (envelope-from sevan@FreeBSD.org) Message-Id: <201610101633.u9AGXiqw064406@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sevan set sender to sevan@FreeBSD.org using -f From: Sevan Janiyan Date: Mon, 10 Oct 2016 16:33:44 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r306993 - stable/11/sbin/mknod X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 Oct 2016 16:33:45 -0000 Author: sevan (doc committer) Date: Mon Oct 10 16:33:44 2016 New Revision: 306993 URL: https://svnweb.freebsd.org/changeset/base/306993 Log: MFC r306606: mknod appeared in V4 UNIX http://minnie.tuhs.org/cgi-bin/utree.pl?file=V4/man/man8/mknod.8 PR: 212509 Approved by: bcr (mentor) Differential Revision: https://reviews.freebsd.org/D8105 Modified: stable/11/sbin/mknod/mknod.8 Directory Properties: stable/11/ (props changed) Modified: stable/11/sbin/mknod/mknod.8 ============================================================================== --- stable/11/sbin/mknod/mknod.8 Mon Oct 10 16:32:55 2016 (r306992) +++ stable/11/sbin/mknod/mknod.8 Mon Oct 10 16:33:44 2016 (r306993) @@ -28,7 +28,7 @@ .\" @(#)mknod.8 8.2 (Berkeley) 12/11/93 .\" $FreeBSD$ .\" -.Dd January 31, 2010 +.Dd October 3, 2016 .Dt MKNOD 8 .Os .Sh NAME @@ -149,4 +149,4 @@ nodes cannot be used to access devices. A .Nm utility appeared in -.At v6 . +.At v4 . From owner-svn-src-all@freebsd.org Mon Oct 10 16:35:26 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id BAC3DC0B6FA; Mon, 10 Oct 2016 16:35:26 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 8A8A62DB; Mon, 10 Oct 2016 16:35:26 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9AGZPZk064553; Mon, 10 Oct 2016 16:35:25 GMT (envelope-from sevan@FreeBSD.org) Received: (from sevan@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9AGZPRP064552; Mon, 10 Oct 2016 16:35:25 GMT (envelope-from sevan@FreeBSD.org) Message-Id: <201610101635.u9AGZPRP064552@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sevan set sender to sevan@FreeBSD.org using -f From: Sevan Janiyan Date: Mon, 10 Oct 2016 16:35:25 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r306994 - stable/11/sbin/mksnap_ffs X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 Oct 2016 16:35:26 -0000 Author: sevan (doc committer) Date: Mon Oct 10 16:35:25 2016 New Revision: 306994 URL: https://svnweb.freebsd.org/changeset/base/306994 Log: MFC r306607: mksnap_ffs appeared in FreeBSD 5.1. PR: 212510 Approved by: bcr (mentor) Differential Revision: https://reviews.freebsd.org/D8105 Modified: stable/11/sbin/mksnap_ffs/mksnap_ffs.8 Directory Properties: stable/11/ (props changed) Modified: stable/11/sbin/mksnap_ffs/mksnap_ffs.8 ============================================================================== --- stable/11/sbin/mksnap_ffs/mksnap_ffs.8 Mon Oct 10 16:33:44 2016 (r306993) +++ stable/11/sbin/mksnap_ffs/mksnap_ffs.8 Mon Oct 10 16:35:25 2016 (r306994) @@ -34,7 +34,7 @@ .\" .\" $FreeBSD$ .\" -.Dd February 14, 2011 +.Dd October 3, 2016 .Dt MKSNAP_FFS 8 .Os .Sh NAME @@ -75,7 +75,7 @@ mount -o ro /dev/md0 /mnt/ The .Nm utility first appeared in -.Fx 5.0 . +.Fx 5.1 . .Sh CAVEATS The disk full situation is not handled gracefully and may lead to a system panic when no free blocks are found. From owner-svn-src-all@freebsd.org Mon Oct 10 16:36:15 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 490E7C0B846; Mon, 10 Oct 2016 16:36:15 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 1ABA86A4; Mon, 10 Oct 2016 16:36:15 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9AGaELQ064655; Mon, 10 Oct 2016 16:36:14 GMT (envelope-from sevan@FreeBSD.org) Received: (from sevan@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9AGaE70064654; Mon, 10 Oct 2016 16:36:14 GMT (envelope-from sevan@FreeBSD.org) Message-Id: <201610101636.u9AGaE70064654@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sevan set sender to sevan@FreeBSD.org using -f From: Sevan Janiyan Date: Mon, 10 Oct 2016 16:36:14 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r306995 - stable/10/sbin/mksnap_ffs X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 Oct 2016 16:36:15 -0000 Author: sevan (doc committer) Date: Mon Oct 10 16:36:14 2016 New Revision: 306995 URL: https://svnweb.freebsd.org/changeset/base/306995 Log: MFC r306607: mksnap_ffs appeared in FreeBSD 5.1. PR: 212510 Approved by: bcr (mentor) Differential Revision: https://reviews.freebsd.org/D8105 Modified: stable/10/sbin/mksnap_ffs/mksnap_ffs.8 Directory Properties: stable/10/ (props changed) Modified: stable/10/sbin/mksnap_ffs/mksnap_ffs.8 ============================================================================== --- stable/10/sbin/mksnap_ffs/mksnap_ffs.8 Mon Oct 10 16:35:25 2016 (r306994) +++ stable/10/sbin/mksnap_ffs/mksnap_ffs.8 Mon Oct 10 16:36:14 2016 (r306995) @@ -34,7 +34,7 @@ .\" .\" $FreeBSD$ .\" -.Dd February 14, 2011 +.Dd October 3, 2016 .Dt MKSNAP_FFS 8 .Os .Sh NAME @@ -75,7 +75,7 @@ mount -o ro /dev/md0 /mnt/ The .Nm utility first appeared in -.Fx 5.0 . +.Fx 5.1 . .Sh CAVEATS The disk full situation is not handled gracefully and may lead to a system panic when no free blocks are found. From owner-svn-src-all@freebsd.org Mon Oct 10 16:38:08 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 654BCC0B918; Mon, 10 Oct 2016 16:38:08 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 3CE4C8B4; Mon, 10 Oct 2016 16:38:08 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9AGc7jP064790; Mon, 10 Oct 2016 16:38:07 GMT (envelope-from sevan@FreeBSD.org) Received: (from sevan@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9AGc7f4064789; Mon, 10 Oct 2016 16:38:07 GMT (envelope-from sevan@FreeBSD.org) Message-Id: <201610101638.u9AGc7f4064789@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sevan set sender to sevan@FreeBSD.org using -f From: Sevan Janiyan Date: Mon, 10 Oct 2016 16:38:07 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r306996 - stable/10/sbin/mount_fusefs X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 Oct 2016 16:38:08 -0000 Author: sevan (doc committer) Date: Mon Oct 10 16:38:07 2016 New Revision: 306996 URL: https://svnweb.freebsd.org/changeset/base/306996 Log: MFC r306610: Note mount_fusefs appeared in FreeBSD 10. Move note regarding implementation to caveats. Address issued raised by Igor. PR: 212513 Approved by: bcr (mentor) Differential Revision: https://reviews.freebsd.org/D8105 Modified: stable/10/sbin/mount_fusefs/mount_fusefs.8 Directory Properties: stable/10/ (props changed) Modified: stable/10/sbin/mount_fusefs/mount_fusefs.8 ============================================================================== --- stable/10/sbin/mount_fusefs/mount_fusefs.8 Mon Oct 10 16:36:14 2016 (r306995) +++ stable/10/sbin/mount_fusefs/mount_fusefs.8 Mon Oct 10 16:38:07 2016 (r306996) @@ -29,7 +29,7 @@ .\" .\" $FreeBSD$ .\" -.Dd October 11, 2012 +.Dd October 3, 2016 .Dt MOUNT_FUSEFS 8 .Os .Sh NAME @@ -52,7 +52,8 @@ .Sh DESCRIPTION Basic usage is to start a fuse daemon on the given .Ar special -file. In practice, the daemon is assigned a +file. +In practice, the daemon is assigned a .Ar special file automatically, which can then be indentified via .Xr fstat 1 . @@ -68,7 +69,8 @@ is appended to the list of arguments, .Nm will call the .Ar fuse_daemon -via that command. In that way the +via that command. +In that way the .Ar fuse_daemon will be instructed to attach itself to .Ar special . @@ -101,7 +103,8 @@ The options are as follows: .It Fl A , Ic --reject-allow_other Prohibit the .Cm allow_other -mount flag. Intended for use in scripts and the +mount flag. +Intended for use in scripts and the .Xr sudoers 5 file. .It Fl S , Ic --safe @@ -143,8 +146,8 @@ Only root can use this option Limit size of read requests to .Ar n .It Cm private -Refuse shared mounting of the daemon. This is the default behaviour, -to allow sharing, expicitly use +Refuse shared mounting of the daemon. +This is the default behaviour, to allow sharing, expicitly use .Fl o Cm noprivate .It Cm neglect_shares Do not refuse unmounting if there are secondary mounts @@ -155,11 +158,13 @@ Prefix absolute symlinks with the mountp .El .Pp Besides the above mount options, there is a set of pseudo-mount options which -are supported by the Fuse library. One can list these by passing +are supported by the Fuse library. +One can list these by passing .Fl h -to a Fuse daemon. Most of these options have effect only on the behaviour of -the daemon (that is, their scope is limited to userspace). However, -there are some which do require in-kernel support. +to a Fuse daemon. +Most of these options only have affect on the behavior of the daemon (that is, +their scope is limited to userspace). +However, there are some which do require in-kernel support. Currently the options supported by the kernel are: .Bl -tag -width indent .It Cm direct_io @@ -190,7 +195,7 @@ only if the filesystem daemon has the sa real gid) as the user. .Pp This is applied for Fuse mounts by default and only root can mount without -the strict access policy (ie. the +the strict access policy (i.e. the .Cm allow_other mount option). .Pp @@ -202,7 +207,7 @@ Users might opt to willingly relax stric are concerned) by doing their own secondary mount (See .Sx SHARED MOUNTS ) . .Sh SHARED MOUNTS -A Fuse daemon can be shared (ie. mounted multiple times). +A Fuse daemon can be shared (i.e. mounted multiple times). When doing the first (primary) mount, the spawner and the mounter of the daemon must have the same uid, or the mounter should be the superuser. .Pp @@ -213,9 +218,9 @@ The behaviour of a secondary mount is an links: they redirect all filesystem operations to the primary mount. .Pp Doing a secondary mount is like signing an agreement: by this action, the mounter -agrees that the Fuse daemon can trace her I/O activities. From then on -she is not banned from using the filesystem (either via her own mount or -via the primary mount), regardless whether +agrees that the Fuse daemon can trace her I/O activities. +From then on she is not banned from using the filesystem +(either via her own mount or via the primary mount), regardless whether .Cm allow_other is used or not. .Pp @@ -227,14 +232,15 @@ mount; e.g. System administrators might want to use a custom mount policy (ie., one going beyond the .Va vfs.usermount -sysctl). The primary tool for such purposes is +sysctl). +The primary tool for such purposes is .Xr sudo 8 . However, given that .Nm is capable of invoking an arbitrary program, one must be careful when doing this. .Nm -is designed in a way such that it makes that easy. For this purpose, -there are options which disable certain risky features (ie. +is designed in a way such that it makes that easy. +For this purpose, there are options which disable certain risky features (i.e. .Fl S and .Fl A ) , @@ -270,8 +276,8 @@ If set, .Nm will ignore uknown mount options. .It Ev MOUNT_FUSEFS_CALL_BY_LIB -Adjust behaviour to the needs of the FUSE library. Currently it effects -help output. +Adjust behavior to the needs of the FUSE library. +Currently it effects help output. .El .Pp Although the following variables do not have any effect on @@ -279,11 +285,13 @@ Although the following variables do not itself, they affect the behaviour of fuse daemons: .Bl -tag -width ".Ev FUSE_DEV_NAME" .It Ev FUSE_DEV_NAME -Device to attach. If not set, the multiplexer path +Device to attach. +If not set, the multiplexer path .Ar /dev/fuse is used. .It Ev FUSE_DEV_FD -File desciptor of an opened Fuse device to use. Overrides +File desciptor of an opened Fuse device to use. +Overrides .Ev FUSE_DEV_NAME . .It Ev FUSE_NO_MOUNT If set, the library will not attempt to mount the filesystem, even @@ -294,7 +302,8 @@ if a mountpoint argument is supplied. .It Pa /dev/fuse Fuse device with which the kernel and Fuse daemons can communicate. .It Pa /dev/fuse -The multiplexer path. An +The multiplexer path. +An .Xr open 2 performed on it automatically is passed to a free Fuse device by the kernel (which might be created just for this puprose). @@ -331,12 +340,19 @@ does not call any external utility and a .Xr sudo 8 .Sh HISTORY .Nm -appears as the part of the FreeBSD implementation of the Fuse userspace filesystem -framework (see http://fuse.sourceforge.net). This user interface is FreeBSD specific. +appeared in +.Fx 10.0 +as the part of the +.Fx +implementation of the Fuse userspace filesystem +framework (see http://fuse.sourceforge.net). .Sh CAVEATS -Secondary mounts should be unmounted via their device name. If an attempt is -made to be unmount them via their filesystem root path, the unmount request -will be forwarded to the primary mount path. +This user interface is +.Fx +specific. +Secondary mounts should be unmounted via their device name. +If an attempt is made to unmount them via their filesystem root path, +the unmount request will be forwarded to the primary mount path. In general, unmounting by device name is less error-prone than by mount path (although the latter will also work under normal circumstances). .Pp From owner-svn-src-all@freebsd.org Mon Oct 10 16:38:53 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 60D0AC0B9D6; Mon, 10 Oct 2016 16:38:53 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 3C1B3A2C; Mon, 10 Oct 2016 16:38:53 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9AGcqBC064880; Mon, 10 Oct 2016 16:38:52 GMT (envelope-from sevan@FreeBSD.org) Received: (from sevan@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9AGcq5N064879; Mon, 10 Oct 2016 16:38:52 GMT (envelope-from sevan@FreeBSD.org) Message-Id: <201610101638.u9AGcq5N064879@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sevan set sender to sevan@FreeBSD.org using -f From: Sevan Janiyan Date: Mon, 10 Oct 2016 16:38:52 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r306997 - stable/11/sbin/mount_fusefs X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 Oct 2016 16:38:53 -0000 Author: sevan (doc committer) Date: Mon Oct 10 16:38:52 2016 New Revision: 306997 URL: https://svnweb.freebsd.org/changeset/base/306997 Log: MFC r306610: Note mount_fusefs appeared in FreeBSD 10. Move note regarding implementation to caveats. Address issued raised by Igor. PR: 212513 Approved by: bcr (mentor) Differential Revision: https://reviews.freebsd.org/D8105 Modified: stable/11/sbin/mount_fusefs/mount_fusefs.8 Directory Properties: stable/11/ (props changed) Modified: stable/11/sbin/mount_fusefs/mount_fusefs.8 ============================================================================== --- stable/11/sbin/mount_fusefs/mount_fusefs.8 Mon Oct 10 16:38:07 2016 (r306996) +++ stable/11/sbin/mount_fusefs/mount_fusefs.8 Mon Oct 10 16:38:52 2016 (r306997) @@ -29,7 +29,7 @@ .\" .\" $FreeBSD$ .\" -.Dd October 11, 2012 +.Dd October 3, 2016 .Dt MOUNT_FUSEFS 8 .Os .Sh NAME @@ -52,7 +52,8 @@ .Sh DESCRIPTION Basic usage is to start a fuse daemon on the given .Ar special -file. In practice, the daemon is assigned a +file. +In practice, the daemon is assigned a .Ar special file automatically, which can then be indentified via .Xr fstat 1 . @@ -68,7 +69,8 @@ is appended to the list of arguments, .Nm will call the .Ar fuse_daemon -via that command. In that way the +via that command. +In that way the .Ar fuse_daemon will be instructed to attach itself to .Ar special . @@ -101,7 +103,8 @@ The options are as follows: .It Fl A , Ic --reject-allow_other Prohibit the .Cm allow_other -mount flag. Intended for use in scripts and the +mount flag. +Intended for use in scripts and the .Xr sudoers 5 file. .It Fl S , Ic --safe @@ -143,8 +146,8 @@ Only root can use this option Limit size of read requests to .Ar n .It Cm private -Refuse shared mounting of the daemon. This is the default behaviour, -to allow sharing, expicitly use +Refuse shared mounting of the daemon. +This is the default behaviour, to allow sharing, expicitly use .Fl o Cm noprivate .It Cm neglect_shares Do not refuse unmounting if there are secondary mounts @@ -154,11 +157,13 @@ Prefix absolute symlinks with the mountp .El .Pp Besides the above mount options, there is a set of pseudo-mount options which -are supported by the Fuse library. One can list these by passing +are supported by the Fuse library. +One can list these by passing .Fl h -to a Fuse daemon. Most of these options have effect only on the behaviour of -the daemon (that is, their scope is limited to userspace). However, -there are some which do require in-kernel support. +to a Fuse daemon. +Most of these options only have affect on the behavior of the daemon (that is, +their scope is limited to userspace). +However, there are some which do require in-kernel support. Currently the options supported by the kernel are: .Bl -tag -width indent .It Cm direct_io @@ -189,7 +194,7 @@ only if the filesystem daemon has the sa real gid) as the user. .Pp This is applied for Fuse mounts by default and only root can mount without -the strict access policy (ie. the +the strict access policy (i.e. the .Cm allow_other mount option). .Pp @@ -201,7 +206,7 @@ Users might opt to willingly relax stric are concerned) by doing their own secondary mount (See .Sx SHARED MOUNTS ) . .Sh SHARED MOUNTS -A Fuse daemon can be shared (ie. mounted multiple times). +A Fuse daemon can be shared (i.e. mounted multiple times). When doing the first (primary) mount, the spawner and the mounter of the daemon must have the same uid, or the mounter should be the superuser. .Pp @@ -212,9 +217,9 @@ The behaviour of a secondary mount is an links: they redirect all filesystem operations to the primary mount. .Pp Doing a secondary mount is like signing an agreement: by this action, the mounter -agrees that the Fuse daemon can trace her I/O activities. From then on -she is not banned from using the filesystem (either via her own mount or -via the primary mount), regardless whether +agrees that the Fuse daemon can trace her I/O activities. +From then on she is not banned from using the filesystem +(either via her own mount or via the primary mount), regardless whether .Cm allow_other is used or not. .Pp @@ -226,14 +231,15 @@ mount; e.g. System administrators might want to use a custom mount policy (ie., one going beyond the .Va vfs.usermount -sysctl). The primary tool for such purposes is +sysctl). +The primary tool for such purposes is .Xr sudo 8 . However, given that .Nm is capable of invoking an arbitrary program, one must be careful when doing this. .Nm -is designed in a way such that it makes that easy. For this purpose, -there are options which disable certain risky features (ie. +is designed in a way such that it makes that easy. +For this purpose, there are options which disable certain risky features (i.e. .Fl S and .Fl A ) , @@ -269,8 +275,8 @@ If set, .Nm will ignore uknown mount options. .It Ev MOUNT_FUSEFS_CALL_BY_LIB -Adjust behaviour to the needs of the FUSE library. Currently it effects -help output. +Adjust behavior to the needs of the FUSE library. +Currently it effects help output. .El .Pp Although the following variables do not have any effect on @@ -278,11 +284,13 @@ Although the following variables do not itself, they affect the behaviour of fuse daemons: .Bl -tag -width ".Ev FUSE_DEV_NAME" .It Ev FUSE_DEV_NAME -Device to attach. If not set, the multiplexer path +Device to attach. +If not set, the multiplexer path .Ar /dev/fuse is used. .It Ev FUSE_DEV_FD -File desciptor of an opened Fuse device to use. Overrides +File desciptor of an opened Fuse device to use. +Overrides .Ev FUSE_DEV_NAME . .It Ev FUSE_NO_MOUNT If set, the library will not attempt to mount the filesystem, even @@ -293,7 +301,8 @@ if a mountpoint argument is supplied. .It Pa /dev/fuse Fuse device with which the kernel and Fuse daemons can communicate. .It Pa /dev/fuse -The multiplexer path. An +The multiplexer path. +An .Xr open 2 performed on it automatically is passed to a free Fuse device by the kernel (which might be created just for this puprose). @@ -330,12 +339,19 @@ does not call any external utility and a .Xr umount 8 .Sh HISTORY .Nm -appears as the part of the FreeBSD implementation of the Fuse userspace filesystem -framework (see http://fuse.sourceforge.net). This user interface is FreeBSD specific. +appeared in +.Fx 10.0 +as the part of the +.Fx +implementation of the Fuse userspace filesystem +framework (see http://fuse.sourceforge.net). .Sh CAVEATS -Secondary mounts should be unmounted via their device name. If an attempt is -made to be unmount them via their filesystem root path, the unmount request -will be forwarded to the primary mount path. +This user interface is +.Fx +specific. +Secondary mounts should be unmounted via their device name. +If an attempt is made to unmount them via their filesystem root path, +the unmount request will be forwarded to the primary mount path. In general, unmounting by device name is less error-prone than by mount path (although the latter will also work under normal circumstances). .Pp From owner-svn-src-all@freebsd.org Mon Oct 10 16:41:19 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 33456C0BB42; Mon, 10 Oct 2016 16:41:19 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id DD02AD06; Mon, 10 Oct 2016 16:41:18 +0000 (UTC) (envelope-from sevan@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9AGfIuu065837; Mon, 10 Oct 2016 16:41:18 GMT (envelope-from sevan@FreeBSD.org) Received: (from sevan@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9AGfI8t065836; Mon, 10 Oct 2016 16:41:18 GMT (envelope-from sevan@FreeBSD.org) Message-Id: <201610101641.u9AGfI8t065836@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sevan set sender to sevan@FreeBSD.org using -f From: Sevan Janiyan Date: Mon, 10 Oct 2016 16:41:17 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r306998 - stable/11/sbin/mount_msdosfs X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 Oct 2016 16:41:19 -0000 Author: sevan (doc committer) Date: Mon Oct 10 16:41:17 2016 New Revision: 306998 URL: https://svnweb.freebsd.org/changeset/base/306998 Log: MFC r306611: Amend history to mention predecessor originated from 386BSD[1] & current implementation from NetBSD[2]. Reword history since the utility was renamed once more in FreeBSD 5.0. Separate out author & historical information regarding character code conversion. Add AUTHORS section. [1] https://groups.google.com/forum/#!search/mount_pcfs.c/comp.unix.bsd/9qhH0v1tZm0/inlPnXZj_2sJ [2] http://cvsweb.netbsd.org/bsdweb.cgi/src/sbin/mount_msdos/mount_msdos.c?rev=1.6&content-type=text/x-cvsweb-markup PR: 212536 Approved by: bcr (mentor) Differential Revision: https://reviews.freebsd.org/D8105 Modified: stable/11/sbin/mount_msdosfs/mount_msdosfs.8 Directory Properties: stable/11/ (props changed) Modified: stable/11/sbin/mount_msdosfs/mount_msdosfs.8 ============================================================================== --- stable/11/sbin/mount_msdosfs/mount_msdosfs.8 Mon Oct 10 16:38:52 2016 (r306997) +++ stable/11/sbin/mount_msdosfs/mount_msdosfs.8 Mon Oct 10 16:41:17 2016 (r306998) @@ -30,7 +30,7 @@ .\" .\" $FreeBSD$ .\" -.Dd October 1, 2013 +.Dd October 3, 2016 .Dt MOUNT_MSDOSFS 8 .Os .Sh NAME @@ -200,21 +200,32 @@ To mount a Japanese MS-DOS file system l List of Localized MS Operating Systems: .Pa http://www.microsoft.com/globaldev/reference/oslocversion.mspx . .Sh HISTORY -The -.Nm -utility first appeared in +The predecessor to +.Nm mount_msdos +utility named +.Nm mount_pcfs +appeared in +.Bx 386 . +It was rewritten in +.Nx 1.0 +and first appeared in .Fx 2.0 . -Its predecessor, the +.Nm mount_msdos +was renamed to the more aptly-named +.Nm +in +.Fx 5.0. +The character code conversion routine was added in 2003. +.Sh AUTHORS +Initial implementation as .Nm mount_pcfs -utility appeared in -.Fx 1.0 , -and was abandoned in favor -of the more aptly-named -.Nm . -.Pp +was written by +.An -nosplit +.An Paul Popelka Aq Mt paulp@uts.amdahl.com . +It was rewritten by +.An Christopher G. Demetriou Aq Mt cgd@NetBSD.org . The character code conversion routine was added by -.An Ryuichiro Imura Aq Mt imura@ryu16.org -in 2003. +.An Ryuichiro Imura Aq Mt imura@ryu16.org . .Sh CAVEATS The use of the .Fl 9 From owner-svn-src-all@freebsd.org Mon Oct 10 16:50:54 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 60569C0BD1D; Mon, 10 Oct 2016 16:50:54 +0000 (UTC) (envelope-from rb743@hermes.cam.ac.uk) Received: from ppsw-31.csi.cam.ac.uk (ppsw-31.csi.cam.ac.uk [131.111.8.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 2B5491E8; Mon, 10 Oct 2016 16:50:53 +0000 (UTC) (envelope-from rb743@hermes.cam.ac.uk) X-Cam-AntiVirus: no malware found X-Cam-ScannerInfo: http://www.cam.ac.uk/cs/email/scanner/ Received: from sc1.bsdpad.com ([163.172.212.18]:35514) by ppsw-31.csi.cam.ac.uk (smtp.hermes.cam.ac.uk [131.111.8.157]:587) with esmtpsa (LOGIN:rb743) (TLSv1:ECDHE-RSA-AES256-SHA:256) id 1btdmu-000vmT-KG (Exim 4.86_36-e07b163) (return-path ); Mon, 10 Oct 2016 17:50:52 +0100 Date: Mon, 10 Oct 2016 16:50:38 +0000 From: Ruslan Bukin To: Conrad Meyer Cc: Ruslan Bukin , src-committers , svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r306962 - head/tests/sys/kern/pipe Message-ID: <20161010165038.GA31246@bsdpad.com> References: <201610101340.u9ADe5XW093068@repo.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.6.1 (2016-04-27) Sender: "R. Bukin" X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 Oct 2016 16:50:54 -0000 There is some direct mode activated when you send >=8192, so this line is required Ruslan On Mon, Oct 10, 2016 at 08:04:44AM -0700, Conrad Meyer wrote: > We also observed this test was broken, but I think the right fix is > much smaller: > > --- a/tests/sys/kern/pipe/pipe_fstat_bug_test.c > +++ b/tests/sys/kern/pipe/pipe_fstat_bug_test.c > @@ -108,7 +108,6 @@ main(void) > SYNC_W(0, go2); > > SYNC_R(0, go); > - SYNC_W(0, go2); /* XXX: why is this required? */ > WRITE(8192); > SYNC_W(0, go2); > > (That line breaks the synchronization mechanism that is the only > guarantee the test passes.) > > Best, > Conrad > > > On Mon, Oct 10, 2016 at 6:40 AM, Ruslan Bukin wrote: > > Author: br > > Date: Mon Oct 10 13:40:05 2016 > > New Revision: 306962 > > URL: https://svnweb.freebsd.org/changeset/base/306962 > > > > Log: > > Ensure data in pipe is available to read. > > Useful for latest (5th, direct mode) test only. > > > > Sponsored by: DARPA, AFRL > > Sponsored by: HEIF5 > > > > Modified: > > head/tests/sys/kern/pipe/pipe_fstat_bug_test.c > > > > Modified: head/tests/sys/kern/pipe/pipe_fstat_bug_test.c > > ============================================================================== > > --- head/tests/sys/kern/pipe/pipe_fstat_bug_test.c Mon Oct 10 11:53:54 2016 (r306961) > > +++ head/tests/sys/kern/pipe/pipe_fstat_bug_test.c Mon Oct 10 13:40:05 2016 (r306962) > > @@ -26,6 +26,7 @@ SUCH DAMAGE. > > #include > > #include > > #include > > +#include > > #include > > #include > > #include > > @@ -49,10 +50,12 @@ main(void) > > { > > char buffer[32768], buffer2[32768], go[] = "go", go2[] = "go2"; > > int desc[2], ipc_coord[2]; > > + struct kevent event, ke; > > ssize_t error; > > int successes = 0; > > struct stat status; > > pid_t new_pid; > > + int kq; > > > > error = pipe(desc); > > if (error == -1) > > @@ -118,9 +121,24 @@ main(void) > > _exit(0); > > } > > > > + kq = kqueue(); > > + if (kq == -1) > > + _exit(1); > > + > > + EV_SET(&ke, desc[0], EVFILT_READ, EV_ADD, 0, 0, NULL); > > + > > + /* Attach event to the kqueue. */ > > + if (kevent(kq, &ke, 1, NULL, 0, NULL) != 0) > > + _exit(2); > > + > > while (successes < 5) { > > SYNC_W(1, go); > > SYNC_R(1, go2); > > + > > + /* Ensure data is available to read */ > > + if (kevent(kq, NULL, 0, &event, 1, NULL) != 1) > > + _exit(3); > > + > > fstat(desc[0], &status); > > error = read(desc[0], &buffer2, sizeof(buffer2)); > > > > > From owner-svn-src-all@freebsd.org Mon Oct 10 17:00:13 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 7A89EC0C09F; Mon, 10 Oct 2016 17:00:13 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4C607A8C; Mon, 10 Oct 2016 17:00:13 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9AH0CCZ072817; Mon, 10 Oct 2016 17:00:12 GMT (envelope-from jhb@FreeBSD.org) Received: (from jhb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9AH0CXj072816; Mon, 10 Oct 2016 17:00:12 GMT (envelope-from jhb@FreeBSD.org) Message-Id: <201610101700.u9AH0CXj072816@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhb set sender to jhb@FreeBSD.org using -f From: John Baldwin Date: Mon, 10 Oct 2016 17:00:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r306999 - head/release/doc/en_US.ISO8859-1/hardware X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 Oct 2016 17:00:13 -0000 Author: jhb Date: Mon Oct 10 17:00:12 2016 New Revision: 306999 URL: https://svnweb.freebsd.org/changeset/base/306999 Log: Add a missing word. MFC after: 1 month Modified: head/release/doc/en_US.ISO8859-1/hardware/article.xml Modified: head/release/doc/en_US.ISO8859-1/hardware/article.xml ============================================================================== --- head/release/doc/en_US.ISO8859-1/hardware/article.xml Mon Oct 10 16:41:17 2016 (r306998) +++ head/release/doc/en_US.ISO8859-1/hardware/article.xml Mon Oct 10 17:00:12 2016 (r306999) @@ -149,7 +149,7 @@ &intel; EM64T is an extended version of IA-32 (x86) and - different from &intel; IA-64 (Itanium) architecture. Some + different from &intel; IA-64 (Itanium) architecture. Some of &intel;'s old documentation refers to &intel; EM64T as 64-bit extension technology or IA-32e. From owner-svn-src-all@freebsd.org Mon Oct 10 17:16:04 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 5A239C0C3B3; Mon, 10 Oct 2016 17:16:04 +0000 (UTC) (envelope-from avos@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 30F7E34D; Mon, 10 Oct 2016 17:16:04 +0000 (UTC) (envelope-from avos@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9AHG3ED079940; Mon, 10 Oct 2016 17:16:03 GMT (envelope-from avos@FreeBSD.org) Received: (from avos@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9AHG2XI079936; Mon, 10 Oct 2016 17:16:02 GMT (envelope-from avos@FreeBSD.org) Message-Id: <201610101716.u9AHG2XI079936@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avos set sender to avos@FreeBSD.org using -f From: Andriy Voskoboinyk Date: Mon, 10 Oct 2016 17:16:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307000 - in head: . share/man/man9 X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 Oct 2016 17:16:04 -0000 Author: avos Date: Mon Oct 10 17:16:02 2016 New Revision: 307000 URL: https://svnweb.freebsd.org/changeset/base/307000 Log: mbuf(9), mbuf_tags(9): fix function prototypes. - Add m_getclr(9) symlink to ObsoleteFiles.inc (removed in r295481). - Add const qualifiers in m_dup(), m_dup_pkthdr() and m_tag_copy_chain() (r286450). - Fix m_dup_pkthdr() definition (it's not the same as m_move_pkthdr()). MFC after: 5 days Modified: head/ObsoleteFiles.inc head/share/man/man9/Makefile head/share/man/man9/mbuf.9 head/share/man/man9/mbuf_tags.9 Modified: head/ObsoleteFiles.inc ============================================================================== --- head/ObsoleteFiles.inc Mon Oct 10 17:00:12 2016 (r306999) +++ head/ObsoleteFiles.inc Mon Oct 10 17:16:02 2016 (r307000) @@ -38,6 +38,8 @@ # xargs -n1 | sort | uniq -d; # done +# 20161010: remove link to removed m_getclr(9) macro +OLD_FILES+=usr/share/man/man9/m_getclr.9 # 20161003: MK_ELFCOPY_AS_OBJCOPY option retired OLD_FILES+=usr/bin/elfcopy OLD_FILES+=usr/share/man/man1/elfcopy.1.gz Modified: head/share/man/man9/Makefile ============================================================================== --- head/share/man/man9/Makefile Mon Oct 10 17:00:12 2016 (r306999) +++ head/share/man/man9/Makefile Mon Oct 10 17:16:02 2016 (r307000) @@ -1138,7 +1138,6 @@ MLINKS+=\ mbuf.9 m_get2.9 \ mbuf.9 m_getjcl.9 \ mbuf.9 m_getcl.9 \ - mbuf.9 m_getclr.9 \ mbuf.9 MGETHDR.9 \ mbuf.9 m_gethdr.9 \ mbuf.9 m_getm.9 \ Modified: head/share/man/man9/mbuf.9 ============================================================================== --- head/share/man/man9/mbuf.9 Mon Oct 10 17:00:12 2016 (r306999) +++ head/share/man/man9/mbuf.9 Mon Oct 10 17:16:02 2016 (r307000) @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd August 30, 2016 +.Dd October 10, 2016 .Dt MBUF 9 .Os .\" @@ -79,8 +79,6 @@ .Ft struct mbuf * .Fn m_getcl "int how" "short type" "int flags" .Ft struct mbuf * -.Fn m_getclr "int how" "short type" -.Ft struct mbuf * .Fn m_gethdr "int how" "short type" .Ft struct mbuf * .Fn m_free "struct mbuf *mbuf" @@ -107,7 +105,7 @@ .Ft struct mbuf * .Fn m_copypacket "struct mbuf *mbuf" "int how" .Ft struct mbuf * -.Fn m_dup "struct mbuf *mbuf" "int how" +.Fn m_dup "const struct mbuf *mbuf" "int how" .Ft void .Fn m_copydata "const struct mbuf *mbuf" "int offset" "int len" "caddr_t buf" .Ft void @@ -126,8 +124,8 @@ .Fn m_catpkt "struct mbuf *m" "struct mbuf *n" .Ft u_int .Fn m_fixhdr "struct mbuf *mbuf" -.Ft void -.Fn m_dup_pkthdr "struct mbuf *to" "struct mbuf *from" +.Ft int +.Fn m_dup_pkthdr "struct mbuf *to" "const struct mbuf *from" "int how" .Ft void .Fn m_move_pkthdr "struct mbuf *to" "struct mbuf *from" .Ft u_int @@ -602,10 +600,6 @@ This is like but it the size of the cluster allocated will be large enough for .Fa size bytes. -.It Fn m_getclr how type -Allocate an -.Vt mbuf -and zero out the data region. .It Fn m_free mbuf Frees .Vt mbuf . Modified: head/share/man/man9/mbuf_tags.9 ============================================================================== --- head/share/man/man9/mbuf_tags.9 Mon Oct 10 17:00:12 2016 (r306999) +++ head/share/man/man9/mbuf_tags.9 Mon Oct 10 17:16:02 2016 (r307000) @@ -33,7 +33,7 @@ .Ft "struct m_tag *" .Fn m_tag_copy "struct m_tag *t" "int how" .Ft int -.Fn m_tag_copy_chain "struct mbuf *to" "struct mbuf *from" "int how" +.Fn m_tag_copy_chain "struct mbuf *to" "const struct mbuf *from" "int how" .Ft void .Fn m_tag_delete "struct mbuf *m" "struct m_tag *t" .Ft void From owner-svn-src-all@freebsd.org Mon Oct 10 17:18:24 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id EEFCCC0C412; Mon, 10 Oct 2016 17:18:24 +0000 (UTC) (envelope-from avos@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id B5CE1766; Mon, 10 Oct 2016 17:18:24 +0000 (UTC) (envelope-from avos@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9AHINwL080057; Mon, 10 Oct 2016 17:18:23 GMT (envelope-from avos@FreeBSD.org) Received: (from avos@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9AHINd2080056; Mon, 10 Oct 2016 17:18:23 GMT (envelope-from avos@FreeBSD.org) Message-Id: <201610101718.u9AHINd2080056@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avos set sender to avos@FreeBSD.org using -f From: Andriy Voskoboinyk Date: Mon, 10 Oct 2016 17:18:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307001 - head X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 Oct 2016 17:18:25 -0000 Author: avos Date: Mon Oct 10 17:18:23 2016 New Revision: 307001 URL: https://svnweb.freebsd.org/changeset/base/307001 Log: Add missing *.gz extension. Modified: head/ObsoleteFiles.inc Modified: head/ObsoleteFiles.inc ============================================================================== --- head/ObsoleteFiles.inc Mon Oct 10 17:16:02 2016 (r307000) +++ head/ObsoleteFiles.inc Mon Oct 10 17:18:23 2016 (r307001) @@ -39,7 +39,7 @@ # done # 20161010: remove link to removed m_getclr(9) macro -OLD_FILES+=usr/share/man/man9/m_getclr.9 +OLD_FILES+=usr/share/man/man9/m_getclr.9.gz # 20161003: MK_ELFCOPY_AS_OBJCOPY option retired OLD_FILES+=usr/bin/elfcopy OLD_FILES+=usr/share/man/man1/elfcopy.1.gz From owner-svn-src-all@freebsd.org Mon Oct 10 17:21:27 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A41BDC0C490; Mon, 10 Oct 2016 17:21:27 +0000 (UTC) (envelope-from cse.cem@gmail.com) Received: from mail-io0-f178.google.com (mail-io0-f178.google.com [209.85.223.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 183D29BD; Mon, 10 Oct 2016 17:21:27 +0000 (UTC) (envelope-from cse.cem@gmail.com) Received: by mail-io0-f178.google.com with SMTP id q192so118049441iod.0; Mon, 10 Oct 2016 10:21:27 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:reply-to:in-reply-to:references :from:date:message-id:subject:to:cc; bh=bwVek/zWoj0aofDu1oUriTo7k0+aXhV9rSr2/roD5wQ=; b=eq5Moq99018jnGkYEKHjDoNzGb2T2T2iyIPLb/KWqLU0I7+ZHQJW1grdR8yIRyduwh OTM3HJz2RS9kGMfgIiOVOPnBq42WlOFlcTq4w9KcbAHvyOsKxs66a0ln65/EsoJ3kpFU tVw7Jxl/z6jH2UjGknl85b9/kAdVrGebKhd51OCfm7EZKstIGa7TODh21efAzi6pqRFi bi28J5qfWlDk1TUDMMUV2Gb4mLqQ2r3424y+iJXyJUMiephqkU4f9vS9Icv/GEsVeUeR jSUMOqVS8TV8eVd7jP6nDHJIp7Wwx2K2OHbog++FlrRLOeQJaMUSOCLtXcYsuVoZ0BfS WV8A== X-Gm-Message-State: AA6/9RnTu3TWH4mFD8qXOUeVtJlJWpdgFlXoEUU4Ht3PGRFaNK6M1ZyIqGTeyVrbbMv4vQ== X-Received: by 10.107.130.16 with SMTP id e16mr34003298iod.38.1476120080414; Mon, 10 Oct 2016 10:21:20 -0700 (PDT) Received: from mail-io0-f182.google.com (mail-io0-f182.google.com. [209.85.223.182]) by smtp.gmail.com with ESMTPSA id e69sm4619909iod.39.2016.10.10.10.21.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 10 Oct 2016 10:21:20 -0700 (PDT) Received: by mail-io0-f182.google.com with SMTP id q192so118049075iod.0; Mon, 10 Oct 2016 10:21:19 -0700 (PDT) X-Received: by 10.107.168.96 with SMTP id r93mr32589024ioe.31.1476120079707; Mon, 10 Oct 2016 10:21:19 -0700 (PDT) MIME-Version: 1.0 Reply-To: cem@freebsd.org Received: by 10.36.220.129 with HTTP; Mon, 10 Oct 2016 10:21:19 -0700 (PDT) In-Reply-To: <20161010165038.GA31246@bsdpad.com> References: <201610101340.u9ADe5XW093068@repo.freebsd.org> <20161010165038.GA31246@bsdpad.com> From: Conrad Meyer Date: Mon, 10 Oct 2016 10:21:19 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: svn commit: r306962 - head/tests/sys/kern/pipe To: Ruslan Bukin Cc: Ruslan Bukin , src-committers , svn-src-all@freebsd.org, svn-src-head@freebsd.org Content-Type: text/plain; charset=UTF-8 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 Oct 2016 17:21:27 -0000 On Mon, Oct 10, 2016 at 9:50 AM, Ruslan Bukin wrote: > On Mon, Oct 10, 2016 at 08:04:44AM -0700, Conrad Meyer wrote: >> We also observed this test was broken, but I think the right fix is >> much smaller: >> >> --- a/tests/sys/kern/pipe/pipe_fstat_bug_test.c >> +++ b/tests/sys/kern/pipe/pipe_fstat_bug_test.c >> @@ -108,7 +108,6 @@ main(void) >> SYNC_W(0, go2); >> >> SYNC_R(0, go); >> - SYNC_W(0, go2); /* XXX: why is this required? */ >> WRITE(8192); >> SYNC_W(0, go2); >> >> (That line breaks the synchronization mechanism that is the only >> guarantee the test passes.) > > There is some direct mode activated when you send >=8192, > so this line is required Given that line breaks the parent-child synchronization entirely and your kevent replaces it, why not remove the remaining go/go2 pipe and read/writes? Best, Conrad From owner-svn-src-all@freebsd.org Mon Oct 10 18:13:25 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 04FC9C0C416; Mon, 10 Oct 2016 18:13:25 +0000 (UTC) (envelope-from nparhar@gmail.com) Received: from mail-qk0-x244.google.com (mail-qk0-x244.google.com [IPv6:2607:f8b0:400d:c09::244]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id B0BBFB9E; Mon, 10 Oct 2016 18:13:24 +0000 (UTC) (envelope-from nparhar@gmail.com) Received: by mail-qk0-x244.google.com with SMTP id v138so6255823qka.2; Mon, 10 Oct 2016 11:13:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:subject:to:references:cc:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding; bh=xy+VCYNQFAyFehGIVpOwi813nVtqMhS+rHIJyQrnKYs=; b=RhO5hjjexCyBQ+5JM6Q38Q0r37qjnESPBJwDufyT+5HxcpPvUUkTgGD7vJlIgMAF+M TTViV5MoCOT5krPbKEc6XVAi8gkyyRpYkFRp1lxlB2ovmdrts+09jmYqR6ZBHG2ZVPpM n84vIj6w/go64MDkJti9inydcUjQ5RB+FwU+U3aS09fTQtoPmsfusrc0MOVtOzYnSoOa GVPwb4Q5B4rx+VvRhjl/7leuYg4zRgLVH/l8Ti3tYfmOGS9XELJapJo+73IhLWDPJjKJ ew2jSHyKRCrRmBBAX51GXRXEw5ftPWAqQoabZ2CUvHRAqQ9IsWqd/7Uz57O/BYRxth61 uSqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:subject:to:references:cc:from:message-id :date:user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=xy+VCYNQFAyFehGIVpOwi813nVtqMhS+rHIJyQrnKYs=; b=kPxmuwx4MBIMw0awknoFZkgSIIryIOkjWVSuuy73/9aI149yWEnxsYU9EUtBGHB+pE V6VhIVXVJEyh7XDwd9WcAJCE5xTRE+UiTgq/GvYa+8/b2DT4vMiT4jn2oAPrAL7WUg1q 8WiTb5czI89VDTSkPsHWuluwjEKNjzdb0kWPNeHMtgC3trFN6LDo82pkQ642wzikERnu xlwhRaiC8BmbwhDPpgfYLmtB+WEW934okkRc/ULwKumF3bXw9QUUdzyd8E6bjMGME88q t9v8grVeUiExD8S0uytkdnG5JSSu63oVw21Rd+mgTHkI9F/pnWpqKSulyg4f2jZVomH6 5OIg== X-Gm-Message-State: AA6/9RlNVRUvBIp1X8MawKcPuBqaz62i2rBcSWTD1Ij3NSHXWXrzgxcwxh91STBHlKOSiQ== X-Received: by 10.55.92.135 with SMTP id q129mr35943715qkb.52.1476123203664; Mon, 10 Oct 2016 11:13:23 -0700 (PDT) Received: from [10.192.166.0] (stargate.chelsio.com. [12.32.117.8]) by smtp.googlemail.com with ESMTPSA id o25sm7623453qta.39.2016.10.10.11.13.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 10 Oct 2016 11:13:22 -0700 (PDT) Sender: Navdeep Parhar Subject: Re: svn commit: r306661 - in stable/11/sys/dev/cxgbe: . tom To: Slawa Olhovchenkov , John Baldwin References: <201610032315.u93NFiHE057529@repo.freebsd.org> <20161010110901.GH6177@zxy.spb.ru> Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org From: Navdeep Parhar Message-ID: Date: Mon, 10 Oct 2016 11:13:20 -0700 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <20161010110901.GH6177@zxy.spb.ru> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 Oct 2016 18:13:25 -0000 On 10/10/2016 04:09, Slawa Olhovchenkov wrote: > On Mon, Oct 03, 2016 at 11:15:44PM +0000, John Baldwin wrote: > >> Author: jhb >> Date: Mon Oct 3 23:15:44 2016 >> New Revision: 306661 >> URL: https://svnweb.freebsd.org/changeset/base/306661 >> >> Log: >> MFC 303405: Add support for zero-copy aio_write() on TOE sockets. >> >> ... > > Do you have any public available application patches for support this? netperf has support for AIO in its trunk/ branch and I assume it will be part of the next netperf release. > May be nginx? > You don't need any patches if nginx supports AIO (aio_write(2) on the socket) already. There's usually a knob in such applications that lets you select the method it uses to transmit data. That's probably the best place to start looking. Regards, Navdeep From owner-svn-src-all@freebsd.org Mon Oct 10 18:19:40 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 4C64FC0C529; Mon, 10 Oct 2016 18:19:40 +0000 (UTC) (envelope-from slw@zxy.spb.ru) Received: from zxy.spb.ru (zxy.spb.ru [195.70.199.98]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 0B95AE1D; Mon, 10 Oct 2016 18:19:40 +0000 (UTC) (envelope-from slw@zxy.spb.ru) Received: from slw by zxy.spb.ru with local (Exim 4.86 (FreeBSD)) (envelope-from ) id 1btfAn-000I8o-TI; Mon, 10 Oct 2016 21:19:37 +0300 Date: Mon, 10 Oct 2016 21:19:37 +0300 From: Slawa Olhovchenkov To: Navdeep Parhar Cc: John Baldwin , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: Re: svn commit: r306661 - in stable/11/sys/dev/cxgbe: . tom Message-ID: <20161010181937.GY54003@zxy.spb.ru> References: <201610032315.u93NFiHE057529@repo.freebsd.org> <20161010110901.GH6177@zxy.spb.ru> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) X-SA-Exim-Connect-IP: X-SA-Exim-Mail-From: slw@zxy.spb.ru X-SA-Exim-Scanned: No (on zxy.spb.ru); SAEximRunCond expanded to false X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 Oct 2016 18:19:40 -0000 On Mon, Oct 10, 2016 at 11:13:20AM -0700, Navdeep Parhar wrote: > On 10/10/2016 04:09, Slawa Olhovchenkov wrote: > > On Mon, Oct 03, 2016 at 11:15:44PM +0000, John Baldwin wrote: > > > >> Author: jhb > >> Date: Mon Oct 3 23:15:44 2016 > >> New Revision: 306661 > >> URL: https://svnweb.freebsd.org/changeset/base/306661 > >> > >> Log: > >> MFC 303405: Add support for zero-copy aio_write() on TOE sockets. > >> > >> ... > > > > Do you have any public available application patches for support this? > > netperf has support for AIO in its trunk/ branch and I assume it will be > part of the next netperf release. > > > May be nginx? > > > > You don't need any patches if nginx supports AIO (aio_write(2) on the > socket) already. There's usually a knob in such applications that lets No, nginx currently don't supports AIO on the socket. > you select the method it uses to transmit data. That's probably the > best place to start looking. > > Regards, > Navdeep From owner-svn-src-all@freebsd.org Mon Oct 10 18:25:43 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 2BEDDC0C858; Mon, 10 Oct 2016 18:25:43 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from mail.baldwin.cx (bigwig.baldwin.cx [96.47.65.170]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 0A660812; Mon, 10 Oct 2016 18:25:42 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from ralph.baldwin.cx (c-73-231-226-104.hsd1.ca.comcast.net [73.231.226.104]) by mail.baldwin.cx (Postfix) with ESMTPSA id D3E9010AF6B; Mon, 10 Oct 2016 14:25:41 -0400 (EDT) From: John Baldwin To: Slawa Olhovchenkov Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: Re: svn commit: r306661 - in stable/11/sys/dev/cxgbe: . tom Date: Mon, 10 Oct 2016 10:46:27 -0700 Message-ID: <1660024.uzJn2AtV1k@ralph.baldwin.cx> User-Agent: KMail/4.14.10 (FreeBSD/11.0-PRERELEASE; KDE/4.14.10; amd64; ; ) In-Reply-To: <20161010110901.GH6177@zxy.spb.ru> References: <201610032315.u93NFiHE057529@repo.freebsd.org> <20161010110901.GH6177@zxy.spb.ru> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.4.3 (mail.baldwin.cx); Mon, 10 Oct 2016 14:25:41 -0400 (EDT) X-Virus-Scanned: clamav-milter 0.99.2 at mail.baldwin.cx X-Virus-Status: Clean X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 Oct 2016 18:25:43 -0000 On Monday, October 10, 2016 02:09:01 PM Slawa Olhovchenkov wrote: > On Mon, Oct 03, 2016 at 11:15:44PM +0000, John Baldwin wrote: > > > Author: jhb > > Date: Mon Oct 3 23:15:44 2016 > > New Revision: 306661 > > URL: https://svnweb.freebsd.org/changeset/base/306661 > > > > Log: > > MFC 303405: Add support for zero-copy aio_write() on TOE sockets. > > > > AIO write requests for a TOE socket on a Chelsio T4+ adapter can now > > DMA directly from the user-supplied buffer. This is implemented by > > wiring the pages backing the user-supplied buffer and queueing special > > mbufs backed by raw VM pages to the socket buffer. The TOE code > > recognizes these special mbufs and builds a sglist from the VM page > > array associated with the mbuf when queueing a work request to the TOE. > > > > Because these mbufs do not have an associated virtual address, m_data > > is not valid. Thus, the AIO handler does not invoke sosend() directly > > for these mbufs but instead inlines portions of sosend_generic() and > > tcp_usr_send(). > > > > An aiotx_buffer structure is used to describe the user buffer (e.g. > > it holds the array of VM pages and a reference to the AIO job). The > > special mbufs reference this structure via m_ext. Note that a single > > job might be split across multiple mbufs (e.g. if it is larger than > > the socket buffer size). The 'ext_arg2' member of each mbuf gives an > > offset relative to the backing aiotx_buffer. The AIO job associated > > with an aiotx_buffer structure is completed when the last reference to > > the structure is released. > > > > Zero-copy aio_write()'s for connections associated with a given > > adapter can be enabled/disabled at runtime via the > > 'dev.t[45]nex.N.toe.tx_zcopy' sysctl. > > > > Sponsored by: Chelsio Communications > > Do you have any public available application patches for support this? > May be nginx? Applications need to use aio_read(), ideally with at least 2 buffers (so queue two reads, then when a read completes, consume the data and do the next read). I'm not sure nginx will find this but so useful as web servers tend to send a lot more data than they receive. The only software I have patched explicitly for this is netperf. -- John Baldwin From owner-svn-src-all@freebsd.org Mon Oct 10 18:28:23 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id F2AFEC0C95C; Mon, 10 Oct 2016 18:28:23 +0000 (UTC) (envelope-from slw@zxy.spb.ru) Received: from zxy.spb.ru (zxy.spb.ru [195.70.199.98]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id B3756AED; Mon, 10 Oct 2016 18:28:23 +0000 (UTC) (envelope-from slw@zxy.spb.ru) Received: from slw by zxy.spb.ru with local (Exim 4.86 (FreeBSD)) (envelope-from ) id 1btfJF-000IPU-P4; Mon, 10 Oct 2016 21:28:21 +0300 Date: Mon, 10 Oct 2016 21:28:21 +0300 From: Slawa Olhovchenkov To: John Baldwin Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: Re: svn commit: r306661 - in stable/11/sys/dev/cxgbe: . tom Message-ID: <20161010182821.GZ54003@zxy.spb.ru> References: <201610032315.u93NFiHE057529@repo.freebsd.org> <20161010110901.GH6177@zxy.spb.ru> <1660024.uzJn2AtV1k@ralph.baldwin.cx> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1660024.uzJn2AtV1k@ralph.baldwin.cx> User-Agent: Mutt/1.5.24 (2015-08-30) X-SA-Exim-Connect-IP: X-SA-Exim-Mail-From: slw@zxy.spb.ru X-SA-Exim-Scanned: No (on zxy.spb.ru); SAEximRunCond expanded to false X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 Oct 2016 18:28:24 -0000 On Mon, Oct 10, 2016 at 10:46:27AM -0700, John Baldwin wrote: > On Monday, October 10, 2016 02:09:01 PM Slawa Olhovchenkov wrote: > > On Mon, Oct 03, 2016 at 11:15:44PM +0000, John Baldwin wrote: > > > > > Author: jhb > > > Date: Mon Oct 3 23:15:44 2016 > > > New Revision: 306661 > > > URL: https://svnweb.freebsd.org/changeset/base/306661 > > > > > > Log: > > > MFC 303405: Add support for zero-copy aio_write() on TOE sockets. > > > > > > AIO write requests for a TOE socket on a Chelsio T4+ adapter can now > > > DMA directly from the user-supplied buffer. This is implemented by > > > wiring the pages backing the user-supplied buffer and queueing special > > > mbufs backed by raw VM pages to the socket buffer. The TOE code > > > recognizes these special mbufs and builds a sglist from the VM page > > > array associated with the mbuf when queueing a work request to the TOE. > > > > > > Because these mbufs do not have an associated virtual address, m_data > > > is not valid. Thus, the AIO handler does not invoke sosend() directly > > > for these mbufs but instead inlines portions of sosend_generic() and > > > tcp_usr_send(). > > > > > > An aiotx_buffer structure is used to describe the user buffer (e.g. > > > it holds the array of VM pages and a reference to the AIO job). The > > > special mbufs reference this structure via m_ext. Note that a single > > > job might be split across multiple mbufs (e.g. if it is larger than > > > the socket buffer size). The 'ext_arg2' member of each mbuf gives an > > > offset relative to the backing aiotx_buffer. The AIO job associated > > > with an aiotx_buffer structure is completed when the last reference to > > > the structure is released. > > > > > > Zero-copy aio_write()'s for connections associated with a given > > > adapter can be enabled/disabled at runtime via the > > > 'dev.t[45]nex.N.toe.tx_zcopy' sysctl. > > > > > > Sponsored by: Chelsio Communications > > > > Do you have any public available application patches for support this? > > May be nginx? > > Applications need to use aio_read(), ideally with at least 2 buffers (so > queue two reads, then when a read completes, consume the data and do the > next read). I'm not sure nginx will find this but so useful as web servers > tend to send a lot more data than they receive. The only software I have > patched explicitly for this is netperf. Hm, this is like only aio_read() on sokets give performance boost, not aio_write()? From owner-svn-src-all@freebsd.org Mon Oct 10 18:34:09 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 365A8C0CAAC; Mon, 10 Oct 2016 18:34:09 +0000 (UTC) (envelope-from nparhar@gmail.com) Received: from mail-qt0-f177.google.com (mail-qt0-f177.google.com [209.85.216.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id DE45CEB9; Mon, 10 Oct 2016 18:34:08 +0000 (UTC) (envelope-from nparhar@gmail.com) Received: by mail-qt0-f177.google.com with SMTP id q7so63503723qtq.1; Mon, 10 Oct 2016 11:34:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:to:references:cc:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding; bh=ca1aqN8BPnAqQEme5Q0GzkPFrbVT/qf31+HfWHtiVwo=; b=Lx3PK3oBUr8H8w+DMUVwb2OivLUC5M4Mjid2PHrLXYNQ+GRNQgnmFDmqiOKdk+nKS/ Llsz7DMjI+hYTCdZRv7ywlKGAt7eIFRngFHfLoBBl0zFswcrBD5YrE9fdv+8iO4PfrzO +tHnzm+h/b8TPZFsx6nmKEPpwEabE5hbmQSiPeeDaIZ6vTuDTExpjH7LuCA4ynD3873F WvUTNvObbtvoAcdyVw6axMHsDuzElA0EqhYu+MObUmkI2gLkSaDc83np+vdw283oqqaf ouygKscJFoyWk0kc48KCn8otXme+1d4rcWQeTlJd9KDlC2Y/jwOyGNApDegWszLC/msy ABvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:to:references:cc:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=ca1aqN8BPnAqQEme5Q0GzkPFrbVT/qf31+HfWHtiVwo=; b=Hem3lgaWh8+rTMLFZIK42pqzChairOwgOx37S7QmbiRnZurF0M9UsTtGhuDkzHXRqF Ilg8OWZzHhz+uOi2XckDf2FnCKDQVRQetyo4dXX5+cM03H8AdZNjaww2dfuUWyZU7hZd GEU08TDkM80e0hMMA9NC9xUJX0gv17G7lB8mnDl2enmmtBeJUwzP++Sc+c4fD1yqeRHL qTuFw4wdeGm8O9Mob2B+sscLj4KXZ2kl8pNFSvlG1YUGnFf9YEb73e+z7DS5l3LHGTvv X4GIoNHEcNGm79xN7V2HyzewMDif75P9Yvu/1eKZ8u3u5pag7eCtH9/bbt7XP2NfiG8N xf1Q== X-Gm-Message-State: AA6/9RmP3ilLNkxIECfuQ79tEbg7ecJM2RNqe2MrmcRq7AEPeyCwbdixLYSGDfonqNAg1Q== X-Received: by 10.200.42.130 with SMTP id b2mr34048357qta.102.1476124382114; Mon, 10 Oct 2016 11:33:02 -0700 (PDT) Received: from [10.192.166.0] (stargate.chelsio.com. [12.32.117.8]) by smtp.googlemail.com with ESMTPSA id j2sm1126049qtb.46.2016.10.10.11.33.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 10 Oct 2016 11:33:01 -0700 (PDT) Subject: Re: svn commit: r306661 - in stable/11/sys/dev/cxgbe: . tom To: Slawa Olhovchenkov , John Baldwin References: <201610032315.u93NFiHE057529@repo.freebsd.org> <20161010110901.GH6177@zxy.spb.ru> <1660024.uzJn2AtV1k@ralph.baldwin.cx> <20161010182821.GZ54003@zxy.spb.ru> Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org From: Navdeep Parhar Message-ID: Date: Mon, 10 Oct 2016 11:32:59 -0700 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <20161010182821.GZ54003@zxy.spb.ru> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 Oct 2016 18:34:09 -0000 On 10/10/2016 11:28, Slawa Olhovchenkov wrote: > On Mon, Oct 10, 2016 at 10:46:27AM -0700, John Baldwin wrote: > >> On Monday, October 10, 2016 02:09:01 PM Slawa Olhovchenkov wrote: >>> On Mon, Oct 03, 2016 at 11:15:44PM +0000, John Baldwin wrote: >>> >>>> Author: jhb >>>> Date: Mon Oct 3 23:15:44 2016 >>>> New Revision: 306661 >>>> URL: https://svnweb.freebsd.org/changeset/base/306661 >>>> >>>> Log: >>>> MFC 303405: Add support for zero-copy aio_write() on TOE sockets. >>>> >>>> AIO write requests for a TOE socket on a Chelsio T4+ adapter can now >>>> DMA directly from the user-supplied buffer. This is implemented by >>>> wiring the pages backing the user-supplied buffer and queueing special >>>> mbufs backed by raw VM pages to the socket buffer. The TOE code >>>> recognizes these special mbufs and builds a sglist from the VM page >>>> array associated with the mbuf when queueing a work request to the TOE. >>>> >>>> Because these mbufs do not have an associated virtual address, m_data >>>> is not valid. Thus, the AIO handler does not invoke sosend() directly >>>> for these mbufs but instead inlines portions of sosend_generic() and >>>> tcp_usr_send(). >>>> >>>> An aiotx_buffer structure is used to describe the user buffer (e.g. >>>> it holds the array of VM pages and a reference to the AIO job). The >>>> special mbufs reference this structure via m_ext. Note that a single >>>> job might be split across multiple mbufs (e.g. if it is larger than >>>> the socket buffer size). The 'ext_arg2' member of each mbuf gives an >>>> offset relative to the backing aiotx_buffer. The AIO job associated >>>> with an aiotx_buffer structure is completed when the last reference to >>>> the structure is released. >>>> >>>> Zero-copy aio_write()'s for connections associated with a given >>>> adapter can be enabled/disabled at runtime via the >>>> 'dev.t[45]nex.N.toe.tx_zcopy' sysctl. >>>> >>>> Sponsored by: Chelsio Communications >>> >>> Do you have any public available application patches for support this? >>> May be nginx? >> >> Applications need to use aio_read(), ideally with at least 2 buffers (so >> queue two reads, then when a read completes, consume the data and do the >> next read). I'm not sure nginx will find this but so useful as web servers >> tend to send a lot more data than they receive. The only software I have >> patched explicitly for this is netperf. > > Hm, this is like only aio_read() on sokets give performance boost, not > aio_write()? > Both. tx_zcopy is the knob for aio_write and ddp is the knob for aio_read. ddp will probably get renamed to rx_zcopy (while still working with the 'ddp' name for backward compat). From owner-svn-src-all@freebsd.org Mon Oct 10 18:36:27 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id AD01AC0CB4E; Mon, 10 Oct 2016 18:36:27 +0000 (UTC) (envelope-from maxim@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 7B595102E; Mon, 10 Oct 2016 18:36:27 +0000 (UTC) (envelope-from maxim@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9AIaQpw010736; Mon, 10 Oct 2016 18:36:26 GMT (envelope-from maxim@FreeBSD.org) Received: (from maxim@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9AIaQbo010735; Mon, 10 Oct 2016 18:36:26 GMT (envelope-from maxim@FreeBSD.org) Message-Id: <201610101836.u9AIaQbo010735@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: maxim set sender to maxim@FreeBSD.org using -f From: Maxim Konovalov Date: Mon, 10 Oct 2016 18:36:26 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307002 - head/share/misc X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 Oct 2016 18:36:27 -0000 Author: maxim Date: Mon Oct 10 18:36:26 2016 New Revision: 307002 URL: https://svnweb.freebsd.org/changeset/base/307002 Log: FreeBSD 11.0 release date added. Modified: head/share/misc/bsd-family-tree Modified: head/share/misc/bsd-family-tree ============================================================================== --- head/share/misc/bsd-family-tree Mon Oct 10 17:18:23 2016 (r307001) +++ head/share/misc/bsd-family-tree Mon Oct 10 18:36:26 2016 (r307002) @@ -703,6 +703,7 @@ FreeBSD 10.3 2016-04-04 [FBD] NetBSD 7.0.1 2016-05-22 [NBD] DragonFly 4.6.0 2016-08-02 [DFB] OpenBSD 6.0 2016-09-01 [OBD] +FreeBSD 11.0 2016-10-10 [FBD] Bibliography ------------------------ From owner-svn-src-all@freebsd.org Mon Oct 10 18:40:30 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 6D4BEC0CC14; Mon, 10 Oct 2016 18:40:30 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from mail.baldwin.cx (bigwig.baldwin.cx [IPv6:2001:470:1f11:75::1]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4851B11FC; Mon, 10 Oct 2016 18:40:30 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from ralph.baldwin.cx (c-73-231-226-104.hsd1.ca.comcast.net [73.231.226.104]) by mail.baldwin.cx (Postfix) with ESMTPSA id 81B7410AF69; Mon, 10 Oct 2016 14:40:28 -0400 (EDT) From: John Baldwin To: Slawa Olhovchenkov Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: Re: svn commit: r306661 - in stable/11/sys/dev/cxgbe: . tom Date: Mon, 10 Oct 2016 11:39:24 -0700 Message-ID: <5243602.cilUCEM5cP@ralph.baldwin.cx> User-Agent: KMail/4.14.10 (FreeBSD/11.0-PRERELEASE; KDE/4.14.10; amd64; ; ) In-Reply-To: <20161010182821.GZ54003@zxy.spb.ru> References: <201610032315.u93NFiHE057529@repo.freebsd.org> <1660024.uzJn2AtV1k@ralph.baldwin.cx> <20161010182821.GZ54003@zxy.spb.ru> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.4.3 (mail.baldwin.cx); Mon, 10 Oct 2016 14:40:28 -0400 (EDT) X-Virus-Scanned: clamav-milter 0.99.2 at mail.baldwin.cx X-Virus-Status: Clean X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 Oct 2016 18:40:30 -0000 On Monday, October 10, 2016 09:28:21 PM Slawa Olhovchenkov wrote: > On Mon, Oct 10, 2016 at 10:46:27AM -0700, John Baldwin wrote: > > > On Monday, October 10, 2016 02:09:01 PM Slawa Olhovchenkov wrote: > > > On Mon, Oct 03, 2016 at 11:15:44PM +0000, John Baldwin wrote: > > > > > > > Author: jhb > > > > Date: Mon Oct 3 23:15:44 2016 > > > > New Revision: 306661 > > > > URL: https://svnweb.freebsd.org/changeset/base/306661 > > > > > > > > Log: > > > > MFC 303405: Add support for zero-copy aio_write() on TOE sockets. > > > > > > > > AIO write requests for a TOE socket on a Chelsio T4+ adapter can now > > > > DMA directly from the user-supplied buffer. This is implemented by > > > > wiring the pages backing the user-supplied buffer and queueing special > > > > mbufs backed by raw VM pages to the socket buffer. The TOE code > > > > recognizes these special mbufs and builds a sglist from the VM page > > > > array associated with the mbuf when queueing a work request to the TOE. > > > > > > > > Because these mbufs do not have an associated virtual address, m_data > > > > is not valid. Thus, the AIO handler does not invoke sosend() directly > > > > for these mbufs but instead inlines portions of sosend_generic() and > > > > tcp_usr_send(). > > > > > > > > An aiotx_buffer structure is used to describe the user buffer (e.g. > > > > it holds the array of VM pages and a reference to the AIO job). The > > > > special mbufs reference this structure via m_ext. Note that a single > > > > job might be split across multiple mbufs (e.g. if it is larger than > > > > the socket buffer size). The 'ext_arg2' member of each mbuf gives an > > > > offset relative to the backing aiotx_buffer. The AIO job associated > > > > with an aiotx_buffer structure is completed when the last reference to > > > > the structure is released. > > > > > > > > Zero-copy aio_write()'s for connections associated with a given > > > > adapter can be enabled/disabled at runtime via the > > > > 'dev.t[45]nex.N.toe.tx_zcopy' sysctl. > > > > > > > > Sponsored by: Chelsio Communications > > > > > > Do you have any public available application patches for support this? > > > May be nginx? > > > > Applications need to use aio_read(), ideally with at least 2 buffers (so > > queue two reads, then when a read completes, consume the data and do the > > next read). I'm not sure nginx will find this but so useful as web servers > > tend to send a lot more data than they receive. The only software I have > > patched explicitly for this is netperf. > > Hm, this is like only aio_read() on sokets give performance boost, not > aio_write()? Sorry, I was confused on the commit, this does affect aio_write() (earlier changes also permit zero-copy for receive via aio_read()). However, as you noted in the reply to Navdeep, it seems that nginx only supports using AIO on the backing files for static content it seems. It would need changes to support using aio_write on sockets (similar to using sendfile). -- John Baldwin From owner-svn-src-all@freebsd.org Mon Oct 10 18:44:00 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id AD897C0CD55; Mon, 10 Oct 2016 18:44:00 +0000 (UTC) (envelope-from slw@zxy.spb.ru) Received: from zxy.spb.ru (zxy.spb.ru [195.70.199.98]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 6D2C7163E; Mon, 10 Oct 2016 18:44:00 +0000 (UTC) (envelope-from slw@zxy.spb.ru) Received: from slw by zxy.spb.ru with local (Exim 4.86 (FreeBSD)) (envelope-from ) id 1btfYL-000Iqo-3q; Mon, 10 Oct 2016 21:43:57 +0300 Date: Mon, 10 Oct 2016 21:43:57 +0300 From: Slawa Olhovchenkov To: John Baldwin Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: Re: svn commit: r306661 - in stable/11/sys/dev/cxgbe: . tom Message-ID: <20161010184357.GB54003@zxy.spb.ru> References: <201610032315.u93NFiHE057529@repo.freebsd.org> <1660024.uzJn2AtV1k@ralph.baldwin.cx> <20161010182821.GZ54003@zxy.spb.ru> <5243602.cilUCEM5cP@ralph.baldwin.cx> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5243602.cilUCEM5cP@ralph.baldwin.cx> User-Agent: Mutt/1.5.24 (2015-08-30) X-SA-Exim-Connect-IP: X-SA-Exim-Mail-From: slw@zxy.spb.ru X-SA-Exim-Scanned: No (on zxy.spb.ru); SAEximRunCond expanded to false X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 Oct 2016 18:44:00 -0000 On Mon, Oct 10, 2016 at 11:39:24AM -0700, John Baldwin wrote: > On Monday, October 10, 2016 09:28:21 PM Slawa Olhovchenkov wrote: > > On Mon, Oct 10, 2016 at 10:46:27AM -0700, John Baldwin wrote: > > > > > On Monday, October 10, 2016 02:09:01 PM Slawa Olhovchenkov wrote: > > > > On Mon, Oct 03, 2016 at 11:15:44PM +0000, John Baldwin wrote: > > > > > > > > > Author: jhb > > > > > Date: Mon Oct 3 23:15:44 2016 > > > > > New Revision: 306661 > > > > > URL: https://svnweb.freebsd.org/changeset/base/306661 > > > > > > > > > > Log: > > > > > MFC 303405: Add support for zero-copy aio_write() on TOE sockets. > > > > > > > > > > AIO write requests for a TOE socket on a Chelsio T4+ adapter can now > > > > > DMA directly from the user-supplied buffer. This is implemented by > > > > > wiring the pages backing the user-supplied buffer and queueing special > > > > > mbufs backed by raw VM pages to the socket buffer. The TOE code > > > > > recognizes these special mbufs and builds a sglist from the VM page > > > > > array associated with the mbuf when queueing a work request to the TOE. > > > > > > > > > > Because these mbufs do not have an associated virtual address, m_data > > > > > is not valid. Thus, the AIO handler does not invoke sosend() directly > > > > > for these mbufs but instead inlines portions of sosend_generic() and > > > > > tcp_usr_send(). > > > > > > > > > > An aiotx_buffer structure is used to describe the user buffer (e.g. > > > > > it holds the array of VM pages and a reference to the AIO job). The > > > > > special mbufs reference this structure via m_ext. Note that a single > > > > > job might be split across multiple mbufs (e.g. if it is larger than > > > > > the socket buffer size). The 'ext_arg2' member of each mbuf gives an > > > > > offset relative to the backing aiotx_buffer. The AIO job associated > > > > > with an aiotx_buffer structure is completed when the last reference to > > > > > the structure is released. > > > > > > > > > > Zero-copy aio_write()'s for connections associated with a given > > > > > adapter can be enabled/disabled at runtime via the > > > > > 'dev.t[45]nex.N.toe.tx_zcopy' sysctl. > > > > > > > > > > Sponsored by: Chelsio Communications > > > > > > > > Do you have any public available application patches for support this? > > > > May be nginx? > > > > > > Applications need to use aio_read(), ideally with at least 2 buffers (so > > > queue two reads, then when a read completes, consume the data and do the > > > next read). I'm not sure nginx will find this but so useful as web servers > > > tend to send a lot more data than they receive. The only software I have > > > patched explicitly for this is netperf. > > > > Hm, this is like only aio_read() on sokets give performance boost, not > > aio_write()? > > Sorry, I was confused on the commit, this does affect aio_write() (earlier > changes also permit zero-copy for receive via aio_read()). However, as you > noted in the reply to Navdeep, it seems that nginx only supports using > AIO on the backing files for static content it seems. It would need changes > to support using aio_write on sockets (similar to using sendfile). Thanks You don't planed to do this? From owner-svn-src-all@freebsd.org Mon Oct 10 19:09:36 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B6891C0C1DA; Mon, 10 Oct 2016 19:09:36 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 76A95164; Mon, 10 Oct 2016 19:09:36 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9AJ9ZWZ022086; Mon, 10 Oct 2016 19:09:35 GMT (envelope-from emaste@FreeBSD.org) Received: (from emaste@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9AJ9ZH0022085; Mon, 10 Oct 2016 19:09:35 GMT (envelope-from emaste@FreeBSD.org) Message-Id: <201610101909.u9AJ9ZH0022085@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: emaste set sender to emaste@FreeBSD.org using -f From: Ed Maste Date: Mon, 10 Oct 2016 19:09:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307003 - head/contrib/mdocml X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 Oct 2016 19:09:36 -0000 Author: emaste Date: Mon Oct 10 19:09:35 2016 New Revision: 307003 URL: https://svnweb.freebsd.org/changeset/base/307003 Log: makewhatis: make output reproducible The mandoc search database generation uses each page's inode number as a hash key to index hard linked pages only once. However, it also processed the pages ordered by hash key resulting in effectively non- deterministic output. Instead: 1) provide fts_open() with a comparison function to process directories and files in a deterministic order 2) in addition to the existing hash, insert pages into a linked list which will be sorted (by virtue of 1) 3) iterate over pages by the list in 2, instead of hash order I will work on upstreaming this change. Reviewed by: bapt MFC after: 1 month Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D8213 Modified: head/contrib/mdocml/mandocdb.c Modified: head/contrib/mdocml/mandocdb.c ============================================================================== --- head/contrib/mdocml/mandocdb.c Mon Oct 10 18:36:26 2016 (r307002) +++ head/contrib/mdocml/mandocdb.c Mon Oct 10 19:09:35 2016 (r307003) @@ -103,6 +103,7 @@ struct mpage { char *arch; /* architecture from file content */ char *title; /* title from file content */ char *desc; /* description from file content */ + struct mpage *next; /* singly linked list */ struct mlink *mlinks; /* singly linked list */ int form; /* format from file content */ int name_head_done; @@ -146,6 +147,7 @@ static void dbadd_mlink_name(const stru static int dbopen(int); static void dbprune(void); static void filescan(const char *); +static int fts_compare(const FTSENT *const *, const FTSENT *const *); static void mlink_add(struct mlink *, const struct stat *); static void mlink_check(struct mpage *, struct mlink *); static void mlink_free(struct mlink *); @@ -204,6 +206,7 @@ static struct ohash strings; /* table o static sqlite3 *db = NULL; /* current database */ static sqlite3_stmt *stmts[STMT__MAX]; /* current statements */ static uint64_t name_mask; +static struct mpage *mpage_head; static const struct mdoc_handler mdocs[MDOC_MAX] = { { NULL, 0 }, /* Ap */ @@ -571,6 +574,20 @@ usage: return (int)MANDOCLEVEL_BADARG; } +static int +fts_compare(const FTSENT *const *a, const FTSENT *const *b) +{ + + /* + * The mpage list is processed in the opposite order to which pages are + * added, so traverse the hierarchy in reverse alpha order, resulting + * in database inserts in alpha order. This is not required for correct + * operation, but is helpful when inspecting the database during + * development. + */ + return -strcmp((*a)->fts_name, (*b)->fts_name); +} + /* * Scan a directory tree rooted at "basedir" for manpages. * We use fts(), scanning directory parts along the way for clues to our @@ -600,8 +617,8 @@ treescan(void) argv[0] = "."; argv[1] = (char *)NULL; - f = fts_open((char * const *)argv, - FTS_PHYSICAL | FTS_NOCHDIR, NULL); + f = fts_open((char * const *)argv, FTS_PHYSICAL | FTS_NOCHDIR, + fts_compare); if (f == NULL) { exitcode = (int)MANDOCLEVEL_SYSERR; say("", "&fts_open"); @@ -966,6 +983,8 @@ mlink_add(struct mlink *mlink, const str mpage = mandoc_calloc(1, sizeof(struct mpage)); mpage->inodev.st_ino = inodev.st_ino; mpage->inodev.st_dev = inodev.st_dev; + mpage->next = mpage_head; + mpage_head = mpage; ohash_insert(&mpages, slot, mpage); } else mlink->next = mpage->mlinks; @@ -989,20 +1008,18 @@ mpages_free(void) { struct mpage *mpage; struct mlink *mlink; - unsigned int slot; - mpage = ohash_first(&mpages, &slot); - while (NULL != mpage) { + while (NULL != (mpage = mpage_head)) { while (NULL != (mlink = mpage->mlinks)) { mpage->mlinks = mlink->next; mlink_free(mlink); } + mpage_head = mpage->next; free(mpage->sec); free(mpage->arch); free(mpage->title); free(mpage->desc); free(mpage); - mpage = ohash_next(&mpages, &slot); } } @@ -1123,16 +1140,14 @@ mpages_merge(struct mparse *mp) char *sodest; char *cp; int fd; - unsigned int pslot; if ( ! nodb) SQL_EXEC("BEGIN TRANSACTION"); - mpage = ohash_first(&mpages, &pslot); - while (mpage != NULL) { + for (mpage = mpage_head; mpage != NULL; mpage = mpage->next) { mlinks_undupe(mpage); if ((mlink = mpage->mlinks) == NULL) { - mpage = ohash_next(&mpages, &pslot); + mpage = mpage->next; continue; } @@ -1256,7 +1271,6 @@ mpages_merge(struct mparse *mp) nextpage: ohash_delete(&strings); ohash_delete(&names); - mpage = ohash_next(&mpages, &pslot); } if (0 == nodb) From owner-svn-src-all@freebsd.org Mon Oct 10 19:21:25 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 3E8B3C0C640; Mon, 10 Oct 2016 19:21:25 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from mail.baldwin.cx (bigwig.baldwin.cx [96.47.65.170]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id F3EA0AF1; Mon, 10 Oct 2016 19:21:24 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from ralph.baldwin.cx (c-73-231-226-104.hsd1.ca.comcast.net [73.231.226.104]) by mail.baldwin.cx (Postfix) with ESMTPSA id 7FB3410AF74; Mon, 10 Oct 2016 15:21:23 -0400 (EDT) From: John Baldwin To: Slawa Olhovchenkov Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: Re: svn commit: r306661 - in stable/11/sys/dev/cxgbe: . tom Date: Mon, 10 Oct 2016 12:21:14 -0700 Message-ID: <4497031.RrIpxcHyXF@ralph.baldwin.cx> User-Agent: KMail/4.14.10 (FreeBSD/11.0-PRERELEASE; KDE/4.14.10; amd64; ; ) In-Reply-To: <20161010184357.GB54003@zxy.spb.ru> References: <201610032315.u93NFiHE057529@repo.freebsd.org> <5243602.cilUCEM5cP@ralph.baldwin.cx> <20161010184357.GB54003@zxy.spb.ru> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.4.3 (mail.baldwin.cx); Mon, 10 Oct 2016 15:21:23 -0400 (EDT) X-Virus-Scanned: clamav-milter 0.99.2 at mail.baldwin.cx X-Virus-Status: Clean X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 Oct 2016 19:21:25 -0000 On Monday, October 10, 2016 09:43:57 PM Slawa Olhovchenkov wrote: > On Mon, Oct 10, 2016 at 11:39:24AM -0700, John Baldwin wrote: > > > On Monday, October 10, 2016 09:28:21 PM Slawa Olhovchenkov wrote: > > > On Mon, Oct 10, 2016 at 10:46:27AM -0700, John Baldwin wrote: > > > > > > > On Monday, October 10, 2016 02:09:01 PM Slawa Olhovchenkov wrote: > > > > > On Mon, Oct 03, 2016 at 11:15:44PM +0000, John Baldwin wrote: > > > > > > > > > > > Author: jhb > > > > > > Date: Mon Oct 3 23:15:44 2016 > > > > > > New Revision: 306661 > > > > > > URL: https://svnweb.freebsd.org/changeset/base/306661 > > > > > > > > > > > > Log: > > > > > > MFC 303405: Add support for zero-copy aio_write() on TOE sockets. > > > > > > > > > > > > AIO write requests for a TOE socket on a Chelsio T4+ adapter can now > > > > > > DMA directly from the user-supplied buffer. This is implemented by > > > > > > wiring the pages backing the user-supplied buffer and queueing special > > > > > > mbufs backed by raw VM pages to the socket buffer. The TOE code > > > > > > recognizes these special mbufs and builds a sglist from the VM page > > > > > > array associated with the mbuf when queueing a work request to the TOE. > > > > > > > > > > > > Because these mbufs do not have an associated virtual address, m_data > > > > > > is not valid. Thus, the AIO handler does not invoke sosend() directly > > > > > > for these mbufs but instead inlines portions of sosend_generic() and > > > > > > tcp_usr_send(). > > > > > > > > > > > > An aiotx_buffer structure is used to describe the user buffer (e.g. > > > > > > it holds the array of VM pages and a reference to the AIO job). The > > > > > > special mbufs reference this structure via m_ext. Note that a single > > > > > > job might be split across multiple mbufs (e.g. if it is larger than > > > > > > the socket buffer size). The 'ext_arg2' member of each mbuf gives an > > > > > > offset relative to the backing aiotx_buffer. The AIO job associated > > > > > > with an aiotx_buffer structure is completed when the last reference to > > > > > > the structure is released. > > > > > > > > > > > > Zero-copy aio_write()'s for connections associated with a given > > > > > > adapter can be enabled/disabled at runtime via the > > > > > > 'dev.t[45]nex.N.toe.tx_zcopy' sysctl. > > > > > > > > > > > > Sponsored by: Chelsio Communications > > > > > > > > > > Do you have any public available application patches for support this? > > > > > May be nginx? > > > > > > > > Applications need to use aio_read(), ideally with at least 2 buffers (so > > > > queue two reads, then when a read completes, consume the data and do the > > > > next read). I'm not sure nginx will find this but so useful as web servers > > > > tend to send a lot more data than they receive. The only software I have > > > > patched explicitly for this is netperf. > > > > > > Hm, this is like only aio_read() on sokets give performance boost, not > > > aio_write()? > > > > Sorry, I was confused on the commit, this does affect aio_write() (earlier > > changes also permit zero-copy for receive via aio_read()). However, as you > > noted in the reply to Navdeep, it seems that nginx only supports using > > AIO on the backing files for static content it seems. It would need changes > > to support using aio_write on sockets (similar to using sendfile). > > Thanks > You don't planed to do this? After talking with Navdeep it looks like I will take a stab at adding support for this and seeing what effects it has. For static content workloads using sendfile I'm not sure it will be a win, but it might let you avoid some of the CPU cycles for dynamically-generated content by avoiding copies for those. -- John Baldwin From owner-svn-src-all@freebsd.org Mon Oct 10 19:27:10 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 57628C0C7A5; Mon, 10 Oct 2016 19:27:10 +0000 (UTC) (envelope-from slw@zxy.spb.ru) Received: from zxy.spb.ru (zxy.spb.ru [195.70.199.98]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id E840E13B; Mon, 10 Oct 2016 19:27:09 +0000 (UTC) (envelope-from slw@zxy.spb.ru) Received: from slw by zxy.spb.ru with local (Exim 4.86 (FreeBSD)) (envelope-from ) id 1btgE7-000K0K-S3; Mon, 10 Oct 2016 22:27:07 +0300 Date: Mon, 10 Oct 2016 22:27:07 +0300 From: Slawa Olhovchenkov To: John Baldwin Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: Re: svn commit: r306661 - in stable/11/sys/dev/cxgbe: . tom Message-ID: <20161010192707.GC54003@zxy.spb.ru> References: <201610032315.u93NFiHE057529@repo.freebsd.org> <5243602.cilUCEM5cP@ralph.baldwin.cx> <20161010184357.GB54003@zxy.spb.ru> <4497031.RrIpxcHyXF@ralph.baldwin.cx> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4497031.RrIpxcHyXF@ralph.baldwin.cx> User-Agent: Mutt/1.5.24 (2015-08-30) X-SA-Exim-Connect-IP: X-SA-Exim-Mail-From: slw@zxy.spb.ru X-SA-Exim-Scanned: No (on zxy.spb.ru); SAEximRunCond expanded to false X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 Oct 2016 19:27:10 -0000 On Mon, Oct 10, 2016 at 12:21:14PM -0700, John Baldwin wrote: > On Monday, October 10, 2016 09:43:57 PM Slawa Olhovchenkov wrote: > > On Mon, Oct 10, 2016 at 11:39:24AM -0700, John Baldwin wrote: > > > > > On Monday, October 10, 2016 09:28:21 PM Slawa Olhovchenkov wrote: > > > > On Mon, Oct 10, 2016 at 10:46:27AM -0700, John Baldwin wrote: > > > > > > > > > On Monday, October 10, 2016 02:09:01 PM Slawa Olhovchenkov wrote: > > > > > > On Mon, Oct 03, 2016 at 11:15:44PM +0000, John Baldwin wrote: > > > > > > > > > > > > > Author: jhb > > > > > > > Date: Mon Oct 3 23:15:44 2016 > > > > > > > New Revision: 306661 > > > > > > > URL: https://svnweb.freebsd.org/changeset/base/306661 > > > > > > > > > > > > > > Log: > > > > > > > MFC 303405: Add support for zero-copy aio_write() on TOE sockets. > > > > > > > > > > > > > > AIO write requests for a TOE socket on a Chelsio T4+ adapter can now > > > > > > > DMA directly from the user-supplied buffer. This is implemented by > > > > > > > wiring the pages backing the user-supplied buffer and queueing special > > > > > > > mbufs backed by raw VM pages to the socket buffer. The TOE code > > > > > > > recognizes these special mbufs and builds a sglist from the VM page > > > > > > > array associated with the mbuf when queueing a work request to the TOE. > > > > > > > > > > > > > > Because these mbufs do not have an associated virtual address, m_data > > > > > > > is not valid. Thus, the AIO handler does not invoke sosend() directly > > > > > > > for these mbufs but instead inlines portions of sosend_generic() and > > > > > > > tcp_usr_send(). > > > > > > > > > > > > > > An aiotx_buffer structure is used to describe the user buffer (e.g. > > > > > > > it holds the array of VM pages and a reference to the AIO job). The > > > > > > > special mbufs reference this structure via m_ext. Note that a single > > > > > > > job might be split across multiple mbufs (e.g. if it is larger than > > > > > > > the socket buffer size). The 'ext_arg2' member of each mbuf gives an > > > > > > > offset relative to the backing aiotx_buffer. The AIO job associated > > > > > > > with an aiotx_buffer structure is completed when the last reference to > > > > > > > the structure is released. > > > > > > > > > > > > > > Zero-copy aio_write()'s for connections associated with a given > > > > > > > adapter can be enabled/disabled at runtime via the > > > > > > > 'dev.t[45]nex.N.toe.tx_zcopy' sysctl. > > > > > > > > > > > > > > Sponsored by: Chelsio Communications > > > > > > > > > > > > Do you have any public available application patches for support this? > > > > > > May be nginx? > > > > > > > > > > Applications need to use aio_read(), ideally with at least 2 buffers (so > > > > > queue two reads, then when a read completes, consume the data and do the > > > > > next read). I'm not sure nginx will find this but so useful as web servers > > > > > tend to send a lot more data than they receive. The only software I have > > > > > patched explicitly for this is netperf. > > > > > > > > Hm, this is like only aio_read() on sokets give performance boost, not > > > > aio_write()? > > > > > > Sorry, I was confused on the commit, this does affect aio_write() (earlier > > > changes also permit zero-copy for receive via aio_read()). However, as you > > > noted in the reply to Navdeep, it seems that nginx only supports using > > > AIO on the backing files for static content it seems. It would need changes > > > to support using aio_write on sockets (similar to using sendfile). > > > > Thanks > > You don't planed to do this? > > After talking with Navdeep it looks like I will take a stab at adding support > for this and seeing what effects it has. For static content workloads using > sendfile I'm not sure it will be a win, but it might let you avoid some of > the CPU cycles for dynamically-generated content by avoiding copies for those. As I remember you tests show performance boost over sendfile. Also, sendfile over ZFS don't work good, as I remember (readahead don't work, at least). From owner-svn-src-all@freebsd.org Mon Oct 10 20:24:34 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 72D38C0CA0A; Mon, 10 Oct 2016 20:24:34 +0000 (UTC) (envelope-from jilles@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 35B4AA67; Mon, 10 Oct 2016 20:24:34 +0000 (UTC) (envelope-from jilles@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9AKOXfT055087; Mon, 10 Oct 2016 20:24:33 GMT (envelope-from jilles@FreeBSD.org) Received: (from jilles@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9AKOXLO055084; Mon, 10 Oct 2016 20:24:33 GMT (envelope-from jilles@FreeBSD.org) Message-Id: <201610102024.u9AKOXLO055084@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jilles set sender to jilles@FreeBSD.org using -f From: Jilles Tjoelker Date: Mon, 10 Oct 2016 20:24:33 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307004 - in stable/11: sys/kern tests/sys/kern X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 Oct 2016 20:24:34 -0000 Author: jilles Date: Mon Oct 10 20:24:32 2016 New Revision: 307004 URL: https://svnweb.freebsd.org/changeset/base/307004 Log: MFC r305676: wait: Do not copyout uninitialized status/rusage/wrusage. If wait4() or wait6() return 0 because of WNOHANG, the status, rusage and wrusage information should not be returned. PR: 212048 Reported by: Casey Lucas Added: stable/11/tests/sys/kern/waitpid_nohang.c - copied unchanged from r305676, head/tests/sys/kern/waitpid_nohang.c Modified: stable/11/sys/kern/kern_exit.c stable/11/tests/sys/kern/Makefile Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/kern/kern_exit.c ============================================================================== --- stable/11/sys/kern/kern_exit.c Mon Oct 10 19:09:35 2016 (r307003) +++ stable/11/sys/kern/kern_exit.c Mon Oct 10 20:24:32 2016 (r307004) @@ -723,9 +723,9 @@ sys_wait4(struct thread *td, struct wait else rup = NULL; error = kern_wait(td, uap->pid, &status, uap->options, rup); - if (uap->status != NULL && error == 0) + if (uap->status != NULL && error == 0 && td->td_retval[0] != 0) error = copyout(&status, uap->status, sizeof(status)); - if (uap->rusage != NULL && error == 0) + if (uap->rusage != NULL && error == 0 && td->td_retval[0] != 0) error = copyout(&ru, uap->rusage, sizeof(struct rusage)); return (error); } @@ -759,9 +759,9 @@ sys_wait6(struct thread *td, struct wait */ error = kern_wait6(td, idtype, id, &status, uap->options, wrup, sip); - if (uap->status != NULL && error == 0) + if (uap->status != NULL && error == 0 && td->td_retval[0] != 0) error = copyout(&status, uap->status, sizeof(status)); - if (uap->wrusage != NULL && error == 0) + if (uap->wrusage != NULL && error == 0 && td->td_retval[0] != 0) error = copyout(&wru, uap->wrusage, sizeof(wru)); if (uap->info != NULL && error == 0) error = copyout(&si, uap->info, sizeof(si)); Modified: stable/11/tests/sys/kern/Makefile ============================================================================== --- stable/11/tests/sys/kern/Makefile Mon Oct 10 19:09:35 2016 (r307003) +++ stable/11/tests/sys/kern/Makefile Mon Oct 10 20:24:32 2016 (r307004) @@ -12,6 +12,7 @@ PLAIN_TESTS_C+= subr_unit_test ATF_TESTS_C+= unix_seqpacket_test ATF_TESTS_C+= unix_passfd_test TEST_METADATA.unix_seqpacket_test+= timeout="15" +ATF_TESTS_C+= waitpid_nohang LIBADD.ptrace_test+= pthread LIBADD.unix_seqpacket_test+= pthread Copied: stable/11/tests/sys/kern/waitpid_nohang.c (from r305676, head/tests/sys/kern/waitpid_nohang.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/11/tests/sys/kern/waitpid_nohang.c Mon Oct 10 20:24:32 2016 (r307004, copy of r305676, head/tests/sys/kern/waitpid_nohang.c) @@ -0,0 +1,70 @@ +/*- + * Copyright (c) 2016 Jilles Tjoelker + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include + +#include +#include +#include + +ATF_TC_WITHOUT_HEAD(waitpid_nohang); +ATF_TC_BODY(waitpid_nohang, tc) +{ + pid_t child, pid; + int status, r; + + child = fork(); + ATF_REQUIRE(child != -1); + if (child == 0) { + sleep(10); + _exit(1); + } + + status = 42; + pid = waitpid(child, &status, WNOHANG); + ATF_REQUIRE(pid == 0); + ATF_CHECK(status == 42); + + r = kill(child, SIGTERM); + ATF_REQUIRE(r == 0); + r = waitid(P_PID, child, NULL, WEXITED | WNOWAIT); + ATF_REQUIRE(r == 0); + + status = -1; + pid = waitpid(child, &status, WNOHANG); + ATF_REQUIRE(pid == child); + ATF_CHECK(WIFSIGNALED(status) && WTERMSIG(status) == SIGTERM); +} + +ATF_TP_ADD_TCS(tp) +{ + + ATF_TP_ADD_TC(tp, waitpid_nohang); + return (atf_no_error()); +} From owner-svn-src-all@freebsd.org Mon Oct 10 22:36:46 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 4C501C0C716; Mon, 10 Oct 2016 22:36:46 +0000 (UTC) (envelope-from np@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 1E6D6B6C; Mon, 10 Oct 2016 22:36:46 +0000 (UTC) (envelope-from np@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9AMajLm006514; Mon, 10 Oct 2016 22:36:45 GMT (envelope-from np@FreeBSD.org) Received: (from np@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9AMajg6006512; Mon, 10 Oct 2016 22:36:45 GMT (envelope-from np@FreeBSD.org) Message-Id: <201610102236.u9AMajg6006512@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: np set sender to np@FreeBSD.org using -f From: Navdeep Parhar Date: Mon, 10 Oct 2016 22:36:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307008 - in head/release: . tools X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 Oct 2016 22:36:46 -0000 Author: np Date: Mon Oct 10 22:36:44 2016 New Revision: 307008 URL: https://svnweb.freebsd.org/changeset/base/307008 Log: Add the ability to override the size of the swap partition when building VM images. The default continues to be 1G. Reviewed by: gjb@ Sponsored by: Chelsio Communications Modified: head/release/Makefile.vm head/release/tools/vmimage.subr Modified: head/release/Makefile.vm ============================================================================== --- head/release/Makefile.vm Mon Oct 10 21:12:56 2016 (r307007) +++ head/release/Makefile.vm Mon Oct 10 22:36:44 2016 (r307008) @@ -8,6 +8,7 @@ VMTARGETS= vm-image VMFORMATS?= vhd vmdk qcow2 raw VMSIZE?= 20G +SWAPSIZE?= 1G VMBASE?= vm VHD_DESC= Azure, VirtualPC, Hyper-V, Xen disk image Modified: head/release/tools/vmimage.subr ============================================================================== --- head/release/tools/vmimage.subr Mon Oct 10 21:12:56 2016 (r307007) +++ head/release/tools/vmimage.subr Mon Oct 10 22:36:44 2016 (r307008) @@ -11,7 +11,7 @@ trap "cleanup" INT QUIT TRAP ABRT TERM write_partition_layout() { if [ -z "${NOSWAP}" ]; then - SWAPOPT="-p freebsd-swap/swapfs::1G" + SWAPOPT="-p freebsd-swap/swapfs::${SWAPSIZE}" fi _OBJDIR="$(make -C ${WORLDDIR} -V .OBJDIR)" From owner-svn-src-all@freebsd.org Mon Oct 10 23:35:56 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id EF43DC07DF7; Mon, 10 Oct 2016 23:35:56 +0000 (UTC) (envelope-from gjb@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id C064C259; Mon, 10 Oct 2016 23:35:56 +0000 (UTC) (envelope-from gjb@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9ANZtj4029212; Mon, 10 Oct 2016 23:35:55 GMT (envelope-from gjb@FreeBSD.org) Received: (from gjb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9ANZtZW029211; Mon, 10 Oct 2016 23:35:55 GMT (envelope-from gjb@FreeBSD.org) Message-Id: <201610102335.u9ANZtZW029211@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: gjb set sender to gjb@FreeBSD.org using -f From: Glen Barber Date: Mon, 10 Oct 2016 23:35:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307009 - stable/11/release/doc/en_US.ISO8859-1/errata X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 Oct 2016 23:35:57 -0000 Author: gjb Date: Mon Oct 10 23:35:55 2016 New Revision: 307009 URL: https://svnweb.freebsd.org/changeset/base/307009 Log: Correct an entry from the release announcement. Sponsored by: The FreeBSD Foundation Modified: stable/11/release/doc/en_US.ISO8859-1/errata/article.xml Modified: stable/11/release/doc/en_US.ISO8859-1/errata/article.xml ============================================================================== --- stable/11/release/doc/en_US.ISO8859-1/errata/article.xml Mon Oct 10 22:36:44 2016 (r307008) +++ stable/11/release/doc/en_US.ISO8859-1/errata/article.xml Mon Oct 10 23:35:55 2016 (r307009) @@ -161,6 +161,13 @@ boot option is enabled by default, however this was disabled prior to the final release build. + + + The release announcement stated "Wireless support + for 802.11n has been added." This was intended to + state "Wireless support for 802.11n has been added for + additional wireless network drivers." + From owner-svn-src-all@freebsd.org Tue Oct 11 02:08:11 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 35884C0BF68; Tue, 11 Oct 2016 02:08:11 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id E1915876; Tue, 11 Oct 2016 02:08:10 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9B28Alq085917; Tue, 11 Oct 2016 02:08:10 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9B28ASC085916; Tue, 11 Oct 2016 02:08:10 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610110208.u9B28ASC085916@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Tue, 11 Oct 2016 02:08:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307010 - stable/11/sys/compat/linuxkpi/common/include/linux X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Oct 2016 02:08:11 -0000 Author: sephe Date: Tue Oct 11 02:08:09 2016 New Revision: 307010 URL: https://svnweb.freebsd.org/changeset/base/307010 Log: MFC 306480 linuxkpi: Fix PCI BAR lazy allocation support. FreeBSD supports lazy allocation of PCI BAR, that is, when a device driver's attach method is invoked, even if the device's PCI BAR address wasn't initialized, the invocation of bus_alloc_resource_any() (the call chain: pci_alloc_resource() -> pci_alloc_multi_resource() -> pci_reserve_map() -> pci_write_bar()) would allocate a proper address for the PCI BAR and write this 'lazy allocated' address into the PCI BAR. This model works fine for native FreeBSD device drivers, but _not_ for device drivers shared with Linux (e.g. dev/mlx5/mlx5_core/mlx5_main.c and ofed/drivers/net/mlx4/main.c. Both of them use pci_request_regions(), which doesn't work properly with the PCI BAR lazy allocation, because pci_resource_type() -> _pci_get_rle() always returns NULL, so pci_request_regions() doesn't have the opportunity to invoke bus_alloc_resource_any(). We now use pci_find_bar() in pci_resource_type(), which is able to locate all available PCI BARs even if some of them will be lazy allocated. Submitted by: Dexuan Cui Reviewed by: hps Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8071 Modified: stable/11/sys/compat/linuxkpi/common/include/linux/pci.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/compat/linuxkpi/common/include/linux/pci.h ============================================================================== --- stable/11/sys/compat/linuxkpi/common/include/linux/pci.h Mon Oct 10 23:35:55 2016 (r307009) +++ stable/11/sys/compat/linuxkpi/common/include/linux/pci.h Tue Oct 11 02:08:09 2016 (r307010) @@ -233,11 +233,16 @@ pci_resource_len(struct pci_dev *pdev, i static inline int pci_resource_type(struct pci_dev *pdev, int bar) { - struct resource_list_entry *rle; + struct pci_map *pm; - if ((rle = _pci_get_bar(pdev, bar)) == NULL) + pm = pci_find_bar(pdev->dev.bsddev, PCIR_BAR(bar)); + if (!pm) return (-1); - return (rle->type); + + if (PCI_BAR_IO(pm->pm_value)) + return (SYS_RES_IOPORT); + else + return (SYS_RES_MEMORY); } /* From owner-svn-src-all@freebsd.org Tue Oct 11 02:26:00 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A07B4C0C832; Tue, 11 Oct 2016 02:26:00 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 595FC20D; Tue, 11 Oct 2016 02:26:00 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9B2Px8n093444; Tue, 11 Oct 2016 02:25:59 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9B2Px3r093443; Tue, 11 Oct 2016 02:25:59 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610110225.u9B2Px3r093443@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Tue, 11 Oct 2016 02:25:59 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307011 - stable/10/sys/ofed/include/linux X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Oct 2016 02:26:00 -0000 Author: sephe Date: Tue Oct 11 02:25:59 2016 New Revision: 307011 URL: https://svnweb.freebsd.org/changeset/base/307011 Log: MFC 306480 linuxkpi: Fix PCI BAR lazy allocation support. FreeBSD supports lazy allocation of PCI BAR, that is, when a device driver's attach method is invoked, even if the device's PCI BAR address wasn't initialized, the invocation of bus_alloc_resource_any() (the call chain: pci_alloc_resource() -> pci_alloc_multi_resource() -> pci_reserve_map() -> pci_write_bar()) would allocate a proper address for the PCI BAR and write this 'lazy allocated' address into the PCI BAR. This model works fine for native FreeBSD device drivers, but _not_ for device drivers shared with Linux (e.g. dev/mlx5/mlx5_core/mlx5_main.c and ofed/drivers/net/mlx4/main.c. Both of them use pci_request_regions(), which doesn't work properly with the PCI BAR lazy allocation, because pci_resource_type() -> _pci_get_rle() always returns NULL, so pci_request_regions() doesn't have the opportunity to invoke bus_alloc_resource_any(). We now use pci_find_bar() in pci_resource_type(), which is able to locate all available PCI BARs even if some of them will be lazy allocated. Submitted by: Dexuan Cui Reviewed by: hps Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8071 Modified: stable/10/sys/ofed/include/linux/pci.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/ofed/include/linux/pci.h ============================================================================== --- stable/10/sys/ofed/include/linux/pci.h Tue Oct 11 02:08:09 2016 (r307010) +++ stable/10/sys/ofed/include/linux/pci.h Tue Oct 11 02:25:59 2016 (r307011) @@ -216,11 +216,16 @@ pci_resource_len(struct pci_dev *pdev, i static inline int pci_resource_type(struct pci_dev *pdev, int bar) { - struct resource_list_entry *rle; + struct pci_map *pm; - if ((rle = _pci_get_bar(pdev, bar)) == NULL) + pm = pci_find_bar(pdev->dev.bsddev, PCIR_BAR(bar)); + if (!pm) return (-1); - return (rle->type); + + if (PCI_BAR_IO(pm->pm_value)) + return (SYS_RES_IOPORT); + else + return (SYS_RES_MEMORY); } /* From owner-svn-src-all@freebsd.org Tue Oct 11 02:43:24 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 5A949C0CE39; Tue, 11 Oct 2016 02:43:24 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 2C213D06; Tue, 11 Oct 2016 02:43:24 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9B2hNsD000740; Tue, 11 Oct 2016 02:43:23 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9B2hNUJ000738; Tue, 11 Oct 2016 02:43:23 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610110243.u9B2hNUJ000738@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Tue, 11 Oct 2016 02:43:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307012 - in head/sys/dev/hyperv: include vmbus X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Oct 2016 02:43:24 -0000 Author: sephe Date: Tue Oct 11 02:43:23 2016 New Revision: 307012 URL: https://svnweb.freebsd.org/changeset/base/307012 Log: hyperv/vmbus: Allow driver to inject synchronous task into channel taskq. MFC after: 1 week Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8208 Modified: head/sys/dev/hyperv/include/vmbus.h head/sys/dev/hyperv/vmbus/vmbus_chan.c Modified: head/sys/dev/hyperv/include/vmbus.h ============================================================================== --- head/sys/dev/hyperv/include/vmbus.h Tue Oct 11 02:25:59 2016 (r307011) +++ head/sys/dev/hyperv/include/vmbus.h Tue Oct 11 02:43:23 2016 (r307012) @@ -117,6 +117,7 @@ struct vmbus_chan_br { struct vmbus_channel; struct hyperv_guid; +struct task; typedef void (*vmbus_chan_callback_t)(struct vmbus_channel *, void *); @@ -134,6 +135,8 @@ int vmbus_chan_open_br(struct vmbus_cha int udlen, vmbus_chan_callback_t cb, void *cbarg); void vmbus_chan_close(struct vmbus_channel *chan); void vmbus_chan_intr_drain(struct vmbus_channel *chan); +void vmbus_chan_run_task(struct vmbus_channel *chan, + struct task *task); int vmbus_chan_gpadl_connect(struct vmbus_channel *chan, bus_addr_t paddr, int size, uint32_t *gpadl); Modified: head/sys/dev/hyperv/vmbus/vmbus_chan.c ============================================================================== --- head/sys/dev/hyperv/vmbus/vmbus_chan.c Tue Oct 11 02:25:59 2016 (r307011) +++ head/sys/dev/hyperv/vmbus/vmbus_chan.c Tue Oct 11 02:43:23 2016 (r307012) @@ -1713,3 +1713,11 @@ vmbus_chan_rx_empty(const struct vmbus_c return (vmbus_rxbr_empty(&chan->ch_rxbr)); } + +void +vmbus_chan_run_task(struct vmbus_channel *chan, struct task *task) +{ + + taskqueue_enqueue(chan->ch_tq, task); + taskqueue_drain(chan->ch_tq, task); +} From owner-svn-src-all@freebsd.org Tue Oct 11 02:54:58 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 61D43C0B208; Tue, 11 Oct 2016 02:54:58 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 3C11430E; Tue, 11 Oct 2016 02:54:58 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9B2svRB004790; Tue, 11 Oct 2016 02:54:57 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9B2svVx004785; Tue, 11 Oct 2016 02:54:57 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610110254.u9B2svVx004785@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Tue, 11 Oct 2016 02:54:57 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307013 - head/sys/dev/hyperv/netvsc X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Oct 2016 02:54:58 -0000 Author: sephe Date: Tue Oct 11 02:54:56 2016 New Revision: 307013 URL: https://svnweb.freebsd.org/changeset/base/307013 Log: hyperv/hn: Rework link status support. This is the preamble for network device SR-IOV and NDIS_STATUS_NETWORK_CHANGE handling. MFC after: 1 week Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8209 Modified: head/sys/dev/hyperv/netvsc/hv_net_vsc.h head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c head/sys/dev/hyperv/netvsc/hv_rndis_filter.c head/sys/dev/hyperv/netvsc/if_hnvar.h Modified: head/sys/dev/hyperv/netvsc/hv_net_vsc.h ============================================================================== --- head/sys/dev/hyperv/netvsc/hv_net_vsc.h Tue Oct 11 02:43:23 2016 (r307012) +++ head/sys/dev/hyperv/netvsc/hv_net_vsc.h Tue Oct 11 02:54:56 2016 (r307013) @@ -233,6 +233,10 @@ struct hn_softc { struct vmbus_xact_ctx *hn_xact; uint32_t hn_nvs_ver; + struct taskqueue *hn_mgmt_taskq; + struct taskqueue *hn_mgmt_taskq0; + struct task hn_link_task; + uint32_t hn_caps; /* HN_CAP_ */ uint32_t hn_flags; /* HN_FLAG_ */ void *hn_rxbuf; @@ -271,7 +275,6 @@ struct hn_softc { */ struct hn_send_ctx; -void netvsc_linkstatus_callback(struct hn_softc *sc, uint32_t status); int hv_nv_on_send(struct vmbus_channel *chan, uint32_t rndis_mtype, struct hn_send_ctx *sndc, struct vmbus_gpa *gpa, int gpa_cnt); Modified: head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c ============================================================================== --- head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Tue Oct 11 02:43:23 2016 (r307012) +++ head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Tue Oct 11 02:54:56 2016 (r307013) @@ -334,6 +334,8 @@ static void hn_fixup_tx_data(struct hn_s static void hn_destroy_tx_data(struct hn_softc *); static void hn_start_taskfunc(void *, int); static void hn_start_txeof_taskfunc(void *, int); +static void hn_link_taskfunc(void *, int); +static void hn_suspend_mgmt_taskfunc(void *, int); static int hn_encap(struct hn_tx_ring *, struct hn_txdesc *, struct mbuf **); static int hn_create_rx_data(struct hn_softc *sc, int); static void hn_destroy_rx_data(struct hn_softc *sc); @@ -349,6 +351,8 @@ static int hn_synth_attach(struct hn_sof static void hn_synth_detach(struct hn_softc *); static bool hn_tx_ring_pending(struct hn_tx_ring *); static void hn_suspend(struct hn_softc *); +static void hn_suspend_data(struct hn_softc *); +static void hn_suspend_mgmt(struct hn_softc *); static void hn_resume(struct hn_softc *); static void hn_rx_drain(struct vmbus_channel *); static void hn_tx_resume(struct hn_softc *, int); @@ -518,7 +522,6 @@ netvsc_attach(device_t dev) struct sysctl_oid_list *child; struct sysctl_ctx_list *ctx; uint8_t eaddr[ETHER_ADDR_LEN]; - uint32_t link_status; struct ifnet *ifp = NULL; int error, ring_cnt, tx_ring_cnt; @@ -551,6 +554,15 @@ netvsc_attach(device_t dev) } /* + * Setup taskqueue for mangement tasks, e.g. link status. + */ + sc->hn_mgmt_taskq0 = taskqueue_create("hn_mgmt", M_WAITOK, + taskqueue_thread_enqueue, &sc->hn_mgmt_taskq0); + taskqueue_start_threads(&sc->hn_mgmt_taskq0, 1, PI_NET, "%s mgmt", + device_get_nameunit(dev)); + TASK_INIT(&sc->hn_link_task, 0, hn_link_taskfunc, sc); + + /* * Allocate ifnet and setup its name earlier, so that if_printf * can be used by functions, which will be called after * ether_ifattach(). @@ -621,12 +633,6 @@ netvsc_attach(device_t dev) if (error) goto failed; - error = hn_rndis_get_linkstatus(sc, &link_status); - if (error) - goto failed; - if (link_status == NDIS_MEDIA_STATE_CONNECTED) - sc->hn_carrier = 1; - error = hn_rndis_get_eaddr(sc, eaddr); if (error) goto failed; @@ -736,6 +742,12 @@ netvsc_attach(device_t dev) /* Inform the upper layer about the long frame support. */ ifp->if_hdrlen = sizeof(struct ether_vlan_header); + /* + * Kick off link status check. + */ + sc->hn_mgmt_taskq = sc->hn_mgmt_taskq0; + hn_link_status_update(sc); + return (0); failed: if (sc->hn_flags & HN_FLAG_SYNTH_ATTACHED) @@ -755,6 +767,12 @@ netvsc_detach(device_t dev) if (sc->hn_flags & HN_FLAG_SYNTH_ATTACHED) { if (ifp->if_drv_flags & IFF_DRV_RUNNING) hn_stop(sc); + /* + * NOTE: + * hn_stop() only suspends data, so managment + * stuffs have to be suspended manually here. + */ + hn_suspend_mgmt(sc); hn_synth_detach(sc); } HN_UNLOCK(sc); @@ -767,6 +785,7 @@ netvsc_detach(device_t dev) if (sc->hn_tx_taskq != hn_tx_taskq) taskqueue_free(sc->hn_tx_taskq); + taskqueue_free(sc->hn_mgmt_taskq0); if (sc->hn_xact != NULL) vmbus_xact_ctx_destroy(sc->hn_xact); @@ -786,6 +805,36 @@ netvsc_shutdown(device_t dev) return (0); } +static void +hn_link_taskfunc(void *xsc, int pending __unused) +{ + struct hn_softc *sc = xsc; + struct ifnet *ifp = sc->hn_ifp; + uint32_t link_status; + int error; + + error = hn_rndis_get_linkstatus(sc, &link_status); + if (error) { + /* XXX what to do? */ + return; + } + + if (link_status == NDIS_MEDIA_STATE_CONNECTED) + sc->hn_carrier = 1; + else + sc->hn_carrier = 0; + if_link_state_change(ifp, + sc->hn_carrier ? LINK_STATE_UP : LINK_STATE_DOWN); +} + +void +hn_link_status_update(struct hn_softc *sc) +{ + + if (sc->hn_mgmt_taskq != NULL) + taskqueue_enqueue(sc->hn_mgmt_taskq, &sc->hn_link_task); +} + static __inline int hn_txdesc_dmamap_load(struct hn_tx_ring *txr, struct hn_txdesc *txd, struct mbuf **m_head, bus_dma_segment_t *segs, int *nsegs) @@ -1311,19 +1360,6 @@ hn_start_locked(struct hn_tx_ring *txr, } /* - * Link up/down notification - */ -void -netvsc_linkstatus_callback(struct hn_softc *sc, uint32_t status) -{ - if (status == 1) { - sc->hn_carrier = 1; - } else { - sc->hn_carrier = 0; - } -} - -/* * Append the specified data to the indicated mbuf chain, * Extend the mbuf chain if the new data does not fit in * existing space. @@ -1801,9 +1837,9 @@ hn_stop(struct hn_softc *sc) KASSERT(sc->hn_flags & HN_FLAG_SYNTH_ATTACHED, ("synthetic parts were not attached")); - /* Clear RUNNING bit _before_ hn_suspend() */ + /* Clear RUNNING bit _before_ hn_suspend_data() */ atomic_clear_int(&ifp->if_drv_flags, IFF_DRV_RUNNING); - hn_suspend(sc); + hn_suspend_data(sc); /* Clear OACTIVE bit. */ atomic_clear_int(&ifp->if_drv_flags, IFF_DRV_OACTIVE); @@ -1896,9 +1932,6 @@ hn_init_locked(struct hn_softc *sc) /* Everything is ready; unleash! */ atomic_set_int(&ifp->if_drv_flags, IFF_DRV_RUNNING); - - /* TODO: check RNDIS link status. */ - if_link_state_change(ifp, LINK_STATE_UP); } static void @@ -3600,7 +3633,7 @@ hn_rx_drain(struct vmbus_channel *chan) } static void -hn_suspend(struct hn_softc *sc) +hn_suspend_data(struct hn_softc *sc) { struct vmbus_channel **subch = NULL; int i, nsubch; @@ -3654,6 +3687,41 @@ hn_suspend(struct hn_softc *sc) } static void +hn_suspend_mgmt_taskfunc(void *xsc, int pending __unused) +{ + + ((struct hn_softc *)xsc)->hn_mgmt_taskq = NULL; +} + +static void +hn_suspend_mgmt(struct hn_softc *sc) +{ + struct task task; + + HN_LOCK_ASSERT(sc); + + /* + * Make sure that hn_mgmt_taskq0 can nolonger be accessed + * through hn_mgmt_taskq. + */ + TASK_INIT(&task, 0, hn_suspend_mgmt_taskfunc, sc); + vmbus_chan_run_task(sc->hn_prichan, &task); + + /* + * Make sure that all pending management tasks are completed. + */ + taskqueue_drain_all(sc->hn_mgmt_taskq0); +} + +static void +hn_suspend(struct hn_softc *sc) +{ + + hn_suspend_data(sc); + hn_suspend_mgmt(sc); +} + +static void hn_tx_resume(struct hn_softc *sc, int tx_ring_cnt) { int i; @@ -3685,7 +3753,8 @@ hn_resume(struct hn_softc *sc) /* * Make sure to clear suspend status on "all" TX rings, - * since hn_tx_ring_inuse can be changed after hn_suspend(). + * since hn_tx_ring_inuse can be changed after + * hn_suspend_data(). */ hn_tx_resume(sc, sc->hn_tx_ring_cnt); @@ -3710,6 +3779,12 @@ hn_resume(struct hn_softc *sc) */ taskqueue_enqueue(txr->hn_tx_taskq, &txr->hn_txeof_task); } + + /* + * Kick off link status check. + */ + sc->hn_mgmt_taskq = sc->hn_mgmt_taskq0; + hn_link_status_update(sc); } static void Modified: head/sys/dev/hyperv/netvsc/hv_rndis_filter.c ============================================================================== --- head/sys/dev/hyperv/netvsc/hv_rndis_filter.c Tue Oct 11 02:43:23 2016 (r307012) +++ head/sys/dev/hyperv/netvsc/hv_rndis_filter.c Tue Oct 11 02:54:56 2016 (r307013) @@ -167,11 +167,8 @@ hv_rf_receive_indicate_status(struct hn_ switch (msg->rm_status) { case RNDIS_STATUS_MEDIA_CONNECT: - netvsc_linkstatus_callback(sc, 1); - break; - case RNDIS_STATUS_MEDIA_DISCONNECT: - netvsc_linkstatus_callback(sc, 0); + hn_link_status_update(sc); break; case RNDIS_STATUS_TASK_OFFLOAD_CURRENT_CONFIG: Modified: head/sys/dev/hyperv/netvsc/if_hnvar.h ============================================================================== --- head/sys/dev/hyperv/netvsc/if_hnvar.h Tue Oct 11 02:43:23 2016 (r307012) +++ head/sys/dev/hyperv/netvsc/if_hnvar.h Tue Oct 11 02:54:56 2016 (r307013) @@ -138,6 +138,7 @@ void hn_nvs_sent_xact(struct hn_send_ct int hn_rxpkt(struct hn_rx_ring *rxr, const void *data, int dlen, const struct hn_recvinfo *info); void hn_chan_rollup(struct hn_rx_ring *rxr, struct hn_tx_ring *txr); +void hn_link_status_update(struct hn_softc *sc); extern struct hn_send_ctx hn_send_ctx_none; From owner-svn-src-all@freebsd.org Tue Oct 11 05:44:39 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 01383C074DC; Tue, 11 Oct 2016 05:44:39 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 96A11380; Tue, 11 Oct 2016 05:44:38 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9B5ibxQ068974; Tue, 11 Oct 2016 05:44:37 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9B5ib1A068963; Tue, 11 Oct 2016 05:44:37 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610110544.u9B5ib1A068963@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Tue, 11 Oct 2016 05:44:37 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307014 - in stable/10/sys/dev/hyperv: include vmbus X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Oct 2016 05:44:39 -0000 Author: sephe Date: Tue Oct 11 05:44:36 2016 New Revision: 307014 URL: https://svnweb.freebsd.org/changeset/base/307014 Log: MFC 302540 hyperv/vmbus: Implement a new set of APIs for post message Hypercall And use this new APIs for Initial Contact post message Hypercall. More post message Hypercalls will be converted. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D6830 Modified: stable/10/sys/dev/hyperv/include/hyperv.h stable/10/sys/dev/hyperv/vmbus/hv_channel_mgmt.c stable/10/sys/dev/hyperv/vmbus/hv_connection.c stable/10/sys/dev/hyperv/vmbus/hv_vmbus_priv.h stable/10/sys/dev/hyperv/vmbus/hyperv.c stable/10/sys/dev/hyperv/vmbus/hyperv_reg.h stable/10/sys/dev/hyperv/vmbus/hyperv_var.h stable/10/sys/dev/hyperv/vmbus/vmbus.c stable/10/sys/dev/hyperv/vmbus/vmbus_reg.h stable/10/sys/dev/hyperv/vmbus/vmbus_var.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/hyperv/include/hyperv.h ============================================================================== --- stable/10/sys/dev/hyperv/include/hyperv.h Tue Oct 11 02:54:56 2016 (r307013) +++ stable/10/sys/dev/hyperv/include/hyperv.h Tue Oct 11 05:44:36 2016 (r307014) @@ -77,10 +77,6 @@ typedef uint8_t hv_bool_uint8_t; #define HV_VMBUS_VERSION_WIN8 ((2 << 16) | (4)) #define HV_VMBUS_VERSION_WIN8_1 ((3 << 16) | (0)) -#define HV_VMBUS_VERSION_INVALID -1 - -#define HV_VMBUS_VERSION_CURRENT HV_VMBUS_VERSION_WIN8_1 - /* * Make maximum size of pipe payload of 16K */ @@ -537,20 +533,6 @@ typedef struct { uint32_t child_rel_id; } __packed hv_vmbus_channel_relid_released; -typedef struct { - hv_vmbus_channel_msg_header header; - uint32_t vmbus_version_requested; - uint32_t padding2; - uint64_t interrupt_page; - uint64_t monitor_page_1; - uint64_t monitor_page_2; -} __packed hv_vmbus_channel_initiate_contact; - -typedef struct { - hv_vmbus_channel_msg_header header; - hv_bool_uint8_t version_supported; -} __packed hv_vmbus_channel_version_response; - typedef hv_vmbus_channel_msg_header hv_vmbus_channel_unload; #define HW_MACADDR_LEN 6 Modified: stable/10/sys/dev/hyperv/vmbus/hv_channel_mgmt.c ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/hv_channel_mgmt.c Tue Oct 11 02:54:56 2016 (r307013) +++ stable/10/sys/dev/hyperv/vmbus/hv_channel_mgmt.c Tue Oct 11 05:44:36 2016 (r307014) @@ -43,29 +43,30 @@ __FBSDID("$FreeBSD$"); * Internal functions */ -typedef void (*vmbus_msg_handler)(const hv_vmbus_channel_msg_header *msg); - typedef struct hv_vmbus_channel_msg_table_entry { hv_vmbus_channel_msg_type messageType; - vmbus_msg_handler messageHandler; + void (*messageHandler) + (struct vmbus_softc *sc, + const struct vmbus_message *msg); } hv_vmbus_channel_msg_table_entry; static void vmbus_channel_on_offer_internal(void *context); static void vmbus_channel_on_offer_rescind_internal(void *context); -static void vmbus_channel_on_offer(const hv_vmbus_channel_msg_header *hdr); -static void vmbus_channel_on_open_result( - const hv_vmbus_channel_msg_header *hdr); -static void vmbus_channel_on_offer_rescind( - const hv_vmbus_channel_msg_header *hdr); -static void vmbus_channel_on_gpadl_created( - const hv_vmbus_channel_msg_header *hdr); -static void vmbus_channel_on_gpadl_torndown( - const hv_vmbus_channel_msg_header *hdr); -static void vmbus_channel_on_offers_delivered( - const hv_vmbus_channel_msg_header *hdr); -static void vmbus_channel_on_version_response( - const hv_vmbus_channel_msg_header *hdr); +static void vmbus_channel_on_offer(struct vmbus_softc *, + const struct vmbus_message *); +static void vmbus_channel_on_open_result(struct vmbus_softc *, + const struct vmbus_message *); +static void vmbus_channel_on_offer_rescind(struct vmbus_softc *, + const struct vmbus_message *); +static void vmbus_channel_on_gpadl_created(struct vmbus_softc *, + const struct vmbus_message *); +static void vmbus_channel_on_gpadl_torndown(struct vmbus_softc *, + const struct vmbus_message *); +static void vmbus_channel_on_offers_delivered(struct vmbus_softc *, + const struct vmbus_message *); +static void vmbus_channel_on_version_response(struct vmbus_softc *, + const struct vmbus_message *); /** * Channel message dispatch table @@ -401,8 +402,11 @@ vmbus_channel_select_defcpu(struct hv_vm * object to process the offer synchronously */ static void -vmbus_channel_on_offer(const hv_vmbus_channel_msg_header *hdr) +vmbus_channel_on_offer(struct vmbus_softc *sc, const struct vmbus_message *msg) { + const hv_vmbus_channel_msg_header *hdr = + (const hv_vmbus_channel_msg_header *)msg->msg_data; + const hv_vmbus_channel_offer_channel *offer; hv_vmbus_channel_offer_channel *copied; @@ -479,8 +483,12 @@ vmbus_channel_on_offer_internal(void* co * synchronously */ static void -vmbus_channel_on_offer_rescind(const hv_vmbus_channel_msg_header *hdr) +vmbus_channel_on_offer_rescind(struct vmbus_softc *sc, + const struct vmbus_message *msg) { + const hv_vmbus_channel_msg_header *hdr = + (const hv_vmbus_channel_msg_header *)msg->msg_data; + const hv_vmbus_channel_rescind_offer *rescind; hv_vmbus_channel* channel; @@ -511,8 +519,8 @@ vmbus_channel_on_offer_rescind_internal( * @brief Invoked when all offers have been delivered. */ static void -vmbus_channel_on_offers_delivered( - const hv_vmbus_channel_msg_header *hdr __unused) +vmbus_channel_on_offers_delivered(struct vmbus_softc *sc __unused, + const struct vmbus_message *msg __unused) { mtx_lock(&vmbus_chwait_lock); @@ -529,8 +537,12 @@ vmbus_channel_on_offers_delivered( * response and signal the requesting thread. */ static void -vmbus_channel_on_open_result(const hv_vmbus_channel_msg_header *hdr) +vmbus_channel_on_open_result(struct vmbus_softc *sc, + const struct vmbus_message *msg) { + const hv_vmbus_channel_msg_header *hdr = + (const hv_vmbus_channel_msg_header *)msg->msg_data; + const hv_vmbus_channel_open_result *result; hv_vmbus_channel_msg_info* msg_info; hv_vmbus_channel_msg_header* requestHeader; @@ -571,8 +583,12 @@ vmbus_channel_on_open_result(const hv_vm * response and signal the requesting thread. */ static void -vmbus_channel_on_gpadl_created(const hv_vmbus_channel_msg_header *hdr) +vmbus_channel_on_gpadl_created(struct vmbus_softc *sc, + const struct vmbus_message *msg) { + const hv_vmbus_channel_msg_header *hdr = + (const hv_vmbus_channel_msg_header *)msg->msg_data; + const hv_vmbus_channel_gpadl_created *gpadl_created; hv_vmbus_channel_msg_info* msg_info; hv_vmbus_channel_msg_header* request_header; @@ -613,8 +629,12 @@ vmbus_channel_on_gpadl_created(const hv_ * response and signal the requesting thread */ static void -vmbus_channel_on_gpadl_torndown(const hv_vmbus_channel_msg_header *hdr) +vmbus_channel_on_gpadl_torndown(struct vmbus_softc *sc, + const struct vmbus_message *msg) { + const hv_vmbus_channel_msg_header *hdr = + (const hv_vmbus_channel_msg_header *)msg->msg_data; + const hv_vmbus_channel_gpadl_torndown *gpadl_torndown; hv_vmbus_channel_msg_info* msg_info; hv_vmbus_channel_msg_header* requestHeader; @@ -650,39 +670,11 @@ vmbus_channel_on_gpadl_torndown(const hv mtx_unlock(&hv_vmbus_g_connection.channel_msg_lock); } -/** - * @brief Version response handler. - * - * This is invoked when we received a response - * to our initiate contact request. Find the matching request, copy th - * response and signal the requesting thread. - */ static void -vmbus_channel_on_version_response(const hv_vmbus_channel_msg_header *hdr) +vmbus_channel_on_version_response(struct vmbus_softc *sc, + const struct vmbus_message *msg) { - hv_vmbus_channel_msg_info* msg_info; - hv_vmbus_channel_msg_header* requestHeader; - hv_vmbus_channel_initiate_contact* initiate; - const hv_vmbus_channel_version_response *versionResponse; - - versionResponse = (const hv_vmbus_channel_version_response *)hdr; - - mtx_lock(&hv_vmbus_g_connection.channel_msg_lock); - TAILQ_FOREACH(msg_info, &hv_vmbus_g_connection.channel_msg_anchor, - msg_list_entry) { - requestHeader = (hv_vmbus_channel_msg_header*) msg_info->msg; - if (requestHeader->message_type - == HV_CHANNEL_MESSAGE_INITIATED_CONTACT) { - initiate = - (hv_vmbus_channel_initiate_contact*) requestHeader; - memcpy(&msg_info->response.version_response, - versionResponse, - sizeof(hv_vmbus_channel_version_response)); - sema_post(&msg_info->wait_sema); - } - } - mtx_unlock(&hv_vmbus_g_connection.channel_msg_lock); - + vmbus_msghc_wakeup(sc, msg); } /** @@ -868,5 +860,5 @@ vmbus_chan_msgproc(struct vmbus_softc *s entry = &g_channel_message_table[msg_type]; if (entry->messageHandler) - entry->messageHandler(hdr); + entry->messageHandler(sc, msg); } Modified: stable/10/sys/dev/hyperv/vmbus/hv_connection.c ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/hv_connection.c Tue Oct 11 02:54:56 2016 (r307013) +++ stable/10/sys/dev/hyperv/vmbus/hv_connection.c Tue Oct 11 05:44:36 2016 (r307014) @@ -42,6 +42,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include @@ -52,97 +53,7 @@ hv_vmbus_connection hv_vmbus_g_connectio { .connect_state = HV_DISCONNECTED, .next_gpadl_handle = 0xE1E10, }; -uint32_t hv_vmbus_protocal_version = HV_VMBUS_VERSION_WS2008; - -static uint32_t -hv_vmbus_get_next_version(uint32_t current_ver) -{ - switch (current_ver) { - case (HV_VMBUS_VERSION_WIN7): - return(HV_VMBUS_VERSION_WS2008); - - case (HV_VMBUS_VERSION_WIN8): - return(HV_VMBUS_VERSION_WIN7); - - case (HV_VMBUS_VERSION_WIN8_1): - return(HV_VMBUS_VERSION_WIN8); - - case (HV_VMBUS_VERSION_WS2008): - default: - return(HV_VMBUS_VERSION_INVALID); - } -} - -/** - * Negotiate the highest supported hypervisor version. - */ -static int -hv_vmbus_negotiate_version(struct vmbus_softc *sc, - hv_vmbus_channel_msg_info *msg_info, uint32_t version) -{ - int ret = 0; - hv_vmbus_channel_initiate_contact *msg; - - sema_init(&msg_info->wait_sema, 0, "Msg Info Sema"); - msg = (hv_vmbus_channel_initiate_contact*) msg_info->msg; - - msg->header.message_type = HV_CHANNEL_MESSAGE_INITIATED_CONTACT; - msg->vmbus_version_requested = version; - - msg->interrupt_page = sc->vmbus_evtflags_dma.hv_paddr; - msg->monitor_page_1 = sc->vmbus_mnf1_dma.hv_paddr; - msg->monitor_page_2 = sc->vmbus_mnf2_dma.hv_paddr; - - /** - * Add to list before we send the request since we may receive the - * response before returning from this routine - */ - mtx_lock(&hv_vmbus_g_connection.channel_msg_lock); - - TAILQ_INSERT_TAIL( - &hv_vmbus_g_connection.channel_msg_anchor, - msg_info, - msg_list_entry); - - mtx_unlock(&hv_vmbus_g_connection.channel_msg_lock); - - ret = hv_vmbus_post_message( - msg, - sizeof(hv_vmbus_channel_initiate_contact)); - - if (ret != 0) { - mtx_lock(&hv_vmbus_g_connection.channel_msg_lock); - TAILQ_REMOVE( - &hv_vmbus_g_connection.channel_msg_anchor, - msg_info, - msg_list_entry); - mtx_unlock(&hv_vmbus_g_connection.channel_msg_lock); - return (ret); - } - - /** - * Wait for the connection response - */ - ret = sema_timedwait(&msg_info->wait_sema, 5 * hz); /* KYS 5 seconds */ - - mtx_lock(&hv_vmbus_g_connection.channel_msg_lock); - TAILQ_REMOVE( - &hv_vmbus_g_connection.channel_msg_anchor, - msg_info, - msg_list_entry); - mtx_unlock(&hv_vmbus_g_connection.channel_msg_lock); - - /** - * Check if successful - */ - if (msg_info->response.version_response.version_supported) { - hv_vmbus_g_connection.connect_state = HV_CONNECTED; - } else { - ret = ECONNREFUSED; - } - - return (ret); -} +uint32_t hv_vmbus_protocal_version; /** * Send a connect request on the partition service connection @@ -150,10 +61,6 @@ hv_vmbus_negotiate_version(struct vmbus_ int hv_vmbus_connect(struct vmbus_softc *sc) { - int ret = 0; - uint32_t version; - hv_vmbus_channel_msg_info* msg_info = NULL; - /** * Make sure we are not connecting or connected */ @@ -174,60 +81,12 @@ hv_vmbus_connect(struct vmbus_softc *sc) mtx_init(&hv_vmbus_g_connection.channel_lock, "vmbus channel", NULL, MTX_DEF); - msg_info = (hv_vmbus_channel_msg_info*) - malloc(sizeof(hv_vmbus_channel_msg_info) + - sizeof(hv_vmbus_channel_initiate_contact), - M_DEVBUF, M_WAITOK | M_ZERO); - hv_vmbus_g_connection.channels = malloc(sizeof(hv_vmbus_channel*) * VMBUS_CHAN_MAX, M_DEVBUF, M_WAITOK | M_ZERO); - /* - * Find the highest vmbus version number we can support. - */ - version = HV_VMBUS_VERSION_CURRENT; - - do { - ret = hv_vmbus_negotiate_version(sc, msg_info, version); - if (ret == EWOULDBLOCK) { - /* - * We timed out. - */ - goto cleanup; - } - - if (hv_vmbus_g_connection.connect_state == HV_CONNECTED) - break; - - version = hv_vmbus_get_next_version(version); - } while (version != HV_VMBUS_VERSION_INVALID); - - hv_vmbus_protocal_version = version; - if (bootverbose) - printf("VMBUS: Protocol Version: %d.%d\n", - version >> 16, version & 0xFFFF); - sema_destroy(&msg_info->wait_sema); - free(msg_info, M_DEVBUF); + hv_vmbus_g_connection.connect_state = HV_CONNECTED; return (0); - - /* - * Cleanup after failure! - */ - cleanup: - - hv_vmbus_g_connection.connect_state = HV_DISCONNECTED; - - mtx_destroy(&hv_vmbus_g_connection.channel_lock); - mtx_destroy(&hv_vmbus_g_connection.channel_msg_lock); - - if (msg_info) { - sema_destroy(&msg_info->wait_sema); - free(msg_info, M_DEVBUF); - } - - free(hv_vmbus_g_connection.channels, M_DEVBUF); - return (ret); } /** @@ -333,7 +192,7 @@ int hv_vmbus_post_message(void *buffer, */ for (retries = 0; retries < 20; retries++) { ret = hv_vmbus_post_msg_via_msg_ipc(connId, - VMBUS_MSGTYPE_CHANNEL, buffer, bufferLen); + HYPERV_MSGTYPE_CHANNEL, buffer, bufferLen); if (ret == HV_STATUS_SUCCESS) return (0); Modified: stable/10/sys/dev/hyperv/vmbus/hv_vmbus_priv.h ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/hv_vmbus_priv.h Tue Oct 11 02:54:56 2016 (r307013) +++ stable/10/sys/dev/hyperv/vmbus/hv_vmbus_priv.h Tue Oct 11 05:44:36 2016 (r307014) @@ -95,7 +95,6 @@ typedef union { hv_vmbus_channel_open_result open_result; hv_vmbus_channel_gpadl_torndown gpadl_torndown; hv_vmbus_channel_gpadl_created gpadl_created; - hv_vmbus_channel_version_response version_response; } hv_vmbus_channel_msg_response; /* Modified: stable/10/sys/dev/hyperv/vmbus/hyperv.c ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/hyperv.c Tue Oct 11 02:54:56 2016 (r307013) +++ stable/10/sys/dev/hyperv/vmbus/hyperv.c Tue Oct 11 05:44:36 2016 (r307014) @@ -118,6 +118,13 @@ hv_vmbus_do_hypercall(uint64_t value, vo in_paddr, out_paddr); } +uint64_t +hypercall_post_message(bus_addr_t msg_paddr) +{ + return hypercall_md(hypercall_context.hc_addr, + HYPERCALL_POST_MESSAGE, msg_paddr, 0); +} + /** * @brief Post a message using the hypervisor message IPC. * (This involves a hypercall.) Modified: stable/10/sys/dev/hyperv/vmbus/hyperv_reg.h ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/hyperv_reg.h Tue Oct 11 02:54:56 2016 (r307013) +++ stable/10/sys/dev/hyperv/vmbus/hyperv_reg.h Tue Oct 11 05:44:36 2016 (r307014) @@ -29,6 +29,8 @@ #ifndef _HYPERV_REG_H_ #define _HYPERV_REG_H_ +#include + /* * Hyper-V Synthetic MSRs */ @@ -130,4 +132,41 @@ #define CPUID_LEAF_HV_LIMITS 0x40000005 #define CPUID_LEAF_HV_HWFEATURES 0x40000006 +/* + * Hyper-V message types + */ +#define HYPERV_MSGTYPE_NONE 0 +#define HYPERV_MSGTYPE_CHANNEL 1 +#define HYPERV_MSGTYPE_TIMER_EXPIRED 0x80000010 + +/* + * Hypercall status codes + */ +#define HYPERCALL_STATUS_SUCCESS 0x0000 + +/* + * Hypercall input values + */ +#define HYPERCALL_POST_MESSAGE 0x005c + +/* + * Hypercall input parameters + */ + +/* + * HYPERCALL_POST_MESSAGE + */ +#define HYPERCALL_POSTMSGIN_DSIZE_MAX 240 +#define HYPERCALL_POSTMSGIN_SIZE 256 +#define HYPERCALL_POSTMSGIN_ALIGN 8 + +struct hypercall_postmsg_in { + uint32_t hc_connid; + uint32_t hc_rsvd; + uint32_t hc_msgtype; /* HYPERV_MSGTYPE_ */ + uint32_t hc_dsize; + uint8_t hc_data[HYPERCALL_POSTMSGIN_DSIZE_MAX]; +} __packed; +CTASSERT(sizeof(struct hypercall_postmsg_in) == HYPERCALL_POSTMSGIN_SIZE); + #endif /* !_HYPERV_REG_H_ */ Modified: stable/10/sys/dev/hyperv/vmbus/hyperv_var.h ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/hyperv_var.h Tue Oct 11 02:54:56 2016 (r307013) +++ stable/10/sys/dev/hyperv/vmbus/hyperv_var.h Tue Oct 11 05:44:36 2016 (r307014) @@ -29,6 +29,8 @@ #ifndef _HYPERV_VAR_H_ #define _HYPERV_VAR_H_ +#include + #ifndef NANOSEC #define NANOSEC 1000000000ULL #endif @@ -38,4 +40,6 @@ extern u_int hyperv_features; extern u_int hyperv_recommends; +uint64_t hypercall_post_message(bus_addr_t msg_paddr); + #endif /* !_HYPERV_VAR_H_ */ Modified: stable/10/sys/dev/hyperv/vmbus/vmbus.c ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/vmbus.c Tue Oct 11 02:54:56 2016 (r307013) +++ stable/10/sys/dev/hyperv/vmbus/vmbus.c Tue Oct 11 05:44:36 2016 (r307014) @@ -69,10 +69,354 @@ __FBSDID("$FreeBSD$"); #include #include "acpi_if.h" +/* + * NOTE: DO NOT CHANGE THESE + */ +#define VMBUS_CONNID_MESSAGE 1 +#define VMBUS_CONNID_EVENT 2 + +struct vmbus_msghc { + struct hypercall_postmsg_in *mh_inprm; + struct hypercall_postmsg_in mh_inprm_save; + struct hyperv_dma mh_inprm_dma; + + struct vmbus_message *mh_resp; + struct vmbus_message mh_resp0; +}; + +struct vmbus_msghc_ctx { + struct vmbus_msghc *mhc_free; + struct mtx mhc_free_lock; + uint32_t mhc_flags; + + struct vmbus_msghc *mhc_active; + struct mtx mhc_active_lock; +}; + +#define VMBUS_MSGHC_CTXF_DESTROY 0x0001 + +static int vmbus_init(struct vmbus_softc *); +static int vmbus_init_contact(struct vmbus_softc *, + uint32_t); + +static struct vmbus_msghc_ctx *vmbus_msghc_ctx_create(bus_dma_tag_t); +static void vmbus_msghc_ctx_destroy( + struct vmbus_msghc_ctx *); +static void vmbus_msghc_ctx_free(struct vmbus_msghc_ctx *); +static struct vmbus_msghc *vmbus_msghc_alloc(bus_dma_tag_t); +static void vmbus_msghc_free(struct vmbus_msghc *); +static struct vmbus_msghc *vmbus_msghc_get1(struct vmbus_msghc_ctx *, + uint32_t); + struct vmbus_softc *vmbus_sc; extern inthand_t IDTVEC(rsvd), IDTVEC(vmbus_isr); +static const uint32_t vmbus_version[] = { + HV_VMBUS_VERSION_WIN8_1, + HV_VMBUS_VERSION_WIN8, + HV_VMBUS_VERSION_WIN7, + HV_VMBUS_VERSION_WS2008 +}; + +static struct vmbus_msghc * +vmbus_msghc_alloc(bus_dma_tag_t parent_dtag) +{ + struct vmbus_msghc *mh; + + mh = malloc(sizeof(*mh), M_DEVBUF, M_WAITOK | M_ZERO); + + mh->mh_inprm = hyperv_dmamem_alloc(parent_dtag, + HYPERCALL_POSTMSGIN_ALIGN, 0, HYPERCALL_POSTMSGIN_SIZE, + &mh->mh_inprm_dma, BUS_DMA_WAITOK); + if (mh->mh_inprm == NULL) { + free(mh, M_DEVBUF); + return NULL; + } + return mh; +} + +static void +vmbus_msghc_free(struct vmbus_msghc *mh) +{ + hyperv_dmamem_free(&mh->mh_inprm_dma, mh->mh_inprm); + free(mh, M_DEVBUF); +} + +static void +vmbus_msghc_ctx_free(struct vmbus_msghc_ctx *mhc) +{ + KASSERT(mhc->mhc_active == NULL, ("still have active msg hypercall")); + KASSERT(mhc->mhc_free == NULL, ("still have hypercall msg")); + + mtx_destroy(&mhc->mhc_free_lock); + mtx_destroy(&mhc->mhc_active_lock); + free(mhc, M_DEVBUF); +} + +static struct vmbus_msghc_ctx * +vmbus_msghc_ctx_create(bus_dma_tag_t parent_dtag) +{ + struct vmbus_msghc_ctx *mhc; + + mhc = malloc(sizeof(*mhc), M_DEVBUF, M_WAITOK | M_ZERO); + mtx_init(&mhc->mhc_free_lock, "vmbus msghc free", NULL, MTX_DEF); + mtx_init(&mhc->mhc_active_lock, "vmbus msghc act", NULL, MTX_DEF); + + mhc->mhc_free = vmbus_msghc_alloc(parent_dtag); + if (mhc->mhc_free == NULL) { + vmbus_msghc_ctx_free(mhc); + return NULL; + } + return mhc; +} + +static struct vmbus_msghc * +vmbus_msghc_get1(struct vmbus_msghc_ctx *mhc, uint32_t dtor_flag) +{ + struct vmbus_msghc *mh; + + mtx_lock(&mhc->mhc_free_lock); + + while ((mhc->mhc_flags & dtor_flag) == 0 && mhc->mhc_free == NULL) { + mtx_sleep(&mhc->mhc_free, &mhc->mhc_free_lock, 0, + "gmsghc", 0); + } + if (mhc->mhc_flags & dtor_flag) { + /* Being destroyed */ + mh = NULL; + } else { + mh = mhc->mhc_free; + KASSERT(mh != NULL, ("no free hypercall msg")); + KASSERT(mh->mh_resp == NULL, + ("hypercall msg has pending response")); + mhc->mhc_free = NULL; + } + + mtx_unlock(&mhc->mhc_free_lock); + + return mh; +} + +struct vmbus_msghc * +vmbus_msghc_get(struct vmbus_softc *sc, size_t dsize) +{ + struct hypercall_postmsg_in *inprm; + struct vmbus_msghc *mh; + + if (dsize > HYPERCALL_POSTMSGIN_DSIZE_MAX) + return NULL; + + mh = vmbus_msghc_get1(sc->vmbus_msg_hc, VMBUS_MSGHC_CTXF_DESTROY); + if (mh == NULL) + return NULL; + + inprm = mh->mh_inprm; + memset(inprm, 0, HYPERCALL_POSTMSGIN_SIZE); + inprm->hc_connid = VMBUS_CONNID_MESSAGE; + inprm->hc_msgtype = HYPERV_MSGTYPE_CHANNEL; + inprm->hc_dsize = dsize; + + return mh; +} + +void +vmbus_msghc_put(struct vmbus_softc *sc, struct vmbus_msghc *mh) +{ + struct vmbus_msghc_ctx *mhc = sc->vmbus_msg_hc; + + KASSERT(mhc->mhc_active == NULL, ("msg hypercall is active")); + mh->mh_resp = NULL; + + mtx_lock(&mhc->mhc_free_lock); + KASSERT(mhc->mhc_free == NULL, ("has free hypercall msg")); + mhc->mhc_free = mh; + mtx_unlock(&mhc->mhc_free_lock); + wakeup(&mhc->mhc_free); +} + +void * +vmbus_msghc_dataptr(struct vmbus_msghc *mh) +{ + return mh->mh_inprm->hc_data; +} + +static void +vmbus_msghc_ctx_destroy(struct vmbus_msghc_ctx *mhc) +{ + struct vmbus_msghc *mh; + + mtx_lock(&mhc->mhc_free_lock); + mhc->mhc_flags |= VMBUS_MSGHC_CTXF_DESTROY; + mtx_unlock(&mhc->mhc_free_lock); + wakeup(&mhc->mhc_free); + + mh = vmbus_msghc_get1(mhc, 0); + if (mh == NULL) + panic("can't get msghc"); + + vmbus_msghc_free(mh); + vmbus_msghc_ctx_free(mhc); +} + +int +vmbus_msghc_exec_noresult(struct vmbus_msghc *mh) +{ + sbintime_t time = SBT_1MS; + int i; + + /* + * Save the input parameter so that we could restore the input + * parameter if the Hypercall failed. + * + * XXX + * Is this really necessary?! i.e. Will the Hypercall ever + * overwrite the input parameter? + */ + memcpy(&mh->mh_inprm_save, mh->mh_inprm, HYPERCALL_POSTMSGIN_SIZE); + + /* + * In order to cope with transient failures, e.g. insufficient + * resources on host side, we retry the post message Hypercall + * several times. 20 retries seem sufficient. + */ +#define HC_RETRY_MAX 20 + + for (i = 0; i < HC_RETRY_MAX; ++i) { + uint64_t status; + + status = hypercall_post_message(mh->mh_inprm_dma.hv_paddr); + if (status == HYPERCALL_STATUS_SUCCESS) + return 0; + + pause_sbt("hcpmsg", time, 0, C_HARDCLOCK); + if (time < SBT_1S * 2) + time *= 2; + + /* Restore input parameter and try again */ + memcpy(mh->mh_inprm, &mh->mh_inprm_save, + HYPERCALL_POSTMSGIN_SIZE); + } + +#undef HC_RETRY_MAX + + return EIO; +} + +int +vmbus_msghc_exec(struct vmbus_softc *sc, struct vmbus_msghc *mh) +{ + struct vmbus_msghc_ctx *mhc = sc->vmbus_msg_hc; + int error; + + KASSERT(mh->mh_resp == NULL, ("hypercall msg has pending response")); + + mtx_lock(&mhc->mhc_active_lock); + KASSERT(mhc->mhc_active == NULL, ("pending active msg hypercall")); + mhc->mhc_active = mh; + mtx_unlock(&mhc->mhc_active_lock); + + error = vmbus_msghc_exec_noresult(mh); + if (error) { + mtx_lock(&mhc->mhc_active_lock); + KASSERT(mhc->mhc_active == mh, ("msghc mismatch")); + mhc->mhc_active = NULL; + mtx_unlock(&mhc->mhc_active_lock); + } + return error; +} + +const struct vmbus_message * +vmbus_msghc_wait_result(struct vmbus_softc *sc, struct vmbus_msghc *mh) +{ + struct vmbus_msghc_ctx *mhc = sc->vmbus_msg_hc; + + mtx_lock(&mhc->mhc_active_lock); + + KASSERT(mhc->mhc_active == mh, ("msghc mismatch")); + while (mh->mh_resp == NULL) { + mtx_sleep(&mhc->mhc_active, &mhc->mhc_active_lock, 0, + "wmsghc", 0); + } + mhc->mhc_active = NULL; + + mtx_unlock(&mhc->mhc_active_lock); + + return mh->mh_resp; +} + +void +vmbus_msghc_wakeup(struct vmbus_softc *sc, const struct vmbus_message *msg) +{ + struct vmbus_msghc_ctx *mhc = sc->vmbus_msg_hc; + struct vmbus_msghc *mh; + + mtx_lock(&mhc->mhc_active_lock); + + mh = mhc->mhc_active; + KASSERT(mh != NULL, ("no pending msg hypercall")); + memcpy(&mh->mh_resp0, msg, sizeof(mh->mh_resp0)); + mh->mh_resp = &mh->mh_resp0; + + mtx_unlock(&mhc->mhc_active_lock); + wakeup(&mhc->mhc_active); +} + +static int +vmbus_init_contact(struct vmbus_softc *sc, uint32_t version) +{ + struct vmbus_chanmsg_init_contact *req; + const struct vmbus_chanmsg_version_resp *resp; + const struct vmbus_message *msg; + struct vmbus_msghc *mh; + int error, supp = 0; + + mh = vmbus_msghc_get(sc, sizeof(*req)); + if (mh == NULL) + return ENXIO; + + req = vmbus_msghc_dataptr(mh); + req->chm_hdr.chm_type = VMBUS_CHANMSG_TYPE_INIT_CONTACT; + req->chm_ver = version; + req->chm_evtflags = sc->vmbus_evtflags_dma.hv_paddr; + req->chm_mnf1 = sc->vmbus_mnf1_dma.hv_paddr; + req->chm_mnf2 = sc->vmbus_mnf2_dma.hv_paddr; + + error = vmbus_msghc_exec(sc, mh); + if (error) { + vmbus_msghc_put(sc, mh); + return error; + } + + msg = vmbus_msghc_wait_result(sc, mh); + resp = (const struct vmbus_chanmsg_version_resp *)msg->msg_data; + supp = resp->chm_supp; + + vmbus_msghc_put(sc, mh); + + return (supp ? 0 : EOPNOTSUPP); +} + +static int +vmbus_init(struct vmbus_softc *sc) +{ + int i; + + for (i = 0; i < nitems(vmbus_version); ++i) { + int error; + + error = vmbus_init_contact(sc, vmbus_version[i]); + if (!error) { + hv_vmbus_protocal_version = vmbus_version[i]; + device_printf(sc->vmbus_dev, "version %u.%u\n", + (hv_vmbus_protocal_version >> 16), + (hv_vmbus_protocal_version & 0xffff)); + return 0; + } + } + return ENXIO; +} + static void vmbus_msg_task(void *xsc, int pending __unused) { @@ -81,19 +425,19 @@ vmbus_msg_task(void *xsc, int pending __ msg = VMBUS_PCPU_GET(sc, message, curcpu) + VMBUS_SINT_MESSAGE; for (;;) { - if (msg->msg_type == VMBUS_MSGTYPE_NONE) { + if (msg->msg_type == HYPERV_MSGTYPE_NONE) { /* No message */ break; - } else if (msg->msg_type == VMBUS_MSGTYPE_CHANNEL) { + } else if (msg->msg_type == HYPERV_MSGTYPE_CHANNEL) { /* Channel message */ vmbus_chan_msgproc(sc, __DEVOLATILE(const struct vmbus_message *, msg)); } - msg->msg_type = VMBUS_MSGTYPE_NONE; + msg->msg_type = HYPERV_MSGTYPE_NONE; /* * Make sure the write to msg_type (i.e. set to - * VMBUS_MSGTYPE_NONE) happens before we read the + * HYPERV_MSGTYPE_NONE) happens before we read the * msg_flags and EOMing. Otherwise, the EOMing will * not deliver any more messages since there is no * empty slot @@ -127,14 +471,14 @@ vmbus_handle_intr1(struct vmbus_softc *s * TODO: move this to independent IDT vector. */ msg = msg_base + VMBUS_SINT_TIMER; - if (msg->msg_type == VMBUS_MSGTYPE_TIMER_EXPIRED) { - msg->msg_type = VMBUS_MSGTYPE_NONE; + if (msg->msg_type == HYPERV_MSGTYPE_TIMER_EXPIRED) { + msg->msg_type = HYPERV_MSGTYPE_NONE; vmbus_et_intr(frame); /* * Make sure the write to msg_type (i.e. set to - * VMBUS_MSGTYPE_NONE) happens before we read the + * HYPERV_MSGTYPE_NONE) happens before we read the * msg_flags and EOMing. Otherwise, the EOMing will * not deliver any more messages since there is no * empty slot @@ -166,7 +510,7 @@ vmbus_handle_intr1(struct vmbus_softc *s * Check messages. Mainly management stuffs; ultra low rate. */ msg = msg_base + VMBUS_SINT_MESSAGE; - if (__predict_false(msg->msg_type != VMBUS_MSGTYPE_NONE)) { + if (__predict_false(msg->msg_type != HYPERV_MSGTYPE_NONE)) { taskqueue_enqueue(VMBUS_PCPU_GET(sc, message_tq, cpu), VMBUS_PCPU_PTR(sc, message_task, cpu)); } @@ -700,6 +1044,16 @@ vmbus_bus_init(void) sc->vmbus_flags |= VMBUS_FLAG_ATTACHED; /* + * Create context for "post message" Hypercalls + */ + sc->vmbus_msg_hc = vmbus_msghc_ctx_create( + bus_get_dma_tag(sc->vmbus_dev)); + if (sc->vmbus_msg_hc == NULL) { + ret = ENXIO; + goto cleanup; + } + + /* * Allocate DMA stuffs. */ ret = vmbus_dma_alloc(sc); @@ -728,6 +1082,10 @@ vmbus_bus_init(void) if (ret != 0) goto cleanup; + ret = vmbus_init(sc); + if (ret != 0) + goto cleanup; + if (hv_vmbus_protocal_version == HV_VMBUS_VERSION_WS2008 || hv_vmbus_protocal_version == HV_VMBUS_VERSION_WIN7) sc->vmbus_event_proc = vmbus_event_proc_compat; @@ -745,6 +1103,10 @@ vmbus_bus_init(void) cleanup: vmbus_intr_teardown(sc); vmbus_dma_free(sc); + if (sc->vmbus_msg_hc != NULL) { + vmbus_msghc_ctx_destroy(sc->vmbus_msg_hc); + sc->vmbus_msg_hc = NULL; + } return (ret); } @@ -812,6 +1174,11 @@ vmbus_detach(device_t dev) vmbus_intr_teardown(sc); vmbus_dma_free(sc); + if (sc->vmbus_msg_hc != NULL) { + vmbus_msghc_ctx_destroy(sc->vmbus_msg_hc); + sc->vmbus_msg_hc = NULL; + } + return (0); } Modified: stable/10/sys/dev/hyperv/vmbus/vmbus_reg.h ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/vmbus_reg.h Tue Oct 11 02:54:56 2016 (r307013) +++ stable/10/sys/dev/hyperv/vmbus/vmbus_reg.h Tue Oct 11 05:44:36 2016 (r307014) @@ -39,7 +39,7 @@ #define VMBUS_MSG_SIZE 256 struct vmbus_message { - uint32_t msg_type; /* VMBUS_MSGTYPE_ */ + uint32_t msg_type; /* HYPERV_MSGTYPE_ */ uint8_t msg_dsize; /* data size */ uint8_t msg_flags; /* VMBUS_MSGFLAG_ */ uint16_t msg_rsvd; @@ -48,10 +48,6 @@ struct vmbus_message { } __packed; CTASSERT(sizeof(struct vmbus_message) == VMBUS_MSG_SIZE); -#define VMBUS_MSGTYPE_NONE 0 -#define VMBUS_MSGTYPE_CHANNEL 1 -#define VMBUS_MSGTYPE_TIMER_EXPIRED 0x80000010 - #define VMBUS_MSGFLAG_PENDING 0x01 /* @@ -81,4 +77,34 @@ CTASSERT(sizeof(struct vmbus_evtflags) = #define VMBUS_CHAN_MAX_COMPAT 256 #define VMBUS_CHAN_MAX (VMBUS_EVTFLAG_LEN * VMBUS_EVTFLAGS_MAX) +/* + * Channel messages + * - Embedded in vmbus_message.msg_data, e.g. response. + * - Embedded in hypercall_postmsg_in.hc_data, e.g. request. + */ + +#define VMBUS_CHANMSG_TYPE_INIT_CONTACT 14 /* REQ */ +#define VMBUS_CHANMSG_TYPE_VERSION_RESP 15 /* RESP */ + +struct vmbus_chanmsg_hdr { + uint32_t chm_type; /* VMBUS_CHANMSG_TYPE_ */ + uint32_t chm_rsvd; +} __packed; + *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-all@freebsd.org Tue Oct 11 05:47:53 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 7D906C075C7; Tue, 11 Oct 2016 05:47:53 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 30E6678E; Tue, 11 Oct 2016 05:47:53 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9B5lqTT069132; Tue, 11 Oct 2016 05:47:52 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9B5lq85069131; Tue, 11 Oct 2016 05:47:52 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610110547.u9B5lq85069131@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Tue, 11 Oct 2016 05:47:52 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307015 - stable/10/sys/dev/hyperv/netvsc X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Oct 2016 05:47:53 -0000 Author: sephe Date: Tue Oct 11 05:47:52 2016 New Revision: 307015 URL: https://svnweb.freebsd.org/changeset/base/307015 Log: MFC 302544 hyperv/hn: Add tunable to allow tcp_lro_queue_mbuf() Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D6841 Modified: stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Tue Oct 11 05:44:36 2016 (r307014) +++ stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Tue Oct 11 05:47:52 2016 (r307015) @@ -299,6 +299,12 @@ static int hn_tx_swq_depth = 0; SYSCTL_INT(_hw_hn, OID_AUTO, tx_swq_depth, CTLFLAG_RDTUN, &hn_tx_swq_depth, 0, "Depth of IFQ or BUFRING"); +#if __FreeBSD_version >= 1100095 +static u_int hn_lro_mbufq_depth = 0; +SYSCTL_UINT(_hw_hn, OID_AUTO, lro_mbufq_depth, CTLFLAG_RDTUN, + &hn_lro_mbufq_depth, 0, "Depth of LRO mbuf queue"); +#endif + static u_int hn_cpu_index; /* @@ -1300,6 +1306,19 @@ hv_m_append(struct mbuf *m0, int len, c_ return (remainder == 0); } +#if defined(INET) || defined(INET6) +static __inline int +hn_lro_rx(struct lro_ctrl *lc, struct mbuf *m) +{ +#if __FreeBSD_version >= 1100095 + if (hn_lro_mbufq_depth) { + tcp_lro_queue_mbuf(lc, m); + return 0; + } +#endif + return tcp_lro_rx(lc, m, 0); +} +#endif /* * Called when we receive a data packet from the "wire" on the @@ -1505,7 +1524,7 @@ skip: if (lro->lro_cnt) { rxr->hn_lro_tried++; - if (tcp_lro_rx(lro, m_new, 0) == 0) { + if (hn_lro_rx(lro, m_new) == 0) { /* DONE! */ return 0; } @@ -2269,7 +2288,8 @@ hn_create_rx_data(struct hn_softc *sc, i */ #if defined(INET) || defined(INET6) #if __FreeBSD_version >= 1100095 - tcp_lro_init_args(&rxr->hn_lro, sc->hn_ifp, lroent_cnt, 0); + tcp_lro_init_args(&rxr->hn_lro, sc->hn_ifp, lroent_cnt, + hn_lro_mbufq_depth); #else tcp_lro_init(&rxr->hn_lro); rxr->hn_lro.ifp = sc->hn_ifp; From owner-svn-src-all@freebsd.org Tue Oct 11 06:04:42 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 61A57C07D7B; Tue, 11 Oct 2016 06:04:42 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 1420811B; Tue, 11 Oct 2016 06:04:42 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9B64fo7076563; Tue, 11 Oct 2016 06:04:41 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9B64e2D076555; Tue, 11 Oct 2016 06:04:40 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610110604.u9B64e2D076555@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Tue, 11 Oct 2016 06:04:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307016 - in stable/10/sys/dev/hyperv: include vmbus X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Oct 2016 06:04:42 -0000 Author: sephe Date: Tue Oct 11 06:04:40 2016 New Revision: 307016 URL: https://svnweb.freebsd.org/changeset/base/307016 Log: MFC 302543,302545,302547,302549,302554,302556,302557,302559,302606 302543 hyperv/vmbus: Use post message Hypercall APIs for channel request Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D6831 302545 hyperv/vmbus: Function renaming. And pass vmbus_softc to vmbus_doattach() Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D6842 302547 hyperv/vmbus: Explicitly assign channel message process array. While I'm here, remove the useless message type from message process array, which is not used and serves no purposes at all. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D6858 302549 hyperv/vmbus: Add sysctl to expose vmbus version. Requested by: Hongxiong Xian Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D6860 302554 hyperv/vmbus: Use post message Hypercall APIs for unload Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D6861 302556 hyperv/vmbus: Create channel synchronously. The device probe/attach has been move to a different thread, so the reasons to create the channel asynchronously are no longer valid. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D6862 302557 hyperv/vmbus: Save vmbus softc to channels. So that we don't need to access the global vmbus softc. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D6863 302559 hyperv/vmbus: Embed channel detach task in channel itself. GC work queue stuffs. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D6864 302606 hyperv/vmbus: Reorganize vmbus scan process. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D6875 Modified: stable/10/sys/dev/hyperv/include/hyperv.h stable/10/sys/dev/hyperv/vmbus/hv_channel.c stable/10/sys/dev/hyperv/vmbus/hv_channel_mgmt.c stable/10/sys/dev/hyperv/vmbus/hv_connection.c stable/10/sys/dev/hyperv/vmbus/hv_vmbus_priv.h stable/10/sys/dev/hyperv/vmbus/vmbus.c stable/10/sys/dev/hyperv/vmbus/vmbus_reg.h stable/10/sys/dev/hyperv/vmbus/vmbus_var.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/hyperv/include/hyperv.h ============================================================================== --- stable/10/sys/dev/hyperv/include/hyperv.h Tue Oct 11 05:47:52 2016 (r307015) +++ stable/10/sys/dev/hyperv/include/hyperv.h Tue Oct 11 06:04:40 2016 (r307016) @@ -713,6 +713,7 @@ typedef struct { typedef struct hv_vmbus_channel { TAILQ_ENTRY(hv_vmbus_channel) list_entry; struct hv_device* device; + struct vmbus_softc *vmbus_sc; hv_vmbus_channel_state state; hv_vmbus_channel_offer_channel offer_msg; /* @@ -808,6 +809,8 @@ typedef struct hv_vmbus_channel { void *hv_chan_priv1; void *hv_chan_priv2; void *hv_chan_priv3; + + struct task ch_detach_task; } hv_vmbus_channel; #define HV_VMBUS_CHAN_ISPRIMARY(chan) ((chan)->primary_channel == NULL) Modified: stable/10/sys/dev/hyperv/vmbus/hv_channel.c ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/hv_channel.c Tue Oct 11 05:47:52 2016 (r307015) +++ stable/10/sys/dev/hyperv/vmbus/hv_channel.c Tue Oct 11 06:04:40 2016 (r307016) @@ -67,7 +67,7 @@ static void vmbus_channel_set_event(hv_vmbus_channel *channel) { if (channel->offer_msg.monitor_allocated) { - struct vmbus_softc *sc = vmbus_get_softc(); + struct vmbus_softc *sc = channel->vmbus_sc; hv_vmbus_monitor_page *monitor_page; uint32_t chanid = channel->offer_msg.child_rel_id; @@ -205,7 +205,7 @@ hv_vmbus_channel_open( vmbus_on_channel_open(new_channel); - new_channel->rxq = VMBUS_PCPU_GET(vmbus_get_softc(), event_tq, + new_channel->rxq = VMBUS_PCPU_GET(new_channel->vmbus_sc, event_tq, new_channel->target_cpu); TASK_INIT(&new_channel->channel_task, 0, VmbusProcessChannelEvent, new_channel); Modified: stable/10/sys/dev/hyperv/vmbus/hv_channel_mgmt.c ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/hv_channel_mgmt.c Tue Oct 11 05:47:52 2016 (r307015) +++ stable/10/sys/dev/hyperv/vmbus/hv_channel_mgmt.c Tue Oct 11 06:04:40 2016 (r307016) @@ -39,19 +39,13 @@ __FBSDID("$FreeBSD$"); #include #include -/* - * Internal functions - */ +typedef void (*vmbus_chanmsg_proc_t) + (struct vmbus_softc *, const struct vmbus_message *); -typedef struct hv_vmbus_channel_msg_table_entry { - hv_vmbus_channel_msg_type messageType; - void (*messageHandler) - (struct vmbus_softc *sc, - const struct vmbus_message *msg); -} hv_vmbus_channel_msg_table_entry; - -static void vmbus_channel_on_offer_internal(void *context); -static void vmbus_channel_on_offer_rescind_internal(void *context); +static struct hv_vmbus_channel *hv_vmbus_allocate_channel(struct vmbus_softc *); +static void vmbus_channel_on_offer_internal(struct vmbus_softc *, + const hv_vmbus_channel_offer_channel *offer); +static void vmbus_chan_detach_task(void *, int); static void vmbus_channel_on_offer(struct vmbus_softc *, const struct vmbus_message *); @@ -71,108 +65,38 @@ static void vmbus_channel_on_version_res /** * Channel message dispatch table */ -static const hv_vmbus_channel_msg_table_entry - g_channel_message_table[HV_CHANNEL_MESSAGE_COUNT] = { - { HV_CHANNEL_MESSAGE_INVALID, - NULL }, - { HV_CHANNEL_MESSAGE_OFFER_CHANNEL, - vmbus_channel_on_offer }, - { HV_CHANNEL_MESSAGE_RESCIND_CHANNEL_OFFER, - vmbus_channel_on_offer_rescind }, - { HV_CHANNEL_MESSAGE_REQUEST_OFFERS, - NULL }, - { HV_CHANNEL_MESSAGE_ALL_OFFERS_DELIVERED, - vmbus_channel_on_offers_delivered }, - { HV_CHANNEL_MESSAGE_OPEN_CHANNEL, - NULL }, - { HV_CHANNEL_MESSAGE_OPEN_CHANNEL_RESULT, - vmbus_channel_on_open_result }, - { HV_CHANNEL_MESSAGE_CLOSE_CHANNEL, - NULL }, - { HV_CHANNEL_MESSAGEL_GPADL_HEADER, - NULL }, - { HV_CHANNEL_MESSAGE_GPADL_BODY, - NULL }, - { HV_CHANNEL_MESSAGE_GPADL_CREATED, - vmbus_channel_on_gpadl_created }, - { HV_CHANNEL_MESSAGE_GPADL_TEARDOWN, - NULL }, - { HV_CHANNEL_MESSAGE_GPADL_TORNDOWN, - vmbus_channel_on_gpadl_torndown }, - { HV_CHANNEL_MESSAGE_REL_ID_RELEASED, - NULL }, - { HV_CHANNEL_MESSAGE_INITIATED_CONTACT, - NULL }, - { HV_CHANNEL_MESSAGE_VERSION_RESPONSE, - vmbus_channel_on_version_response }, - { HV_CHANNEL_MESSAGE_UNLOAD, - NULL } +static const vmbus_chanmsg_proc_t +vmbus_chanmsg_process[HV_CHANNEL_MESSAGE_COUNT] = { + [HV_CHANNEL_MESSAGE_OFFER_CHANNEL] = + vmbus_channel_on_offer, + [HV_CHANNEL_MESSAGE_RESCIND_CHANNEL_OFFER] = + vmbus_channel_on_offer_rescind, + [HV_CHANNEL_MESSAGE_ALL_OFFERS_DELIVERED] = + vmbus_channel_on_offers_delivered, + [HV_CHANNEL_MESSAGE_OPEN_CHANNEL_RESULT] = + vmbus_channel_on_open_result, + [HV_CHANNEL_MESSAGE_GPADL_CREATED] = + vmbus_channel_on_gpadl_created, + [HV_CHANNEL_MESSAGE_GPADL_TORNDOWN] = + vmbus_channel_on_gpadl_torndown, + [HV_CHANNEL_MESSAGE_VERSION_RESPONSE] = + vmbus_channel_on_version_response }; -typedef struct hv_work_item { - struct task work; - void (*callback)(void *); - void* context; -} hv_work_item; - -static struct mtx vmbus_chwait_lock; -MTX_SYSINIT(vmbus_chwait_lk, &vmbus_chwait_lock, "vmbus primarych wait lock", - MTX_DEF); -static uint32_t vmbus_chancnt; -static uint32_t vmbus_devcnt; - -#define VMBUS_CHANCNT_DONE 0x80000000 - -/** - * Implementation of the work abstraction. - */ -static void -work_item_callback(void *work, int pending) -{ - struct hv_work_item *w = (struct hv_work_item *)work; - - w->callback(w->context); - - free(w, M_DEVBUF); -} - -/** - * @brief Create work item - */ -static int -hv_queue_work_item( - void (*callback)(void *), void *context) -{ - struct hv_work_item *w = malloc(sizeof(struct hv_work_item), - M_DEVBUF, M_NOWAIT); - KASSERT(w != NULL, ("Error VMBUS: Failed to allocate WorkItem\n")); - if (w == NULL) - return (ENOMEM); - - w->callback = callback; - w->context = context; - - TASK_INIT(&w->work, 0, work_item_callback, w); - - return (taskqueue_enqueue(taskqueue_thread, &w->work)); -} - - /** * @brief Allocate and initialize a vmbus channel object */ -hv_vmbus_channel* -hv_vmbus_allocate_channel(void) +static struct hv_vmbus_channel * +hv_vmbus_allocate_channel(struct vmbus_softc *sc) { - hv_vmbus_channel* channel; + struct hv_vmbus_channel *channel; - channel = (hv_vmbus_channel*) malloc( - sizeof(hv_vmbus_channel), - M_DEVBUF, - M_WAITOK | M_ZERO); + channel = malloc(sizeof(*channel), M_DEVBUF, M_WAITOK | M_ZERO); + channel->vmbus_sc = sc; mtx_init(&channel->sc_lock, "vmbus multi channel", NULL, MTX_DEF); TAILQ_INIT(&channel->sc_list_anchor); + TASK_INIT(&channel->ch_detach_task, 0, vmbus_chan_detach_task, channel); return (channel); } @@ -195,7 +119,6 @@ static void vmbus_channel_process_offer(hv_vmbus_channel *new_channel) { hv_vmbus_channel* channel; - int ret; uint32_t relid; relid = new_channel->offer_msg.child_rel_id; @@ -300,19 +223,8 @@ vmbus_channel_process_offer(hv_vmbus_cha * binding which eventually invokes the device driver's AddDevice() * method. */ - ret = hv_vmbus_child_device_register(new_channel->device); - if (ret != 0) { - mtx_lock(&hv_vmbus_g_connection.channel_lock); - TAILQ_REMOVE(&hv_vmbus_g_connection.channel_anchor, - new_channel, list_entry); - mtx_unlock(&hv_vmbus_g_connection.channel_lock); - hv_vmbus_free_vmbus_channel(new_channel); - } - - mtx_lock(&vmbus_chwait_lock); - vmbus_devcnt++; - mtx_unlock(&vmbus_chwait_lock); - wakeup(&vmbus_devcnt); + hv_vmbus_child_device_register(new_channel->vmbus_sc, + new_channel->device); } void @@ -327,7 +239,7 @@ vmbus_channel_cpu_set(struct hv_vmbus_ch } chan->target_cpu = cpu; - chan->target_vcpu = VMBUS_PCPU_GET(vmbus_get_softc(), vcpuid, cpu); + chan->target_vcpu = VMBUS_PCPU_GET(chan->vmbus_sc, vcpuid, cpu); if (bootverbose) { printf("vmbus_chan%u: assigned to cpu%u [vcpu%u]\n", @@ -396,46 +308,28 @@ vmbus_channel_select_defcpu(struct hv_vm /** * @brief Handler for channel offers from Hyper-V/Azure * - * Handler for channel offers from vmbus in parent partition. We ignore - * all offers except network and storage offers. For each network and storage - * offers, we create a channel object and queue a work item to the channel - * object to process the offer synchronously + * Handler for channel offers from vmbus in parent partition. */ static void vmbus_channel_on_offer(struct vmbus_softc *sc, const struct vmbus_message *msg) { - const hv_vmbus_channel_msg_header *hdr = - (const hv_vmbus_channel_msg_header *)msg->msg_data; - const hv_vmbus_channel_offer_channel *offer; - hv_vmbus_channel_offer_channel *copied; - offer = (const hv_vmbus_channel_offer_channel *)hdr; + /* New channel is offered by vmbus */ + vmbus_scan_newchan(sc); - // copy offer data - copied = malloc(sizeof(*copied), M_DEVBUF, M_NOWAIT); - if (copied == NULL) { - printf("fail to allocate memory\n"); - return; - } - - memcpy(copied, hdr, sizeof(*copied)); - hv_queue_work_item(vmbus_channel_on_offer_internal, copied); - - mtx_lock(&vmbus_chwait_lock); - if ((vmbus_chancnt & VMBUS_CHANCNT_DONE) == 0) - vmbus_chancnt++; - mtx_unlock(&vmbus_chwait_lock); + offer = (const hv_vmbus_channel_offer_channel *)msg->msg_data; + vmbus_channel_on_offer_internal(sc, offer); } static void -vmbus_channel_on_offer_internal(void* context) +vmbus_channel_on_offer_internal(struct vmbus_softc *sc, + const hv_vmbus_channel_offer_channel *offer) { hv_vmbus_channel* new_channel; - hv_vmbus_channel_offer_channel* offer = (hv_vmbus_channel_offer_channel*)context; /* Allocate the channel object and save this offer */ - new_channel = hv_vmbus_allocate_channel(); + new_channel = hv_vmbus_allocate_channel(sc); /* * By default we setup state to enable batched @@ -472,45 +366,41 @@ vmbus_channel_on_offer_internal(void* co vmbus_channel_select_defcpu(new_channel); vmbus_channel_process_offer(new_channel); - - free(offer, M_DEVBUF); } /** * @brief Rescind offer handler. * * We queue a work item to process this offer - * synchronously + * synchronously. + * + * XXX pretty broken; need rework. */ static void vmbus_channel_on_offer_rescind(struct vmbus_softc *sc, const struct vmbus_message *msg) { - const hv_vmbus_channel_msg_header *hdr = - (const hv_vmbus_channel_msg_header *)msg->msg_data; - const hv_vmbus_channel_rescind_offer *rescind; hv_vmbus_channel* channel; - rescind = (const hv_vmbus_channel_rescind_offer *)hdr; + rescind = (const hv_vmbus_channel_rescind_offer *)msg->msg_data; channel = hv_vmbus_g_connection.channels[rescind->child_rel_id]; if (channel == NULL) return; - - hv_queue_work_item(vmbus_channel_on_offer_rescind_internal, channel); hv_vmbus_g_connection.channels[rescind->child_rel_id] = NULL; + + taskqueue_enqueue(taskqueue_thread, &channel->ch_detach_task); } static void -vmbus_channel_on_offer_rescind_internal(void *context) +vmbus_chan_detach_task(void *xchan, int pending __unused) { - hv_vmbus_channel* channel; + struct hv_vmbus_channel *chan = xchan; - channel = (hv_vmbus_channel*)context; - if (HV_VMBUS_CHAN_ISPRIMARY(channel)) { + if (HV_VMBUS_CHAN_ISPRIMARY(chan)) { /* Only primary channel owns the hv_device */ - hv_vmbus_child_device_unregister(channel->device); + hv_vmbus_child_device_unregister(chan->device); } } @@ -519,14 +409,12 @@ vmbus_channel_on_offer_rescind_internal( * @brief Invoked when all offers have been delivered. */ static void -vmbus_channel_on_offers_delivered(struct vmbus_softc *sc __unused, +vmbus_channel_on_offers_delivered(struct vmbus_softc *sc, const struct vmbus_message *msg __unused) { - mtx_lock(&vmbus_chwait_lock); - vmbus_chancnt |= VMBUS_CHANCNT_DONE; - mtx_unlock(&vmbus_chwait_lock); - wakeup(&vmbus_chancnt); + /* No more new channels for the channel request. */ + vmbus_scan_done(sc); } /** @@ -678,36 +566,6 @@ vmbus_channel_on_version_response(struct } /** - * @brief Send a request to get all our pending offers. - */ -int -hv_vmbus_request_channel_offers(void) -{ - int ret; - hv_vmbus_channel_msg_header* msg; - hv_vmbus_channel_msg_info* msg_info; - - msg_info = (hv_vmbus_channel_msg_info *) - malloc(sizeof(hv_vmbus_channel_msg_info) - + sizeof(hv_vmbus_channel_msg_header), M_DEVBUF, M_NOWAIT); - - if (msg_info == NULL) { - if(bootverbose) - printf("Error VMBUS: malloc failed for Request Offers\n"); - return (ENOMEM); - } - - msg = (hv_vmbus_channel_msg_header*) msg_info->msg; - msg->message_type = HV_CHANNEL_MESSAGE_REQUEST_OFFERS; - - ret = hv_vmbus_post_message(msg, sizeof(hv_vmbus_channel_msg_header)); - - free(msg_info, M_DEVBUF); - - return (ret); -} - -/** * @brief Release channels that are unattached/unconnected (i.e., no drivers associated) */ void @@ -760,7 +618,7 @@ vmbus_select_outgoing_channel(struct hv_ return outgoing_channel; } - cur_vcpu = VMBUS_PCPU_GET(vmbus_get_softc(), vcpuid, smp_pro_id); + cur_vcpu = VMBUS_PCPU_GET(primary->vmbus_sc, vcpuid, smp_pro_id); TAILQ_FOREACH(new_channel, &primary->sc_list_anchor, sc_list_entry) { if (new_channel->state != HV_CHANNEL_OPENED_STATE){ @@ -789,21 +647,6 @@ vmbus_select_outgoing_channel(struct hv_ return(outgoing_channel); } -void -vmbus_scan(void) -{ - uint32_t chancnt; - - mtx_lock(&vmbus_chwait_lock); - while ((vmbus_chancnt & VMBUS_CHANCNT_DONE) == 0) - mtx_sleep(&vmbus_chancnt, &vmbus_chwait_lock, 0, "waitch", 0); - chancnt = vmbus_chancnt & ~VMBUS_CHANCNT_DONE; - - while (vmbus_devcnt != chancnt) - mtx_sleep(&vmbus_devcnt, &vmbus_chwait_lock, 0, "waitdev", 0); - mtx_unlock(&vmbus_chwait_lock); -} - struct hv_vmbus_channel ** vmbus_get_subchan(struct hv_vmbus_channel *pri_chan, int subchan_cnt) { @@ -845,20 +688,17 @@ vmbus_rel_subchan(struct hv_vmbus_channe void vmbus_chan_msgproc(struct vmbus_softc *sc, const struct vmbus_message *msg) { - const hv_vmbus_channel_msg_table_entry *entry; - const hv_vmbus_channel_msg_header *hdr; - hv_vmbus_channel_msg_type msg_type; - - hdr = (const hv_vmbus_channel_msg_header *)msg->msg_data; - msg_type = hdr->message_type; + vmbus_chanmsg_proc_t msg_proc; + uint32_t msg_type; + msg_type = ((const struct vmbus_chanmsg_hdr *)msg->msg_data)->chm_type; if (msg_type >= HV_CHANNEL_MESSAGE_COUNT) { device_printf(sc->vmbus_dev, "unknown message type 0x%x\n", msg_type); return; } - entry = &g_channel_message_table[msg_type]; - if (entry->messageHandler) - entry->messageHandler(sc, msg); + msg_proc = vmbus_chanmsg_process[msg_type]; + if (msg_proc != NULL) + msg_proc(sc, msg); } Modified: stable/10/sys/dev/hyperv/vmbus/hv_connection.c ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/hv_connection.c Tue Oct 11 05:47:52 2016 (r307015) +++ stable/10/sys/dev/hyperv/vmbus/hv_connection.c Tue Oct 11 06:04:40 2016 (r307016) @@ -95,19 +95,13 @@ hv_vmbus_connect(struct vmbus_softc *sc) int hv_vmbus_disconnect(void) { - int ret = 0; - hv_vmbus_channel_unload msg; - - msg.message_type = HV_CHANNEL_MESSAGE_UNLOAD; - - ret = hv_vmbus_post_message(&msg, sizeof(hv_vmbus_channel_unload)); mtx_destroy(&hv_vmbus_g_connection.channel_msg_lock); free(hv_vmbus_g_connection.channels, M_DEVBUF); hv_vmbus_g_connection.connect_state = HV_DISCONNECTED; - return (ret); + return (0); } static __inline void @@ -213,7 +207,7 @@ int hv_vmbus_post_message(void *buffer, int hv_vmbus_set_event(hv_vmbus_channel *channel) { - struct vmbus_softc *sc = vmbus_get_softc(); + struct vmbus_softc *sc = channel->vmbus_sc; int ret = 0; uint32_t chanid = channel->offer_msg.child_rel_id; @@ -231,7 +225,7 @@ vmbus_on_channel_open(const struct hv_vm int flag_cnt; flag_cnt = (chan->offer_msg.child_rel_id / VMBUS_EVTFLAG_LEN) + 1; - flag_cnt_ptr = VMBUS_PCPU_PTR(vmbus_get_softc(), event_flags_cnt, + flag_cnt_ptr = VMBUS_PCPU_PTR(chan->vmbus_sc, event_flags_cnt, chan->target_cpu); for (;;) { Modified: stable/10/sys/dev/hyperv/vmbus/hv_vmbus_priv.h ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/hv_vmbus_priv.h Tue Oct 11 05:47:52 2016 (r307015) +++ stable/10/sys/dev/hyperv/vmbus/hv_vmbus_priv.h Tue Oct 11 06:04:40 2016 (r307016) @@ -395,9 +395,7 @@ void hv_ring_buffer_read_begin( uint32_t hv_ring_buffer_read_end( hv_vmbus_ring_buffer_info *ring_info); -hv_vmbus_channel* hv_vmbus_allocate_channel(void); void hv_vmbus_free_vmbus_channel(hv_vmbus_channel *channel); -int hv_vmbus_request_channel_offers(void); void hv_vmbus_release_unattached_channels(void); uint16_t hv_vmbus_post_msg_via_msg_ipc( @@ -413,7 +411,9 @@ struct hv_device* hv_vmbus_child_device_ hv_guid device_instance, hv_vmbus_channel *channel); -int hv_vmbus_child_device_register( +struct vmbus_softc; + +void hv_vmbus_child_device_register(struct vmbus_softc *, struct hv_device *child_dev); int hv_vmbus_child_device_unregister( struct hv_device *child_dev); @@ -421,13 +421,9 @@ int hv_vmbus_child_device_unregister( /** * Connection interfaces */ -struct vmbus_softc; int hv_vmbus_connect(struct vmbus_softc *); int hv_vmbus_disconnect(void); int hv_vmbus_post_message(void *buffer, size_t buf_size); int hv_vmbus_set_event(hv_vmbus_channel *channel); -/* Wait for device creation */ -void vmbus_scan(void); - #endif /* __HYPERV_PRIV_H__ */ Modified: stable/10/sys/dev/hyperv/vmbus/vmbus.c ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/vmbus.c Tue Oct 11 05:47:52 2016 (r307015) +++ stable/10/sys/dev/hyperv/vmbus/vmbus.c Tue Oct 11 06:04:40 2016 (r307016) @@ -98,6 +98,13 @@ struct vmbus_msghc_ctx { static int vmbus_init(struct vmbus_softc *); static int vmbus_init_contact(struct vmbus_softc *, uint32_t); +static int vmbus_req_channels(struct vmbus_softc *sc); +static void vmbus_uninit(struct vmbus_softc *); +static int vmbus_scan(struct vmbus_softc *); +static void vmbus_scan_wait(struct vmbus_softc *); +static void vmbus_scan_newdev(struct vmbus_softc *); + +static int vmbus_sysctl_version(SYSCTL_HANDLER_ARGS); static struct vmbus_msghc_ctx *vmbus_msghc_ctx_create(bus_dma_tag_t); static void vmbus_msghc_ctx_destroy( @@ -418,6 +425,131 @@ vmbus_init(struct vmbus_softc *sc) } static void +vmbus_uninit(struct vmbus_softc *sc) +{ + struct vmbus_chanmsg_unload *req; + struct vmbus_msghc *mh; + int error; + + mh = vmbus_msghc_get(sc, sizeof(*req)); + if (mh == NULL) { + device_printf(sc->vmbus_dev, + "can not get msg hypercall for unload\n"); + return; + } + + req = vmbus_msghc_dataptr(mh); + req->chm_hdr.chm_type = VMBUS_CHANMSG_TYPE_UNLOAD; + + error = vmbus_msghc_exec_noresult(mh); + vmbus_msghc_put(sc, mh); + + if (error) { + device_printf(sc->vmbus_dev, + "unload msg hypercall failed\n"); + } +} + +static int +vmbus_req_channels(struct vmbus_softc *sc) +{ + struct vmbus_chanmsg_channel_req *req; + struct vmbus_msghc *mh; + int error; + + mh = vmbus_msghc_get(sc, sizeof(*req)); + if (mh == NULL) + return ENXIO; + + req = vmbus_msghc_dataptr(mh); + req->chm_hdr.chm_type = VMBUS_CHANMSG_TYPE_CHANNEL_REQ; + + error = vmbus_msghc_exec_noresult(mh); + vmbus_msghc_put(sc, mh); + + return error; +} + +void +vmbus_scan_newchan(struct vmbus_softc *sc) +{ + mtx_lock(&sc->vmbus_scan_lock); + if ((sc->vmbus_scan_chcnt & VMBUS_SCAN_CHCNT_DONE) == 0) + sc->vmbus_scan_chcnt++; + mtx_unlock(&sc->vmbus_scan_lock); +} + +void +vmbus_scan_done(struct vmbus_softc *sc) +{ + mtx_lock(&sc->vmbus_scan_lock); + sc->vmbus_scan_chcnt |= VMBUS_SCAN_CHCNT_DONE; + mtx_unlock(&sc->vmbus_scan_lock); + wakeup(&sc->vmbus_scan_chcnt); +} + +static void +vmbus_scan_newdev(struct vmbus_softc *sc) +{ + mtx_lock(&sc->vmbus_scan_lock); + sc->vmbus_scan_devcnt++; + mtx_unlock(&sc->vmbus_scan_lock); + wakeup(&sc->vmbus_scan_devcnt); +} + +static void +vmbus_scan_wait(struct vmbus_softc *sc) +{ + uint32_t chancnt; + + mtx_lock(&sc->vmbus_scan_lock); + while ((sc->vmbus_scan_chcnt & VMBUS_SCAN_CHCNT_DONE) == 0) { + mtx_sleep(&sc->vmbus_scan_chcnt, &sc->vmbus_scan_lock, 0, + "waitch", 0); + } + chancnt = sc->vmbus_scan_chcnt & ~VMBUS_SCAN_CHCNT_DONE; + + while (sc->vmbus_scan_devcnt != chancnt) { + mtx_sleep(&sc->vmbus_scan_devcnt, &sc->vmbus_scan_lock, 0, + "waitdev", 0); + } + mtx_unlock(&sc->vmbus_scan_lock); +} + +static int +vmbus_scan(struct vmbus_softc *sc) +{ + int error; + + /* + * Start vmbus scanning. + */ + error = vmbus_req_channels(sc); + if (error) { + device_printf(sc->vmbus_dev, "channel request failed: %d\n", + error); + return error; + } + + /* + * Wait for all devices are added to vmbus. + */ + vmbus_scan_wait(sc); + + /* + * Identify, probe and attach. + */ + bus_generic_probe(sc->vmbus_dev); + bus_generic_attach(sc->vmbus_dev); + + if (bootverbose) { + device_printf(sc->vmbus_dev, "device scan, probe and attach " + "done\n"); + } + return 0; +} + +static void vmbus_msg_task(void *xsc, int pending __unused) { struct vmbus_softc *sc = xsc; @@ -972,12 +1104,13 @@ hv_vmbus_child_device_create(hv_guid typ return (child_dev); } -int -hv_vmbus_child_device_register(struct hv_device *child_dev) +void +hv_vmbus_child_device_register(struct vmbus_softc *sc, + struct hv_device *child_dev) { device_t child, parent; - parent = vmbus_get_device(); + parent = sc->vmbus_dev; if (bootverbose) { char name[HYPERV_GUID_STRLEN]; @@ -989,7 +1122,8 @@ hv_vmbus_child_device_register(struct hv child_dev->device = child; device_set_ivars(child, child_dev); - return (0); + /* New device was added to vmbus */ + vmbus_scan_newdev(sc); } int @@ -1007,6 +1141,17 @@ hv_vmbus_child_device_unregister(struct } static int +vmbus_sysctl_version(SYSCTL_HANDLER_ARGS) +{ + char verstr[16]; + + snprintf(verstr, sizeof(verstr), "%u.%u", + hv_vmbus_protocal_version >> 16, + hv_vmbus_protocal_version & 0xffff); + return sysctl_handle_string(oidp, verstr, sizeof(verstr), req); +} + +static int vmbus_probe(device_t dev) { char *id[] = { "VMBUS", NULL }; @@ -1034,15 +1179,18 @@ vmbus_probe(device_t dev) * - retrieve the channel offers */ static int -vmbus_bus_init(void) +vmbus_doattach(struct vmbus_softc *sc) { - struct vmbus_softc *sc = vmbus_get_softc(); + struct sysctl_oid_list *child; + struct sysctl_ctx_list *ctx; int ret; if (sc->vmbus_flags & VMBUS_FLAG_ATTACHED) return (0); sc->vmbus_flags |= VMBUS_FLAG_ATTACHED; + mtx_init(&sc->vmbus_scan_lock, "vmbus scan", NULL, MTX_DEF); + /* * Create context for "post message" Hypercalls */ @@ -1092,11 +1240,15 @@ vmbus_bus_init(void) else sc->vmbus_event_proc = vmbus_event_proc; - hv_vmbus_request_channel_offers(); + ret = vmbus_scan(sc); + if (ret != 0) + goto cleanup; - vmbus_scan(); - bus_generic_attach(sc->vmbus_dev); - device_printf(sc->vmbus_dev, "device scan, probe and attach done\n"); + ctx = device_get_sysctl_ctx(sc->vmbus_dev); + child = SYSCTL_CHILDREN(device_get_sysctl_tree(sc->vmbus_dev)); + SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "version", + CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, NULL, 0, + vmbus_sysctl_version, "A", "vmbus version"); return (ret); @@ -1107,6 +1259,7 @@ cleanup: vmbus_msghc_ctx_destroy(sc->vmbus_msg_hc); sc->vmbus_msg_hc = NULL; } + mtx_destroy(&sc->vmbus_scan_lock); return (ret); } @@ -1136,16 +1289,17 @@ vmbus_attach(device_t dev) * initialization directly. */ if (!cold) - vmbus_bus_init(); + vmbus_doattach(vmbus_sc); - bus_generic_probe(dev); return (0); } static void vmbus_sysinit(void *arg __unused) { - if (vm_guest != VM_GUEST_HV || vmbus_get_softc() == NULL) + struct vmbus_softc *sc = vmbus_get_softc(); + + if (vm_guest != VM_GUEST_HV || sc == NULL) return; /* @@ -1155,7 +1309,7 @@ vmbus_sysinit(void *arg __unused) * initialization directly. */ if (!cold) - vmbus_bus_init(); + vmbus_doattach(sc); } static int @@ -1164,6 +1318,8 @@ vmbus_detach(device_t dev) struct vmbus_softc *sc = device_get_softc(dev); hv_vmbus_release_unattached_channels(); + + vmbus_uninit(sc); hv_vmbus_disconnect(); if (sc->vmbus_flags & VMBUS_FLAG_SYNIC) { @@ -1179,6 +1335,7 @@ vmbus_detach(device_t dev) sc->vmbus_msg_hc = NULL; } + mtx_destroy(&sc->vmbus_scan_lock); return (0); } Modified: stable/10/sys/dev/hyperv/vmbus/vmbus_reg.h ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/vmbus_reg.h Tue Oct 11 05:47:52 2016 (r307015) +++ stable/10/sys/dev/hyperv/vmbus/vmbus_reg.h Tue Oct 11 06:04:40 2016 (r307016) @@ -83,8 +83,10 @@ CTASSERT(sizeof(struct vmbus_evtflags) = * - Embedded in hypercall_postmsg_in.hc_data, e.g. request. */ +#define VMBUS_CHANMSG_TYPE_CHANNEL_REQ 3 /* REQ */ #define VMBUS_CHANMSG_TYPE_INIT_CONTACT 14 /* REQ */ #define VMBUS_CHANMSG_TYPE_VERSION_RESP 15 /* RESP */ +#define VMBUS_CHANMSG_TYPE_UNLOAD 16 /* REQ */ struct vmbus_chanmsg_hdr { uint32_t chm_type; /* VMBUS_CHANMSG_TYPE_ */ @@ -107,4 +109,14 @@ struct vmbus_chanmsg_version_resp { uint8_t chm_supp; } __packed; +/* VMBUS_CHANMSG_TYPE_CHANNEL_REQ */ +struct vmbus_chanmsg_channel_req { + struct vmbus_chanmsg_hdr chm_hdr; +} __packed; + +/* VMBUS_CHANMSG_TYPE_UNLOAD */ +struct vmbus_chanmsg_unload { + struct vmbus_chanmsg_hdr chm_hdr; +} __packed; + #endif /* !_VMBUS_REG_H_ */ Modified: stable/10/sys/dev/hyperv/vmbus/vmbus_var.h ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/vmbus_var.h Tue Oct 11 05:47:52 2016 (r307015) +++ stable/10/sys/dev/hyperv/vmbus/vmbus_var.h Tue Oct 11 06:04:40 2016 (r307016) @@ -83,6 +83,11 @@ struct vmbus_softc { void *vmbus_mnf1; /* monitored by VM, unused */ struct hyperv_dma vmbus_mnf1_dma; struct hyperv_dma vmbus_mnf2_dma; + + struct mtx vmbus_scan_lock; + uint32_t vmbus_scan_chcnt; +#define VMBUS_SCAN_CHCNT_DONE 0x80000000 + uint32_t vmbus_scan_devcnt; }; #define VMBUS_FLAG_ATTACHED 0x0001 /* vmbus was attached */ @@ -128,4 +133,7 @@ const struct vmbus_message *vmbus_msghc_ struct vmbus_msghc *); void vmbus_msghc_wakeup(struct vmbus_softc *, const struct vmbus_message *); +void vmbus_scan_done(struct vmbus_softc *); +void vmbus_scan_newchan(struct vmbus_softc *); + #endif /* !_VMBUS_VAR_H_ */ From owner-svn-src-all@freebsd.org Tue Oct 11 06:19:08 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 0D5E2C0C35C; Tue, 11 Oct 2016 06:19:08 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 97C7C8EB; Tue, 11 Oct 2016 06:19:07 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9B6J62S080533; Tue, 11 Oct 2016 06:19:06 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9B6J6NA080529; Tue, 11 Oct 2016 06:19:06 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610110619.u9B6J6NA080529@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Tue, 11 Oct 2016 06:19:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307017 - in stable/10/sys/dev/hyperv: include vmbus X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Oct 2016 06:19:08 -0000 Author: sephe Date: Tue Oct 11 06:19:06 2016 New Revision: 307017 URL: https://svnweb.freebsd.org/changeset/base/307017 Log: MFC 302607-302612 302607 hyperv/vmbus: Use post message Hypercall APIs for channel open Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D6876 302608 hyperv/vmbus: Remove unnecessary check and unapplied comment Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D6877 302609 hyperv/vmbus: Use post message Hypercall APIs for GPADL connect. This also fixes memory leakge if sub-connect messages are needed. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D6878 302610 hyperv/vmbus: Use post message Hypercall APIs for channel close Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D6906 302611 hyperv/vmbus: Use post message Hypercall APIs for GPA disconnect Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D6912 302612 hyperv: Nuke unused stuffs Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D6913 Modified: stable/10/sys/dev/hyperv/include/hyperv.h stable/10/sys/dev/hyperv/vmbus/hv_channel.c stable/10/sys/dev/hyperv/vmbus/hv_channel_mgmt.c stable/10/sys/dev/hyperv/vmbus/hv_connection.c stable/10/sys/dev/hyperv/vmbus/hv_vmbus_priv.h stable/10/sys/dev/hyperv/vmbus/hyperv.c stable/10/sys/dev/hyperv/vmbus/vmbus.c stable/10/sys/dev/hyperv/vmbus/vmbus_reg.h stable/10/sys/dev/hyperv/vmbus/vmbus_var.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/hyperv/include/hyperv.h ============================================================================== --- stable/10/sys/dev/hyperv/include/hyperv.h Tue Oct 11 06:04:40 2016 (r307016) +++ stable/10/sys/dev/hyperv/include/hyperv.h Tue Oct 11 06:19:06 2016 (r307017) @@ -179,8 +179,6 @@ typedef struct hv_vmbus_channel_offer { } __packed hv_vmbus_channel_offer; -typedef uint32_t hv_gpadl_handle; - typedef struct { uint16_t type; uint16_t data_offset8; @@ -352,14 +350,6 @@ typedef struct { } __packed hv_vmbus_channel_query_vmbus_version; /* - * VMBus Version Supported parameters - */ -typedef struct { - hv_vmbus_channel_msg_header header; - hv_bool_uint8_t version_supported; -} __packed hv_vmbus_channel_version_supported; - -/* * Channel Offer parameters */ typedef struct { @@ -397,171 +387,13 @@ typedef struct uint32_t child_rel_id; } __packed hv_vmbus_channel_rescind_offer; - -/* - * Request Offer -- no parameters, SynIC message contains the partition ID - * - * Set Snoop -- no parameters, SynIC message contains the partition ID - * - * Clear Snoop -- no parameters, SynIC message contains the partition ID - * - * All Offers Delivered -- no parameters, SynIC message contains the - * partition ID - * - * Flush Client -- no parameters, SynIC message contains the partition ID - */ - - -/* - * Open Channel parameters - */ -typedef struct -{ - hv_vmbus_channel_msg_header header; - - /* - * Identifies the specific VMBus channel that is being opened. - */ - uint32_t child_rel_id; - - /* - * ID making a particular open request at a channel offer unique. - */ - uint32_t open_id; - - /* - * GPADL for the channel's ring buffer. - */ - hv_gpadl_handle ring_buffer_gpadl_handle; - - /* - * Before win8, all incoming channel interrupts are only - * delivered on cpu 0. Setting this value to 0 would - * preserve the earlier behavior. - */ - uint32_t target_vcpu; - - /* - * The upstream ring buffer begins at offset zero in the memory described - * by ring_buffer_gpadl_handle. The downstream ring buffer follows it at - * this offset (in pages). - */ - uint32_t downstream_ring_buffer_page_offset; - - /* - * User-specific data to be passed along to the server endpoint. - */ - uint8_t user_data[HV_MAX_USER_DEFINED_BYTES]; - -} __packed hv_vmbus_channel_open_channel; - -typedef uint32_t hv_nt_status; - -/* - * Open Channel Result parameters - */ -typedef struct -{ - hv_vmbus_channel_msg_header header; - uint32_t child_rel_id; - uint32_t open_id; - hv_nt_status status; -} __packed hv_vmbus_channel_open_result; - -/* - * Close channel parameters - */ -typedef struct -{ - hv_vmbus_channel_msg_header header; - uint32_t child_rel_id; -} __packed hv_vmbus_channel_close_channel; - -/* - * Channel Message GPADL - */ -#define HV_GPADL_TYPE_RING_BUFFER 1 -#define HV_GPADL_TYPE_SERVER_SAVE_AREA 2 -#define HV_GPADL_TYPE_TRANSACTION 8 - -/* - * The number of PFNs in a GPADL message is defined by the number of pages - * that would be spanned by byte_count and byte_offset. If the implied number - * of PFNs won't fit in this packet, there will be a follow-up packet that - * contains more - */ - -typedef struct { - hv_vmbus_channel_msg_header header; - uint32_t child_rel_id; - uint32_t gpadl; - uint16_t range_buf_len; - uint16_t range_count; - hv_gpa_range range[0]; -} __packed hv_vmbus_channel_gpadl_header; - -/* - * This is the follow-up packet that contains more PFNs - */ -typedef struct { - hv_vmbus_channel_msg_header header; - uint32_t message_number; - uint32_t gpadl; - uint64_t pfn[0]; -} __packed hv_vmbus_channel_gpadl_body; - -typedef struct { - hv_vmbus_channel_msg_header header; - uint32_t child_rel_id; - uint32_t gpadl; - uint32_t creation_status; -} __packed hv_vmbus_channel_gpadl_created; - -typedef struct { - hv_vmbus_channel_msg_header header; - uint32_t child_rel_id; - uint32_t gpadl; -} __packed hv_vmbus_channel_gpadl_teardown; - -typedef struct { - hv_vmbus_channel_msg_header header; - uint32_t gpadl; -} __packed hv_vmbus_channel_gpadl_torndown; - typedef struct { hv_vmbus_channel_msg_header header; uint32_t child_rel_id; } __packed hv_vmbus_channel_relid_released; -typedef hv_vmbus_channel_msg_header hv_vmbus_channel_unload; - #define HW_MACADDR_LEN 6 -/* - * Fixme: Added to quiet "typeof" errors involving hv_vmbus.h when - * the including C file was compiled with "-std=c99". - */ -#ifndef typeof -#define typeof __typeof -#endif - -#ifndef NULL -#define NULL (void *)0 -#endif - -typedef void *hv_vmbus_handle; - -#ifndef CONTAINING_RECORD -#define CONTAINING_RECORD(address, type, field) ((type *)( \ - (uint8_t *)(address) - \ - (uint8_t *)(&((type *)0)->field))) -#endif /* CONTAINING_RECORD */ - - -#define container_of(ptr, type, member) ({ \ - __typeof__( ((type *)0)->member ) *__mptr = (ptr); \ - (type *)( (char *)__mptr - offsetof(type,member) );}) - enum { HV_VMBUS_IVAR_TYPE, HV_VMBUS_IVAR_INSTANCE, Modified: stable/10/sys/dev/hyperv/vmbus/hv_channel.c ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/hv_channel.c Tue Oct 11 06:04:40 2016 (r307016) +++ stable/10/sys/dev/hyperv/vmbus/hv_channel.c Tue Oct 11 06:19:06 2016 (r307017) @@ -49,14 +49,6 @@ __FBSDID("$FreeBSD$"); #include #include -static int vmbus_channel_create_gpadl_header( - /* must be phys and virt contiguous*/ - void* contig_buffer, - /* page-size multiple */ - uint32_t size, - hv_vmbus_channel_msg_info** msg_info, - uint32_t* message_count); - static void vmbus_channel_set_event(hv_vmbus_channel* channel); static void VmbusProcessChannelEvent(void* channel, int pending); @@ -182,11 +174,21 @@ hv_vmbus_channel_open( hv_vmbus_pfn_channel_callback pfn_on_channel_callback, void* context) { - + struct vmbus_softc *sc = new_channel->vmbus_sc; + const struct vmbus_chanmsg_chopen_resp *resp; + const struct vmbus_message *msg; + struct vmbus_chanmsg_chopen *req; + struct vmbus_msghc *mh; + uint32_t status; int ret = 0; void *in, *out; - hv_vmbus_channel_open_channel* open_msg; - hv_vmbus_channel_msg_info* open_info; + + if (user_data_len > VMBUS_CHANMSG_CHOPEN_UDATA_SIZE) { + device_printf(sc->vmbus_dev, + "invalid udata len %u for chan%u\n", + user_data_len, new_channel->offer_msg.child_rel_id); + return EINVAL; + } mtx_lock(&new_channel->sc_lock); if (new_channel->state == HV_CHANNEL_OPEN_STATE) { @@ -248,381 +250,231 @@ hv_vmbus_channel_open( send_ring_buffer_size + recv_ring_buffer_size, &new_channel->ring_buffer_gpadl_handle); - /** - * Create and init the channel open message + /* + * Open channel w/ the bufring GPADL on the target CPU. */ - open_info = (hv_vmbus_channel_msg_info*) malloc( - sizeof(hv_vmbus_channel_msg_info) + - sizeof(hv_vmbus_channel_open_channel), - M_DEVBUF, - M_NOWAIT); - KASSERT(open_info != NULL, - ("Error VMBUS: malloc failed to allocate Open Channel message!")); - - if (open_info == NULL) - return (ENOMEM); - - sema_init(&open_info->wait_sema, 0, "Open Info Sema"); - - open_msg = (hv_vmbus_channel_open_channel*) open_info->msg; - open_msg->header.message_type = HV_CHANNEL_MESSAGE_OPEN_CHANNEL; - open_msg->open_id = new_channel->offer_msg.child_rel_id; - open_msg->child_rel_id = new_channel->offer_msg.child_rel_id; - open_msg->ring_buffer_gpadl_handle = - new_channel->ring_buffer_gpadl_handle; - open_msg->downstream_ring_buffer_page_offset = send_ring_buffer_size - >> PAGE_SHIFT; - open_msg->target_vcpu = new_channel->target_vcpu; - + mh = vmbus_msghc_get(sc, sizeof(*req)); + if (mh == NULL) { + device_printf(sc->vmbus_dev, + "can not get msg hypercall for chopen(chan%u)\n", + new_channel->offer_msg.child_rel_id); + return ENXIO; + } + + req = vmbus_msghc_dataptr(mh); + req->chm_hdr.chm_type = VMBUS_CHANMSG_TYPE_CHOPEN; + req->chm_chanid = new_channel->offer_msg.child_rel_id; + req->chm_openid = new_channel->offer_msg.child_rel_id; + req->chm_gpadl = new_channel->ring_buffer_gpadl_handle; + req->chm_vcpuid = new_channel->target_vcpu; + req->chm_rxbr_pgofs = send_ring_buffer_size >> PAGE_SHIFT; if (user_data_len) - memcpy(open_msg->user_data, user_data, user_data_len); - - mtx_lock(&hv_vmbus_g_connection.channel_msg_lock); - TAILQ_INSERT_TAIL( - &hv_vmbus_g_connection.channel_msg_anchor, - open_info, - msg_list_entry); - mtx_unlock(&hv_vmbus_g_connection.channel_msg_lock); - - ret = hv_vmbus_post_message( - open_msg, sizeof(hv_vmbus_channel_open_channel)); + memcpy(req->chm_udata, user_data, user_data_len); - if (ret != 0) - goto cleanup; - - ret = sema_timedwait(&open_info->wait_sema, 5 * hz); /* KYS 5 seconds */ - - if (ret) { - if(bootverbose) - printf("VMBUS: channel <%p> open timeout.\n", new_channel); - goto cleanup; + ret = vmbus_msghc_exec(sc, mh); + if (ret != 0) { + device_printf(sc->vmbus_dev, + "chopen(chan%u) msg hypercall exec failed: %d\n", + new_channel->offer_msg.child_rel_id, ret); + vmbus_msghc_put(sc, mh); + return ret; } - if (open_info->response.open_result.status == 0) { - new_channel->state = HV_CHANNEL_OPENED_STATE; - if(bootverbose) - printf("VMBUS: channel <%p> open success.\n", new_channel); + msg = vmbus_msghc_wait_result(sc, mh); + resp = (const struct vmbus_chanmsg_chopen_resp *)msg->msg_data; + status = resp->chm_status; + + vmbus_msghc_put(sc, mh); + + if (status == 0) { + new_channel->state = HV_CHANNEL_OPENED_STATE; + if (bootverbose) { + device_printf(sc->vmbus_dev, "chan%u opened\n", + new_channel->offer_msg.child_rel_id); + } } else { - if(bootverbose) - printf("Error VMBUS: channel <%p> open failed - %d!\n", - new_channel, open_info->response.open_result.status); + device_printf(sc->vmbus_dev, "failed to open chan%u\n", + new_channel->offer_msg.child_rel_id); + ret = ENXIO; } - - cleanup: - mtx_lock(&hv_vmbus_g_connection.channel_msg_lock); - TAILQ_REMOVE( - &hv_vmbus_g_connection.channel_msg_anchor, - open_info, - msg_list_entry); - mtx_unlock(&hv_vmbus_g_connection.channel_msg_lock); - sema_destroy(&open_info->wait_sema); - free(open_info, M_DEVBUF); - return (ret); } /** - * @brief Create a gpadl for the specified buffer - */ -static int -vmbus_channel_create_gpadl_header( - void* contig_buffer, - uint32_t size, /* page-size multiple */ - hv_vmbus_channel_msg_info** msg_info, - uint32_t* message_count) -{ - int i; - int page_count; - unsigned long long pfn; - uint32_t msg_size; - hv_vmbus_channel_gpadl_header* gpa_header; - hv_vmbus_channel_gpadl_body* gpadl_body; - hv_vmbus_channel_msg_info* msg_header; - hv_vmbus_channel_msg_info* msg_body; - - int pfnSum, pfnCount, pfnLeft, pfnCurr, pfnSize; - - page_count = size >> PAGE_SHIFT; - pfn = hv_get_phys_addr(contig_buffer) >> PAGE_SHIFT; - - /*do we need a gpadl body msg */ - pfnSize = HV_MAX_SIZE_CHANNEL_MESSAGE - - sizeof(hv_vmbus_channel_gpadl_header) - - sizeof(hv_gpa_range); - pfnCount = pfnSize / sizeof(uint64_t); - - if (page_count > pfnCount) { /* if(we need a gpadl body) */ - /* fill in the header */ - msg_size = sizeof(hv_vmbus_channel_msg_info) - + sizeof(hv_vmbus_channel_gpadl_header) - + sizeof(hv_gpa_range) - + pfnCount * sizeof(uint64_t); - msg_header = malloc(msg_size, M_DEVBUF, M_NOWAIT | M_ZERO); - KASSERT( - msg_header != NULL, - ("Error VMBUS: malloc failed to allocate Gpadl Message!")); - if (msg_header == NULL) - return (ENOMEM); - - TAILQ_INIT(&msg_header->sub_msg_list_anchor); - msg_header->message_size = msg_size; - - gpa_header = (hv_vmbus_channel_gpadl_header*) msg_header->msg; - gpa_header->range_count = 1; - gpa_header->range_buf_len = sizeof(hv_gpa_range) - + page_count * sizeof(uint64_t); - gpa_header->range[0].byte_offset = 0; - gpa_header->range[0].byte_count = size; - for (i = 0; i < pfnCount; i++) { - gpa_header->range[0].pfn_array[i] = pfn + i; - } - *msg_info = msg_header; - *message_count = 1; - - pfnSum = pfnCount; - pfnLeft = page_count - pfnCount; - - /* - * figure out how many pfns we can fit - */ - pfnSize = HV_MAX_SIZE_CHANNEL_MESSAGE - - sizeof(hv_vmbus_channel_gpadl_body); - pfnCount = pfnSize / sizeof(uint64_t); - - /* - * fill in the body - */ - while (pfnLeft) { - if (pfnLeft > pfnCount) { - pfnCurr = pfnCount; - } else { - pfnCurr = pfnLeft; - } - - msg_size = sizeof(hv_vmbus_channel_msg_info) + - sizeof(hv_vmbus_channel_gpadl_body) + - pfnCurr * sizeof(uint64_t); - msg_body = malloc(msg_size, M_DEVBUF, M_NOWAIT | M_ZERO); - KASSERT( - msg_body != NULL, - ("Error VMBUS: malloc failed to allocate Gpadl msg_body!")); - if (msg_body == NULL) - return (ENOMEM); - - msg_body->message_size = msg_size; - (*message_count)++; - gpadl_body = - (hv_vmbus_channel_gpadl_body*) msg_body->msg; - /* - * gpadl_body->gpadl = kbuffer; - */ - for (i = 0; i < pfnCurr; i++) { - gpadl_body->pfn[i] = pfn + pfnSum + i; - } - - TAILQ_INSERT_TAIL( - &msg_header->sub_msg_list_anchor, - msg_body, - msg_list_entry); - pfnSum += pfnCurr; - pfnLeft -= pfnCurr; - } - } else { /* else everything fits in a header */ - - msg_size = sizeof(hv_vmbus_channel_msg_info) + - sizeof(hv_vmbus_channel_gpadl_header) + - sizeof(hv_gpa_range) + - page_count * sizeof(uint64_t); - msg_header = malloc(msg_size, M_DEVBUF, M_NOWAIT | M_ZERO); - KASSERT( - msg_header != NULL, - ("Error VMBUS: malloc failed to allocate Gpadl Message!")); - if (msg_header == NULL) - return (ENOMEM); - - msg_header->message_size = msg_size; - - gpa_header = (hv_vmbus_channel_gpadl_header*) msg_header->msg; - gpa_header->range_count = 1; - gpa_header->range_buf_len = sizeof(hv_gpa_range) + - page_count * sizeof(uint64_t); - gpa_header->range[0].byte_offset = 0; - gpa_header->range[0].byte_count = size; - for (i = 0; i < page_count; i++) { - gpa_header->range[0].pfn_array[i] = pfn + i; - } - - *msg_info = msg_header; - *message_count = 1; - } - - return (0); -} - -/** * @brief Establish a GPADL for the specified buffer */ int -hv_vmbus_channel_establish_gpadl( - hv_vmbus_channel* channel, - void* contig_buffer, - uint32_t size, /* page-size multiple */ - uint32_t* gpadl_handle) - +hv_vmbus_channel_establish_gpadl(struct hv_vmbus_channel *channel, + void *contig_buffer, uint32_t size, uint32_t *gpadl0) { - int ret = 0; - hv_vmbus_channel_gpadl_header* gpadl_msg; - hv_vmbus_channel_gpadl_body* gpadl_body; - hv_vmbus_channel_msg_info* msg_info; - hv_vmbus_channel_msg_info* sub_msg_info; - uint32_t msg_count; - hv_vmbus_channel_msg_info* curr; - uint32_t next_gpadl_handle; - - next_gpadl_handle = atomic_fetchadd_int( - &hv_vmbus_g_connection.next_gpadl_handle, 1); - - ret = vmbus_channel_create_gpadl_header( - contig_buffer, size, &msg_info, &msg_count); + struct vmbus_softc *sc = channel->vmbus_sc; + struct vmbus_msghc *mh; + struct vmbus_chanmsg_gpadl_conn *req; + const struct vmbus_message *msg; + size_t reqsz; + uint32_t gpadl, status; + int page_count, range_len, i, cnt, error; + uint64_t page_id, paddr; - if(ret != 0) { - /* - * XXX - * We can _not_ even revert the above incremental, - * if multiple GPADL establishments are running - * parallelly, decrement the global next_gpadl_handle - * is calling for _big_ trouble. A better solution - * is to have a 0-based GPADL id bitmap ... - */ - return ret; - } + /* + * Preliminary checks. + */ - sema_init(&msg_info->wait_sema, 0, "Open Info Sema"); - gpadl_msg = (hv_vmbus_channel_gpadl_header*) msg_info->msg; - gpadl_msg->header.message_type = HV_CHANNEL_MESSAGEL_GPADL_HEADER; - gpadl_msg->child_rel_id = channel->offer_msg.child_rel_id; - gpadl_msg->gpadl = next_gpadl_handle; - - mtx_lock(&hv_vmbus_g_connection.channel_msg_lock); - TAILQ_INSERT_TAIL( - &hv_vmbus_g_connection.channel_msg_anchor, - msg_info, - msg_list_entry); - - mtx_unlock(&hv_vmbus_g_connection.channel_msg_lock); - - ret = hv_vmbus_post_message( - gpadl_msg, - msg_info->message_size - - (uint32_t) sizeof(hv_vmbus_channel_msg_info)); + KASSERT((size & PAGE_MASK) == 0, + ("invalid GPA size %u, not multiple page size", size)); + page_count = size >> PAGE_SHIFT; - if (ret != 0) - goto cleanup; + paddr = hv_get_phys_addr(contig_buffer); + KASSERT((paddr & PAGE_MASK) == 0, + ("GPA is not page aligned %jx", (uintmax_t)paddr)); + page_id = paddr >> PAGE_SHIFT; - if (msg_count > 1) { - TAILQ_FOREACH(curr, - &msg_info->sub_msg_list_anchor, msg_list_entry) { - sub_msg_info = curr; - gpadl_body = - (hv_vmbus_channel_gpadl_body*) sub_msg_info->msg; - - gpadl_body->header.message_type = - HV_CHANNEL_MESSAGE_GPADL_BODY; - gpadl_body->gpadl = next_gpadl_handle; - - ret = hv_vmbus_post_message( - gpadl_body, - sub_msg_info->message_size - - (uint32_t) sizeof(hv_vmbus_channel_msg_info)); - /* if (the post message failed) give up and clean up */ - if(ret != 0) - goto cleanup; - } + range_len = __offsetof(struct vmbus_gpa_range, gpa_page[page_count]); + /* + * We don't support multiple GPA ranges. + */ + if (range_len > UINT16_MAX) { + device_printf(sc->vmbus_dev, "GPA too large, %d pages\n", + page_count); + return EOPNOTSUPP; } - ret = sema_timedwait(&msg_info->wait_sema, 5 * hz); /* KYS 5 seconds*/ - if (ret != 0) - goto cleanup; - - *gpadl_handle = gpadl_msg->gpadl; - -cleanup: - - mtx_lock(&hv_vmbus_g_connection.channel_msg_lock); - TAILQ_REMOVE(&hv_vmbus_g_connection.channel_msg_anchor, - msg_info, msg_list_entry); - mtx_unlock(&hv_vmbus_g_connection.channel_msg_lock); - - sema_destroy(&msg_info->wait_sema); - free(msg_info, M_DEVBUF); + /* + * Allocate GPADL id. + */ + gpadl = atomic_fetchadd_int( + &hv_vmbus_g_connection.next_gpadl_handle, 1); + *gpadl0 = gpadl; - return (ret); + /* + * Connect this GPADL to the target channel. + * + * NOTE: + * Since each message can only hold small set of page + * addresses, several messages may be required to + * complete the connection. + */ + if (page_count > VMBUS_CHANMSG_GPADL_CONN_PGMAX) + cnt = VMBUS_CHANMSG_GPADL_CONN_PGMAX; + else + cnt = page_count; + page_count -= cnt; + + reqsz = __offsetof(struct vmbus_chanmsg_gpadl_conn, + chm_range.gpa_page[cnt]); + mh = vmbus_msghc_get(sc, reqsz); + if (mh == NULL) { + device_printf(sc->vmbus_dev, + "can not get msg hypercall for gpadl->chan%u\n", + channel->offer_msg.child_rel_id); + return EIO; + } + + req = vmbus_msghc_dataptr(mh); + req->chm_hdr.chm_type = VMBUS_CHANMSG_TYPE_GPADL_CONN; + req->chm_chanid = channel->offer_msg.child_rel_id; + req->chm_gpadl = gpadl; + req->chm_range_len = range_len; + req->chm_range_cnt = 1; + req->chm_range.gpa_len = size; + req->chm_range.gpa_ofs = 0; + for (i = 0; i < cnt; ++i) + req->chm_range.gpa_page[i] = page_id++; + + error = vmbus_msghc_exec(sc, mh); + if (error) { + device_printf(sc->vmbus_dev, + "gpadl->chan%u msg hypercall exec failed: %d\n", + channel->offer_msg.child_rel_id, error); + vmbus_msghc_put(sc, mh); + return error; + } + + while (page_count > 0) { + struct vmbus_chanmsg_gpadl_subconn *subreq; + + if (page_count > VMBUS_CHANMSG_GPADL_SUBCONN_PGMAX) + cnt = VMBUS_CHANMSG_GPADL_SUBCONN_PGMAX; + else + cnt = page_count; + page_count -= cnt; + + reqsz = __offsetof(struct vmbus_chanmsg_gpadl_subconn, + chm_gpa_page[cnt]); + vmbus_msghc_reset(mh, reqsz); + + subreq = vmbus_msghc_dataptr(mh); + subreq->chm_hdr.chm_type = VMBUS_CHANMSG_TYPE_GPADL_SUBCONN; + subreq->chm_gpadl = gpadl; + for (i = 0; i < cnt; ++i) + subreq->chm_gpa_page[i] = page_id++; + + vmbus_msghc_exec_noresult(mh); + } + KASSERT(page_count == 0, ("invalid page count %d", page_count)); + + msg = vmbus_msghc_wait_result(sc, mh); + status = ((const struct vmbus_chanmsg_gpadl_connresp *) + msg->msg_data)->chm_status; + + vmbus_msghc_put(sc, mh); + + if (status != 0) { + device_printf(sc->vmbus_dev, "gpadl->chan%u failed: " + "status %u\n", channel->offer_msg.child_rel_id, status); + return EIO; + } + return 0; } -/** - * @brief Teardown the specified GPADL handle +/* + * Disconnect the GPA from the target channel */ int -hv_vmbus_channel_teardown_gpdal( - hv_vmbus_channel* channel, - uint32_t gpadl_handle) +hv_vmbus_channel_teardown_gpdal(struct hv_vmbus_channel *chan, uint32_t gpadl) { - int ret = 0; - hv_vmbus_channel_gpadl_teardown* msg; - hv_vmbus_channel_msg_info* info; - - info = (hv_vmbus_channel_msg_info *) - malloc( sizeof(hv_vmbus_channel_msg_info) + - sizeof(hv_vmbus_channel_gpadl_teardown), - M_DEVBUF, M_NOWAIT); - KASSERT(info != NULL, - ("Error VMBUS: malloc failed to allocate Gpadl Teardown Msg!")); - if (info == NULL) { - ret = ENOMEM; - goto cleanup; - } - - sema_init(&info->wait_sema, 0, "Open Info Sema"); - - msg = (hv_vmbus_channel_gpadl_teardown*) info->msg; - - msg->header.message_type = HV_CHANNEL_MESSAGE_GPADL_TEARDOWN; - msg->child_rel_id = channel->offer_msg.child_rel_id; - msg->gpadl = gpadl_handle; - - mtx_lock(&hv_vmbus_g_connection.channel_msg_lock); - TAILQ_INSERT_TAIL(&hv_vmbus_g_connection.channel_msg_anchor, - info, msg_list_entry); - mtx_unlock(&hv_vmbus_g_connection.channel_msg_lock); - - ret = hv_vmbus_post_message(msg, - sizeof(hv_vmbus_channel_gpadl_teardown)); - if (ret != 0) - goto cleanup; - - ret = sema_timedwait(&info->wait_sema, 5 * hz); /* KYS 5 seconds */ - -cleanup: - /* - * Received a torndown response - */ - mtx_lock(&hv_vmbus_g_connection.channel_msg_lock); - TAILQ_REMOVE(&hv_vmbus_g_connection.channel_msg_anchor, - info, msg_list_entry); - mtx_unlock(&hv_vmbus_g_connection.channel_msg_lock); - sema_destroy(&info->wait_sema); - free(info, M_DEVBUF); + struct vmbus_softc *sc = chan->vmbus_sc; + struct vmbus_msghc *mh; + struct vmbus_chanmsg_gpadl_disconn *req; + int error; + + mh = vmbus_msghc_get(sc, sizeof(*req)); + if (mh == NULL) { + device_printf(sc->vmbus_dev, + "can not get msg hypercall for gpa x->chan%u\n", + chan->offer_msg.child_rel_id); + return EBUSY; + } + + req = vmbus_msghc_dataptr(mh); + req->chm_hdr.chm_type = VMBUS_CHANMSG_TYPE_GPADL_DISCONN; + req->chm_chanid = chan->offer_msg.child_rel_id; + req->chm_gpadl = gpadl; + + error = vmbus_msghc_exec(sc, mh); + if (error) { + device_printf(sc->vmbus_dev, + "gpa x->chan%u msg hypercall exec failed: %d\n", + chan->offer_msg.child_rel_id, error); + vmbus_msghc_put(sc, mh); + return error; + } + + vmbus_msghc_wait_result(sc, mh); + /* Discard result; no useful information */ + vmbus_msghc_put(sc, mh); - return (ret); + return 0; } static void hv_vmbus_channel_close_internal(hv_vmbus_channel *channel) { - int ret = 0; + struct vmbus_softc *sc = channel->vmbus_sc; + struct vmbus_msghc *mh; + struct vmbus_chanmsg_chclose *req; struct taskqueue *rxq = channel->rxq; - hv_vmbus_channel_close_channel* msg; - hv_vmbus_channel_msg_info* info; + int error; channel->state = HV_CHANNEL_OPEN_STATE; @@ -636,20 +488,31 @@ hv_vmbus_channel_close_internal(hv_vmbus /** * Send a closing message */ - info = (hv_vmbus_channel_msg_info *) - malloc( sizeof(hv_vmbus_channel_msg_info) + - sizeof(hv_vmbus_channel_close_channel), - M_DEVBUF, M_NOWAIT); - KASSERT(info != NULL, ("VMBUS: malloc failed hv_vmbus_channel_close!")); - if(info == NULL) - return; - - msg = (hv_vmbus_channel_close_channel*) info->msg; - msg->header.message_type = HV_CHANNEL_MESSAGE_CLOSE_CHANNEL; - msg->child_rel_id = channel->offer_msg.child_rel_id; - ret = hv_vmbus_post_message( - msg, sizeof(hv_vmbus_channel_close_channel)); + mh = vmbus_msghc_get(sc, sizeof(*req)); + if (mh == NULL) { + device_printf(sc->vmbus_dev, + "can not get msg hypercall for chclose(chan%u)\n", + channel->offer_msg.child_rel_id); + return; + } + + req = vmbus_msghc_dataptr(mh); + req->chm_hdr.chm_type = VMBUS_CHANMSG_TYPE_CHCLOSE; + req->chm_chanid = channel->offer_msg.child_rel_id; + + error = vmbus_msghc_exec_noresult(mh); + vmbus_msghc_put(sc, mh); + + if (error) { + device_printf(sc->vmbus_dev, + "chclose(chan%u) msg hypercall exec failed: %d\n", + channel->offer_msg.child_rel_id, error); + return; + } else if (bootverbose) { + device_printf(sc->vmbus_dev, "close chan%u\n", + channel->offer_msg.child_rel_id); + } /* Tear down the gpadl for the channel's ring buffer */ if (channel->ring_buffer_gpadl_handle) { @@ -665,8 +528,6 @@ hv_vmbus_channel_close_internal(hv_vmbus contigfree(channel->ring_buffer_pages, channel->ring_buffer_size, M_DEVBUF); - - free(info, M_DEVBUF); } /** @@ -988,23 +849,6 @@ VmbusProcessChannelEvent(void* context, hv_vmbus_channel* channel = (hv_vmbus_channel*)context; boolean_t is_batched_reading; - /** - * Find the channel based on this relid and invokes - * the channel callback to process the event - */ - - if (channel == NULL) { - return; - } - /** - * To deal with the race condition where we might - * receive a packet while the relevant driver is - * being unloaded, dispatch the callback while - * holding the channel lock. The unloading driver - * will acquire the same channel lock to set the - * callback to NULL. This closes the window. - */ - if (channel->on_channel_callback != NULL) { arg = channel->channel_callback_context; is_batched_reading = channel->batched_reading; Modified: stable/10/sys/dev/hyperv/vmbus/hv_channel_mgmt.c ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/hv_channel_mgmt.c Tue Oct 11 06:04:40 2016 (r307016) +++ stable/10/sys/dev/hyperv/vmbus/hv_channel_mgmt.c Tue Oct 11 06:19:06 2016 (r307017) @@ -421,46 +421,13 @@ vmbus_channel_on_offers_delivered(struct * @brief Open result handler. * * This is invoked when we received a response - * to our channel open request. Find the matching request, copy the - * response and signal the requesting thread. + * to our channel open request. */ static void vmbus_channel_on_open_result(struct vmbus_softc *sc, const struct vmbus_message *msg) { - const hv_vmbus_channel_msg_header *hdr = - (const hv_vmbus_channel_msg_header *)msg->msg_data; - - const hv_vmbus_channel_open_result *result; - hv_vmbus_channel_msg_info* msg_info; - hv_vmbus_channel_msg_header* requestHeader; - hv_vmbus_channel_open_channel* openMsg; - - result = (const hv_vmbus_channel_open_result *)hdr; - - /* - * Find the open msg, copy the result and signal/unblock the wait event - */ - mtx_lock(&hv_vmbus_g_connection.channel_msg_lock); - - TAILQ_FOREACH(msg_info, &hv_vmbus_g_connection.channel_msg_anchor, - msg_list_entry) { - requestHeader = (hv_vmbus_channel_msg_header*) msg_info->msg; - - if (requestHeader->message_type == - HV_CHANNEL_MESSAGE_OPEN_CHANNEL) { - openMsg = (hv_vmbus_channel_open_channel*) msg_info->msg; - if (openMsg->child_rel_id == result->child_rel_id - && openMsg->open_id == result->open_id) { - memcpy(&msg_info->response.open_result, result, - sizeof(hv_vmbus_channel_open_result)); - sema_post(&msg_info->wait_sema); - break; - } - } - } - mtx_unlock(&hv_vmbus_g_connection.channel_msg_lock); - + vmbus_msghc_wakeup(sc, msg); } /** @@ -474,39 +441,7 @@ static void vmbus_channel_on_gpadl_created(struct vmbus_softc *sc, const struct vmbus_message *msg) { - const hv_vmbus_channel_msg_header *hdr = - (const hv_vmbus_channel_msg_header *)msg->msg_data; - - const hv_vmbus_channel_gpadl_created *gpadl_created; - hv_vmbus_channel_msg_info* msg_info; - hv_vmbus_channel_msg_header* request_header; - hv_vmbus_channel_gpadl_header* gpadl_header; - - gpadl_created = (const hv_vmbus_channel_gpadl_created *)hdr; - - /* Find the establish msg, copy the result and signal/unblock - * the wait event - */ - mtx_lock(&hv_vmbus_g_connection.channel_msg_lock); - TAILQ_FOREACH(msg_info, &hv_vmbus_g_connection.channel_msg_anchor, - msg_list_entry) { - request_header = (hv_vmbus_channel_msg_header*) msg_info->msg; - if (request_header->message_type == - HV_CHANNEL_MESSAGEL_GPADL_HEADER) { - gpadl_header = - (hv_vmbus_channel_gpadl_header*) request_header; - - if ((gpadl_created->child_rel_id == gpadl_header->child_rel_id) - && (gpadl_created->gpadl == gpadl_header->gpadl)) { - memcpy(&msg_info->response.gpadl_created, - gpadl_created, - sizeof(hv_vmbus_channel_gpadl_created)); - sema_post(&msg_info->wait_sema); - break; - } - } - } - mtx_unlock(&hv_vmbus_g_connection.channel_msg_lock); + vmbus_msghc_wakeup(sc, msg); } /** @@ -520,42 +455,7 @@ static void vmbus_channel_on_gpadl_torndown(struct vmbus_softc *sc, const struct vmbus_message *msg) { - const hv_vmbus_channel_msg_header *hdr = - (const hv_vmbus_channel_msg_header *)msg->msg_data; - - const hv_vmbus_channel_gpadl_torndown *gpadl_torndown; - hv_vmbus_channel_msg_info* msg_info; - hv_vmbus_channel_msg_header* requestHeader; - hv_vmbus_channel_gpadl_teardown* gpadlTeardown; - - gpadl_torndown = (const hv_vmbus_channel_gpadl_torndown *)hdr; - - /* - * Find the open msg, copy the result and signal/unblock the - * wait event. *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-all@freebsd.org Tue Oct 11 06:35:31 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D1782C0C92F; Tue, 11 Oct 2016 06:35:31 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 980D317B; Tue, 11 Oct 2016 06:35:31 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9B6ZUab088104; Tue, 11 Oct 2016 06:35:30 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9B6ZTbO088089; Tue, 11 Oct 2016 06:35:29 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610110635.u9B6ZTbO088089@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Tue, 11 Oct 2016 06:35:29 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307018 - in stable/10/sys: conf dev/hyperv/include dev/hyperv/netvsc dev/hyperv/storvsc dev/hyperv/vmbus modules/hyperv/netvsc modules/hyperv/storvsc modules/hyperv/vmbus X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Oct 2016 06:35:31 -0000 Author: sephe Date: Tue Oct 11 06:35:29 2016 New Revision: 307018 URL: https://svnweb.freebsd.org/changeset/base/307018 Log: MFC 302617-302621,302623,302629-302631 302617 hyperv/vmbus: Flatten channel message response processing. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D6914 302618 hyperv/vmbus: Avoid tx_evtflags setting code duplication. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D6915 302619 hyperv/vmbus: Busdma-fy Hypercall signal event input parameter. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D6916 302620 hyperv: Nuke unused stuffs Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D6917 302621 hyperv/vmbus: Don't be oversmart in default cpu selection. Pin the channel to cpu0 by default. Drivers having special channel-cpu mapping requirement should call vmbus_channel_cpu_{set,rr}() themselves. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D6918 302623 hyperv/vmbus: Minor renaming Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D6919 302629 hyperv/vmbus: Rework vmbus version accessing. Instead of global variable, vmbus version is accessed through a vmbus DEVMETHOD now. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D6953 302630 hyperv/vmbus: Move GPADL index into vmbus_softc Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D6954 302631 hyperv/vmbus: Move channel list to vmbus_softc Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D6956 Added: stable/10/sys/dev/hyperv/vmbus/vmbus_if.m - copied unchanged from r302629, head/sys/dev/hyperv/vmbus/vmbus_if.m Modified: stable/10/sys/conf/files.amd64 stable/10/sys/conf/files.i386 stable/10/sys/dev/hyperv/include/hyperv.h stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c stable/10/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c stable/10/sys/dev/hyperv/vmbus/hv_channel.c stable/10/sys/dev/hyperv/vmbus/hv_channel_mgmt.c stable/10/sys/dev/hyperv/vmbus/hv_connection.c stable/10/sys/dev/hyperv/vmbus/hv_vmbus_priv.h stable/10/sys/dev/hyperv/vmbus/hyperv.c stable/10/sys/dev/hyperv/vmbus/hyperv_reg.h stable/10/sys/dev/hyperv/vmbus/hyperv_var.h stable/10/sys/dev/hyperv/vmbus/vmbus.c stable/10/sys/dev/hyperv/vmbus/vmbus_reg.h stable/10/sys/dev/hyperv/vmbus/vmbus_var.h stable/10/sys/modules/hyperv/netvsc/Makefile stable/10/sys/modules/hyperv/storvsc/Makefile stable/10/sys/modules/hyperv/vmbus/Makefile Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/conf/files.amd64 ============================================================================== --- stable/10/sys/conf/files.amd64 Tue Oct 11 06:19:06 2016 (r307017) +++ stable/10/sys/conf/files.amd64 Tue Oct 11 06:35:29 2016 (r307018) @@ -279,6 +279,7 @@ dev/hyperv/vmbus/hyperv.c optional hy dev/hyperv/vmbus/hyperv_busdma.c optional hyperv dev/hyperv/vmbus/vmbus.c optional hyperv dev/hyperv/vmbus/vmbus_et.c optional hyperv +dev/hyperv/vmbus/vmbus_if.m optional hyperv dev/hyperv/vmbus/amd64/hyperv_machdep.c optional hyperv dev/hyperv/vmbus/amd64/vmbus_vector.S optional hyperv dev/lindev/full.c optional lindev Modified: stable/10/sys/conf/files.i386 ============================================================================== --- stable/10/sys/conf/files.i386 Tue Oct 11 06:19:06 2016 (r307017) +++ stable/10/sys/conf/files.i386 Tue Oct 11 06:35:29 2016 (r307018) @@ -256,6 +256,7 @@ dev/hyperv/vmbus/hyperv.c optional hy dev/hyperv/vmbus/hyperv_busdma.c optional hyperv dev/hyperv/vmbus/vmbus.c optional hyperv dev/hyperv/vmbus/vmbus_et.c optional hyperv +dev/hyperv/vmbus/vmbus_if.m optional hyperv dev/hyperv/vmbus/i386/hyperv_machdep.c optional hyperv dev/hyperv/vmbus/i386/vmbus_vector.S optional hyperv dev/ichwd/ichwd.c optional ichwd Modified: stable/10/sys/dev/hyperv/include/hyperv.h ============================================================================== --- stable/10/sys/dev/hyperv/include/hyperv.h Tue Oct 11 06:19:06 2016 (r307017) +++ stable/10/sys/dev/hyperv/include/hyperv.h Tue Oct 11 06:35:29 2016 (r307018) @@ -55,6 +55,7 @@ #include #include +#include typedef uint8_t hv_bool_uint8_t; @@ -72,10 +73,13 @@ typedef uint8_t hv_bool_uint8_t; * 2.4 -- Windows 8 * 3.0 -- Windows 8.1 */ -#define HV_VMBUS_VERSION_WS2008 ((0 << 16) | (13)) -#define HV_VMBUS_VERSION_WIN7 ((1 << 16) | (1)) -#define HV_VMBUS_VERSION_WIN8 ((2 << 16) | (4)) -#define HV_VMBUS_VERSION_WIN8_1 ((3 << 16) | (0)) +#define VMBUS_VERSION_WS2008 ((0 << 16) | (13)) +#define VMBUS_VERSION_WIN7 ((1 << 16) | (1)) +#define VMBUS_VERSION_WIN8 ((2 << 16) | (4)) +#define VMBUS_VERSION_WIN8_1 ((3 << 16) | (0)) + +#define VMBUS_VERSION_MAJOR(ver) (((uint32_t)(ver)) >> 16) +#define VMBUS_VERSION_MINOR(ver) (((uint32_t)(ver)) & 0xffff) /* * Make maximum size of pipe payload of 16K @@ -528,22 +532,7 @@ typedef union { } __packed hv_vmbus_connection_id; -/* - * Definition of the hv_vmbus_signal_event hypercall input structure - */ -typedef struct { - hv_vmbus_connection_id connection_id; - uint16_t flag_number; - uint16_t rsvd_z; -} __packed hv_vmbus_input_signal_event; - -typedef struct { - uint64_t align8; - hv_vmbus_input_signal_event event; -} __packed hv_vmbus_input_signal_event_buffer; - typedef struct hv_vmbus_channel { - TAILQ_ENTRY(hv_vmbus_channel) list_entry; struct hv_device* device; struct vmbus_softc *vmbus_sc; hv_vmbus_channel_state state; @@ -589,14 +578,8 @@ typedef struct hv_vmbus_channel { boolean_t is_dedicated_interrupt; - /* - * Used as an input param for HV_CALL_SIGNAL_EVENT hypercall. - */ - hv_vmbus_input_signal_event_buffer signal_event_buffer; - /* - * 8-bytes aligned of the buffer above - */ - hv_vmbus_input_signal_event *signal_event_param; + struct hypercall_sigevt_in *ch_sigevt; + struct hyperv_dma ch_sigevt_dma; /* * From Win8, this field specifies the target virtual process @@ -643,6 +626,7 @@ typedef struct hv_vmbus_channel { void *hv_chan_priv3; struct task ch_detach_task; + TAILQ_ENTRY(hv_vmbus_channel) ch_link; } hv_vmbus_channel; #define HV_VMBUS_CHAN_ISPRIMARY(chan) ((chan)->primary_channel == NULL) @@ -726,6 +710,7 @@ int hv_vmbus_channel_teardown_gpdal( struct hv_vmbus_channel* vmbus_select_outgoing_channel(struct hv_vmbus_channel *promary); void vmbus_channel_cpu_set(struct hv_vmbus_channel *chan, int cpu); +void vmbus_channel_cpu_rr(struct hv_vmbus_channel *chan); struct hv_vmbus_channel ** vmbus_get_subchan(struct hv_vmbus_channel *pri_chan, int subchan_cnt); void vmbus_rel_subchan(struct hv_vmbus_channel **subchan, int subchan_cnt); @@ -741,5 +726,4 @@ hv_get_phys_addr(void *virt) return (ret); } -extern uint32_t hv_vmbus_protocal_version; #endif /* __HYPERV_H__ */ Modified: stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Tue Oct 11 06:19:06 2016 (r307017) +++ stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Tue Oct 11 06:35:29 2016 (r307018) @@ -116,9 +116,11 @@ __FBSDID("$FreeBSD$"); #include #include + #include "hv_net_vsc.h" #include "hv_rndis.h" #include "hv_rndis_filter.h" +#include "vmbus_if.h" #define hv_chan_rxr hv_chan_priv1 #define hv_chan_txr hv_chan_priv2 @@ -2425,8 +2427,10 @@ static int hn_create_tx_ring(struct hn_softc *sc, int id) { struct hn_tx_ring *txr = &sc->hn_tx_ring[id]; + device_t dev = sc->hn_dev; bus_dma_tag_t parent_dtag; int error, i; + uint32_t version; txr->hn_sc = sc; txr->hn_tx_idx = id; @@ -2465,10 +2469,18 @@ hn_create_tx_ring(struct hn_softc *sc, i } txr->hn_direct_tx_size = hn_direct_tx_size; - if (hv_vmbus_protocal_version >= HV_VMBUS_VERSION_WIN8_1) + version = VMBUS_GET_VERSION(device_get_parent(dev), dev); + if (version >= VMBUS_VERSION_WIN8_1) { txr->hn_csum_assist = HN_CSUM_ASSIST; - else + } else { txr->hn_csum_assist = HN_CSUM_ASSIST_WIN8; + if (id == 0) { + device_printf(dev, "bus version %u.%u, " + "no UDP checksum offloading\n", + VMBUS_VERSION_MAJOR(version), + VMBUS_VERSION_MINOR(version)); + } + } /* * Always schedule transmission instead of trying to do direct @@ -2476,7 +2488,7 @@ hn_create_tx_ring(struct hn_softc *sc, i */ txr->hn_sched_tx = 1; - parent_dtag = bus_get_dma_tag(sc->hn_dev); + parent_dtag = bus_get_dma_tag(dev); /* DMA tag for RNDIS messages. */ error = bus_dma_tag_create(parent_dtag, /* parent */ @@ -2493,7 +2505,7 @@ hn_create_tx_ring(struct hn_softc *sc, i NULL, /* lockfuncarg */ &txr->hn_tx_rndis_dtag); if (error) { - device_printf(sc->hn_dev, "failed to create rndis dmatag\n"); + device_printf(dev, "failed to create rndis dmatag\n"); return error; } @@ -2512,7 +2524,7 @@ hn_create_tx_ring(struct hn_softc *sc, i NULL, /* lockfuncarg */ &txr->hn_tx_data_dtag); if (error) { - device_printf(sc->hn_dev, "failed to create data dmatag\n"); + device_printf(dev, "failed to create data dmatag\n"); return error; } @@ -2529,7 +2541,7 @@ hn_create_tx_ring(struct hn_softc *sc, i BUS_DMA_WAITOK | BUS_DMA_COHERENT, &txd->rndis_msg_dmap); if (error) { - device_printf(sc->hn_dev, + device_printf(dev, "failed to allocate rndis_msg, %d\n", i); return error; } @@ -2540,7 +2552,7 @@ hn_create_tx_ring(struct hn_softc *sc, i hyperv_dma_map_paddr, &txd->rndis_msg_paddr, BUS_DMA_NOWAIT); if (error) { - device_printf(sc->hn_dev, + device_printf(dev, "failed to load rndis_msg, %d\n", i); bus_dmamem_free(txr->hn_tx_rndis_dtag, txd->rndis_msg, txd->rndis_msg_dmap); @@ -2551,7 +2563,7 @@ hn_create_tx_ring(struct hn_softc *sc, i error = bus_dmamap_create(txr->hn_tx_data_dtag, 0, &txd->data_dmap); if (error) { - device_printf(sc->hn_dev, + device_printf(dev, "failed to allocate tx data dmamap\n"); bus_dmamap_unload(txr->hn_tx_rndis_dtag, txd->rndis_msg_dmap); @@ -2579,7 +2591,7 @@ hn_create_tx_ring(struct hn_softc *sc, i * Create per TX ring sysctl tree: * dev.hn.UNIT.tx.RINGID */ - ctx = device_get_sysctl_ctx(sc->hn_dev); + ctx = device_get_sysctl_ctx(dev); child = SYSCTL_CHILDREN(sc->hn_tx_sysctl_tree); snprintf(name, sizeof(name), "%d", id); Modified: stable/10/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c ============================================================================== --- stable/10/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c Tue Oct 11 06:19:06 2016 (r307017) +++ stable/10/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c Tue Oct 11 06:35:29 2016 (r307018) @@ -72,7 +72,9 @@ __FBSDID("$FreeBSD$"); #include #include + #include "hv_vstorage.h" +#include "vmbus_if.h" #define STORVSC_RINGBUFFER_SIZE (20*PAGE_SIZE) #define STORVSC_MAX_LUNS_PER_TARGET (64) @@ -361,6 +363,7 @@ storvsc_subchan_attach(struct hv_vmbus_c memset(&props, 0, sizeof(props)); + vmbus_channel_cpu_rr(new_channel); ret = hv_vmbus_channel_open(new_channel, sc->hs_drv_props->drv_ringbuffer_size, sc->hs_drv_props->drv_ringbuffer_size, @@ -464,6 +467,7 @@ hv_storvsc_channel_init(struct hv_device struct storvsc_softc *sc; uint16_t max_chans = 0; boolean_t support_multichannel = FALSE; + uint32_t version; max_chans = 0; support_multichannel = FALSE; @@ -588,8 +592,9 @@ hv_storvsc_channel_init(struct hv_device /* multi-channels feature is supported by WIN8 and above version */ max_chans = vstor_packet->u.chan_props.max_channel_cnt; - if ((hv_vmbus_protocal_version != HV_VMBUS_VERSION_WIN7) && - (hv_vmbus_protocal_version != HV_VMBUS_VERSION_WS2008) && + version = VMBUS_GET_VERSION(device_get_parent(dev->device), + dev->device); + if (version != VMBUS_VERSION_WIN7 && version != VMBUS_VERSION_WS2008 && (vstor_packet->u.chan_props.flags & HV_STORAGE_SUPPORTS_MULTI_CHANNEL)) { support_multichannel = TRUE; @@ -655,7 +660,7 @@ hv_storvsc_connect_vsp(struct hv_device /* * Open the channel */ - + vmbus_channel_cpu_rr(dev->channel); ret = hv_vmbus_channel_open( dev->channel, sc->hs_drv_props->drv_ringbuffer_size, Modified: stable/10/sys/dev/hyperv/vmbus/hv_channel.c ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/hv_channel.c Tue Oct 11 06:19:06 2016 (r307017) +++ stable/10/sys/dev/hyperv/vmbus/hv_channel.c Tue Oct 11 06:35:29 2016 (r307018) @@ -46,6 +46,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include @@ -58,21 +59,21 @@ static void VmbusProcessChannelEvent(voi static void vmbus_channel_set_event(hv_vmbus_channel *channel) { + struct vmbus_softc *sc = channel->vmbus_sc; + uint32_t chanid = channel->offer_msg.child_rel_id; + + atomic_set_long(&sc->vmbus_tx_evtflags[chanid >> VMBUS_EVTFLAG_SHIFT], + 1UL << (chanid & VMBUS_EVTFLAG_MASK)); + if (channel->offer_msg.monitor_allocated) { - struct vmbus_softc *sc = channel->vmbus_sc; hv_vmbus_monitor_page *monitor_page; - uint32_t chanid = channel->offer_msg.child_rel_id; - - atomic_set_long( - &sc->vmbus_tx_evtflags[chanid >> VMBUS_EVTFLAG_SHIFT], - 1UL << (chanid & VMBUS_EVTFLAG_MASK)); monitor_page = sc->vmbus_mnf2; synch_set_bit(channel->monitor_bit, (uint32_t *)&monitor_page-> trigger_group[channel->monitor_group].u.pending); } else { - hv_vmbus_set_event(channel); + hypercall_signal_event(channel->ch_sigevt_dma.hv_paddr); } } @@ -342,8 +343,7 @@ hv_vmbus_channel_establish_gpadl(struct /* * Allocate GPADL id. */ - gpadl = atomic_fetchadd_int( - &hv_vmbus_g_connection.next_gpadl_handle, 1); + gpadl = vmbus_gpadl_alloc(sc); *gpadl0 = gpadl; /* Modified: stable/10/sys/dev/hyperv/vmbus/hv_channel_mgmt.c ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/hv_channel_mgmt.c Tue Oct 11 06:19:06 2016 (r307017) +++ stable/10/sys/dev/hyperv/vmbus/hv_channel_mgmt.c Tue Oct 11 06:35:29 2016 (r307018) @@ -35,6 +35,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include #include @@ -49,18 +50,10 @@ static void vmbus_chan_detach_task(void static void vmbus_channel_on_offer(struct vmbus_softc *, const struct vmbus_message *); -static void vmbus_channel_on_open_result(struct vmbus_softc *, - const struct vmbus_message *); static void vmbus_channel_on_offer_rescind(struct vmbus_softc *, const struct vmbus_message *); -static void vmbus_channel_on_gpadl_created(struct vmbus_softc *, - const struct vmbus_message *); -static void vmbus_channel_on_gpadl_torndown(struct vmbus_softc *, - const struct vmbus_message *); static void vmbus_channel_on_offers_delivered(struct vmbus_softc *, const struct vmbus_message *); -static void vmbus_channel_on_version_response(struct vmbus_softc *, - const struct vmbus_message *); /** * Channel message dispatch table @@ -74,13 +67,13 @@ vmbus_chanmsg_process[HV_CHANNEL_MESSAGE [HV_CHANNEL_MESSAGE_ALL_OFFERS_DELIVERED] = vmbus_channel_on_offers_delivered, [HV_CHANNEL_MESSAGE_OPEN_CHANNEL_RESULT] = - vmbus_channel_on_open_result, + vmbus_msghc_wakeup, [HV_CHANNEL_MESSAGE_GPADL_CREATED] = - vmbus_channel_on_gpadl_created, + vmbus_msghc_wakeup, [HV_CHANNEL_MESSAGE_GPADL_TORNDOWN] = - vmbus_channel_on_gpadl_torndown, + vmbus_msghc_wakeup, [HV_CHANNEL_MESSAGE_VERSION_RESPONSE] = - vmbus_channel_on_version_response + vmbus_msghc_wakeup }; /** @@ -118,6 +111,7 @@ hv_vmbus_free_vmbus_channel(hv_vmbus_cha static void vmbus_channel_process_offer(hv_vmbus_channel *new_channel) { + struct vmbus_softc *sc = new_channel->vmbus_sc; hv_vmbus_channel* channel; uint32_t relid; @@ -125,7 +119,7 @@ vmbus_channel_process_offer(hv_vmbus_cha /* * Make sure this is a new offer */ - mtx_lock(&hv_vmbus_g_connection.channel_lock); + mtx_lock(&sc->vmbus_chlist_lock); if (relid == 0) { /* * XXX channel0 will not be processed; skip it. @@ -135,8 +129,7 @@ vmbus_channel_process_offer(hv_vmbus_cha hv_vmbus_g_connection.channels[relid] = new_channel; } - TAILQ_FOREACH(channel, &hv_vmbus_g_connection.channel_anchor, - list_entry) { + TAILQ_FOREACH(channel, &sc->vmbus_chlist, ch_link) { if (memcmp(&channel->offer_msg.offer.interface_type, &new_channel->offer_msg.offer.interface_type, sizeof(hv_guid)) == 0 && @@ -148,10 +141,9 @@ vmbus_channel_process_offer(hv_vmbus_cha if (channel == NULL) { /* Install the new primary channel */ - TAILQ_INSERT_TAIL(&hv_vmbus_g_connection.channel_anchor, - new_channel, list_entry); + TAILQ_INSERT_TAIL(&sc->vmbus_chlist, new_channel, ch_link); } - mtx_unlock(&hv_vmbus_g_connection.channel_lock); + mtx_unlock(&sc->vmbus_chlist_lock); if (channel != NULL) { /* @@ -175,11 +167,19 @@ vmbus_channel_process_offer(hv_vmbus_cha new_channel->offer_msg.offer.sub_channel_index); } - /* Insert new channel into channel_anchor. */ - mtx_lock(&hv_vmbus_g_connection.channel_lock); - TAILQ_INSERT_TAIL(&hv_vmbus_g_connection.channel_anchor, - new_channel, list_entry); - mtx_unlock(&hv_vmbus_g_connection.channel_lock); + /* + * Insert the new channel to the end of the global + * channel list. + * + * NOTE: + * The new sub-channel MUST be inserted AFTER it's + * primary channel, so that the primary channel will + * be found in the above loop for its baby siblings. + */ + mtx_lock(&sc->vmbus_chlist_lock); + TAILQ_INSERT_TAIL(&sc->vmbus_chlist, new_channel, + ch_link); + mtx_unlock(&sc->vmbus_chlist_lock); if(bootverbose) printf("VMBUS: new multi-channel offer <%p>, " @@ -232,8 +232,8 @@ vmbus_channel_cpu_set(struct hv_vmbus_ch { KASSERT(cpu >= 0 && cpu < mp_ncpus, ("invalid cpu %d", cpu)); - if (hv_vmbus_protocal_version == HV_VMBUS_VERSION_WS2008 || - hv_vmbus_protocal_version == HV_VMBUS_VERSION_WIN7) { + if (chan->vmbus_sc->vmbus_version == VMBUS_VERSION_WS2008 || + chan->vmbus_sc->vmbus_version == VMBUS_VERSION_WIN7) { /* Only cpu0 is supported */ cpu = 0; } @@ -248,61 +248,25 @@ vmbus_channel_cpu_set(struct hv_vmbus_ch } } -/** - * Array of device guids that are performance critical. We try to distribute - * the interrupt load for these devices across all online cpus. - */ -static const hv_guid high_perf_devices[] = { - {HV_NIC_GUID, }, - {HV_IDE_GUID, }, - {HV_SCSI_GUID, }, -}; - -enum { - PERF_CHN_NIC = 0, - PERF_CHN_IDE, - PERF_CHN_SCSI, - MAX_PERF_CHN, -}; +void +vmbus_channel_cpu_rr(struct hv_vmbus_channel *chan) +{ + static uint32_t vmbus_chan_nextcpu; + int cpu; -/* - * We use this static number to distribute the channel interrupt load. - */ -static uint32_t next_vcpu; + cpu = atomic_fetchadd_int(&vmbus_chan_nextcpu, 1) % mp_ncpus; + vmbus_channel_cpu_set(chan, cpu); +} -/** - * Starting with Win8, we can statically distribute the incoming - * channel interrupt load by binding a channel to VCPU. We - * implement here a simple round robin scheme for distributing - * the interrupt load. - * We will bind channels that are not performance critical to cpu 0 and - * performance critical channels (IDE, SCSI and Network) will be uniformly - * distributed across all available CPUs. - */ static void -vmbus_channel_select_defcpu(struct hv_vmbus_channel *channel) +vmbus_channel_select_defcpu(struct hv_vmbus_channel *chan) { - uint32_t current_cpu; - int i; - boolean_t is_perf_channel = FALSE; - const hv_guid *guid = &channel->offer_msg.offer.interface_type; - - for (i = PERF_CHN_NIC; i < MAX_PERF_CHN; i++) { - if (memcmp(guid->data, high_perf_devices[i].data, - sizeof(hv_guid)) == 0) { - is_perf_channel = TRUE; - break; - } - } - - if (!is_perf_channel) { - /* Stick to cpu0 */ - vmbus_channel_cpu_set(channel, 0); - return; - } - /* mp_ncpus should have the number cpus currently online */ - current_cpu = (++next_vcpu % mp_ncpus); - vmbus_channel_cpu_set(channel, current_cpu); + /* + * By default, pin the channel to cpu0. Devices having + * special channel-cpu mapping requirement should call + * vmbus_channel_cpu_{set,rr}(). + */ + vmbus_channel_cpu_set(chan, 0); } /** @@ -338,23 +302,23 @@ vmbus_channel_on_offer_internal(struct v */ new_channel->batched_reading = TRUE; - new_channel->signal_event_param = - (hv_vmbus_input_signal_event *) - (HV_ALIGN_UP((unsigned long) - &new_channel->signal_event_buffer, - HV_HYPERCALL_PARAM_ALIGN)); - - new_channel->signal_event_param->connection_id.as_uint32_t = 0; - new_channel->signal_event_param->connection_id.u.id = - HV_VMBUS_EVENT_CONNECTION_ID; - new_channel->signal_event_param->flag_number = 0; - new_channel->signal_event_param->rsvd_z = 0; + new_channel->ch_sigevt = hyperv_dmamem_alloc( + bus_get_dma_tag(sc->vmbus_dev), + HYPERCALL_SIGEVTIN_ALIGN, 0, sizeof(struct hypercall_sigevt_in), + &new_channel->ch_sigevt_dma, BUS_DMA_WAITOK | BUS_DMA_ZERO); + if (new_channel->ch_sigevt == NULL) { + device_printf(sc->vmbus_dev, "sigevt alloc failed\n"); + /* XXX */ + mtx_destroy(&new_channel->sc_lock); + free(new_channel, M_DEVBUF); + return; + } + new_channel->ch_sigevt->hc_connid = VMBUS_CONNID_EVENT; - if (hv_vmbus_protocal_version != HV_VMBUS_VERSION_WS2008) { + if (sc->vmbus_version != VMBUS_VERSION_WS2008) { new_channel->is_dedicated_interrupt = (offer->is_dedicated_interrupt != 0); - new_channel->signal_event_param->connection_id.u.id = - offer->connection_id; + new_channel->ch_sigevt->hc_connid = offer->connection_id; } memcpy(&new_channel->offer_msg, offer, @@ -418,67 +382,18 @@ vmbus_channel_on_offers_delivered(struct } /** - * @brief Open result handler. - * - * This is invoked when we received a response - * to our channel open request. - */ -static void -vmbus_channel_on_open_result(struct vmbus_softc *sc, - const struct vmbus_message *msg) -{ - vmbus_msghc_wakeup(sc, msg); -} - -/** - * @brief GPADL created handler. - * - * This is invoked when we received a response - * to our gpadl create request. Find the matching request, copy the - * response and signal the requesting thread. - */ -static void -vmbus_channel_on_gpadl_created(struct vmbus_softc *sc, - const struct vmbus_message *msg) -{ - vmbus_msghc_wakeup(sc, msg); -} - -/** - * @brief GPADL torndown handler. - * - * This is invoked when we received a respons - * to our gpadl teardown request. Find the matching request, copy the - * response and signal the requesting thread - */ -static void -vmbus_channel_on_gpadl_torndown(struct vmbus_softc *sc, - const struct vmbus_message *msg) -{ - vmbus_msghc_wakeup(sc, msg); -} - -static void -vmbus_channel_on_version_response(struct vmbus_softc *sc, - const struct vmbus_message *msg) -{ - vmbus_msghc_wakeup(sc, msg); -} - -/** * @brief Release channels that are unattached/unconnected (i.e., no drivers associated) */ void -hv_vmbus_release_unattached_channels(void) +hv_vmbus_release_unattached_channels(struct vmbus_softc *sc) { hv_vmbus_channel *channel; - mtx_lock(&hv_vmbus_g_connection.channel_lock); + mtx_lock(&sc->vmbus_chlist_lock); - while (!TAILQ_EMPTY(&hv_vmbus_g_connection.channel_anchor)) { - channel = TAILQ_FIRST(&hv_vmbus_g_connection.channel_anchor); - TAILQ_REMOVE(&hv_vmbus_g_connection.channel_anchor, - channel, list_entry); + while (!TAILQ_EMPTY(&sc->vmbus_chlist)) { + channel = TAILQ_FIRST(&sc->vmbus_chlist); + TAILQ_REMOVE(&sc->vmbus_chlist, channel, ch_link); if (HV_VMBUS_CHAN_ISPRIMARY(channel)) { /* Only primary channel owns the hv_device */ @@ -488,7 +403,8 @@ hv_vmbus_release_unattached_channels(voi } bzero(hv_vmbus_g_connection.channels, sizeof(hv_vmbus_channel*) * VMBUS_CHAN_MAX); - mtx_unlock(&hv_vmbus_g_connection.channel_lock); + + mtx_unlock(&sc->vmbus_chlist_lock); } /** Modified: stable/10/sys/dev/hyperv/vmbus/hv_connection.c ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/hv_connection.c Tue Oct 11 06:19:06 2016 (r307017) +++ stable/10/sys/dev/hyperv/vmbus/hv_connection.c Tue Oct 11 06:35:29 2016 (r307018) @@ -50,10 +50,7 @@ __FBSDID("$FreeBSD$"); * Globals */ hv_vmbus_connection hv_vmbus_g_connection = - { .connect_state = HV_DISCONNECTED, - .next_gpadl_handle = 0xE1E10, }; - -uint32_t hv_vmbus_protocal_version; + { .connect_state = HV_DISCONNECTED }; /** * Send a connect request on the partition service connection @@ -73,10 +70,6 @@ hv_vmbus_connect(struct vmbus_softc *sc) */ hv_vmbus_g_connection.connect_state = HV_CONNECTING; - TAILQ_INIT(&hv_vmbus_g_connection.channel_anchor); - mtx_init(&hv_vmbus_g_connection.channel_lock, "vmbus channel", - NULL, MTX_DEF); - hv_vmbus_g_connection.channels = malloc(sizeof(hv_vmbus_channel*) * VMBUS_CHAN_MAX, M_DEVBUF, M_WAITOK | M_ZERO); @@ -161,23 +154,6 @@ vmbus_event_proc_compat(struct vmbus_sof } } -/** - * Send an event notification to the parent - */ -int -hv_vmbus_set_event(hv_vmbus_channel *channel) -{ - struct vmbus_softc *sc = channel->vmbus_sc; - int ret = 0; - uint32_t chanid = channel->offer_msg.child_rel_id; - - atomic_set_long(&sc->vmbus_tx_evtflags[chanid >> VMBUS_EVTFLAG_SHIFT], - 1UL << (chanid & VMBUS_EVTFLAG_MASK)); - ret = hv_vmbus_signal_event(channel->signal_event_param); - - return (ret); -} - void vmbus_on_channel_open(const struct hv_vmbus_channel *chan) { Modified: stable/10/sys/dev/hyperv/vmbus/hv_vmbus_priv.h ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/hv_vmbus_priv.h Tue Oct 11 06:19:06 2016 (r307017) +++ stable/10/sys/dev/hyperv/vmbus/hv_vmbus_priv.h Tue Oct 11 06:35:29 2016 (r307018) @@ -38,28 +38,7 @@ #include - -/* - * Status codes for hypervisor operations. - */ - -typedef uint16_t hv_vmbus_status; - -#define HV_MESSAGE_SIZE (256) -#define HV_MESSAGE_PAYLOAD_BYTE_COUNT (240) -#define HV_MESSAGE_PAYLOAD_QWORD_COUNT (30) -#define HV_ANY_VP (0xFFFFFFFF) - -/* - * MessageId: HV_STATUS_INSUFFICIENT_BUFFERS - * MessageText: - * You did not supply enough message buffers to send a message. - */ - -#define HV_STATUS_SUCCESS ((uint16_t)0) -#define HV_STATUS_INSUFFICIENT_BUFFERS ((uint16_t)0x0013) - -typedef void (*hv_vmbus_channel_callback)(void *context); +struct vmbus_softc; typedef struct { void* data; @@ -118,74 +97,6 @@ typedef struct hv_vmbus_channel_packet_m hv_vmbus_multipage_buffer range; } __packed hv_vmbus_channel_packet_multipage_buffer; -enum { - HV_VMBUS_MESSAGE_CONNECTION_ID = 1, - HV_VMBUS_MESSAGE_PORT_ID = 1, - HV_VMBUS_EVENT_CONNECTION_ID = 2, - HV_VMBUS_EVENT_PORT_ID = 2, - HV_VMBUS_MONITOR_CONNECTION_ID = 3, - HV_VMBUS_MONITOR_PORT_ID = 3, -}; - -#define HV_PRESENT_BIT 0x80000000 - -#define HV_HYPERCALL_PARAM_ALIGN sizeof(uint64_t) - -/* - * Define hypervisor message types - */ -typedef enum { - - HV_MESSAGE_TYPE_NONE = 0x00000000, - - /* - * Memory access messages - */ - HV_MESSAGE_TYPE_UNMAPPED_GPA = 0x80000000, - HV_MESSAGE_TYPE_GPA_INTERCEPT = 0x80000001, - - /* - * Timer notification messages - */ - HV_MESSAGE_TIMER_EXPIRED = 0x80000010, - - /* - * Error messages - */ - HV_MESSAGE_TYPE_INVALID_VP_REGISTER_VALUE = 0x80000020, - HV_MESSAGE_TYPE_UNRECOVERABLE_EXCEPTION = 0x80000021, - HV_MESSAGE_TYPE_UNSUPPORTED_FEATURE = 0x80000022, - - /* - * Trace buffer complete messages - */ - HV_MESSAGE_TYPE_EVENT_LOG_BUFFER_COMPLETE = 0x80000040, - - /* - * Platform-specific processor intercept messages - */ - HV_MESSAGE_TYPE_X64_IO_PORT_INTERCEPT = 0x80010000, - HV_MESSAGE_TYPE_X64_MSR_INTERCEPT = 0x80010001, - HV_MESSAGE_TYPE_X64_CPU_INTERCEPT = 0x80010002, - HV_MESSAGE_TYPE_X64_EXCEPTION_INTERCEPT = 0x80010003, - HV_MESSAGE_TYPE_X64_APIC_EOI = 0x80010004, - HV_MESSAGE_TYPE_X64_LEGACY_FP_ERROR = 0x80010005 - -} hv_vmbus_msg_type; - -/* - * Define port identifier type - */ -typedef union _hv_vmbus_port_id { - uint32_t as_uint32_t; - struct { - uint32_t id:24; - uint32_t reserved:8; - } u ; -} hv_vmbus_port_id; - -typedef uint64_t hv_vmbus_partition_id; - /* * VM Bus connection states */ @@ -196,19 +107,8 @@ typedef enum { HV_DISCONNECTING } hv_vmbus_connect_state; -#define HV_MAX_SIZE_CHANNEL_MESSAGE HV_MESSAGE_PAYLOAD_BYTE_COUNT - - typedef struct { hv_vmbus_connect_state connect_state; - uint32_t next_gpadl_handle; - - /** - * List of primary channels. Sub channels will be linked - * under their primary channel. - */ - TAILQ_HEAD(, hv_vmbus_channel) channel_anchor; - struct mtx channel_lock; /** * channel table for fast lookup through id. @@ -277,14 +177,6 @@ typedef struct { uint8_t rsvd_z4[1984]; } hv_vmbus_monitor_page; -/* - * Declare the various hypercall operations - */ -typedef enum { - HV_CALL_POST_MESSAGE = 0x005c, - HV_CALL_SIGNAL_EVENT = 0x005d, -} hv_vmbus_call_code; - /** * Global variables */ @@ -342,17 +234,14 @@ uint32_t hv_ring_buffer_read_end( hv_vmbus_ring_buffer_info *ring_info); void hv_vmbus_free_vmbus_channel(hv_vmbus_channel *channel); -void hv_vmbus_release_unattached_channels(void); - -uint16_t hv_vmbus_signal_event(void *con_id); +void hv_vmbus_release_unattached_channels( + struct vmbus_softc *); struct hv_device* hv_vmbus_child_device_create( hv_guid device_type, hv_guid device_instance, hv_vmbus_channel *channel); -struct vmbus_softc; - void hv_vmbus_child_device_register(struct vmbus_softc *, struct hv_device *child_dev); int hv_vmbus_child_device_unregister( @@ -363,6 +252,5 @@ int hv_vmbus_child_device_unregister( */ int hv_vmbus_connect(struct vmbus_softc *); int hv_vmbus_disconnect(void); -int hv_vmbus_set_event(hv_vmbus_channel *channel); #endif /* __HYPERV_PRIV_H__ */ Modified: stable/10/sys/dev/hyperv/vmbus/hyperv.c ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/hyperv.c Tue Oct 11 06:19:06 2016 (r307017) +++ stable/10/sys/dev/hyperv/vmbus/hyperv.c Tue Oct 11 06:35:29 2016 (r307018) @@ -101,23 +101,6 @@ hyperv_get_timecount(struct timecounter return rdmsr(MSR_HV_TIME_REF_COUNT); } -/** - * @brief Invoke the specified hypercall - */ -static uint64_t -hv_vmbus_do_hypercall(uint64_t value, void *input, void *output) -{ - uint64_t in_paddr = 0, out_paddr = 0; - - if (input != NULL) - in_paddr = hv_get_phys_addr(input); - if (output != NULL) - out_paddr = hv_get_phys_addr(output); - - return hypercall_md(hypercall_context.hc_addr, value, - in_paddr, out_paddr); -} - uint64_t hypercall_post_message(bus_addr_t msg_paddr) { @@ -125,21 +108,11 @@ hypercall_post_message(bus_addr_t msg_pa HYPERCALL_POST_MESSAGE, msg_paddr, 0); } -/** - * @brief Signal an event on the specified connection using the hypervisor - * event IPC. (This involves a hypercall.) - */ -hv_vmbus_status -hv_vmbus_signal_event(void *con_id) -{ - hv_vmbus_status status; - - status = hv_vmbus_do_hypercall( - HV_CALL_SIGNAL_EVENT, - con_id, - 0) & 0xFFFF; - - return (status); +uint64_t +hypercall_signal_event(bus_addr_t sigevt_paddr) +{ + return hypercall_md(hypercall_context.hc_addr, + HYPERCALL_SIGNAL_EVENT, sigevt_paddr, 0); } int Modified: stable/10/sys/dev/hyperv/vmbus/hyperv_reg.h ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/hyperv_reg.h Tue Oct 11 06:19:06 2016 (r307017) +++ stable/10/sys/dev/hyperv/vmbus/hyperv_reg.h Tue Oct 11 06:35:29 2016 (r307018) @@ -148,6 +148,7 @@ * Hypercall input values */ #define HYPERCALL_POST_MESSAGE 0x005c +#define HYPERCALL_SIGNAL_EVENT 0x005d /* * Hypercall input parameters @@ -169,4 +170,15 @@ struct hypercall_postmsg_in { } __packed; CTASSERT(sizeof(struct hypercall_postmsg_in) == HYPERCALL_POSTMSGIN_SIZE); +/* + * HYPERCALL_SIGNAL_EVENT + */ +#define HYPERCALL_SIGEVTIN_ALIGN 8 + +struct hypercall_sigevt_in { + uint32_t hc_connid; + uint16_t hc_evtflag_ofs; + uint16_t hc_rsvd; +} __packed; + #endif /* !_HYPERV_REG_H_ */ Modified: stable/10/sys/dev/hyperv/vmbus/hyperv_var.h ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/hyperv_var.h Tue Oct 11 06:19:06 2016 (r307017) +++ stable/10/sys/dev/hyperv/vmbus/hyperv_var.h Tue Oct 11 06:35:29 2016 (r307018) @@ -41,5 +41,6 @@ extern u_int hyperv_features; extern u_int hyperv_recommends; uint64_t hypercall_post_message(bus_addr_t msg_paddr); +uint64_t hypercall_signal_event(bus_addr_t sigevt_paddr); #endif /* !_HYPERV_VAR_H_ */ Modified: stable/10/sys/dev/hyperv/vmbus/vmbus.c ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/vmbus.c Tue Oct 11 06:19:06 2016 (r307017) +++ stable/10/sys/dev/hyperv/vmbus/vmbus.c Tue Oct 11 06:35:29 2016 (r307018) @@ -68,12 +68,9 @@ __FBSDID("$FreeBSD$"); #include #include "acpi_if.h" +#include "vmbus_if.h" -/* - * NOTE: DO NOT CHANGE THESE - */ -#define VMBUS_CONNID_MESSAGE 1 -#define VMBUS_CONNID_EVENT 2 +#define VMBUS_GPADL_START 0xe1e10 struct vmbus_msghc { struct hypercall_postmsg_in *mh_inprm; @@ -96,10 +93,9 @@ struct vmbus_msghc_ctx { #define VMBUS_MSGHC_CTXF_DESTROY 0x0001 static int vmbus_init(struct vmbus_softc *); -static int vmbus_init_contact(struct vmbus_softc *, - uint32_t); +static int vmbus_connect(struct vmbus_softc *, uint32_t); static int vmbus_req_channels(struct vmbus_softc *sc); -static void vmbus_uninit(struct vmbus_softc *); +static void vmbus_disconnect(struct vmbus_softc *); static int vmbus_scan(struct vmbus_softc *); static void vmbus_scan_wait(struct vmbus_softc *); static void vmbus_scan_newdev(struct vmbus_softc *); @@ -120,10 +116,10 @@ struct vmbus_softc *vmbus_sc; extern inthand_t IDTVEC(rsvd), IDTVEC(vmbus_isr); static const uint32_t vmbus_version[] = { - HV_VMBUS_VERSION_WIN8_1, - HV_VMBUS_VERSION_WIN8, - HV_VMBUS_VERSION_WIN7, - HV_VMBUS_VERSION_WS2008 + VMBUS_VERSION_WIN8_1, + VMBUS_VERSION_WIN8, + VMBUS_VERSION_WIN7, + VMBUS_VERSION_WS2008 }; static struct vmbus_msghc * @@ -378,21 +374,26 @@ vmbus_msghc_wakeup(struct vmbus_softc *s wakeup(&mhc->mhc_active); } +uint32_t +vmbus_gpadl_alloc(struct vmbus_softc *sc) +{ + return atomic_fetchadd_int(&sc->vmbus_gpadl, 1); +} + static int *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-all@freebsd.org Tue Oct 11 06:46:26 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 87E90C0CDD0; Tue, 11 Oct 2016 06:46:26 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 5F7F6988; Tue, 11 Oct 2016 06:46:26 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9B6kPnv091859; Tue, 11 Oct 2016 06:46:25 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9B6kOVK091854; Tue, 11 Oct 2016 06:46:24 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610110646.u9B6kOVK091854@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Tue, 11 Oct 2016 06:46:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307019 - in stable/10/sys/dev/hyperv: include netvsc vmbus X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Oct 2016 06:46:26 -0000 Author: sephe Date: Tue Oct 11 06:46:24 2016 New Revision: 307019 URL: https://svnweb.freebsd.org/changeset/base/307019 Log: MFC 302632-302634 302632 hyperv/vmbus: More verbose for GPADL_connect/chan_{rescind,offer} Reviewed by: Dexuan Cui , Hongjiang Zhang Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D6976 302633 hyperv/vmbus: Free sysctl properly upon channel close. Prepare for sub-channel re-open. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D6977 302634 hyperv/vmbus: Fix sub-channel re-open support. For multi-channel devices, once the primary channel is closed, a set of 'rescind' messages for sub-channels will be delivered by Hypervisor. Sub-channel MUST be freed according to these 'rescind' messages; directly re-openning sub-channels in the same fashion as the primary channel's re-opening does NOT work at all. After the primary channel is re-opened, requested # of sub- channels will be delivered though 'channel offer' messages, and this set of newly offered channels can be opened along side with the primary channel. This unbreaks the MTU setting for hn(4), which requires re- openning all existsing channels upon MTU change. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D6978 Modified: stable/10/sys/dev/hyperv/include/hyperv.h stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c stable/10/sys/dev/hyperv/vmbus/hv_channel.c stable/10/sys/dev/hyperv/vmbus/hv_channel_mgmt.c stable/10/sys/dev/hyperv/vmbus/vmbus_reg.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/hyperv/include/hyperv.h ============================================================================== --- stable/10/sys/dev/hyperv/include/hyperv.h Tue Oct 11 06:35:29 2016 (r307018) +++ stable/10/sys/dev/hyperv/include/hyperv.h Tue Oct 11 06:46:24 2016 (r307019) @@ -49,6 +49,7 @@ #include #include #include +#include #include #include #include @@ -627,6 +628,8 @@ typedef struct hv_vmbus_channel { struct task ch_detach_task; TAILQ_ENTRY(hv_vmbus_channel) ch_link; + + struct sysctl_ctx_list ch_sysctl_ctx; } hv_vmbus_channel; #define HV_VMBUS_CHAN_ISPRIMARY(chan) ((chan)->primary_channel == NULL) @@ -714,6 +717,7 @@ void vmbus_channel_cpu_rr(struct hv_vmb struct hv_vmbus_channel ** vmbus_get_subchan(struct hv_vmbus_channel *pri_chan, int subchan_cnt); void vmbus_rel_subchan(struct hv_vmbus_channel **subchan, int subchan_cnt); +void vmbus_drain_subchan(struct hv_vmbus_channel *pri_chan); /** * @brief Get physical address from virtual Modified: stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Tue Oct 11 06:35:29 2016 (r307018) +++ stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Tue Oct 11 06:46:24 2016 (r307019) @@ -349,6 +349,7 @@ static void hn_destroy_rx_data(struct hn static void hn_set_tx_chimney_size(struct hn_softc *, int); static void hn_channel_attach(struct hn_softc *, struct hv_vmbus_channel *); static void hn_subchan_attach(struct hn_softc *, struct hv_vmbus_channel *); +static void hn_subchan_setup(struct hn_softc *); static int hn_transmit(struct ifnet *, struct mbuf *); static void hn_xmit_qflush(struct ifnet *); @@ -591,25 +592,8 @@ netvsc_attach(device_t dev) device_printf(dev, "%d TX ring, %d RX ring\n", sc->hn_tx_ring_inuse, sc->hn_rx_ring_inuse); - if (sc->net_dev->num_channel > 1) { - struct hv_vmbus_channel **subchan; - int subchan_cnt = sc->net_dev->num_channel - 1; - int i; - - /* Wait for sub-channels setup to complete. */ - subchan = vmbus_get_subchan(pri_chan, subchan_cnt); - - /* Attach the sub-channels. */ - for (i = 0; i < subchan_cnt; ++i) { - /* NOTE: Calling order is critical. */ - hn_subchan_attach(sc, subchan[i]); - hv_nv_subchan_attach(subchan[i]); - } - - /* Release the sub-channels */ - vmbus_rel_subchan(subchan, subchan_cnt); - device_printf(dev, "%d sub-channels setup done\n", subchan_cnt); - } + if (sc->net_dev->num_channel > 1) + hn_subchan_setup(sc); #if __FreeBSD_version >= 1100099 if (sc->hn_rx_ring_inuse > 1) { @@ -1637,6 +1621,10 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, NV_UNLOCK(sc); break; } + + /* Wait for subchannels to be destroyed */ + vmbus_drain_subchan(hn_dev->channel); + error = hv_rf_on_device_add(hn_dev, &device_info, sc->hn_rx_ring_inuse); if (error) { @@ -1645,6 +1633,26 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, NV_UNLOCK(sc); break; } + KASSERT(sc->hn_rx_ring_cnt == sc->net_dev->num_channel, + ("RX ring count %d and channel count %u mismatch", + sc->hn_rx_ring_cnt, sc->net_dev->num_channel)); + if (sc->net_dev->num_channel > 1) { + int r; + + /* + * Skip the rings on primary channel; they are + * handled by the hv_rf_on_device_add() above. + */ + for (r = 1; r < sc->hn_rx_ring_cnt; ++r) { + sc->hn_rx_ring[r].hn_rx_flags &= + ~HN_RX_FLAG_ATTACHED; + } + for (r = 1; r < sc->hn_tx_ring_cnt; ++r) { + sc->hn_tx_ring[r].hn_tx_flags &= + ~HN_TX_FLAG_ATTACHED; + } + hn_subchan_setup(sc); + } sc->hn_tx_chimney_max = sc->net_dev->send_section_size; if (sc->hn_tx_ring[0].hn_tx_chimney_size > @@ -3036,6 +3044,29 @@ hn_subchan_attach(struct hn_softc *sc, s } static void +hn_subchan_setup(struct hn_softc *sc) +{ + struct hv_device *device_ctx = vmbus_get_devctx(sc->hn_dev); + struct hv_vmbus_channel **subchan; + int subchan_cnt = sc->net_dev->num_channel - 1; + int i; + + /* Wait for sub-channels setup to complete. */ + subchan = vmbus_get_subchan(device_ctx->channel, subchan_cnt); + + /* Attach the sub-channels. */ + for (i = 0; i < subchan_cnt; ++i) { + /* NOTE: Calling order is critical. */ + hn_subchan_attach(sc, subchan[i]); + hv_nv_subchan_attach(subchan[i]); + } + + /* Release the sub-channels */ + vmbus_rel_subchan(subchan, subchan_cnt); + if_printf(sc->hn_ifp, "%d sub-channels setup done\n", subchan_cnt); +} + +static void hn_tx_taskq_create(void *arg __unused) { if (!hn_share_tx_taskq) Modified: stable/10/sys/dev/hyperv/vmbus/hv_channel.c ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/hv_channel.c Tue Oct 11 06:35:29 2016 (r307018) +++ stable/10/sys/dev/hyperv/vmbus/hv_channel.c Tue Oct 11 06:46:24 2016 (r307019) @@ -111,7 +111,8 @@ vmbus_channel_sysctl_create(hv_vmbus_cha ch_id = primary_ch->offer_msg.child_rel_id; sub_ch_id = channel->offer_msg.offer.sub_channel_index; } - ctx = device_get_sysctl_ctx(dev); + ctx = &channel->ch_sysctl_ctx; + sysctl_ctx_init(ctx); /* This creates dev.DEVNAME.DEVUNIT.channel tree */ devch_sysctl = SYSCTL_ADD_NODE(ctx, SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), @@ -423,6 +424,11 @@ hv_vmbus_channel_establish_gpadl(struct device_printf(sc->vmbus_dev, "gpadl->chan%u failed: " "status %u\n", channel->offer_msg.child_rel_id, status); return EIO; + } else { + if (bootverbose) { + device_printf(sc->vmbus_dev, "gpadl->chan%u " + "succeeded\n", channel->offer_msg.child_rel_id); + } } return 0; } @@ -477,6 +483,7 @@ hv_vmbus_channel_close_internal(hv_vmbus int error; channel->state = HV_CHANNEL_OPEN_STATE; + sysctl_ctx_free(&channel->ch_sysctl_ctx); /* * set rxq to NULL to avoid more requests be scheduled Modified: stable/10/sys/dev/hyperv/vmbus/hv_channel_mgmt.c ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/hv_channel_mgmt.c Tue Oct 11 06:35:29 2016 (r307018) +++ stable/10/sys/dev/hyperv/vmbus/hv_channel_mgmt.c Tue Oct 11 06:46:24 2016 (r307019) @@ -145,6 +145,19 @@ vmbus_channel_process_offer(hv_vmbus_cha } mtx_unlock(&sc->vmbus_chlist_lock); + if (bootverbose) { + char logstr[64]; + + logstr[0] = '\0'; + if (channel != NULL) { + snprintf(logstr, sizeof(logstr), ", primary chan%u", + channel->offer_msg.child_rel_id); + } + device_printf(sc->vmbus_dev, "chan%u subchanid%u offer%s\n", + new_channel->offer_msg.child_rel_id, + new_channel->offer_msg.offer.sub_channel_index, logstr); + } + if (channel != NULL) { /* * Check if this is a sub channel. @@ -160,13 +173,6 @@ vmbus_channel_process_offer(hv_vmbus_cha new_channel, sc_list_entry); mtx_unlock(&channel->sc_lock); - if (bootverbose) { - printf("VMBUS get multi-channel offer, " - "rel=%u, sub=%u\n", - new_channel->offer_msg.child_rel_id, - new_channel->offer_msg.offer.sub_channel_index); - } - /* * Insert the new channel to the end of the global * channel list. @@ -181,11 +187,6 @@ vmbus_channel_process_offer(hv_vmbus_cha ch_link); mtx_unlock(&sc->vmbus_chlist_lock); - if(bootverbose) - printf("VMBUS: new multi-channel offer <%p>, " - "its primary channel is <%p>.\n", - new_channel, new_channel->primary_channel); - new_channel->state = HV_CHANNEL_OPEN_STATE; /* @@ -348,6 +349,10 @@ vmbus_channel_on_offer_rescind(struct vm hv_vmbus_channel* channel; rescind = (const hv_vmbus_channel_rescind_offer *)msg->msg_data; + if (bootverbose) { + device_printf(sc->vmbus_dev, "chan%u rescind\n", + rescind->child_rel_id); + } channel = hv_vmbus_g_connection.channels[rescind->child_rel_id]; if (channel == NULL) @@ -365,6 +370,54 @@ vmbus_chan_detach_task(void *xchan, int if (HV_VMBUS_CHAN_ISPRIMARY(chan)) { /* Only primary channel owns the hv_device */ hv_vmbus_child_device_unregister(chan->device); + /* NOTE: DO NOT free primary channel for now */ + } else { + struct vmbus_softc *sc = chan->vmbus_sc; + struct hv_vmbus_channel *pri_chan = chan->primary_channel; + struct vmbus_chanmsg_chfree *req; + struct vmbus_msghc *mh; + int error; + + mh = vmbus_msghc_get(sc, sizeof(*req)); + if (mh == NULL) { + device_printf(sc->vmbus_dev, + "can not get msg hypercall for chfree(chan%u)\n", + chan->offer_msg.child_rel_id); + goto remove; + } + + req = vmbus_msghc_dataptr(mh); + req->chm_hdr.chm_type = VMBUS_CHANMSG_TYPE_CHFREE; + req->chm_chanid = chan->offer_msg.child_rel_id; + + error = vmbus_msghc_exec_noresult(mh); + vmbus_msghc_put(sc, mh); + + if (error) { + device_printf(sc->vmbus_dev, + "chfree(chan%u) failed: %d", + chan->offer_msg.child_rel_id, error); + /* NOTE: Move on! */ + } else { + if (bootverbose) { + device_printf(sc->vmbus_dev, "chan%u freed\n", + chan->offer_msg.child_rel_id); + } + } +remove: + mtx_lock(&sc->vmbus_chlist_lock); + TAILQ_REMOVE(&sc->vmbus_chlist, chan, ch_link); + mtx_unlock(&sc->vmbus_chlist_lock); + + mtx_lock(&pri_chan->sc_lock); + TAILQ_REMOVE(&pri_chan->sc_list_anchor, chan, sc_list_entry); + KASSERT(pri_chan->subchan_cnt > 0, + ("invalid subchan_cnt %d", pri_chan->subchan_cnt)); + pri_chan->subchan_cnt--; + mtx_unlock(&pri_chan->sc_lock); + wakeup(pri_chan); + + hv_vmbus_free_vmbus_channel(chan); } } @@ -502,6 +555,15 @@ vmbus_rel_subchan(struct hv_vmbus_channe } void +vmbus_drain_subchan(struct hv_vmbus_channel *pri_chan) +{ + mtx_lock(&pri_chan->sc_lock); + while (pri_chan->subchan_cnt > 0) + mtx_sleep(pri_chan, &pri_chan->sc_lock, 0, "dsubch", 0); + mtx_unlock(&pri_chan->sc_lock); +} + +void vmbus_chan_msgproc(struct vmbus_softc *sc, const struct vmbus_message *msg) { vmbus_chanmsg_proc_t msg_proc; Modified: stable/10/sys/dev/hyperv/vmbus/vmbus_reg.h ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/vmbus_reg.h Tue Oct 11 06:35:29 2016 (r307018) +++ stable/10/sys/dev/hyperv/vmbus/vmbus_reg.h Tue Oct 11 06:46:24 2016 (r307019) @@ -102,6 +102,7 @@ struct vmbus_gpa_range { #define VMBUS_CHANMSG_TYPE_GPADL_CONNRESP 10 /* RESP */ #define VMBUS_CHANMSG_TYPE_GPADL_DISCONN 11 /* REQ */ #define VMBUS_CHANMSG_TYPE_GPADL_DISCONNRESP 12 /* RESP */ +#define VMBUS_CHANMSG_TYPE_CHFREE 13 /* REQ */ #define VMBUS_CHANMSG_TYPE_CONNECT 14 /* REQ */ #define VMBUS_CHANMSG_TYPE_CONNECT_RESP 15 /* RESP */ #define VMBUS_CHANMSG_TYPE_DISCONNECT 16 /* REQ */ @@ -206,4 +207,10 @@ struct vmbus_chanmsg_gpadl_disconn { uint32_t chm_gpadl; } __packed; +/* VMBUS_CHANMSG_TYPE_CHFREE */ +struct vmbus_chanmsg_chfree { + struct vmbus_chanmsg_hdr chm_hdr; + uint32_t chm_chanid; +} __packed; + #endif /* !_VMBUS_REG_H_ */ From owner-svn-src-all@freebsd.org Tue Oct 11 07:00:45 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 15CE6C0D233; Tue, 11 Oct 2016 07:00:45 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id E6C3161; Tue, 11 Oct 2016 07:00:44 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9B70iK6096529; Tue, 11 Oct 2016 07:00:44 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9B70hZl096520; Tue, 11 Oct 2016 07:00:43 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610110700.u9B70hZl096520@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Tue, 11 Oct 2016 07:00:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307020 - in stable/10/sys: conf dev/hyperv/vmbus modules/hyperv/vmbus X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Oct 2016 07:00:45 -0000 Author: sephe Date: Tue Oct 11 07:00:43 2016 New Revision: 307020 URL: https://svnweb.freebsd.org/changeset/base/307020 Log: MFC 302636-302638,302692 302636 hyperv/vmbus: Move channel map to vmbus_softc Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D6982 302637 hyperv/vmbus: Remove needed bits Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7002 302638 hyperv/vmbus: Destroy channel list lock upon attach failure and detach. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7003 302692 hyperv/vmbus: Merge hv_connection.c into hv_channel.c Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7004 Deleted: stable/10/sys/dev/hyperv/vmbus/hv_connection.c Modified: stable/10/sys/conf/files.amd64 stable/10/sys/conf/files.i386 stable/10/sys/dev/hyperv/vmbus/hv_channel.c stable/10/sys/dev/hyperv/vmbus/hv_channel_mgmt.c stable/10/sys/dev/hyperv/vmbus/hv_vmbus_priv.h stable/10/sys/dev/hyperv/vmbus/vmbus.c stable/10/sys/dev/hyperv/vmbus/vmbus_var.h stable/10/sys/modules/hyperv/vmbus/Makefile Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/conf/files.amd64 ============================================================================== --- stable/10/sys/conf/files.amd64 Tue Oct 11 06:46:24 2016 (r307019) +++ stable/10/sys/conf/files.amd64 Tue Oct 11 07:00:43 2016 (r307020) @@ -273,7 +273,6 @@ dev/hyperv/utilities/hv_timesync.c opt dev/hyperv/utilities/hv_util.c optional hyperv dev/hyperv/vmbus/hv_channel.c optional hyperv dev/hyperv/vmbus/hv_channel_mgmt.c optional hyperv -dev/hyperv/vmbus/hv_connection.c optional hyperv dev/hyperv/vmbus/hv_ring_buffer.c optional hyperv dev/hyperv/vmbus/hyperv.c optional hyperv dev/hyperv/vmbus/hyperv_busdma.c optional hyperv Modified: stable/10/sys/conf/files.i386 ============================================================================== --- stable/10/sys/conf/files.i386 Tue Oct 11 06:46:24 2016 (r307019) +++ stable/10/sys/conf/files.i386 Tue Oct 11 07:00:43 2016 (r307020) @@ -250,7 +250,6 @@ dev/hyperv/utilities/hv_timesync.c opt dev/hyperv/utilities/hv_util.c optional hyperv dev/hyperv/vmbus/hv_channel.c optional hyperv dev/hyperv/vmbus/hv_channel_mgmt.c optional hyperv -dev/hyperv/vmbus/hv_connection.c optional hyperv dev/hyperv/vmbus/hv_ring_buffer.c optional hyperv dev/hyperv/vmbus/hyperv.c optional hyperv dev/hyperv/vmbus/hyperv_busdma.c optional hyperv Modified: stable/10/sys/dev/hyperv/vmbus/hv_channel.c ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/hv_channel.c Tue Oct 11 06:46:24 2016 (r307019) +++ stable/10/sys/dev/hyperv/vmbus/hv_channel.c Tue Oct 11 07:00:43 2016 (r307020) @@ -52,6 +52,8 @@ __FBSDID("$FreeBSD$"); static void vmbus_channel_set_event(hv_vmbus_channel* channel); static void VmbusProcessChannelEvent(void* channel, int pending); +static void vmbus_chan_update_evtflagcnt(struct vmbus_softc *, + const struct hv_vmbus_channel *); /** * @brief Trigger an event notification on the specified channel @@ -207,7 +209,7 @@ hv_vmbus_channel_open( new_channel->on_channel_callback = pfn_on_channel_callback; new_channel->channel_callback_context = context; - vmbus_on_channel_open(new_channel); + vmbus_chan_update_evtflagcnt(sc, new_channel); new_channel->rxq = VMBUS_PCPU_GET(new_channel->vmbus_sc, event_tq, new_channel->target_cpu); @@ -883,3 +885,95 @@ VmbusProcessChannelEvent(void* context, } while (is_batched_reading && (bytes_to_read != 0)); } } + +static __inline void +vmbus_event_flags_proc(struct vmbus_softc *sc, volatile u_long *event_flags, + int flag_cnt) +{ + int f; + + for (f = 0; f < flag_cnt; ++f) { + uint32_t rel_id_base; + u_long flags; + int bit; + + if (event_flags[f] == 0) + continue; + + flags = atomic_swap_long(&event_flags[f], 0); + rel_id_base = f << VMBUS_EVTFLAG_SHIFT; + + while ((bit = ffsl(flags)) != 0) { + struct hv_vmbus_channel *channel; + uint32_t rel_id; + + --bit; /* NOTE: ffsl is 1-based */ + flags &= ~(1UL << bit); + + rel_id = rel_id_base + bit; + channel = sc->vmbus_chmap[rel_id]; + + /* if channel is closed or closing */ + if (channel == NULL || channel->rxq == NULL) + continue; + + if (channel->batched_reading) + hv_ring_buffer_read_begin(&channel->inbound); + taskqueue_enqueue(channel->rxq, &channel->channel_task); + } + } +} + +void +vmbus_event_proc(struct vmbus_softc *sc, int cpu) +{ + struct vmbus_evtflags *eventf; + + /* + * On Host with Win8 or above, the event page can be checked directly + * to get the id of the channel that has the pending interrupt. + */ + eventf = VMBUS_PCPU_GET(sc, event_flags, cpu) + VMBUS_SINT_MESSAGE; + vmbus_event_flags_proc(sc, eventf->evt_flags, + VMBUS_PCPU_GET(sc, event_flags_cnt, cpu)); +} + +void +vmbus_event_proc_compat(struct vmbus_softc *sc, int cpu) +{ + struct vmbus_evtflags *eventf; + + eventf = VMBUS_PCPU_GET(sc, event_flags, cpu) + VMBUS_SINT_MESSAGE; + if (atomic_testandclear_long(&eventf->evt_flags[0], 0)) { + vmbus_event_flags_proc(sc, sc->vmbus_rx_evtflags, + VMBUS_CHAN_MAX_COMPAT >> VMBUS_EVTFLAG_SHIFT); + } +} + +static void +vmbus_chan_update_evtflagcnt(struct vmbus_softc *sc, + const struct hv_vmbus_channel *chan) +{ + volatile int *flag_cnt_ptr; + int flag_cnt; + + flag_cnt = (chan->offer_msg.child_rel_id / VMBUS_EVTFLAG_LEN) + 1; + flag_cnt_ptr = VMBUS_PCPU_PTR(sc, event_flags_cnt, chan->target_cpu); + + for (;;) { + int old_flag_cnt; + + old_flag_cnt = *flag_cnt_ptr; + if (old_flag_cnt >= flag_cnt) + break; + if (atomic_cmpset_int(flag_cnt_ptr, old_flag_cnt, flag_cnt)) { + if (bootverbose) { + device_printf(sc->vmbus_dev, + "channel%u update cpu%d flag_cnt to %d\n", + chan->offer_msg.child_rel_id, + chan->target_cpu, flag_cnt); + } + break; + } + } +} Modified: stable/10/sys/dev/hyperv/vmbus/hv_channel_mgmt.c ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/hv_channel_mgmt.c Tue Oct 11 06:46:24 2016 (r307019) +++ stable/10/sys/dev/hyperv/vmbus/hv_channel_mgmt.c Tue Oct 11 07:00:43 2016 (r307020) @@ -126,7 +126,7 @@ vmbus_channel_process_offer(hv_vmbus_cha */ printf("VMBUS: got channel0 offer\n"); } else { - hv_vmbus_g_connection.channels[relid] = new_channel; + sc->vmbus_chmap[relid] = new_channel; } TAILQ_FOREACH(channel, &sc->vmbus_chlist, ch_link) { @@ -354,10 +354,10 @@ vmbus_channel_on_offer_rescind(struct vm rescind->child_rel_id); } - channel = hv_vmbus_g_connection.channels[rescind->child_rel_id]; + channel = sc->vmbus_chmap[rescind->child_rel_id]; if (channel == NULL) return; - hv_vmbus_g_connection.channels[rescind->child_rel_id] = NULL; + sc->vmbus_chmap[rescind->child_rel_id] = NULL; taskqueue_enqueue(taskqueue_thread, &channel->ch_detach_task); } @@ -454,8 +454,8 @@ hv_vmbus_release_unattached_channels(str } hv_vmbus_free_vmbus_channel(channel); } - bzero(hv_vmbus_g_connection.channels, - sizeof(hv_vmbus_channel*) * VMBUS_CHAN_MAX); + bzero(sc->vmbus_chmap, + sizeof(struct hv_vmbus_channel *) * VMBUS_CHAN_MAX); mtx_unlock(&sc->vmbus_chlist_lock); } Modified: stable/10/sys/dev/hyperv/vmbus/hv_vmbus_priv.h ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/hv_vmbus_priv.h Tue Oct 11 06:46:24 2016 (r307019) +++ stable/10/sys/dev/hyperv/vmbus/hv_vmbus_priv.h Tue Oct 11 07:00:43 2016 (r307020) @@ -97,25 +97,6 @@ typedef struct hv_vmbus_channel_packet_m hv_vmbus_multipage_buffer range; } __packed hv_vmbus_channel_packet_multipage_buffer; -/* - * VM Bus connection states - */ -typedef enum { - HV_DISCONNECTED, - HV_CONNECTING, - HV_CONNECTED, - HV_DISCONNECTING -} hv_vmbus_connect_state; - -typedef struct { - hv_vmbus_connect_state connect_state; - - /** - * channel table for fast lookup through id. - */ - hv_vmbus_channel **channels; -} hv_vmbus_connection; - typedef union { uint32_t as_uint32_t; struct { @@ -177,12 +158,6 @@ typedef struct { uint8_t rsvd_z4[1984]; } hv_vmbus_monitor_page; -/** - * Global variables - */ - -extern hv_vmbus_connection hv_vmbus_g_connection; - /* * Private, VM Bus functions */ @@ -247,10 +222,4 @@ void hv_vmbus_child_device_register(st int hv_vmbus_child_device_unregister( struct hv_device *child_dev); -/** - * Connection interfaces - */ -int hv_vmbus_connect(struct vmbus_softc *); -int hv_vmbus_disconnect(void); - #endif /* __HYPERV_PRIV_H__ */ Modified: stable/10/sys/dev/hyperv/vmbus/vmbus.c ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/vmbus.c Tue Oct 11 06:46:24 2016 (r307019) +++ stable/10/sys/dev/hyperv/vmbus/vmbus.c Tue Oct 11 07:00:43 2016 (r307020) @@ -1212,6 +1212,9 @@ vmbus_doattach(struct vmbus_softc *sc) sc->vmbus_gpadl = VMBUS_GPADL_START; mtx_init(&sc->vmbus_chlist_lock, "vmbus chlist", NULL, MTX_DEF); TAILQ_INIT(&sc->vmbus_chlist); + sc->vmbus_chmap = malloc( + sizeof(struct hv_vmbus_channel *) * VMBUS_CHAN_MAX, M_DEVBUF, + M_WAITOK | M_ZERO); /* * Create context for "post message" Hypercalls @@ -1246,12 +1249,8 @@ vmbus_doattach(struct vmbus_softc *sc) sc->vmbus_flags |= VMBUS_FLAG_SYNIC; /* - * Connect to VMBus in the root partition + * Initialize vmbus, e.g. connect to Hypervisor. */ - ret = hv_vmbus_connect(sc); - if (ret != 0) - goto cleanup; - ret = vmbus_init(sc); if (ret != 0) goto cleanup; @@ -1281,7 +1280,9 @@ cleanup: vmbus_msghc_ctx_destroy(sc->vmbus_msg_hc); sc->vmbus_msg_hc = NULL; } + free(sc->vmbus_chmap, M_DEVBUF); mtx_destroy(&sc->vmbus_scan_lock); + mtx_destroy(&sc->vmbus_chlist_lock); return (ret); } @@ -1342,7 +1343,6 @@ vmbus_detach(device_t dev) hv_vmbus_release_unattached_channels(sc); vmbus_disconnect(sc); - hv_vmbus_disconnect(); if (sc->vmbus_flags & VMBUS_FLAG_SYNIC) { sc->vmbus_flags &= ~VMBUS_FLAG_SYNIC; @@ -1357,7 +1357,10 @@ vmbus_detach(device_t dev) sc->vmbus_msg_hc = NULL; } + free(sc->vmbus_chmap, M_DEVBUF); mtx_destroy(&sc->vmbus_scan_lock); + mtx_destroy(&sc->vmbus_chlist_lock); + return (0); } Modified: stable/10/sys/dev/hyperv/vmbus/vmbus_var.h ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/vmbus_var.h Tue Oct 11 06:46:24 2016 (r307019) +++ stable/10/sys/dev/hyperv/vmbus/vmbus_var.h Tue Oct 11 07:00:43 2016 (r307020) @@ -74,6 +74,7 @@ struct vmbus_softc { u_long *vmbus_rx_evtflags; /* compat evtflgs from host */ + struct hv_vmbus_channel **vmbus_chmap; struct vmbus_msghc_ctx *vmbus_msg_hc; struct vmbus_pcpu_data vmbus_pcpu[MAXCPU]; @@ -129,7 +130,6 @@ struct trapframe; struct vmbus_message; struct vmbus_msghc; -void vmbus_on_channel_open(const struct hv_vmbus_channel *); void vmbus_event_proc(struct vmbus_softc *, int); void vmbus_event_proc_compat(struct vmbus_softc *, int); void vmbus_handle_intr(struct trapframe *); Modified: stable/10/sys/modules/hyperv/vmbus/Makefile ============================================================================== --- stable/10/sys/modules/hyperv/vmbus/Makefile Tue Oct 11 06:46:24 2016 (r307019) +++ stable/10/sys/modules/hyperv/vmbus/Makefile Tue Oct 11 07:00:43 2016 (r307020) @@ -6,7 +6,6 @@ KMOD= hv_vmbus SRCS= hv_channel.c \ hv_channel_mgmt.c \ - hv_connection.c \ hv_ring_buffer.c \ hyperv.c \ hyperv_busdma.c \ From owner-svn-src-all@freebsd.org Tue Oct 11 07:10:13 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id EC085C0D525; Tue, 11 Oct 2016 07:10:13 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id B543F74F; Tue, 11 Oct 2016 07:10:13 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9B7ACdu099600; Tue, 11 Oct 2016 07:10:12 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9B7ACqT099594; Tue, 11 Oct 2016 07:10:12 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610110710.u9B7ACqT099594@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Tue, 11 Oct 2016 07:10:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307021 - in stable/10/sys/dev/hyperv: include netvsc vmbus X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Oct 2016 07:10:14 -0000 Author: sephe Date: Tue Oct 11 07:10:12 2016 New Revision: 307021 URL: https://svnweb.freebsd.org/changeset/base/307021 Log: MFC 302693-302697 302693 hyperv/vmbus: Make channel id a field of hv_vmbus_channel. This prepares to remove the unnecessary offer message embedding in hv_vmbus_channel. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7014 302694 hyperv/vmbus: Make subchan index a field of hv_vmbus_channel. This prepares to remove the unnecessary offer message embedding in hv_vmbus_channel. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7015 302695 hyperv/vmbus: Add flags field into hv_vmbus_channel for MNF indication This prepares to remove the unnecessary offer message embedding in hv_vmbus_channel. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7019 302696 hyperv/vmbus: Add type/instance guid fields into hv_vmbus_channel This prepares to remove the unnecessary offer message embedding in hv_vmbus_channel. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7020 302697 hyperv/vmbus: Remove the embedded offer message from hv_vmbus_channel Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7021 Modified: stable/10/sys/dev/hyperv/include/hyperv.h stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c stable/10/sys/dev/hyperv/vmbus/hv_channel.c stable/10/sys/dev/hyperv/vmbus/hv_channel_mgmt.c stable/10/sys/dev/hyperv/vmbus/hv_vmbus_priv.h stable/10/sys/dev/hyperv/vmbus/vmbus.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/hyperv/include/hyperv.h ============================================================================== --- stable/10/sys/dev/hyperv/include/hyperv.h Tue Oct 11 07:00:43 2016 (r307020) +++ stable/10/sys/dev/hyperv/include/hyperv.h Tue Oct 11 07:10:12 2016 (r307021) @@ -537,7 +537,8 @@ typedef struct hv_vmbus_channel { struct hv_device* device; struct vmbus_softc *vmbus_sc; hv_vmbus_channel_state state; - hv_vmbus_channel_offer_channel offer_msg; + uint32_t ch_flags; /* VMBUS_CHAN_FLAG_ */ + uint32_t ch_id; /* channel id */ /* * These are based on the offer_msg.monitor_id. * Save it here for easy access. @@ -628,12 +629,18 @@ typedef struct hv_vmbus_channel { struct task ch_detach_task; TAILQ_ENTRY(hv_vmbus_channel) ch_link; + uint32_t ch_subidx; /* subchan index */ + + struct hv_guid ch_guid_type; + struct hv_guid ch_guid_inst; struct sysctl_ctx_list ch_sysctl_ctx; } hv_vmbus_channel; #define HV_VMBUS_CHAN_ISPRIMARY(chan) ((chan)->primary_channel == NULL) +#define VMBUS_CHAN_FLAG_HASMNF 0x0001 + static inline void hv_set_channel_read_state(hv_vmbus_channel* channel, boolean_t state) { Modified: stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Tue Oct 11 07:00:43 2016 (r307020) +++ stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Tue Oct 11 07:10:12 2016 (r307021) @@ -534,9 +534,9 @@ netvsc_attach(device_t dev) */ pri_chan = device_ctx->channel; KASSERT(HV_VMBUS_CHAN_ISPRIMARY(pri_chan), ("not primary channel")); - KASSERT(pri_chan->offer_msg.offer.sub_channel_index == 0, + KASSERT(pri_chan->ch_subidx == 0, ("primary channel subidx %u", - pri_chan->offer_msg.offer.sub_channel_index)); + pri_chan->ch_subidx)); hn_channel_attach(sc, pri_chan); ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; @@ -821,8 +821,8 @@ hn_tx_done(struct hv_vmbus_channel *chan txr = txd->txr; KASSERT(txr->hn_chan == chan, ("channel mismatch, on channel%u, should be channel%u", - chan->offer_msg.offer.sub_channel_index, - txr->hn_chan->offer_msg.offer.sub_channel_index)); + chan->ch_subidx, + txr->hn_chan->ch_subidx)); txr->hn_has_txeof = 1; hn_txdesc_put(txr, txd); @@ -2996,7 +2996,7 @@ hn_channel_attach(struct hn_softc *sc, s struct hn_rx_ring *rxr; int idx; - idx = chan->offer_msg.offer.sub_channel_index; + idx = chan->ch_subidx; KASSERT(idx >= 0 && idx < sc->hn_rx_ring_inuse, ("invalid channel index %d, should > 0 && < %d", @@ -3009,7 +3009,7 @@ hn_channel_attach(struct hn_softc *sc, s chan->hv_chan_rxr = rxr; if (bootverbose) { if_printf(sc->hn_ifp, "link RX ring %d to channel%u\n", - idx, chan->offer_msg.child_rel_id); + idx, chan->ch_id); } if (idx < sc->hn_tx_ring_inuse) { @@ -3023,7 +3023,7 @@ hn_channel_attach(struct hn_softc *sc, s txr->hn_chan = chan; if (bootverbose) { if_printf(sc->hn_ifp, "link TX ring %d to channel%u\n", - idx, chan->offer_msg.child_rel_id); + idx, chan->ch_id); } } @@ -3037,9 +3037,9 @@ hn_subchan_attach(struct hn_softc *sc, s KASSERT(!HV_VMBUS_CHAN_ISPRIMARY(chan), ("subchannel callback on primary channel")); - KASSERT(chan->offer_msg.offer.sub_channel_index > 0, + KASSERT(chan->ch_subidx > 0, ("invalid channel subidx %u", - chan->offer_msg.offer.sub_channel_index)); + chan->ch_subidx)); hn_channel_attach(sc, chan); } Modified: stable/10/sys/dev/hyperv/vmbus/hv_channel.c ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/hv_channel.c Tue Oct 11 07:00:43 2016 (r307020) +++ stable/10/sys/dev/hyperv/vmbus/hv_channel.c Tue Oct 11 07:10:12 2016 (r307021) @@ -62,12 +62,12 @@ static void vmbus_channel_set_event(hv_vmbus_channel *channel) { struct vmbus_softc *sc = channel->vmbus_sc; - uint32_t chanid = channel->offer_msg.child_rel_id; + uint32_t chanid = channel->ch_id; atomic_set_long(&sc->vmbus_tx_evtflags[chanid >> VMBUS_EVTFLAG_SHIFT], 1UL << (chanid & VMBUS_EVTFLAG_MASK)); - if (channel->offer_msg.monitor_allocated) { + if (channel->ch_flags & VMBUS_CHAN_FLAG_HASMNF) { hv_vmbus_monitor_page *monitor_page; monitor_page = sc->vmbus_mnf2; @@ -86,7 +86,7 @@ vmbus_channel_sysctl_monalloc(SYSCTL_HAN struct hv_vmbus_channel *chan = arg1; int alloc = 0; - if (chan->offer_msg.monitor_allocated) + if (chan->ch_flags & VMBUS_CHAN_FLAG_HASMNF) alloc = 1; return sysctl_handle_int(oidp, &alloc, 0, req); } @@ -107,11 +107,11 @@ vmbus_channel_sysctl_create(hv_vmbus_cha if (primary_ch == NULL) { dev = channel->device->device; - ch_id = channel->offer_msg.child_rel_id; + ch_id = channel->ch_id; } else { dev = primary_ch->device->device; - ch_id = primary_ch->offer_msg.child_rel_id; - sub_ch_id = channel->offer_msg.offer.sub_channel_index; + ch_id = primary_ch->ch_id; + sub_ch_id = channel->ch_subidx; } ctx = &channel->ch_sysctl_ctx; sysctl_ctx_init(ctx); @@ -136,7 +136,7 @@ vmbus_channel_sysctl_create(hv_vmbus_cha SYSCTL_ADD_UINT(ctx, SYSCTL_CHILDREN(devch_id_sysctl), OID_AUTO, "chanid", CTLFLAG_RD, - &channel->offer_msg.child_rel_id, 0, "channel id"); + &channel->ch_id, 0, "channel id"); } SYSCTL_ADD_UINT(ctx, SYSCTL_CHILDREN(devch_id_sysctl), OID_AUTO, "cpu", CTLFLAG_RD, &channel->target_cpu, 0, "owner CPU id"); @@ -190,7 +190,7 @@ hv_vmbus_channel_open( if (user_data_len > VMBUS_CHANMSG_CHOPEN_UDATA_SIZE) { device_printf(sc->vmbus_dev, "invalid udata len %u for chan%u\n", - user_data_len, new_channel->offer_msg.child_rel_id); + user_data_len, new_channel->ch_id); return EINVAL; } @@ -261,14 +261,14 @@ hv_vmbus_channel_open( if (mh == NULL) { device_printf(sc->vmbus_dev, "can not get msg hypercall for chopen(chan%u)\n", - new_channel->offer_msg.child_rel_id); + new_channel->ch_id); return ENXIO; } req = vmbus_msghc_dataptr(mh); req->chm_hdr.chm_type = VMBUS_CHANMSG_TYPE_CHOPEN; - req->chm_chanid = new_channel->offer_msg.child_rel_id; - req->chm_openid = new_channel->offer_msg.child_rel_id; + req->chm_chanid = new_channel->ch_id; + req->chm_openid = new_channel->ch_id; req->chm_gpadl = new_channel->ring_buffer_gpadl_handle; req->chm_vcpuid = new_channel->target_vcpu; req->chm_rxbr_pgofs = send_ring_buffer_size >> PAGE_SHIFT; @@ -279,7 +279,7 @@ hv_vmbus_channel_open( if (ret != 0) { device_printf(sc->vmbus_dev, "chopen(chan%u) msg hypercall exec failed: %d\n", - new_channel->offer_msg.child_rel_id, ret); + new_channel->ch_id, ret); vmbus_msghc_put(sc, mh); return ret; } @@ -294,11 +294,11 @@ hv_vmbus_channel_open( new_channel->state = HV_CHANNEL_OPENED_STATE; if (bootverbose) { device_printf(sc->vmbus_dev, "chan%u opened\n", - new_channel->offer_msg.child_rel_id); + new_channel->ch_id); } } else { device_printf(sc->vmbus_dev, "failed to open chan%u\n", - new_channel->offer_msg.child_rel_id); + new_channel->ch_id); ret = ENXIO; } return (ret); @@ -369,13 +369,13 @@ hv_vmbus_channel_establish_gpadl(struct if (mh == NULL) { device_printf(sc->vmbus_dev, "can not get msg hypercall for gpadl->chan%u\n", - channel->offer_msg.child_rel_id); + channel->ch_id); return EIO; } req = vmbus_msghc_dataptr(mh); req->chm_hdr.chm_type = VMBUS_CHANMSG_TYPE_GPADL_CONN; - req->chm_chanid = channel->offer_msg.child_rel_id; + req->chm_chanid = channel->ch_id; req->chm_gpadl = gpadl; req->chm_range_len = range_len; req->chm_range_cnt = 1; @@ -388,7 +388,7 @@ hv_vmbus_channel_establish_gpadl(struct if (error) { device_printf(sc->vmbus_dev, "gpadl->chan%u msg hypercall exec failed: %d\n", - channel->offer_msg.child_rel_id, error); + channel->ch_id, error); vmbus_msghc_put(sc, mh); return error; } @@ -424,12 +424,12 @@ hv_vmbus_channel_establish_gpadl(struct if (status != 0) { device_printf(sc->vmbus_dev, "gpadl->chan%u failed: " - "status %u\n", channel->offer_msg.child_rel_id, status); + "status %u\n", channel->ch_id, status); return EIO; } else { if (bootverbose) { device_printf(sc->vmbus_dev, "gpadl->chan%u " - "succeeded\n", channel->offer_msg.child_rel_id); + "succeeded\n", channel->ch_id); } } return 0; @@ -450,20 +450,20 @@ hv_vmbus_channel_teardown_gpdal(struct h if (mh == NULL) { device_printf(sc->vmbus_dev, "can not get msg hypercall for gpa x->chan%u\n", - chan->offer_msg.child_rel_id); + chan->ch_id); return EBUSY; } req = vmbus_msghc_dataptr(mh); req->chm_hdr.chm_type = VMBUS_CHANMSG_TYPE_GPADL_DISCONN; - req->chm_chanid = chan->offer_msg.child_rel_id; + req->chm_chanid = chan->ch_id; req->chm_gpadl = gpadl; error = vmbus_msghc_exec(sc, mh); if (error) { device_printf(sc->vmbus_dev, "gpa x->chan%u msg hypercall exec failed: %d\n", - chan->offer_msg.child_rel_id, error); + chan->ch_id, error); vmbus_msghc_put(sc, mh); return error; } @@ -502,13 +502,13 @@ hv_vmbus_channel_close_internal(hv_vmbus if (mh == NULL) { device_printf(sc->vmbus_dev, "can not get msg hypercall for chclose(chan%u)\n", - channel->offer_msg.child_rel_id); + channel->ch_id); return; } req = vmbus_msghc_dataptr(mh); req->chm_hdr.chm_type = VMBUS_CHANMSG_TYPE_CHCLOSE; - req->chm_chanid = channel->offer_msg.child_rel_id; + req->chm_chanid = channel->ch_id; error = vmbus_msghc_exec_noresult(mh); vmbus_msghc_put(sc, mh); @@ -516,11 +516,11 @@ hv_vmbus_channel_close_internal(hv_vmbus if (error) { device_printf(sc->vmbus_dev, "chclose(chan%u) msg hypercall exec failed: %d\n", - channel->offer_msg.child_rel_id, error); + channel->ch_id, error); return; } else if (bootverbose) { device_printf(sc->vmbus_dev, "close chan%u\n", - channel->offer_msg.child_rel_id); + channel->ch_id); } /* Tear down the gpadl for the channel's ring buffer */ @@ -957,7 +957,7 @@ vmbus_chan_update_evtflagcnt(struct vmbu volatile int *flag_cnt_ptr; int flag_cnt; - flag_cnt = (chan->offer_msg.child_rel_id / VMBUS_EVTFLAG_LEN) + 1; + flag_cnt = (chan->ch_id / VMBUS_EVTFLAG_LEN) + 1; flag_cnt_ptr = VMBUS_PCPU_PTR(sc, event_flags_cnt, chan->target_cpu); for (;;) { @@ -970,7 +970,7 @@ vmbus_chan_update_evtflagcnt(struct vmbu if (bootverbose) { device_printf(sc->vmbus_dev, "channel%u update cpu%d flag_cnt to %d\n", - chan->offer_msg.child_rel_id, + chan->ch_id, chan->target_cpu, flag_cnt); } break; Modified: stable/10/sys/dev/hyperv/vmbus/hv_channel_mgmt.c ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/hv_channel_mgmt.c Tue Oct 11 07:00:43 2016 (r307020) +++ stable/10/sys/dev/hyperv/vmbus/hv_channel_mgmt.c Tue Oct 11 07:10:12 2016 (r307021) @@ -115,7 +115,7 @@ vmbus_channel_process_offer(hv_vmbus_cha hv_vmbus_channel* channel; uint32_t relid; - relid = new_channel->offer_msg.child_rel_id; + relid = new_channel->ch_id; /* * Make sure this is a new offer */ @@ -130,11 +130,9 @@ vmbus_channel_process_offer(hv_vmbus_cha } TAILQ_FOREACH(channel, &sc->vmbus_chlist, ch_link) { - if (memcmp(&channel->offer_msg.offer.interface_type, - &new_channel->offer_msg.offer.interface_type, + if (memcmp(&channel->ch_guid_type, &new_channel->ch_guid_type, sizeof(hv_guid)) == 0 && - memcmp(&channel->offer_msg.offer.interface_instance, - &new_channel->offer_msg.offer.interface_instance, + memcmp(&channel->ch_guid_inst, &new_channel->ch_guid_inst, sizeof(hv_guid)) == 0) break; } @@ -151,18 +149,18 @@ vmbus_channel_process_offer(hv_vmbus_cha logstr[0] = '\0'; if (channel != NULL) { snprintf(logstr, sizeof(logstr), ", primary chan%u", - channel->offer_msg.child_rel_id); + channel->ch_id); } device_printf(sc->vmbus_dev, "chan%u subchanid%u offer%s\n", - new_channel->offer_msg.child_rel_id, - new_channel->offer_msg.offer.sub_channel_index, logstr); + new_channel->ch_id, + new_channel->ch_subidx, logstr); } if (channel != NULL) { /* * Check if this is a sub channel. */ - if (new_channel->offer_msg.offer.sub_channel_index != 0) { + if (new_channel->ch_subidx != 0) { /* * It is a sub channel offer, process it. */ @@ -203,7 +201,7 @@ vmbus_channel_process_offer(hv_vmbus_cha } printf("VMBUS: duplicated primary channel%u\n", - new_channel->offer_msg.child_rel_id); + new_channel->ch_id); hv_vmbus_free_vmbus_channel(new_channel); return; } @@ -215,9 +213,7 @@ vmbus_channel_process_offer(hv_vmbus_cha * (We need to set the device field before calling * hv_vmbus_child_device_add()) */ - new_channel->device = hv_vmbus_child_device_create( - new_channel->offer_msg.offer.interface_type, - new_channel->offer_msg.offer.interface_instance, new_channel); + new_channel->device = hv_vmbus_child_device_create(new_channel); /* * Add the new device to the bus. This will kick off device-driver @@ -244,7 +240,7 @@ vmbus_channel_cpu_set(struct hv_vmbus_ch if (bootverbose) { printf("vmbus_chan%u: assigned to cpu%u [vcpu%u]\n", - chan->offer_msg.child_rel_id, + chan->ch_id, chan->target_cpu, chan->target_vcpu); } } @@ -295,6 +291,12 @@ vmbus_channel_on_offer_internal(struct v /* Allocate the channel object and save this offer */ new_channel = hv_vmbus_allocate_channel(sc); + new_channel->ch_id = offer->child_rel_id; + new_channel->ch_subidx = offer->offer.sub_channel_index; + if (offer->monitor_allocated) + new_channel->ch_flags |= VMBUS_CHAN_FLAG_HASMNF; + new_channel->ch_guid_type = offer->offer.interface_type; + new_channel->ch_guid_inst = offer->offer.interface_instance; /* * By default we setup state to enable batched @@ -322,8 +324,6 @@ vmbus_channel_on_offer_internal(struct v new_channel->ch_sigevt->hc_connid = offer->connection_id; } - memcpy(&new_channel->offer_msg, offer, - sizeof(hv_vmbus_channel_offer_channel)); new_channel->monitor_group = (uint8_t) offer->monitor_id / 32; new_channel->monitor_bit = (uint8_t) offer->monitor_id % 32; @@ -382,13 +382,13 @@ vmbus_chan_detach_task(void *xchan, int if (mh == NULL) { device_printf(sc->vmbus_dev, "can not get msg hypercall for chfree(chan%u)\n", - chan->offer_msg.child_rel_id); + chan->ch_id); goto remove; } req = vmbus_msghc_dataptr(mh); req->chm_hdr.chm_type = VMBUS_CHANMSG_TYPE_CHFREE; - req->chm_chanid = chan->offer_msg.child_rel_id; + req->chm_chanid = chan->ch_id; error = vmbus_msghc_exec_noresult(mh); vmbus_msghc_put(sc, mh); @@ -396,12 +396,12 @@ vmbus_chan_detach_task(void *xchan, int if (error) { device_printf(sc->vmbus_dev, "chfree(chan%u) failed: %d", - chan->offer_msg.child_rel_id, error); + chan->ch_id, error); /* NOTE: Move on! */ } else { if (bootverbose) { device_printf(sc->vmbus_dev, "chan%u freed\n", - chan->offer_msg.child_rel_id); + chan->ch_id); } } remove: Modified: stable/10/sys/dev/hyperv/vmbus/hv_vmbus_priv.h ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/hv_vmbus_priv.h Tue Oct 11 07:00:43 2016 (r307020) +++ stable/10/sys/dev/hyperv/vmbus/hv_vmbus_priv.h Tue Oct 11 07:10:12 2016 (r307021) @@ -213,9 +213,7 @@ void hv_vmbus_release_unattached_chann struct vmbus_softc *); struct hv_device* hv_vmbus_child_device_create( - hv_guid device_type, - hv_guid device_instance, - hv_vmbus_channel *channel); + struct hv_vmbus_channel *channel); void hv_vmbus_child_device_register(struct vmbus_softc *, struct hv_device *child_dev); Modified: stable/10/sys/dev/hyperv/vmbus/vmbus.c ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/vmbus.c Tue Oct 11 07:00:43 2016 (r307020) +++ stable/10/sys/dev/hyperv/vmbus/vmbus.c Tue Oct 11 07:10:12 2016 (r307021) @@ -1097,8 +1097,7 @@ vmbus_child_pnpinfo_str(device_t dev, de } struct hv_device * -hv_vmbus_child_device_create(hv_guid type, hv_guid instance, - hv_vmbus_channel *channel) +hv_vmbus_child_device_create(struct hv_vmbus_channel *channel) { hv_device *child_dev; @@ -1108,8 +1107,8 @@ hv_vmbus_child_device_create(hv_guid typ child_dev = malloc(sizeof(hv_device), M_DEVBUF, M_WAITOK | M_ZERO); child_dev->channel = channel; - memcpy(&child_dev->class_id, &type, sizeof(hv_guid)); - memcpy(&child_dev->device_id, &instance, sizeof(hv_guid)); + child_dev->class_id = channel->ch_guid_type; + child_dev->device_id = channel->ch_guid_inst; return (child_dev); } From owner-svn-src-all@freebsd.org Tue Oct 11 07:31:01 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 1CDF6C0DBFD; Tue, 11 Oct 2016 07:31:01 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id A989E1B2; Tue, 11 Oct 2016 07:31:00 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9B7Uxxi009580; Tue, 11 Oct 2016 07:30:59 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9B7Uxon009572; Tue, 11 Oct 2016 07:30:59 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610110730.u9B7Uxon009572@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Tue, 11 Oct 2016 07:30:59 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307022 - in stable/10/sys: dev/hyperv/include dev/hyperv/netvsc dev/hyperv/storvsc dev/hyperv/utilities dev/hyperv/vmbus modules/hyperv/utilities X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Oct 2016 07:31:01 -0000 Author: sephe Date: Tue Oct 11 07:30:59 2016 New Revision: 307022 URL: https://svnweb.freebsd.org/changeset/base/307022 Log: MFC 302698-302704,302706 302698 hyperv/vmbus: Add vmbus method for GUID base device probing. Reduce the exposure of hv_device. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7024 302699 hyperv/vmbus: All ivars are read-only; nuke unnecessary write_ivar Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7025 302700 hyperv/vmbus: Add channel ivar accessor. This makes life easier during the transition period to nuke the hv_device. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7026 302701 hyperv/stor: Avoid the hv_device and nuke the broken get_stor_device This paves way to nuke the hv_device, which is actually an unncessary indirection. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7027 302702 hyperv/util: Avoid the hv_device This paves way to nuke the hv_device, which is actually an unncessary indirection. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7028 302703 hyperv/vmbus: Deprecate the usage of hv_device. This paves way to nuke the hv_device, which is actually an unncessary indirection. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7032 302704 hyperv/hn: Avoid the hv_device This paves way to nuke the hv_device, which is actually an unncessary indirection. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7033 302706 hyperv: Get rid of hv_device, which is unnecessary indirection. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7034 Modified: stable/10/sys/dev/hyperv/include/hyperv.h stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.c stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.c stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.h stable/10/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c stable/10/sys/dev/hyperv/utilities/hv_heartbeat.c stable/10/sys/dev/hyperv/utilities/hv_kvp.c stable/10/sys/dev/hyperv/utilities/hv_shutdown.c stable/10/sys/dev/hyperv/utilities/hv_timesync.c stable/10/sys/dev/hyperv/utilities/hv_util.c stable/10/sys/dev/hyperv/utilities/hv_util.h stable/10/sys/dev/hyperv/vmbus/hv_channel.c stable/10/sys/dev/hyperv/vmbus/hv_channel_mgmt.c stable/10/sys/dev/hyperv/vmbus/hv_vmbus_priv.h stable/10/sys/dev/hyperv/vmbus/vmbus.c stable/10/sys/dev/hyperv/vmbus/vmbus_if.m stable/10/sys/modules/hyperv/utilities/Makefile Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/hyperv/include/hyperv.h ============================================================================== --- stable/10/sys/dev/hyperv/include/hyperv.h Tue Oct 11 07:10:12 2016 (r307021) +++ stable/10/sys/dev/hyperv/include/hyperv.h Tue Oct 11 07:30:59 2016 (r307022) @@ -399,20 +399,6 @@ typedef struct { #define HW_MACADDR_LEN 6 -enum { - HV_VMBUS_IVAR_TYPE, - HV_VMBUS_IVAR_INSTANCE, - HV_VMBUS_IVAR_NODE, - HV_VMBUS_IVAR_DEVCTX -}; - -#define HV_VMBUS_ACCESSOR(var, ivar, type) \ - __BUS_ACCESSOR(vmbus, var, HV_VMBUS, ivar, type) - -HV_VMBUS_ACCESSOR(type, TYPE, const char *) -HV_VMBUS_ACCESSOR(devctx, DEVCTX, struct hv_device *) - - /* * Common defines for Hyper-V ICs */ @@ -534,7 +520,7 @@ typedef union { } __packed hv_vmbus_connection_id; typedef struct hv_vmbus_channel { - struct hv_device* device; + device_t ch_dev; struct vmbus_softc *vmbus_sc; hv_vmbus_channel_state state; uint32_t ch_flags; /* VMBUS_CHAN_FLAG_ */ @@ -647,15 +633,6 @@ hv_set_channel_read_state(hv_vmbus_chann channel->batched_reading = state; } -typedef struct hv_device { - hv_guid class_id; - hv_guid device_id; - device_t device; - hv_vmbus_channel* channel; -} hv_device; - - - int hv_vmbus_channel_recv_packet( hv_vmbus_channel* channel, void* buffer, @@ -737,4 +714,10 @@ hv_get_phys_addr(void *virt) return (ret); } +static __inline struct hv_vmbus_channel * +vmbus_get_channel(device_t dev) +{ + return device_get_ivars(dev); +} + #endif /* __HYPERV_H__ */ Modified: stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.c Tue Oct 11 07:10:12 2016 (r307021) +++ stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.c Tue Oct 11 07:30:59 2016 (r307022) @@ -57,31 +57,30 @@ MALLOC_DEFINE(M_NETVSC, "netvsc", "Hyper * Forward declarations */ static void hv_nv_on_channel_callback(void *xchan); -static int hv_nv_init_send_buffer_with_net_vsp(struct hv_device *device); -static int hv_nv_init_rx_buffer_with_net_vsp(struct hv_device *device); +static int hv_nv_init_send_buffer_with_net_vsp(struct hn_softc *sc); +static int hv_nv_init_rx_buffer_with_net_vsp(struct hn_softc *); static int hv_nv_destroy_send_buffer(netvsc_dev *net_dev); static int hv_nv_destroy_rx_buffer(netvsc_dev *net_dev); -static int hv_nv_connect_to_vsp(struct hv_device *device); +static int hv_nv_connect_to_vsp(struct hn_softc *sc); static void hv_nv_on_send_completion(netvsc_dev *net_dev, - struct hv_device *device, struct hv_vmbus_channel *, hv_vm_packet_descriptor *pkt); + struct hv_vmbus_channel *, hv_vm_packet_descriptor *pkt); static void hv_nv_on_receive_completion(struct hv_vmbus_channel *chan, uint64_t tid, uint32_t status); static void hv_nv_on_receive(netvsc_dev *net_dev, - struct hv_device *device, struct hv_vmbus_channel *chan, + struct hn_softc *sc, struct hv_vmbus_channel *chan, hv_vm_packet_descriptor *pkt); /* * */ static inline netvsc_dev * -hv_nv_alloc_net_device(struct hv_device *device) +hv_nv_alloc_net_device(struct hn_softc *sc) { netvsc_dev *net_dev; - hn_softc_t *sc = device_get_softc(device->device); net_dev = malloc(sizeof(netvsc_dev), M_NETVSC, M_WAITOK | M_ZERO); - net_dev->dev = device; + net_dev->sc = sc; net_dev->destroy = FALSE; sc->net_dev = net_dev; @@ -89,43 +88,21 @@ hv_nv_alloc_net_device(struct hv_device } /* - * + * XXX unnecessary; nuke it. */ static inline netvsc_dev * -hv_nv_get_outbound_net_device(struct hv_device *device) +hv_nv_get_outbound_net_device(struct hn_softc *sc) { - hn_softc_t *sc = device_get_softc(device->device); - netvsc_dev *net_dev = sc->net_dev;; - - if ((net_dev != NULL) && net_dev->destroy) { - return (NULL); - } - - return (net_dev); + return sc->net_dev; } /* - * + * XXX unnecessary; nuke it. */ static inline netvsc_dev * -hv_nv_get_inbound_net_device(struct hv_device *device) +hv_nv_get_inbound_net_device(struct hn_softc *sc) { - hn_softc_t *sc = device_get_softc(device->device); - netvsc_dev *net_dev = sc->net_dev;; - - if (net_dev == NULL) { - return (net_dev); - } - /* - * When the device is being destroyed; we only - * permit incoming packets if and only if there - * are outstanding sends. - */ - if (net_dev->destroy) { - return (NULL); - } - - return (net_dev); + return sc->net_dev; } int @@ -163,13 +140,13 @@ hv_nv_get_next_send_section(netvsc_dev * * Hyper-V extensible switch and the synthetic data path. */ static int -hv_nv_init_rx_buffer_with_net_vsp(struct hv_device *device) +hv_nv_init_rx_buffer_with_net_vsp(struct hn_softc *sc) { netvsc_dev *net_dev; nvsp_msg *init_pkt; int ret = 0; - net_dev = hv_nv_get_outbound_net_device(device); + net_dev = hv_nv_get_outbound_net_device(sc); if (!net_dev) { return (ENODEV); } @@ -184,7 +161,7 @@ hv_nv_init_rx_buffer_with_net_vsp(struct * GPADL: Guest physical address descriptor list. */ ret = hv_vmbus_channel_establish_gpadl( - device->channel, net_dev->rx_buf, + sc->hn_prichan, net_dev->rx_buf, net_dev->rx_buf_size, &net_dev->rx_buf_gpadl_handle); if (ret != 0) { goto cleanup; @@ -205,7 +182,7 @@ hv_nv_init_rx_buffer_with_net_vsp(struct /* Send the gpadl notification request */ - ret = hv_vmbus_channel_send_packet(device->channel, init_pkt, + ret = hv_vmbus_channel_send_packet(sc->hn_prichan, init_pkt, sizeof(nvsp_msg), (uint64_t)(uintptr_t)init_pkt, HV_VMBUS_PACKET_TYPE_DATA_IN_BAND, HV_VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED); @@ -255,13 +232,13 @@ exit: * Net VSC initialize send buffer with net VSP */ static int -hv_nv_init_send_buffer_with_net_vsp(struct hv_device *device) +hv_nv_init_send_buffer_with_net_vsp(struct hn_softc *sc) { netvsc_dev *net_dev; nvsp_msg *init_pkt; int ret = 0; - net_dev = hv_nv_get_outbound_net_device(device); + net_dev = hv_nv_get_outbound_net_device(sc); if (!net_dev) { return (ENODEV); } @@ -278,7 +255,7 @@ hv_nv_init_send_buffer_with_net_vsp(stru * Note: This call uses the vmbus connection rather than the * channel to establish the gpadl handle. */ - ret = hv_vmbus_channel_establish_gpadl(device->channel, + ret = hv_vmbus_channel_establish_gpadl(sc->hn_prichan, net_dev->send_buf, net_dev->send_buf_size, &net_dev->send_buf_gpadl_handle); if (ret != 0) { @@ -299,7 +276,7 @@ hv_nv_init_send_buffer_with_net_vsp(stru /* Send the gpadl notification request */ - ret = hv_vmbus_channel_send_packet(device->channel, init_pkt, + ret = hv_vmbus_channel_send_packet(sc->hn_prichan, init_pkt, sizeof(nvsp_msg), (uint64_t)init_pkt, HV_VMBUS_PACKET_TYPE_DATA_IN_BAND, HV_VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED); @@ -359,7 +336,7 @@ hv_nv_destroy_rx_buffer(netvsc_dev *net_ revoke_pkt->msgs.vers_1_msgs.revoke_rx_buf.id = NETVSC_RECEIVE_BUFFER_ID; - ret = hv_vmbus_channel_send_packet(net_dev->dev->channel, + ret = hv_vmbus_channel_send_packet(net_dev->sc->hn_prichan, revoke_pkt, sizeof(nvsp_msg), (uint64_t)(uintptr_t)revoke_pkt, HV_VMBUS_PACKET_TYPE_DATA_IN_BAND, 0); @@ -375,7 +352,7 @@ hv_nv_destroy_rx_buffer(netvsc_dev *net_ /* Tear down the gpadl on the vsp end */ if (net_dev->rx_buf_gpadl_handle) { - ret = hv_vmbus_channel_teardown_gpdal(net_dev->dev->channel, + ret = hv_vmbus_channel_teardown_gpdal(net_dev->sc->hn_prichan, net_dev->rx_buf_gpadl_handle); /* * If we failed here, we might as well return and have a leak @@ -427,7 +404,7 @@ hv_nv_destroy_send_buffer(netvsc_dev *ne revoke_pkt->msgs.vers_1_msgs.revoke_send_buf.id = NETVSC_SEND_BUFFER_ID; - ret = hv_vmbus_channel_send_packet(net_dev->dev->channel, + ret = hv_vmbus_channel_send_packet(net_dev->sc->hn_prichan, revoke_pkt, sizeof(nvsp_msg), (uint64_t)(uintptr_t)revoke_pkt, HV_VMBUS_PACKET_TYPE_DATA_IN_BAND, 0); @@ -442,7 +419,7 @@ hv_nv_destroy_send_buffer(netvsc_dev *ne /* Tear down the gpadl on the vsp end */ if (net_dev->send_buf_gpadl_handle) { - ret = hv_vmbus_channel_teardown_gpdal(net_dev->dev->channel, + ret = hv_vmbus_channel_teardown_gpdal(net_dev->sc->hn_prichan, net_dev->send_buf_gpadl_handle); /* @@ -477,7 +454,7 @@ hv_nv_destroy_send_buffer(netvsc_dev *ne * to the negotiated version, so we cannot rely on that. */ static int -hv_nv_negotiate_nvsp_protocol(struct hv_device *device, netvsc_dev *net_dev, +hv_nv_negotiate_nvsp_protocol(struct hn_softc *sc, netvsc_dev *net_dev, uint32_t nvsp_ver) { nvsp_msg *init_pkt; @@ -494,7 +471,7 @@ hv_nv_negotiate_nvsp_protocol(struct hv_ init_pkt->msgs.init_msgs.init.protocol_version_2 = nvsp_ver; /* Send the init request */ - ret = hv_vmbus_channel_send_packet(device->channel, init_pkt, + ret = hv_vmbus_channel_send_packet(sc->hn_prichan, init_pkt, sizeof(nvsp_msg), (uint64_t)(uintptr_t)init_pkt, HV_VMBUS_PACKET_TYPE_DATA_IN_BAND, HV_VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED); @@ -515,13 +492,13 @@ hv_nv_negotiate_nvsp_protocol(struct hv_ * Not valid for NDIS version 1. */ static int -hv_nv_send_ndis_config(struct hv_device *device, uint32_t mtu) +hv_nv_send_ndis_config(struct hn_softc *sc, uint32_t mtu) { netvsc_dev *net_dev; nvsp_msg *init_pkt; int ret; - net_dev = hv_nv_get_outbound_net_device(device); + net_dev = hv_nv_get_outbound_net_device(sc); if (!net_dev) return (-ENODEV); @@ -538,7 +515,7 @@ hv_nv_send_ndis_config(struct hv_device = 1; /* Send the configuration packet */ - ret = hv_vmbus_channel_send_packet(device->channel, init_pkt, + ret = hv_vmbus_channel_send_packet(sc->hn_prichan, init_pkt, sizeof(nvsp_msg), (uint64_t)(uintptr_t)init_pkt, HV_VMBUS_PACKET_TYPE_DATA_IN_BAND, 0); if (ret != 0) @@ -551,7 +528,7 @@ hv_nv_send_ndis_config(struct hv_device * Net VSC connect to VSP */ static int -hv_nv_connect_to_vsp(struct hv_device *device) +hv_nv_connect_to_vsp(struct hn_softc *sc) { netvsc_dev *net_dev; nvsp_msg *init_pkt; @@ -563,20 +540,16 @@ hv_nv_connect_to_vsp(struct hv_device *d int i; int protocol_number = nitems(protocol_list); int ret = 0; - device_t dev = device->device; - hn_softc_t *sc = device_get_softc(dev); + device_t dev = sc->hn_dev; struct ifnet *ifp = sc->arpcom.ac_ifp; - net_dev = hv_nv_get_outbound_net_device(device); - if (!net_dev) { - return (ENODEV); - } + net_dev = hv_nv_get_outbound_net_device(sc); /* * Negotiate the NVSP version. Try the latest NVSP first. */ for (i = protocol_number - 1; i >= 0; i--) { - if (hv_nv_negotiate_nvsp_protocol(device, net_dev, + if (hv_nv_negotiate_nvsp_protocol(sc, net_dev, protocol_list[i]) == 0) { net_dev->nvsp_version = protocol_list[i]; if (bootverbose) @@ -598,7 +571,7 @@ hv_nv_connect_to_vsp(struct hv_device *d * This needs to be right after the NVSP init message per Haiyang */ if (net_dev->nvsp_version >= NVSP_PROTOCOL_VERSION_2) - ret = hv_nv_send_ndis_config(device, ifp->if_mtu); + ret = hv_nv_send_ndis_config(sc, ifp->if_mtu); /* * Send the NDIS version @@ -621,7 +594,7 @@ hv_nv_connect_to_vsp(struct hv_device *d /* Send the init request */ - ret = hv_vmbus_channel_send_packet(device->channel, init_pkt, + ret = hv_vmbus_channel_send_packet(sc->hn_prichan, init_pkt, sizeof(nvsp_msg), (uint64_t)(uintptr_t)init_pkt, HV_VMBUS_PACKET_TYPE_DATA_IN_BAND, 0); if (ret != 0) { @@ -642,9 +615,9 @@ hv_nv_connect_to_vsp(struct hv_device *d net_dev->rx_buf_size = NETVSC_RECEIVE_BUFFER_SIZE; net_dev->send_buf_size = NETVSC_SEND_BUFFER_SIZE; - ret = hv_nv_init_rx_buffer_with_net_vsp(device); + ret = hv_nv_init_rx_buffer_with_net_vsp(sc); if (ret == 0) - ret = hv_nv_init_send_buffer_with_net_vsp(device); + ret = hv_nv_init_send_buffer_with_net_vsp(sc); cleanup: return (ret); @@ -676,13 +649,13 @@ hv_nv_subchan_attach(struct hv_vmbus_cha * Callback when the device belonging to this driver is added */ netvsc_dev * -hv_nv_on_device_add(struct hv_device *device, void *additional_info) +hv_nv_on_device_add(struct hn_softc *sc, void *additional_info) { - struct hv_vmbus_channel *chan = device->channel; + struct hv_vmbus_channel *chan = sc->hn_prichan; netvsc_dev *net_dev; int ret = 0; - net_dev = hv_nv_alloc_net_device(device); + net_dev = hv_nv_alloc_net_device(sc); if (net_dev == NULL) return NULL; @@ -706,7 +679,7 @@ hv_nv_on_device_add(struct hv_device *de /* * Connect with the NetVsp */ - ret = hv_nv_connect_to_vsp(device); + ret = hv_nv_connect_to_vsp(sc); if (ret != 0) goto close; @@ -732,9 +705,8 @@ cleanup: * Net VSC on device remove */ int -hv_nv_on_device_remove(struct hv_device *device, boolean_t destroy_channel) +hv_nv_on_device_remove(struct hn_softc *sc, boolean_t destroy_channel) { - hn_softc_t *sc = device_get_softc(device->device); netvsc_dev *net_dev = sc->net_dev;; /* Stop outbound traffic ie sends and receives completions */ @@ -747,12 +719,12 @@ hv_nv_on_device_remove(struct hv_device /* Now, we can close the channel safely */ if (!destroy_channel) { - device->channel->state = + sc->hn_prichan->state = HV_CHANNEL_CLOSING_NONDESTRUCTIVE_STATE; } - free(device->channel->hv_chan_rdbuf, M_NETVSC); - hv_vmbus_channel_close(device->channel); + free(sc->hn_prichan->hv_chan_rdbuf, M_NETVSC); + hv_vmbus_channel_close(sc->hn_prichan); sema_destroy(&net_dev->channel_init_sema); free(net_dev, M_NETVSC); @@ -764,8 +736,7 @@ hv_nv_on_device_remove(struct hv_device * Net VSC on send completion */ static void -hv_nv_on_send_completion(netvsc_dev *net_dev, - struct hv_device *device, struct hv_vmbus_channel *chan, +hv_nv_on_send_completion(netvsc_dev *net_dev, struct hv_vmbus_channel *chan, hv_vm_packet_descriptor *pkt) { nvsp_msg *nvsp_msg_pkt; @@ -870,14 +841,14 @@ hv_nv_on_send(struct hv_vmbus_channel *c * with virtual addresses. */ static void -hv_nv_on_receive(netvsc_dev *net_dev, struct hv_device *device, +hv_nv_on_receive(netvsc_dev *net_dev, struct hn_softc *sc, struct hv_vmbus_channel *chan, hv_vm_packet_descriptor *pkt) { hv_vm_transfer_page_packet_header *vm_xfer_page_pkt; nvsp_msg *nvsp_msg_pkt; netvsc_packet vsc_pkt; netvsc_packet *net_vsc_pkt = &vsc_pkt; - device_t dev = device->device; + device_t dev = sc->hn_dev; int count = 0; int i = 0; int status = nvsp_status_success; @@ -911,7 +882,6 @@ hv_nv_on_receive(netvsc_dev *net_dev, st } count = vm_xfer_page_pkt->range_count; - net_vsc_pkt->device = device; /* Each range represents 1 RNDIS pkt that contains 1 Ethernet frame */ for (i = 0; i < count; i++) { @@ -921,7 +891,7 @@ hv_nv_on_receive(netvsc_dev *net_dev, st net_vsc_pkt->tot_data_buf_len = vm_xfer_page_pkt->ranges[i].byte_count; - hv_rf_on_receive(net_dev, device, chan, net_vsc_pkt); + hv_rf_on_receive(net_dev, chan, net_vsc_pkt); if (net_vsc_pkt->status != nvsp_status_success) { status = nvsp_status_failure; } @@ -977,14 +947,14 @@ retry_send_cmplt: * Net VSC receiving vRSS send table from VSP */ static void -hv_nv_send_table(struct hv_device *device, hv_vm_packet_descriptor *pkt) +hv_nv_send_table(struct hn_softc *sc, hv_vm_packet_descriptor *pkt) { netvsc_dev *net_dev; nvsp_msg *nvsp_msg_pkt; int i; uint32_t count, *table; - net_dev = hv_nv_get_inbound_net_device(device); + net_dev = hv_nv_get_inbound_net_device(sc); if (!net_dev) return; @@ -1020,9 +990,9 @@ static void hv_nv_on_channel_callback(void *xchan) { struct hv_vmbus_channel *chan = xchan; - struct hv_device *device = chan->device; + device_t dev = chan->ch_dev; + struct hn_softc *sc = device_get_softc(dev); netvsc_dev *net_dev; - device_t dev = device->device; uint32_t bytes_rxed; uint64_t request_id; hv_vm_packet_descriptor *desc; @@ -1030,7 +1000,7 @@ hv_nv_on_channel_callback(void *xchan) int bufferlen = NETVSC_PACKET_SIZE; int ret = 0; - net_dev = hv_nv_get_inbound_net_device(device); + net_dev = hv_nv_get_inbound_net_device(sc); if (net_dev == NULL) return; @@ -1044,14 +1014,14 @@ hv_nv_on_channel_callback(void *xchan) desc = (hv_vm_packet_descriptor *)buffer; switch (desc->type) { case HV_VMBUS_PACKET_TYPE_COMPLETION: - hv_nv_on_send_completion(net_dev, device, - chan, desc); + hv_nv_on_send_completion(net_dev, chan, + desc); break; case HV_VMBUS_PACKET_TYPE_DATA_USING_TRANSFER_PAGES: - hv_nv_on_receive(net_dev, device, chan, desc); + hv_nv_on_receive(net_dev, sc, chan, desc); break; case HV_VMBUS_PACKET_TYPE_DATA_IN_BAND: - hv_nv_send_table(device, desc); + hv_nv_send_table(sc, desc); break; default: device_printf(dev, Modified: stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h Tue Oct 11 07:10:12 2016 (r307021) +++ stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h Tue Oct 11 07:30:59 2016 (r307022) @@ -1040,7 +1040,7 @@ typedef struct nvsp_msg_ { * Per netvsc channel-specific */ typedef struct netvsc_dev_ { - struct hv_device *dev; + struct hn_softc *sc; /* Send buffer allocated by us but manages by NetVSP */ void *send_buf; @@ -1107,7 +1107,6 @@ typedef void (*pfn_on_send_rx_completion #endif typedef struct netvsc_packet_ { - struct hv_device *device; hv_bool_uint8_t is_data_pkt; /* One byte */ uint16_t vlan_tci; uint32_t status; @@ -1240,8 +1239,8 @@ typedef struct hn_softc { int hn_initdone; /* See hv_netvsc_drv_freebsd.c for rules on how to use */ int temp_unusable; - struct hv_device *hn_dev_obj; netvsc_dev *net_dev; + struct hv_vmbus_channel *hn_prichan; int hn_rx_ring_cnt; int hn_rx_ring_inuse; @@ -1263,10 +1262,10 @@ typedef struct hn_softc { */ extern int hv_promisc_mode; -void netvsc_linkstatus_callback(struct hv_device *device_obj, uint32_t status); -netvsc_dev *hv_nv_on_device_add(struct hv_device *device, +void netvsc_linkstatus_callback(struct hn_softc *sc, uint32_t status); +netvsc_dev *hv_nv_on_device_add(struct hn_softc *sc, void *additional_info); -int hv_nv_on_device_remove(struct hv_device *device, +int hv_nv_on_device_remove(struct hn_softc *sc, boolean_t destroy_channel); int hv_nv_on_send(struct hv_vmbus_channel *chan, netvsc_packet *pkt); int hv_nv_get_next_send_section(netvsc_dev *net_dev); Modified: stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Tue Oct 11 07:10:12 2016 (r307021) +++ stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Tue Oct 11 07:30:59 2016 (r307022) @@ -415,18 +415,12 @@ static const hv_guid g_net_vsc_device_ty static int netvsc_probe(device_t dev) { - const char *p; - - p = vmbus_get_type(dev); - if (!memcmp(p, &g_net_vsc_device_type.data, sizeof(hv_guid))) { + if (VMBUS_PROBE_GUID(device_get_parent(dev), dev, + &g_net_vsc_device_type) == 0) { device_set_desc(dev, "Hyper-V Network Interface"); - if (bootverbose) - printf("Netvsc probe... DONE \n"); - - return (BUS_PROBE_DEFAULT); + return BUS_PROBE_DEFAULT; } - - return (ENXIO); + return ENXIO; } static void @@ -451,8 +445,6 @@ hn_cpuset_setthread_task(void *xmask, in static int netvsc_attach(device_t dev) { - struct hv_device *device_ctx = vmbus_get_devctx(dev); - struct hv_vmbus_channel *pri_chan; netvsc_device_info device_info; hn_softc_t *sc; int unit = device_get_unit(dev); @@ -464,6 +456,7 @@ netvsc_attach(device_t dev) sc->hn_unit = unit; sc->hn_dev = dev; + sc->hn_prichan = vmbus_get_channel(dev); if (hn_tx_taskq == NULL) { sc->hn_tx_taskq = taskqueue_create("hn_tx", M_WAITOK, @@ -488,8 +481,6 @@ netvsc_attach(device_t dev) } NV_LOCK_INIT(sc, "NetVSCLock"); - sc->hn_dev_obj = device_ctx; - ifp = sc->hn_ifp = sc->arpcom.ac_ifp = if_alloc(IFT_ETHER); ifp->if_softc = sc; if_initname(ifp, device_get_name(dev), device_get_unit(dev)); @@ -532,12 +523,7 @@ netvsc_attach(device_t dev) /* * Associate the first TX/RX ring w/ the primary channel. */ - pri_chan = device_ctx->channel; - KASSERT(HV_VMBUS_CHAN_ISPRIMARY(pri_chan), ("not primary channel")); - KASSERT(pri_chan->ch_subidx == 0, - ("primary channel subidx %u", - pri_chan->ch_subidx)); - hn_channel_attach(sc, pri_chan); + hn_channel_attach(sc, sc->hn_prichan); ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; ifp->if_ioctl = hn_ioctl; @@ -574,7 +560,7 @@ netvsc_attach(device_t dev) IFCAP_LRO; ifp->if_hwassist = sc->hn_tx_ring[0].hn_csum_assist | CSUM_TSO; - error = hv_rf_on_device_add(device_ctx, &device_info, ring_cnt); + error = hv_rf_on_device_add(sc, &device_info, ring_cnt); if (error) goto failed; KASSERT(sc->net_dev->num_channel > 0 && @@ -644,7 +630,6 @@ static int netvsc_detach(device_t dev) { struct hn_softc *sc = device_get_softc(dev); - struct hv_device *hv_device = vmbus_get_devctx(dev); if (bootverbose) printf("netvsc_detach\n"); @@ -660,7 +645,7 @@ netvsc_detach(device_t dev) * the netdevice. */ - hv_rf_on_device_remove(hv_device, HV_RF_NV_DESTROY_CHANNEL); + hv_rf_on_device_remove(sc, HV_RF_NV_DESTROY_CHANNEL); hn_stop_tx_tasks(sc); @@ -1224,10 +1209,8 @@ hn_start_locked(struct hn_tx_ring *txr, * Link up/down notification */ void -netvsc_linkstatus_callback(struct hv_device *device_obj, uint32_t status) +netvsc_linkstatus_callback(struct hn_softc *sc, uint32_t status) { - hn_softc_t *sc = device_get_softc(device_obj->device); - if (status == 1) { sc->hn_carrier = 1; } else { @@ -1548,7 +1531,6 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, struct ifaddr *ifa = (struct ifaddr *)data; #endif netvsc_device_info device_info; - struct hv_device *hn_dev; int mask, error = 0; int retry_cnt = 500; @@ -1566,8 +1548,6 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, error = ether_ioctl(ifp, cmd, data); break; case SIOCSIFMTU: - hn_dev = vmbus_get_devctx(sc->hn_dev); - /* Check MTU value change */ if (ifp->if_mtu == ifr->ifr_mtu) break; @@ -1614,7 +1594,7 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, * MTU to take effect. This includes tearing down, but not * deleting the channel, then bringing it back up. */ - error = hv_rf_on_device_remove(hn_dev, HV_RF_NV_RETAIN_CHANNEL); + error = hv_rf_on_device_remove(sc, HV_RF_NV_RETAIN_CHANNEL); if (error) { NV_LOCK(sc); sc->temp_unusable = FALSE; @@ -1623,9 +1603,9 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, } /* Wait for subchannels to be destroyed */ - vmbus_drain_subchan(hn_dev->channel); + vmbus_drain_subchan(sc->hn_prichan); - error = hv_rf_on_device_add(hn_dev, &device_info, + error = hv_rf_on_device_add(sc, &device_info, sc->hn_rx_ring_inuse); if (error) { NV_LOCK(sc); @@ -1790,7 +1770,6 @@ hn_stop(hn_softc_t *sc) { struct ifnet *ifp; int ret, i; - struct hv_device *device_ctx = vmbus_get_devctx(sc->hn_dev); ifp = sc->hn_ifp; @@ -1805,7 +1784,7 @@ hn_stop(hn_softc_t *sc) if_link_state_change(ifp, LINK_STATE_DOWN); sc->hn_initdone = 0; - ret = hv_rf_on_close(device_ctx); + ret = hv_rf_on_close(sc); } /* @@ -1873,7 +1852,6 @@ static void hn_ifinit_locked(hn_softc_t *sc) { struct ifnet *ifp; - struct hv_device *device_ctx = vmbus_get_devctx(sc->hn_dev); int ret, i; ifp = sc->hn_ifp; @@ -1884,7 +1862,7 @@ hn_ifinit_locked(hn_softc_t *sc) hv_promisc_mode = 1; - ret = hv_rf_on_open(device_ctx); + ret = hv_rf_on_open(sc); if (ret != 0) { return; } else { @@ -3046,13 +3024,12 @@ hn_subchan_attach(struct hn_softc *sc, s static void hn_subchan_setup(struct hn_softc *sc) { - struct hv_device *device_ctx = vmbus_get_devctx(sc->hn_dev); struct hv_vmbus_channel **subchan; int subchan_cnt = sc->net_dev->num_channel - 1; int i; /* Wait for sub-channels setup to complete. */ - subchan = vmbus_get_subchan(device_ctx->channel, subchan_cnt); + subchan = vmbus_get_subchan(sc->hn_prichan, subchan_cnt); /* Attach the sub-channels. */ for (i = 0; i < subchan_cnt; ++i) { Modified: stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.c Tue Oct 11 07:10:12 2016 (r307021) +++ stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.c Tue Oct 11 07:30:59 2016 (r307022) @@ -89,7 +89,7 @@ static int hv_rf_close_device(rndis_dev static void hv_rf_on_send_request_completion(struct hv_vmbus_channel *, void *context); static void hv_rf_on_send_request_halt_completion(struct hv_vmbus_channel *, void *context); int -hv_rf_send_offload_request(struct hv_device *device, +hv_rf_send_offload_request(struct hn_softc *sc, rndis_offload_params *offloads); /* * Set the Per-Packet-Info with the specified type @@ -299,7 +299,7 @@ hv_rf_send_request(rndis_device *device, packet->send_buf_section_size = 0; sendit: - ret = hv_nv_on_send(device->net_dev->dev->channel, packet); + ret = hv_nv_on_send(device->net_dev->sc->hn_prichan, packet); return (ret); } @@ -351,7 +351,7 @@ hv_rf_receive_response(rndis_device *dev } int -hv_rf_send_offload_request(struct hv_device *device, +hv_rf_send_offload_request(struct hn_softc *sc, rndis_offload_params *offloads) { rndis_request *request; @@ -359,8 +359,7 @@ hv_rf_send_offload_request(struct hv_dev rndis_offload_params *offload_req; rndis_set_complete *set_complete; rndis_device *rndis_dev; - hn_softc_t *sc = device_get_softc(device->device); - device_t dev = device->device; + device_t dev = sc->hn_dev; netvsc_dev *net_dev = sc->net_dev; uint32_t vsp_version = net_dev->nvsp_version; uint32_t extlen = sizeof(rndis_offload_params); @@ -437,14 +436,14 @@ hv_rf_receive_indicate_status(rndis_devi switch(indicate->status) { case RNDIS_STATUS_MEDIA_CONNECT: - netvsc_linkstatus_callback(device->net_dev->dev, 1); + netvsc_linkstatus_callback(device->net_dev->sc, 1); break; case RNDIS_STATUS_MEDIA_DISCONNECT: - netvsc_linkstatus_callback(device->net_dev->dev, 0); + netvsc_linkstatus_callback(device->net_dev->sc, 0); break; default: /* TODO: */ - device_printf(device->net_dev->dev->device, + device_printf(device->net_dev->sc->hn_dev, "unknown status %d received\n", indicate->status); break; } @@ -537,7 +536,7 @@ hv_rf_receive_data(rndis_device *device, { rndis_packet *rndis_pkt; uint32_t data_offset; - device_t dev = device->net_dev->dev->device; + device_t dev = device->net_dev->sc->hn_dev; struct hv_rf_recvinfo info; rndis_pkt = &message->msg.packet; @@ -580,7 +579,7 @@ hv_rf_receive_data(rndis_device *device, * RNDIS filter on receive */ int -hv_rf_on_receive(netvsc_dev *net_dev, struct hv_device *device, +hv_rf_on_receive(netvsc_dev *net_dev, struct hv_vmbus_channel *chan, netvsc_packet *pkt) { rndis_device *rndis_dev; @@ -1062,7 +1061,7 @@ hv_rf_close_device(rndis_device *device) * RNDIS filter on device add */ int -hv_rf_on_device_add(struct hv_device *device, void *additl_info, +hv_rf_on_device_add(struct hn_softc *sc, void *additl_info, int nchan) { int ret; @@ -1073,7 +1072,7 @@ hv_rf_on_device_add(struct hv_device *de struct rndis_recv_scale_cap rsscaps; uint32_t rsscaps_size = sizeof(struct rndis_recv_scale_cap); netvsc_device_info *dev_info = (netvsc_device_info *)additl_info; - device_t dev = device->device; + device_t dev = sc->hn_dev; rndis_dev = hv_get_rndis_device(); if (rndis_dev == NULL) { @@ -1086,7 +1085,7 @@ hv_rf_on_device_add(struct hv_device *de * (hv_rf_on_receive()) before this call is completed. * Note: Earlier code used a function pointer here. */ - net_dev = hv_nv_on_device_add(device, additl_info); + net_dev = hv_nv_on_device_add(sc, additl_info); if (!net_dev) { hv_put_rndis_device(rndis_dev); @@ -1124,7 +1123,7 @@ hv_rf_on_device_add(struct hv_device *de offloads.udp_ipv6_csum = RNDIS_OFFLOAD_PARAMETERS_TX_RX_ENABLED; offloads.lso_v2_ipv4 = RNDIS_OFFLOAD_PARAMETERS_LSOV2_ENABLED; - ret = hv_rf_send_offload_request(device, &offloads); + ret = hv_rf_send_offload_request(sc, &offloads); if (ret != 0) { /* TODO: shut down rndis device and the channel */ device_printf(dev, @@ -1171,7 +1170,7 @@ hv_rf_on_device_add(struct hv_device *de init_pkt->msgs.vers_5_msgs.subchannel_request.num_subchannels = net_dev->num_channel - 1; - ret = hv_vmbus_channel_send_packet(device->channel, init_pkt, + ret = hv_vmbus_channel_send_packet(sc->hn_prichan, init_pkt, sizeof(nvsp_msg), (uint64_t)(uintptr_t)init_pkt, HV_VMBUS_PACKET_TYPE_DATA_IN_BAND, HV_VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED); @@ -1205,9 +1204,8 @@ out: * RNDIS filter on device remove */ int -hv_rf_on_device_remove(struct hv_device *device, boolean_t destroy_channel) +hv_rf_on_device_remove(struct hn_softc *sc, boolean_t destroy_channel) { - hn_softc_t *sc = device_get_softc(device->device); netvsc_dev *net_dev = sc->net_dev; rndis_device *rndis_dev = (rndis_device *)net_dev->extension; int ret; @@ -1219,7 +1217,7 @@ hv_rf_on_device_remove(struct hv_device net_dev->extension = NULL; /* Pass control to inner driver to remove the device */ - ret |= hv_nv_on_device_remove(device, destroy_channel); + ret |= hv_nv_on_device_remove(sc, destroy_channel); return (ret); } @@ -1228,9 +1226,8 @@ hv_rf_on_device_remove(struct hv_device * RNDIS filter on open */ int -hv_rf_on_open(struct hv_device *device) +hv_rf_on_open(struct hn_softc *sc) { - hn_softc_t *sc = device_get_softc(device->device); netvsc_dev *net_dev = sc->net_dev; return (hv_rf_open_device((rndis_device *)net_dev->extension)); @@ -1240,9 +1237,8 @@ hv_rf_on_open(struct hv_device *device) * RNDIS filter on close */ int -hv_rf_on_close(struct hv_device *device) +hv_rf_on_close(struct hn_softc *sc) { - hn_softc_t *sc = device_get_softc(device->device); netvsc_dev *net_dev = sc->net_dev; return (hv_rf_close_device((rndis_device *)net_dev->extension)); Modified: stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.h ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.h Tue Oct 11 07:10:12 2016 (r307021) +++ stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.h Tue Oct 11 07:30:59 2016 (r307022) @@ -111,15 +111,16 @@ typedef struct rndis_device_ { * Externs */ struct hv_vmbus_channel; +struct hn_softc; -int hv_rf_on_receive(netvsc_dev *net_dev, struct hv_device *device, +int hv_rf_on_receive(netvsc_dev *net_dev, struct hv_vmbus_channel *chan, netvsc_packet *pkt); void hv_rf_receive_rollup(netvsc_dev *net_dev); void hv_rf_channel_rollup(struct hv_vmbus_channel *chan); -int hv_rf_on_device_add(struct hv_device *device, void *additl_info, int nchan); -int hv_rf_on_device_remove(struct hv_device *device, boolean_t destroy_channel); -int hv_rf_on_open(struct hv_device *device); -int hv_rf_on_close(struct hv_device *device); +int hv_rf_on_device_add(struct hn_softc *sc, void *additl_info, int nchan); +int hv_rf_on_device_remove(struct hn_softc *sc, boolean_t destroy_channel); +int hv_rf_on_open(struct hn_softc *sc); +int hv_rf_on_close(struct hn_softc *sc); #endif /* __HV_RNDIS_FILTER_H__ */ Modified: stable/10/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c ============================================================================== --- stable/10/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c Tue Oct 11 07:10:12 2016 (r307021) +++ stable/10/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c Tue Oct 11 07:30:59 2016 (r307022) @@ -125,7 +125,7 @@ struct hv_storvsc_request { }; struct storvsc_softc { - struct hv_device *hs_dev; + struct hv_vmbus_channel *hs_chan; LIST_HEAD(, hv_storvsc_request) hs_free_list; struct mtx hs_lock; struct storvsc_driver_props *hs_drv_props; @@ -139,6 +139,7 @@ struct storvsc_softc { struct sema hs_drain_sema; struct hv_storvsc_request hs_init_req; struct hv_storvsc_request hs_reset_req; + device_t hs_dev; }; @@ -264,11 +265,11 @@ static int create_storvsc_request(union static void storvsc_free_request(struct storvsc_softc *sc, struct hv_storvsc_request *reqp); static enum hv_storage_type storvsc_get_storage_type(device_t dev); static void hv_storvsc_rescan_target(struct storvsc_softc *sc); -static void hv_storvsc_on_channel_callback(void *context); +static void hv_storvsc_on_channel_callback(void *xchan); static void hv_storvsc_on_iocompletion( struct storvsc_softc *sc, struct vstor_packet *vstor_packet, struct hv_storvsc_request *request); -static int hv_storvsc_connect_vsp(struct hv_device *device); +static int hv_storvsc_connect_vsp(struct storvsc_softc *); static void storvsc_io_done(struct hv_storvsc_request *reqp); static void storvsc_copy_sgl_to_bounce_buf(struct sglist *bounce_sgl, bus_dma_segment_t *orig_sgl, @@ -297,72 +298,16 @@ DRIVER_MODULE(storvsc, vmbus, storvsc_dr MODULE_VERSION(storvsc, 1); MODULE_DEPEND(storvsc, vmbus, 1, 1, 1); - -/** - * The host is capable of sending messages to us that are - * completely unsolicited. So, we need to address the race - * condition where we may be in the process of unloading the - * driver when the host may send us an unsolicited message. - * We address this issue by implementing a sequentially - * consistent protocol: - * - * 1. Channel callback is invoked while holding the the channel lock - * and an unloading driver will reset the channel callback under - * the protection of this channel lock. - * - * 2. To ensure bounded wait time for unloading a driver, we don't - * permit outgoing traffic once the device is marked as being - * destroyed. - * - * 3. Once the device is marked as being destroyed, we only - * permit incoming traffic to properly account for - * packets already sent out. - */ -static inline struct storvsc_softc * -get_stor_device(struct hv_device *device, - boolean_t outbound) -{ - struct storvsc_softc *sc; - - sc = device_get_softc(device->device); - - if (outbound) { *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-all@freebsd.org Tue Oct 11 07:37:46 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id EB6FDC0DD55; Tue, 11 Oct 2016 07:37:46 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id C6946873; Tue, 11 Oct 2016 07:37:46 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9B7bjkx011137; Tue, 11 Oct 2016 07:37:45 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9B7bjWN011133; Tue, 11 Oct 2016 07:37:45 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610110737.u9B7bjWN011133@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Tue, 11 Oct 2016 07:37:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307023 - in stable/10/sys/dev/hyperv: include vmbus X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Oct 2016 07:37:47 -0000 Author: sephe Date: Tue Oct 11 07:37:45 2016 New Revision: 307023 URL: https://svnweb.freebsd.org/changeset/base/307023 Log: MFC 302707-302709 302707 hyperv/vmbus: Nuke unused field from hv_vmbus_channel. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7036 302708 hyperv/bufring: Remove unused fields Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7037 302709 hyperv/vmbus: Pack bool field into flags field Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7038 Modified: stable/10/sys/dev/hyperv/include/hyperv.h stable/10/sys/dev/hyperv/vmbus/hv_channel.c stable/10/sys/dev/hyperv/vmbus/hv_channel_mgmt.c stable/10/sys/dev/hyperv/vmbus/hv_ring_buffer.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/hyperv/include/hyperv.h ============================================================================== --- stable/10/sys/dev/hyperv/include/hyperv.h Tue Oct 11 07:30:59 2016 (r307022) +++ stable/10/sys/dev/hyperv/include/hyperv.h Tue Oct 11 07:37:45 2016 (r307023) @@ -471,7 +471,7 @@ typedef struct { uint8_t reserved[4084]; /* - * WARNING: Ring data starts here + ring_data_start_offset + * WARNING: Ring data starts here * !!! DO NOT place any fields below this !!! */ uint8_t buffer[0]; /* doubles as interrupt mask */ @@ -491,10 +491,8 @@ typedef struct { typedef struct { hv_vmbus_ring_buffer* ring_buffer; - uint32_t ring_size; /* Include the shared header */ struct mtx ring_lock; uint32_t ring_data_size; /* ring_size */ - uint32_t ring_data_start_offset; } hv_vmbus_ring_buffer_info; typedef void (*hv_vmbus_pfn_channel_callback)(void *context); @@ -553,19 +551,6 @@ typedef struct hv_vmbus_channel { hv_vmbus_pfn_channel_callback on_channel_callback; void* channel_callback_context; - /* - * If batched_reading is set to "true", mask the interrupt - * and read until the channel is empty. - * If batched_reading is set to "false", the channel is not - * going to perform batched reading. - * - * Batched reading is enabled by default; specific - * drivers that don't want this behavior can turn it off. - */ - boolean_t batched_reading; - - boolean_t is_dedicated_interrupt; - struct hypercall_sigevt_in *ch_sigevt; struct hyperv_dma ch_sigevt_dma; @@ -626,11 +611,23 @@ typedef struct hv_vmbus_channel { #define HV_VMBUS_CHAN_ISPRIMARY(chan) ((chan)->primary_channel == NULL) #define VMBUS_CHAN_FLAG_HASMNF 0x0001 +/* + * If this flag is set, this channel's interrupt will be masked in ISR, + * and the RX bufring will be drained before this channel's interrupt is + * unmasked. + * + * This flag is turned on by default. Drivers can turn it off according + * to their own requirement. + */ +#define VMBUS_CHAN_FLAG_BATCHREAD 0x0002 static inline void -hv_set_channel_read_state(hv_vmbus_channel* channel, boolean_t state) +hv_set_channel_read_state(hv_vmbus_channel* channel, boolean_t on) { - channel->batched_reading = state; + if (!on) + channel->ch_flags &= ~VMBUS_CHAN_FLAG_BATCHREAD; + else + channel->ch_flags |= VMBUS_CHAN_FLAG_BATCHREAD; } int hv_vmbus_channel_recv_packet( Modified: stable/10/sys/dev/hyperv/vmbus/hv_channel.c ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/hv_channel.c Tue Oct 11 07:30:59 2016 (r307022) +++ stable/10/sys/dev/hyperv/vmbus/hv_channel.c Tue Oct 11 07:37:45 2016 (r307023) @@ -856,11 +856,13 @@ VmbusProcessChannelEvent(void* context, void* arg; uint32_t bytes_to_read; hv_vmbus_channel* channel = (hv_vmbus_channel*)context; - boolean_t is_batched_reading; + bool is_batched_reading = false; + + if (channel->ch_flags & VMBUS_CHAN_FLAG_BATCHREAD) + is_batched_reading = true; if (channel->on_channel_callback != NULL) { arg = channel->channel_callback_context; - is_batched_reading = channel->batched_reading; /* * Optimize host to guest signaling by ensuring: * 1. While reading the channel, we disable interrupts from @@ -917,7 +919,7 @@ vmbus_event_flags_proc(struct vmbus_soft if (channel == NULL || channel->rxq == NULL) continue; - if (channel->batched_reading) + if (channel->ch_flags & VMBUS_CHAN_FLAG_BATCHREAD) hv_ring_buffer_read_begin(&channel->inbound); taskqueue_enqueue(channel->rxq, &channel->channel_task); } Modified: stable/10/sys/dev/hyperv/vmbus/hv_channel_mgmt.c ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/hv_channel_mgmt.c Tue Oct 11 07:30:59 2016 (r307022) +++ stable/10/sys/dev/hyperv/vmbus/hv_channel_mgmt.c Tue Oct 11 07:37:45 2016 (r307023) @@ -285,21 +285,19 @@ vmbus_channel_on_offer_internal(struct v { hv_vmbus_channel* new_channel; - /* Allocate the channel object and save this offer */ + /* + * Allocate the channel object and save this offer + */ new_channel = hv_vmbus_allocate_channel(sc); new_channel->ch_id = offer->child_rel_id; new_channel->ch_subidx = offer->offer.sub_channel_index; - if (offer->monitor_allocated) - new_channel->ch_flags |= VMBUS_CHAN_FLAG_HASMNF; new_channel->ch_guid_type = offer->offer.interface_type; new_channel->ch_guid_inst = offer->offer.interface_instance; - /* - * By default we setup state to enable batched - * reading. A specific service can choose to - * disable this prior to opening the channel. - */ - new_channel->batched_reading = TRUE; + /* Batch reading is on by default */ + new_channel->ch_flags |= VMBUS_CHAN_FLAG_BATCHREAD; + if (offer->monitor_allocated) + new_channel->ch_flags |= VMBUS_CHAN_FLAG_HASMNF; new_channel->ch_sigevt = hyperv_dmamem_alloc( bus_get_dma_tag(sc->vmbus_dev), @@ -313,12 +311,8 @@ vmbus_channel_on_offer_internal(struct v return; } new_channel->ch_sigevt->hc_connid = VMBUS_CONNID_EVENT; - - if (sc->vmbus_version != VMBUS_VERSION_WS2008) { - new_channel->is_dedicated_interrupt = - (offer->is_dedicated_interrupt != 0); + if (sc->vmbus_version != VMBUS_VERSION_WS2008) new_channel->ch_sigevt->hc_connid = offer->connection_id; - } new_channel->monitor_group = (uint8_t) offer->monitor_id / 32; new_channel->monitor_bit = (uint8_t) offer->monitor_id % 32; Modified: stable/10/sys/dev/hyperv/vmbus/hv_ring_buffer.c ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/hv_ring_buffer.c Tue Oct 11 07:30:59 2016 (r307022) +++ stable/10/sys/dev/hyperv/vmbus/hv_ring_buffer.c Tue Oct 11 07:37:45 2016 (r307023) @@ -288,7 +288,6 @@ hv_vmbus_ring_buffer_init( ring_info->ring_buffer->read_index = ring_info->ring_buffer->write_index = 0; - ring_info->ring_size = buffer_len; ring_info->ring_data_size = buffer_len - sizeof(hv_vmbus_ring_buffer); mtx_init(&ring_info->ring_lock, "vmbus ring buffer", NULL, MTX_SPIN); From owner-svn-src-all@freebsd.org Tue Oct 11 07:44:28 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 41139C0DF9F; Tue, 11 Oct 2016 07:44:28 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 1B08CDFB; Tue, 11 Oct 2016 07:44:28 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9B7iRvB014874; Tue, 11 Oct 2016 07:44:27 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9B7iR6t014873; Tue, 11 Oct 2016 07:44:27 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610110744.u9B7iR6t014873@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Tue, 11 Oct 2016 07:44:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307024 - stable/10/sys/dev/hyperv/vmbus X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Oct 2016 07:44:28 -0000 Author: sephe Date: Tue Oct 11 07:44:26 2016 New Revision: 307024 URL: https://svnweb.freebsd.org/changeset/base/307024 Log: MFC 302710,302713 302710 hyperv/vmbus: Remove unnecessary callback check. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7046 302713 hyperv/vmbus: Install different task function for batch/non-batch channels This avoids bunch of unnecessary checks on hot path and simplifies the channel processing. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7085 Modified: stable/10/sys/dev/hyperv/vmbus/hv_channel.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/hyperv/vmbus/hv_channel.c ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/hv_channel.c Tue Oct 11 07:37:45 2016 (r307023) +++ stable/10/sys/dev/hyperv/vmbus/hv_channel.c Tue Oct 11 07:44:26 2016 (r307024) @@ -51,9 +51,10 @@ __FBSDID("$FreeBSD$"); #include static void vmbus_channel_set_event(hv_vmbus_channel* channel); -static void VmbusProcessChannelEvent(void* channel, int pending); static void vmbus_chan_update_evtflagcnt(struct vmbus_softc *, const struct hv_vmbus_channel *); +static void vmbus_chan_task(void *, int); +static void vmbus_chan_task_nobatch(void *, int); /** * @brief Trigger an event notification on the specified channel @@ -213,7 +214,13 @@ hv_vmbus_channel_open( new_channel->rxq = VMBUS_PCPU_GET(new_channel->vmbus_sc, event_tq, new_channel->target_cpu); - TASK_INIT(&new_channel->channel_task, 0, VmbusProcessChannelEvent, new_channel); + if (new_channel->ch_flags & VMBUS_CHAN_FLAG_BATCHREAD) { + TASK_INIT(&new_channel->channel_task, 0, + vmbus_chan_task, new_channel); + } else { + TASK_INIT(&new_channel->channel_task, 0, + vmbus_chan_task_nobatch, new_channel); + } /* Allocate the ring buffer */ out = contigmalloc((send_ring_buffer_size + recv_ring_buffer_size), @@ -846,46 +853,48 @@ hv_vmbus_channel_recv_packet_raw( return (0); } - -/** - * Process a channel event notification - */ static void -VmbusProcessChannelEvent(void* context, int pending) +vmbus_chan_task(void *xchan, int pending __unused) { - void* arg; - uint32_t bytes_to_read; - hv_vmbus_channel* channel = (hv_vmbus_channel*)context; - bool is_batched_reading = false; + struct hv_vmbus_channel *chan = xchan; + void (*callback)(void *); + void *arg; + + arg = chan->channel_callback_context; + callback = chan->on_channel_callback; + + /* + * Optimize host to guest signaling by ensuring: + * 1. While reading the channel, we disable interrupts from + * host. + * 2. Ensure that we process all posted messages from the host + * before returning from this callback. + * 3. Once we return, enable signaling from the host. Once this + * state is set we check to see if additional packets are + * available to read. In this case we repeat the process. + * + * NOTE: Interrupt has been disabled in the ISR. + */ + for (;;) { + uint32_t left; - if (channel->ch_flags & VMBUS_CHAN_FLAG_BATCHREAD) - is_batched_reading = true; + callback(arg); - if (channel->on_channel_callback != NULL) { - arg = channel->channel_callback_context; - /* - * Optimize host to guest signaling by ensuring: - * 1. While reading the channel, we disable interrupts from - * host. - * 2. Ensure that we process all posted messages from the host - * before returning from this callback. - * 3. Once we return, enable signaling from the host. Once this - * state is set we check to see if additional packets are - * available to read. In this case we repeat the process. - */ - do { - if (is_batched_reading) - hv_ring_buffer_read_begin(&channel->inbound); + left = hv_ring_buffer_read_end(&chan->inbound); + if (left == 0) { + /* No more data in RX bufring; done */ + break; + } + hv_ring_buffer_read_begin(&chan->inbound); + } +} - channel->on_channel_callback(arg); +static void +vmbus_chan_task_nobatch(void *xchan, int pending __unused) +{ + struct hv_vmbus_channel *chan = xchan; - if (is_batched_reading) - bytes_to_read = - hv_ring_buffer_read_end(&channel->inbound); - else - bytes_to_read = 0; - } while (is_batched_reading && (bytes_to_read != 0)); - } + chan->on_channel_callback(chan->channel_callback_context); } static __inline void From owner-svn-src-all@freebsd.org Tue Oct 11 07:50:11 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B96DCC0D155; Tue, 11 Oct 2016 07:50:11 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 947BF163; Tue, 11 Oct 2016 07:50:11 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9B7oA0F015445; Tue, 11 Oct 2016 07:50:10 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9B7o90c015436; Tue, 11 Oct 2016 07:50:09 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610110750.u9B7o90c015436@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Tue, 11 Oct 2016 07:50:09 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307025 - in stable/10/sys/dev/hyperv: include vmbus X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Oct 2016 07:50:11 -0000 Author: sephe Date: Tue Oct 11 07:50:09 2016 New Revision: 307025 URL: https://svnweb.freebsd.org/changeset/base/307025 Log: MFC 302723,302726,302731 302723 hyperv: All Hypercall parameters have same alignment requirement. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7086 302726 hyperv: Signal event input parameter is shared w/ MNF Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7087 302731 hyperv/vmbus: Reorganize MNF event sending. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7088 Modified: stable/10/sys/dev/hyperv/include/hyperv.h stable/10/sys/dev/hyperv/vmbus/hv_channel.c stable/10/sys/dev/hyperv/vmbus/hv_channel_mgmt.c stable/10/sys/dev/hyperv/vmbus/hyperv.c stable/10/sys/dev/hyperv/vmbus/hyperv_reg.h stable/10/sys/dev/hyperv/vmbus/hyperv_var.h stable/10/sys/dev/hyperv/vmbus/vmbus.c stable/10/sys/dev/hyperv/vmbus/vmbus_reg.h stable/10/sys/dev/hyperv/vmbus/vmbus_var.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/hyperv/include/hyperv.h ============================================================================== --- stable/10/sys/dev/hyperv/include/hyperv.h Tue Oct 11 07:44:26 2016 (r307024) +++ stable/10/sys/dev/hyperv/include/hyperv.h Tue Oct 11 07:50:09 2016 (r307025) @@ -523,12 +523,13 @@ typedef struct hv_vmbus_channel { hv_vmbus_channel_state state; uint32_t ch_flags; /* VMBUS_CHAN_FLAG_ */ uint32_t ch_id; /* channel id */ + /* * These are based on the offer_msg.monitor_id. * Save it here for easy access. */ - uint8_t monitor_group; - uint8_t monitor_bit; + int ch_montrig_idx; /* MNF trig index */ + uint32_t ch_montrig_mask;/* MNF trig mask */ uint32_t ring_buffer_gpadl_handle; /* @@ -551,8 +552,8 @@ typedef struct hv_vmbus_channel { hv_vmbus_pfn_channel_callback on_channel_callback; void* channel_callback_context; - struct hypercall_sigevt_in *ch_sigevt; - struct hyperv_dma ch_sigevt_dma; + struct hyperv_mon_param *ch_monprm; + struct hyperv_dma ch_monprm_dma; /* * From Win8, this field specifies the target virtual process Modified: stable/10/sys/dev/hyperv/vmbus/hv_channel.c ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/hv_channel.c Tue Oct 11 07:44:26 2016 (r307024) +++ stable/10/sys/dev/hyperv/vmbus/hv_channel.c Tue Oct 11 07:50:09 2016 (r307025) @@ -50,7 +50,7 @@ __FBSDID("$FreeBSD$"); #include #include -static void vmbus_channel_set_event(hv_vmbus_channel* channel); +static void vmbus_chan_send_event(hv_vmbus_channel* channel); static void vmbus_chan_update_evtflagcnt(struct vmbus_softc *, const struct hv_vmbus_channel *); static void vmbus_chan_task(void *, int); @@ -60,7 +60,7 @@ static void vmbus_chan_task_nobatch(void * @brief Trigger an event notification on the specified channel */ static void -vmbus_channel_set_event(hv_vmbus_channel *channel) +vmbus_chan_send_event(hv_vmbus_channel *channel) { struct vmbus_softc *sc = channel->vmbus_sc; uint32_t chanid = channel->ch_id; @@ -69,16 +69,12 @@ vmbus_channel_set_event(hv_vmbus_channel 1UL << (chanid & VMBUS_EVTFLAG_MASK)); if (channel->ch_flags & VMBUS_CHAN_FLAG_HASMNF) { - hv_vmbus_monitor_page *monitor_page; - - monitor_page = sc->vmbus_mnf2; - synch_set_bit(channel->monitor_bit, - (uint32_t *)&monitor_page-> - trigger_group[channel->monitor_group].u.pending); + atomic_set_int( + &sc->vmbus_mnf2->mnf_trigs[channel->ch_montrig_idx].mt_pending, + channel->ch_montrig_mask); } else { - hypercall_signal_event(channel->ch_sigevt_dma.hv_paddr); + hypercall_signal_event(channel->ch_monprm_dma.hv_paddr); } - } static int @@ -622,9 +618,8 @@ hv_vmbus_channel_send_packet( &need_sig); /* TODO: We should determine if this is optional */ - if (ret == 0 && need_sig) { - vmbus_channel_set_event(channel); - } + if (ret == 0 && need_sig) + vmbus_chan_send_event(channel); return (ret); } @@ -690,9 +685,8 @@ hv_vmbus_channel_send_packet_pagebuffer( &need_sig); /* TODO: We should determine if this is optional */ - if (ret == 0 && need_sig) { - vmbus_channel_set_event(channel); - } + if (ret == 0 && need_sig) + vmbus_chan_send_event(channel); return (ret); } @@ -766,9 +760,8 @@ hv_vmbus_channel_send_packet_multipagebu &need_sig); /* TODO: We should determine if this is optional */ - if (ret == 0 && need_sig) { - vmbus_channel_set_event(channel); - } + if (ret == 0 && need_sig) + vmbus_chan_send_event(channel); return (ret); } Modified: stable/10/sys/dev/hyperv/vmbus/hv_channel_mgmt.c ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/hv_channel_mgmt.c Tue Oct 11 07:44:26 2016 (r307024) +++ stable/10/sys/dev/hyperv/vmbus/hv_channel_mgmt.c Tue Oct 11 07:50:09 2016 (r307025) @@ -299,23 +299,29 @@ vmbus_channel_on_offer_internal(struct v if (offer->monitor_allocated) new_channel->ch_flags |= VMBUS_CHAN_FLAG_HASMNF; - new_channel->ch_sigevt = hyperv_dmamem_alloc( + new_channel->ch_monprm = hyperv_dmamem_alloc( bus_get_dma_tag(sc->vmbus_dev), - HYPERCALL_SIGEVTIN_ALIGN, 0, sizeof(struct hypercall_sigevt_in), - &new_channel->ch_sigevt_dma, BUS_DMA_WAITOK | BUS_DMA_ZERO); - if (new_channel->ch_sigevt == NULL) { - device_printf(sc->vmbus_dev, "sigevt alloc failed\n"); + HYPERCALL_PARAM_ALIGN, 0, sizeof(struct hyperv_mon_param), + &new_channel->ch_monprm_dma, BUS_DMA_WAITOK | BUS_DMA_ZERO); + if (new_channel->ch_monprm == NULL) { + device_printf(sc->vmbus_dev, "monprm alloc failed\n"); /* XXX */ mtx_destroy(&new_channel->sc_lock); free(new_channel, M_DEVBUF); return; } - new_channel->ch_sigevt->hc_connid = VMBUS_CONNID_EVENT; + new_channel->ch_monprm->mp_connid = VMBUS_CONNID_EVENT; if (sc->vmbus_version != VMBUS_VERSION_WS2008) - new_channel->ch_sigevt->hc_connid = offer->connection_id; + new_channel->ch_monprm->mp_connid = offer->connection_id; - new_channel->monitor_group = (uint8_t) offer->monitor_id / 32; - new_channel->monitor_bit = (uint8_t) offer->monitor_id % 32; + if (new_channel->ch_flags & VMBUS_CHAN_FLAG_HASMNF) { + new_channel->ch_montrig_idx = + offer->monitor_id / VMBUS_MONTRIG_LEN; + if (new_channel->ch_montrig_idx >= VMBUS_MONTRIGS_MAX) + panic("invalid monitor id %u", offer->monitor_id); + new_channel->ch_montrig_mask = + 1 << (offer->monitor_id % VMBUS_MONTRIG_LEN); + } /* Select default cpu for this channel. */ vmbus_channel_select_defcpu(new_channel); Modified: stable/10/sys/dev/hyperv/vmbus/hyperv.c ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/hyperv.c Tue Oct 11 07:44:26 2016 (r307024) +++ stable/10/sys/dev/hyperv/vmbus/hyperv.c Tue Oct 11 07:50:09 2016 (r307025) @@ -109,10 +109,10 @@ hypercall_post_message(bus_addr_t msg_pa } uint64_t -hypercall_signal_event(bus_addr_t sigevt_paddr) +hypercall_signal_event(bus_addr_t monprm_paddr) { return hypercall_md(hypercall_context.hc_addr, - HYPERCALL_SIGNAL_EVENT, sigevt_paddr, 0); + HYPERCALL_SIGNAL_EVENT, monprm_paddr, 0); } int Modified: stable/10/sys/dev/hyperv/vmbus/hyperv_reg.h ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/hyperv_reg.h Tue Oct 11 07:44:26 2016 (r307024) +++ stable/10/sys/dev/hyperv/vmbus/hyperv_reg.h Tue Oct 11 07:50:09 2016 (r307025) @@ -133,6 +133,15 @@ #define CPUID_LEAF_HV_HWFEATURES 0x40000006 /* + * Hyper-V Monitor Notification Facility + */ +struct hyperv_mon_param { + uint32_t mp_connid; + uint16_t mp_evtflag_ofs; + uint16_t mp_rsvd; +} __packed; + +/* * Hyper-V message types */ #define HYPERV_MSGTYPE_NONE 0 @@ -153,13 +162,22 @@ /* * Hypercall input parameters */ +#define HYPERCALL_PARAM_ALIGN 8 +#if 0 +/* + * XXX + * <> requires + * input parameters size to be multiple of 8, however, many post + * message input parameters do _not_ meet this requirement. + */ +#define HYPERCALL_PARAM_SIZE_ALIGN 8 +#endif /* * HYPERCALL_POST_MESSAGE */ #define HYPERCALL_POSTMSGIN_DSIZE_MAX 240 #define HYPERCALL_POSTMSGIN_SIZE 256 -#define HYPERCALL_POSTMSGIN_ALIGN 8 struct hypercall_postmsg_in { uint32_t hc_connid; @@ -172,13 +190,8 @@ CTASSERT(sizeof(struct hypercall_postmsg /* * HYPERCALL_SIGNAL_EVENT + * + * struct hyperv_mon_param. */ -#define HYPERCALL_SIGEVTIN_ALIGN 8 - -struct hypercall_sigevt_in { - uint32_t hc_connid; - uint16_t hc_evtflag_ofs; - uint16_t hc_rsvd; -} __packed; #endif /* !_HYPERV_REG_H_ */ Modified: stable/10/sys/dev/hyperv/vmbus/hyperv_var.h ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/hyperv_var.h Tue Oct 11 07:44:26 2016 (r307024) +++ stable/10/sys/dev/hyperv/vmbus/hyperv_var.h Tue Oct 11 07:50:09 2016 (r307025) @@ -41,6 +41,6 @@ extern u_int hyperv_features; extern u_int hyperv_recommends; uint64_t hypercall_post_message(bus_addr_t msg_paddr); -uint64_t hypercall_signal_event(bus_addr_t sigevt_paddr); +uint64_t hypercall_signal_event(bus_addr_t monprm_paddr); #endif /* !_HYPERV_VAR_H_ */ Modified: stable/10/sys/dev/hyperv/vmbus/vmbus.c ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/vmbus.c Tue Oct 11 07:44:26 2016 (r307024) +++ stable/10/sys/dev/hyperv/vmbus/vmbus.c Tue Oct 11 07:50:09 2016 (r307025) @@ -130,7 +130,7 @@ vmbus_msghc_alloc(bus_dma_tag_t parent_d mh = malloc(sizeof(*mh), M_DEVBUF, M_WAITOK | M_ZERO); mh->mh_inprm = hyperv_dmamem_alloc(parent_dtag, - HYPERCALL_POSTMSGIN_ALIGN, 0, HYPERCALL_POSTMSGIN_SIZE, + HYPERCALL_PARAM_ALIGN, 0, HYPERCALL_POSTMSGIN_SIZE, &mh->mh_inprm_dma, BUS_DMA_WAITOK); if (mh->mh_inprm == NULL) { free(mh, M_DEVBUF); @@ -835,7 +835,8 @@ vmbus_dma_alloc(struct vmbus_softc *sc) return ENOMEM; sc->vmbus_mnf2 = hyperv_dmamem_alloc(parent_dtag, PAGE_SIZE, 0, - PAGE_SIZE, &sc->vmbus_mnf2_dma, BUS_DMA_WAITOK | BUS_DMA_ZERO); + sizeof(struct vmbus_mnf), &sc->vmbus_mnf2_dma, + BUS_DMA_WAITOK | BUS_DMA_ZERO); if (sc->vmbus_mnf2 == NULL) return ENOMEM; Modified: stable/10/sys/dev/hyperv/vmbus/vmbus_reg.h ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/vmbus_reg.h Tue Oct 11 07:44:26 2016 (r307024) +++ stable/10/sys/dev/hyperv/vmbus/vmbus_reg.h Tue Oct 11 07:50:09 2016 (r307025) @@ -72,6 +72,34 @@ struct vmbus_evtflags { CTASSERT(sizeof(struct vmbus_evtflags) == VMBUS_EVTFLAGS_SIZE); /* + * Hyper-V Monitor Notification Facility + */ + +struct vmbus_mon_trig { + uint32_t mt_pending; + uint32_t mt_armed; +} __packed; + +#define VMBUS_MONTRIGS_MAX 4 +#define VMBUS_MONTRIG_LEN 32 + +struct vmbus_mnf { + uint32_t mnf_state; + uint32_t mnf_rsvd1; + + struct vmbus_mon_trig mnf_trigs[VMBUS_MONTRIGS_MAX]; + uint8_t mnf_rsvd2[536]; + + uint16_t mnf_lat[VMBUS_MONTRIGS_MAX][VMBUS_MONTRIG_LEN]; + uint8_t mnf_rsvd3[256]; + + struct hyperv_mon_param + mnf_param[VMBUS_MONTRIGS_MAX][VMBUS_MONTRIG_LEN]; + uint8_t mnf_rsvd4[1984]; +} __packed; +CTASSERT(sizeof(struct vmbus_mnf) == PAGE_SIZE); + +/* * Channel */ Modified: stable/10/sys/dev/hyperv/vmbus/vmbus_var.h ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/vmbus_var.h Tue Oct 11 07:44:26 2016 (r307024) +++ stable/10/sys/dev/hyperv/vmbus/vmbus_var.h Tue Oct 11 07:50:09 2016 (r307025) @@ -70,7 +70,7 @@ struct vmbus_softc { void (*vmbus_event_proc)(struct vmbus_softc *, int); u_long *vmbus_tx_evtflags; /* event flags to host */ - void *vmbus_mnf2; /* monitored by host */ + struct vmbus_mnf *vmbus_mnf2; /* monitored by host */ u_long *vmbus_rx_evtflags; /* compat evtflgs from host */ From owner-svn-src-all@freebsd.org Tue Oct 11 08:01:46 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E192DC0D689; Tue, 11 Oct 2016 08:01:45 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 7F6FBA71; Tue, 11 Oct 2016 08:01:45 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9B81iJq019924; Tue, 11 Oct 2016 08:01:44 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9B81hjB019910; Tue, 11 Oct 2016 08:01:43 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610110801.u9B81hjB019910@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Tue, 11 Oct 2016 08:01:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307026 - in stable/10/sys/dev/hyperv: include netvsc storvsc utilities vmbus X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Oct 2016 08:01:46 -0000 Author: sephe Date: Tue Oct 11 08:01:43 2016 New Revision: 307026 URL: https://svnweb.freebsd.org/changeset/base/307026 Log: MFC 302733,302737,302801-302806 302733 hyperv/vmbus: Remove unused code Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7089 302737 hyperv/vmbus: Cleanup channel rescind Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7090 302801 hyperv/vmbus: Remove unused bits Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7091 302802 hyperv: hv_guid -> struct hyperv_guid. This paves way for the further cleanup/disentangle. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7092 302803 hyperv/vmbus: Move channel offer message definition to vmbus_reg.h - Avoid bit fields. - Avoid unnecessary indirection. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7093 302804 hyperv/vmbus: Switch to vmbus channel message macros Prepare for more cleanup. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7094 302805 hyperv/vmbus: Remove unused bits Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7095 302806 hyperv/vmbus: Get rid of rel{_id,id}, use channel id consistently. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7100 Modified: stable/10/sys/dev/hyperv/include/hyperv.h stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c stable/10/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c stable/10/sys/dev/hyperv/utilities/hv_heartbeat.c stable/10/sys/dev/hyperv/utilities/hv_kvp.c stable/10/sys/dev/hyperv/utilities/hv_shutdown.c stable/10/sys/dev/hyperv/utilities/hv_timesync.c stable/10/sys/dev/hyperv/vmbus/hv_channel.c stable/10/sys/dev/hyperv/vmbus/hv_channel_mgmt.c stable/10/sys/dev/hyperv/vmbus/hv_vmbus_priv.h stable/10/sys/dev/hyperv/vmbus/hyperv.c stable/10/sys/dev/hyperv/vmbus/vmbus.c stable/10/sys/dev/hyperv/vmbus/vmbus_if.m stable/10/sys/dev/hyperv/vmbus/vmbus_reg.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/hyperv/include/hyperv.h ============================================================================== --- stable/10/sys/dev/hyperv/include/hyperv.h Tue Oct 11 07:50:09 2016 (r307025) +++ stable/10/sys/dev/hyperv/include/hyperv.h Tue Oct 11 08:01:43 2016 (r307026) @@ -82,32 +82,6 @@ typedef uint8_t hv_bool_uint8_t; #define VMBUS_VERSION_MAJOR(ver) (((uint32_t)(ver)) >> 16) #define VMBUS_VERSION_MINOR(ver) (((uint32_t)(ver)) & 0xffff) -/* - * Make maximum size of pipe payload of 16K - */ - -#define HV_MAX_PIPE_DATA_PAYLOAD (sizeof(BYTE) * 16384) - -/* - * Define pipe_mode values - */ - -#define HV_VMBUS_PIPE_TYPE_BYTE 0x00000000 -#define HV_VMBUS_PIPE_TYPE_MESSAGE 0x00000004 - -/* - * The size of the user defined data buffer for non-pipe offers - */ - -#define HV_MAX_USER_DEFINED_BYTES 120 - -/* - * The size of the user defined data buffer for pipe offers - */ - -#define HV_MAX_PIPE_USER_DEFINED_BYTES 116 - - #define HV_MAX_PAGE_BUFFER_COUNT 32 #define HV_MAX_MULTIPAGE_BUFFER_COUNT 32 @@ -121,68 +95,13 @@ typedef uint8_t hv_bool_uint8_t; ((HV_ALIGN_UP(addr+len, PAGE_SIZE) - \ HV_ALIGN_DOWN(addr, PAGE_SIZE)) >> PAGE_SHIFT ) -typedef struct hv_guid { - uint8_t data[16]; -} __packed hv_guid; +struct hyperv_guid { + uint8_t hv_guid[16]; +} __packed; #define HYPERV_GUID_STRLEN 40 -int hyperv_guid2str(const struct hv_guid *, char *, size_t); - -#define HV_NIC_GUID \ - .data = {0x63, 0x51, 0x61, 0xF8, 0x3E, 0xDF, 0xc5, 0x46, \ - 0x91, 0x3F, 0xF2, 0xD2, 0xF9, 0x65, 0xED, 0x0E} - -#define HV_IDE_GUID \ - .data = {0x32, 0x26, 0x41, 0x32, 0xcb, 0x86, 0xa2, 0x44, \ - 0x9b, 0x5c, 0x50, 0xd1, 0x41, 0x73, 0x54, 0xf5} - -#define HV_SCSI_GUID \ - .data = {0xd9, 0x63, 0x61, 0xba, 0xa1, 0x04, 0x29, 0x4d, \ - 0xb6, 0x05, 0x72, 0xe2, 0xff, 0xb1, 0xdc, 0x7f} - -/* - * At the center of the Channel Management library is - * the Channel Offer. This struct contains the - * fundamental information about an offer. - */ - -typedef struct hv_vmbus_channel_offer { - hv_guid interface_type; - hv_guid interface_instance; - uint64_t interrupt_latency_in_100ns_units; - uint32_t interface_revision; - uint32_t server_context_area_size; /* in bytes */ - uint16_t channel_flags; - uint16_t mmio_megabytes; /* in bytes * 1024 * 1024 */ - union - { - /* - * Non-pipes: The user has HV_MAX_USER_DEFINED_BYTES bytes. - */ - struct { - uint8_t user_defined[HV_MAX_USER_DEFINED_BYTES]; - } __packed standard; - - /* - * Pipes: The following structure is an integrated pipe protocol, which - * is implemented on top of standard user-defined data. pipe - * clients have HV_MAX_PIPE_USER_DEFINED_BYTES left for their - * own use. - */ - struct { - uint32_t pipe_mode; - uint8_t user_defined[HV_MAX_PIPE_USER_DEFINED_BYTES]; - } __packed pipe; - } u; - - /* - * Sub_channel_index, newly added in Win8. - */ - uint16_t sub_channel_index; - uint16_t padding; - -} __packed hv_vmbus_channel_offer; +int hyperv_guid2str(const struct hyperv_guid *, char *, size_t); typedef struct { uint16_t type; @@ -192,13 +111,6 @@ typedef struct { uint64_t transaction_id; } __packed hv_vm_packet_descriptor; -typedef uint32_t hv_previous_packet_offset; - -typedef struct { - hv_previous_packet_offset previous_packet_start_offset; - hv_vm_packet_descriptor descriptor; -} __packed hv_vm_packet_header; - typedef struct { uint32_t byte_count; uint32_t byte_offset; @@ -213,91 +125,6 @@ typedef struct { hv_vm_transfer_page ranges[1]; } __packed hv_vm_transfer_page_packet_header; -typedef struct { - hv_vm_packet_descriptor d; - uint32_t gpadl; - uint32_t reserved; -} __packed hv_vm_gpadl_packet_header; - -typedef struct { - hv_vm_packet_descriptor d; - uint32_t gpadl; - uint16_t transfer_page_set_id; - uint16_t reserved; -} __packed hv_vm_add_remove_transfer_page_set; - -/* - * This structure defines a range in guest - * physical space that can be made - * to look virtually contiguous. - */ - -typedef struct { - uint32_t byte_count; - uint32_t byte_offset; - uint64_t pfn_array[0]; -} __packed hv_gpa_range; - -/* - * This is the format for an Establish Gpadl packet, which contains a handle - * by which this GPADL will be known and a set of GPA ranges associated with - * it. This can be converted to a MDL by the guest OS. If there are multiple - * GPA ranges, then the resulting MDL will be "chained," representing multiple - * VA ranges. - */ - -typedef struct { - hv_vm_packet_descriptor d; - uint32_t gpadl; - uint32_t range_count; - hv_gpa_range range[1]; -} __packed hv_vm_establish_gpadl; - -/* - * This is the format for a Teardown Gpadl packet, which indicates that the - * GPADL handle in the Establish Gpadl packet will never be referenced again. - */ - -typedef struct { - hv_vm_packet_descriptor d; - uint32_t gpadl; - /* for alignment to a 8-byte boundary */ - uint32_t reserved; -} __packed hv_vm_teardown_gpadl; - -/* - * This is the format for a GPA-Direct packet, which contains a set of GPA - * ranges, in addition to commands and/or data. - */ - -typedef struct { - hv_vm_packet_descriptor d; - uint32_t reserved; - uint32_t range_count; - hv_gpa_range range[1]; -} __packed hv_vm_data_gpa_direct; - -/* - * This is the format for a Additional data Packet. - */ -typedef struct { - hv_vm_packet_descriptor d; - uint64_t total_bytes; - uint32_t byte_offset; - uint32_t byte_count; - uint8_t data[1]; -} __packed hv_vm_additional_data; - -typedef union { - hv_vm_packet_descriptor simple_header; - hv_vm_transfer_page_packet_header transfer_page_header; - hv_vm_gpadl_packet_header gpadl_header; - hv_vm_add_remove_transfer_page_set add_remove_transfer_page_header; - hv_vm_establish_gpadl establish_gpadl_header; - hv_vm_teardown_gpadl teardown_gpadl_header; - hv_vm_data_gpa_direct data_gpa_direct_header; -} __packed hv_vm_packet_largest_possible_header; - typedef enum { HV_VMBUS_PACKET_TYPE_INVALID = 0x0, HV_VMBUS_PACKET_TYPES_SYNCH = 0x1, @@ -317,86 +144,6 @@ typedef enum { #define HV_VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED 1 -/* - * Version 1 messages - */ -typedef enum { - HV_CHANNEL_MESSAGE_INVALID = 0, - HV_CHANNEL_MESSAGE_OFFER_CHANNEL = 1, - HV_CHANNEL_MESSAGE_RESCIND_CHANNEL_OFFER = 2, - HV_CHANNEL_MESSAGE_REQUEST_OFFERS = 3, - HV_CHANNEL_MESSAGE_ALL_OFFERS_DELIVERED = 4, - HV_CHANNEL_MESSAGE_OPEN_CHANNEL = 5, - HV_CHANNEL_MESSAGE_OPEN_CHANNEL_RESULT = 6, - HV_CHANNEL_MESSAGE_CLOSE_CHANNEL = 7, - HV_CHANNEL_MESSAGEL_GPADL_HEADER = 8, - HV_CHANNEL_MESSAGE_GPADL_BODY = 9, - HV_CHANNEL_MESSAGE_GPADL_CREATED = 10, - HV_CHANNEL_MESSAGE_GPADL_TEARDOWN = 11, - HV_CHANNEL_MESSAGE_GPADL_TORNDOWN = 12, - HV_CHANNEL_MESSAGE_REL_ID_RELEASED = 13, - HV_CHANNEL_MESSAGE_INITIATED_CONTACT = 14, - HV_CHANNEL_MESSAGE_VERSION_RESPONSE = 15, - HV_CHANNEL_MESSAGE_UNLOAD = 16, - HV_CHANNEL_MESSAGE_COUNT -} hv_vmbus_channel_msg_type; - -typedef struct { - hv_vmbus_channel_msg_type message_type; - uint32_t padding; -} __packed hv_vmbus_channel_msg_header; - -/* - * Query VMBus Version parameters - */ -typedef struct { - hv_vmbus_channel_msg_header header; - uint32_t version; -} __packed hv_vmbus_channel_query_vmbus_version; - -/* - * Channel Offer parameters - */ -typedef struct { - hv_vmbus_channel_msg_header header; - hv_vmbus_channel_offer offer; - uint32_t child_rel_id; - uint8_t monitor_id; - /* - * This field has been split into a bit field on Win7 - * and higher. - */ - uint8_t monitor_allocated:1; - uint8_t reserved:7; - /* - * Following fields were added in win7 and higher. - * Make sure to check the version before accessing these fields. - * - * If "is_dedicated_interrupt" is set, we must not set the - * associated bit in the channel bitmap while sending the - * interrupt to the host. - * - * connection_id is used in signaling the host. - */ - uint16_t is_dedicated_interrupt:1; - uint16_t reserved1:15; - uint32_t connection_id; -} __packed hv_vmbus_channel_offer_channel; - -/* - * Rescind Offer parameters - */ -typedef struct -{ - hv_vmbus_channel_msg_header header; - uint32_t child_rel_id; -} __packed hv_vmbus_channel_rescind_offer; - -typedef struct { - hv_vmbus_channel_msg_header header; - uint32_t child_rel_id; -} __packed hv_vmbus_channel_relid_released; - #define HW_MACADDR_LEN 6 /* @@ -505,18 +252,6 @@ typedef enum { HV_CHANNEL_CLOSING_NONDESTRUCTIVE_STATE, } hv_vmbus_channel_state; -/* - * Connection identifier type - */ -typedef union { - uint32_t as_uint32_t; - struct { - uint32_t id:24; - uint32_t reserved:8; - } u; - -} __packed hv_vmbus_connection_id; - typedef struct hv_vmbus_channel { device_t ch_dev; struct vmbus_softc *vmbus_sc; @@ -603,8 +338,8 @@ typedef struct hv_vmbus_channel { TAILQ_ENTRY(hv_vmbus_channel) ch_link; uint32_t ch_subidx; /* subchan index */ - struct hv_guid ch_guid_type; - struct hv_guid ch_guid_inst; + struct hyperv_guid ch_guid_type; + struct hyperv_guid ch_guid_inst; struct sysctl_ctx_list ch_sysctl_ctx; } hv_vmbus_channel; Modified: stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Tue Oct 11 07:50:09 2016 (r307025) +++ stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Tue Oct 11 08:01:43 2016 (r307026) @@ -403,8 +403,8 @@ hn_ifmedia_sts(struct ifnet *ifp, struct } /* {F8615163-DF3E-46c5-913F-F2D2F965ED0E} */ -static const hv_guid g_net_vsc_device_type = { - .data = {0x63, 0x51, 0x61, 0xF8, 0x3E, 0xDF, 0xc5, 0x46, +static const struct hyperv_guid g_net_vsc_device_type = { + .hv_guid = {0x63, 0x51, 0x61, 0xF8, 0x3E, 0xDF, 0xc5, 0x46, 0x91, 0x3F, 0xF2, 0xD2, 0xF9, 0x65, 0xED, 0x0E} }; Modified: stable/10/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c ============================================================================== --- stable/10/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c Tue Oct 11 07:50:09 2016 (r307025) +++ stable/10/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c Tue Oct 11 08:01:43 2016 (r307026) @@ -180,14 +180,14 @@ enum hv_storage_type { #define HV_STORAGE_SUPPORTS_MULTI_CHANNEL 0x1 /* {ba6163d9-04a1-4d29-b605-72e2ffb1dc7f} */ -static const hv_guid gStorVscDeviceType={ - .data = {0xd9, 0x63, 0x61, 0xba, 0xa1, 0x04, 0x29, 0x4d, +static const struct hyperv_guid gStorVscDeviceType={ + .hv_guid = {0xd9, 0x63, 0x61, 0xba, 0xa1, 0x04, 0x29, 0x4d, 0xb6, 0x05, 0x72, 0xe2, 0xff, 0xb1, 0xdc, 0x7f} }; /* {32412632-86cb-44a2-9b5c-50d1417354f5} */ -static const hv_guid gBlkVscDeviceType={ - .data = {0x32, 0x26, 0x41, 0x32, 0xcb, 0x86, 0xa2, 0x44, +static const struct hyperv_guid gBlkVscDeviceType={ + .hv_guid = {0x32, 0x26, 0x41, 0x32, 0xcb, 0x86, 0xa2, 0x44, 0x9b, 0x5c, 0x50, 0xd1, 0x41, 0x73, 0x54, 0xf5} }; Modified: stable/10/sys/dev/hyperv/utilities/hv_heartbeat.c ============================================================================== --- stable/10/sys/dev/hyperv/utilities/hv_heartbeat.c Tue Oct 11 07:50:09 2016 (r307025) +++ stable/10/sys/dev/hyperv/utilities/hv_heartbeat.c Tue Oct 11 08:01:43 2016 (r307026) @@ -39,7 +39,7 @@ #include "vmbus_if.h" /* Heartbeat Service */ -static const hv_guid service_guid = { .data = +static const struct hyperv_guid service_guid = { .hv_guid = {0x39, 0x4f, 0x16, 0x57, 0x15, 0x91, 0x78, 0x4e, 0xab, 0x55, 0x38, 0x2f, 0x3b, 0xd5, 0x42, 0x2d} }; Modified: stable/10/sys/dev/hyperv/utilities/hv_kvp.c ============================================================================== --- stable/10/sys/dev/hyperv/utilities/hv_kvp.c Tue Oct 11 07:50:09 2016 (r307025) +++ stable/10/sys/dev/hyperv/utilities/hv_kvp.c Tue Oct 11 08:01:43 2016 (r307026) @@ -90,7 +90,7 @@ static int hv_kvp_log = 0; log(LOG_INFO, "hv_kvp: " __VA_ARGS__); \ } while (0) -static const hv_guid service_guid = { .data = +static const struct hyperv_guid service_guid = { .hv_guid = {0xe7, 0xf4, 0xa0, 0xa9, 0x45, 0x5a, 0x96, 0x4d, 0xb8, 0x27, 0x8a, 0x84, 0x1e, 0x8c, 0x3, 0xe6} }; Modified: stable/10/sys/dev/hyperv/utilities/hv_shutdown.c ============================================================================== --- stable/10/sys/dev/hyperv/utilities/hv_shutdown.c Tue Oct 11 07:50:09 2016 (r307025) +++ stable/10/sys/dev/hyperv/utilities/hv_shutdown.c Tue Oct 11 08:01:43 2016 (r307026) @@ -43,7 +43,7 @@ #include "hv_util.h" #include "vmbus_if.h" -static const hv_guid service_guid = { .data = +static const struct hyperv_guid service_guid = { .hv_guid = {0x31, 0x60, 0x0B, 0X0E, 0x13, 0x52, 0x34, 0x49, 0x81, 0x8B, 0x38, 0XD9, 0x0C, 0xED, 0x39, 0xDB} }; Modified: stable/10/sys/dev/hyperv/utilities/hv_timesync.c ============================================================================== --- stable/10/sys/dev/hyperv/utilities/hv_timesync.c Tue Oct 11 07:50:09 2016 (r307025) +++ stable/10/sys/dev/hyperv/utilities/hv_timesync.c Tue Oct 11 08:01:43 2016 (r307026) @@ -55,7 +55,7 @@ typedef struct { } time_sync_data; /* Time Synch Service */ -static const hv_guid service_guid = {.data = +static const struct hyperv_guid service_guid = {.hv_guid = {0x30, 0xe6, 0x27, 0x95, 0xae, 0xd0, 0x7b, 0x49, 0xad, 0xce, 0xe8, 0x0a, 0xb0, 0x17, 0x5c, 0xaf } }; Modified: stable/10/sys/dev/hyperv/vmbus/hv_channel.c ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/hv_channel.c Tue Oct 11 07:50:09 2016 (r307025) +++ stable/10/sys/dev/hyperv/vmbus/hv_channel.c Tue Oct 11 08:01:43 2016 (r307026) @@ -897,25 +897,23 @@ vmbus_event_flags_proc(struct vmbus_soft int f; for (f = 0; f < flag_cnt; ++f) { - uint32_t rel_id_base; + uint32_t chid_base; u_long flags; - int bit; + int chid_ofs; if (event_flags[f] == 0) continue; flags = atomic_swap_long(&event_flags[f], 0); - rel_id_base = f << VMBUS_EVTFLAG_SHIFT; + chid_base = f << VMBUS_EVTFLAG_SHIFT; - while ((bit = ffsl(flags)) != 0) { + while ((chid_ofs = ffsl(flags)) != 0) { struct hv_vmbus_channel *channel; - uint32_t rel_id; - --bit; /* NOTE: ffsl is 1-based */ - flags &= ~(1UL << bit); + --chid_ofs; /* NOTE: ffsl is 1-based */ + flags &= ~(1UL << chid_ofs); - rel_id = rel_id_base + bit; - channel = sc->vmbus_chmap[rel_id]; + channel = sc->vmbus_chmap[chid_base + chid_ofs]; /* if channel is closed or closing */ if (channel == NULL || channel->rxq == NULL) Modified: stable/10/sys/dev/hyperv/vmbus/hv_channel_mgmt.c ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/hv_channel_mgmt.c Tue Oct 11 07:50:09 2016 (r307025) +++ stable/10/sys/dev/hyperv/vmbus/hv_channel_mgmt.c Tue Oct 11 08:01:43 2016 (r307026) @@ -45,37 +45,40 @@ typedef void (*vmbus_chanmsg_proc_t) static struct hv_vmbus_channel *hv_vmbus_allocate_channel(struct vmbus_softc *); static void vmbus_channel_on_offer_internal(struct vmbus_softc *, - const hv_vmbus_channel_offer_channel *offer); + const struct vmbus_chanmsg_choffer *); static void vmbus_chan_detach_task(void *, int); static void vmbus_channel_on_offer(struct vmbus_softc *, const struct vmbus_message *); -static void vmbus_channel_on_offer_rescind(struct vmbus_softc *, - const struct vmbus_message *); static void vmbus_channel_on_offers_delivered(struct vmbus_softc *, const struct vmbus_message *); +static void vmbus_chan_msgproc_chrescind(struct vmbus_softc *, + const struct vmbus_message *); -/** - * Channel message dispatch table +/* + * Vmbus channel message processing. */ + +#define VMBUS_CHANMSG_PROC(name, func) \ + [VMBUS_CHANMSG_TYPE_##name] = func +#define VMBUS_CHANMSG_PROC_WAKEUP(name) \ + VMBUS_CHANMSG_PROC(name, vmbus_msghc_wakeup) + static const vmbus_chanmsg_proc_t -vmbus_chanmsg_process[HV_CHANNEL_MESSAGE_COUNT] = { - [HV_CHANNEL_MESSAGE_OFFER_CHANNEL] = - vmbus_channel_on_offer, - [HV_CHANNEL_MESSAGE_RESCIND_CHANNEL_OFFER] = - vmbus_channel_on_offer_rescind, - [HV_CHANNEL_MESSAGE_ALL_OFFERS_DELIVERED] = - vmbus_channel_on_offers_delivered, - [HV_CHANNEL_MESSAGE_OPEN_CHANNEL_RESULT] = - vmbus_msghc_wakeup, - [HV_CHANNEL_MESSAGE_GPADL_CREATED] = - vmbus_msghc_wakeup, - [HV_CHANNEL_MESSAGE_GPADL_TORNDOWN] = - vmbus_msghc_wakeup, - [HV_CHANNEL_MESSAGE_VERSION_RESPONSE] = - vmbus_msghc_wakeup +vmbus_chanmsg_process[VMBUS_CHANMSG_TYPE_MAX] = { + VMBUS_CHANMSG_PROC(CHOFFER, vmbus_channel_on_offer), + VMBUS_CHANMSG_PROC(CHRESCIND, vmbus_chan_msgproc_chrescind), + VMBUS_CHANMSG_PROC(CHOFFER_DONE,vmbus_channel_on_offers_delivered), + + VMBUS_CHANMSG_PROC_WAKEUP(CHOPEN_RESP), + VMBUS_CHANMSG_PROC_WAKEUP(GPADL_CONNRESP), + VMBUS_CHANMSG_PROC_WAKEUP(GPADL_DISCONNRESP), + VMBUS_CHANMSG_PROC_WAKEUP(CONNECT_RESP) }; +#undef VMBUS_CHANMSG_PROC_WAKEUP +#undef VMBUS_CHANMSG_PROC + /** * @brief Allocate and initialize a vmbus channel object */ @@ -113,27 +116,25 @@ vmbus_channel_process_offer(hv_vmbus_cha { struct vmbus_softc *sc = new_channel->vmbus_sc; hv_vmbus_channel* channel; - uint32_t relid; - relid = new_channel->ch_id; /* * Make sure this is a new offer */ mtx_lock(&sc->vmbus_chlist_lock); - if (relid == 0) { + if (new_channel->ch_id == 0) { /* * XXX channel0 will not be processed; skip it. */ printf("VMBUS: got channel0 offer\n"); } else { - sc->vmbus_chmap[relid] = new_channel; + sc->vmbus_chmap[new_channel->ch_id] = new_channel; } TAILQ_FOREACH(channel, &sc->vmbus_chlist, ch_link) { if (memcmp(&channel->ch_guid_type, &new_channel->ch_guid_type, - sizeof(hv_guid)) == 0 && + sizeof(struct hyperv_guid)) == 0 && memcmp(&channel->ch_guid_inst, &new_channel->ch_guid_inst, - sizeof(hv_guid)) == 0) + sizeof(struct hyperv_guid)) == 0) break; } @@ -270,18 +271,16 @@ vmbus_channel_select_defcpu(struct hv_vm static void vmbus_channel_on_offer(struct vmbus_softc *sc, const struct vmbus_message *msg) { - const hv_vmbus_channel_offer_channel *offer; - /* New channel is offered by vmbus */ vmbus_scan_newchan(sc); - offer = (const hv_vmbus_channel_offer_channel *)msg->msg_data; - vmbus_channel_on_offer_internal(sc, offer); + vmbus_channel_on_offer_internal(sc, + (const struct vmbus_chanmsg_choffer *)msg->msg_data); } static void vmbus_channel_on_offer_internal(struct vmbus_softc *sc, - const hv_vmbus_channel_offer_channel *offer) + const struct vmbus_chanmsg_choffer *offer) { hv_vmbus_channel* new_channel; @@ -289,14 +288,14 @@ vmbus_channel_on_offer_internal(struct v * Allocate the channel object and save this offer */ new_channel = hv_vmbus_allocate_channel(sc); - new_channel->ch_id = offer->child_rel_id; - new_channel->ch_subidx = offer->offer.sub_channel_index; - new_channel->ch_guid_type = offer->offer.interface_type; - new_channel->ch_guid_inst = offer->offer.interface_instance; + new_channel->ch_id = offer->chm_chanid; + new_channel->ch_subidx = offer->chm_subidx; + new_channel->ch_guid_type = offer->chm_chtype; + new_channel->ch_guid_inst = offer->chm_chinst; /* Batch reading is on by default */ new_channel->ch_flags |= VMBUS_CHAN_FLAG_BATCHREAD; - if (offer->monitor_allocated) + if (offer->chm_flags1 & VMBUS_CHOFFER_FLAG1_HASMNF) new_channel->ch_flags |= VMBUS_CHAN_FLAG_HASMNF; new_channel->ch_monprm = hyperv_dmamem_alloc( @@ -312,15 +311,15 @@ vmbus_channel_on_offer_internal(struct v } new_channel->ch_monprm->mp_connid = VMBUS_CONNID_EVENT; if (sc->vmbus_version != VMBUS_VERSION_WS2008) - new_channel->ch_monprm->mp_connid = offer->connection_id; + new_channel->ch_monprm->mp_connid = offer->chm_connid; if (new_channel->ch_flags & VMBUS_CHAN_FLAG_HASMNF) { new_channel->ch_montrig_idx = - offer->monitor_id / VMBUS_MONTRIG_LEN; + offer->chm_montrig / VMBUS_MONTRIG_LEN; if (new_channel->ch_montrig_idx >= VMBUS_MONTRIGS_MAX) - panic("invalid monitor id %u", offer->monitor_id); + panic("invalid monitor trigger %u", offer->chm_montrig); new_channel->ch_montrig_mask = - 1 << (offer->monitor_id % VMBUS_MONTRIG_LEN); + 1 << (offer->chm_montrig % VMBUS_MONTRIG_LEN); } /* Select default cpu for this channel. */ @@ -329,33 +328,34 @@ vmbus_channel_on_offer_internal(struct v vmbus_channel_process_offer(new_channel); } -/** - * @brief Rescind offer handler. - * - * We queue a work item to process this offer - * synchronously. - * +/* * XXX pretty broken; need rework. */ static void -vmbus_channel_on_offer_rescind(struct vmbus_softc *sc, +vmbus_chan_msgproc_chrescind(struct vmbus_softc *sc, const struct vmbus_message *msg) { - const hv_vmbus_channel_rescind_offer *rescind; - hv_vmbus_channel* channel; + const struct vmbus_chanmsg_chrescind *note; + struct hv_vmbus_channel *chan; + + note = (const struct vmbus_chanmsg_chrescind *)msg->msg_data; + if (note->chm_chanid > VMBUS_CHAN_MAX) { + device_printf(sc->vmbus_dev, "invalid rescinded chan%u\n", + note->chm_chanid); + return; + } - rescind = (const hv_vmbus_channel_rescind_offer *)msg->msg_data; if (bootverbose) { - device_printf(sc->vmbus_dev, "chan%u rescind\n", - rescind->child_rel_id); + device_printf(sc->vmbus_dev, "chan%u rescinded\n", + note->chm_chanid); } - channel = sc->vmbus_chmap[rescind->child_rel_id]; - if (channel == NULL) - return; - sc->vmbus_chmap[rescind->child_rel_id] = NULL; + chan = sc->vmbus_chmap[note->chm_chanid]; + if (chan == NULL) + return; + sc->vmbus_chmap[note->chm_chanid] = NULL; - taskqueue_enqueue(taskqueue_thread, &channel->ch_detach_task); + taskqueue_enqueue(taskqueue_thread, &chan->ch_detach_task); } static void @@ -566,7 +566,7 @@ vmbus_chan_msgproc(struct vmbus_softc *s uint32_t msg_type; msg_type = ((const struct vmbus_chanmsg_hdr *)msg->msg_data)->chm_type; - if (msg_type >= HV_CHANNEL_MESSAGE_COUNT) { + if (msg_type >= VMBUS_CHANMSG_TYPE_MAX) { device_printf(sc->vmbus_dev, "unknown message type 0x%x\n", msg_type); return; Modified: stable/10/sys/dev/hyperv/vmbus/hv_vmbus_priv.h ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/hv_vmbus_priv.h Tue Oct 11 07:50:09 2016 (r307025) +++ stable/10/sys/dev/hyperv/vmbus/hv_vmbus_priv.h Tue Oct 11 08:01:43 2016 (r307026) @@ -56,8 +56,8 @@ typedef struct { typedef struct { uint32_t rel_id; hv_vmbus_channel_state state; - hv_guid interface_type; - hv_guid interface_instance; + struct hyperv_guid interface_type; + struct hyperv_guid interface_instance; uint32_t monitor_id; uint32_t server_monitor_pending; uint32_t server_monitor_latency; @@ -97,67 +97,6 @@ typedef struct hv_vmbus_channel_packet_m hv_vmbus_multipage_buffer range; } __packed hv_vmbus_channel_packet_multipage_buffer; -typedef union { - uint32_t as_uint32_t; - struct { - uint32_t group_enable :4; - uint32_t rsvd_z :28; - } u; -} hv_vmbus_monitor_trigger_state; - -typedef union { - uint64_t as_uint64_t; - struct { - uint32_t pending; - uint32_t armed; - } u; -} hv_vmbus_monitor_trigger_group; - -typedef struct { - hv_vmbus_connection_id connection_id; - uint16_t flag_number; - uint16_t rsvd_z; -} hv_vmbus_monitor_parameter; - -/* - * hv_vmbus_monitor_page Layout - * ------------------------------------------------------ - * | 0 | trigger_state (4 bytes) | Rsvd1 (4 bytes) | - * | 8 | trigger_group[0] | - * | 10 | trigger_group[1] | - * | 18 | trigger_group[2] | - * | 20 | trigger_group[3] | - * | 28 | Rsvd2[0] | - * | 30 | Rsvd2[1] | - * | 38 | Rsvd2[2] | - * | 40 | next_check_time[0][0] | next_check_time[0][1] | - * | ... | - * | 240 | latency[0][0..3] | - * | 340 | Rsvz3[0] | - * | 440 | parameter[0][0] | - * | 448 | parameter[0][1] | - * | ... | - * | 840 | Rsvd4[0] | - * ------------------------------------------------------ - */ - -typedef struct { - hv_vmbus_monitor_trigger_state trigger_state; - uint32_t rsvd_z1; - - hv_vmbus_monitor_trigger_group trigger_group[4]; - uint64_t rsvd_z2[3]; - - int32_t next_check_time[4][32]; - - uint16_t latency[4][32]; - uint64_t rsvd_z3[32]; - - hv_vmbus_monitor_parameter parameter[4][32]; - - uint8_t rsvd_z4[1984]; -} hv_vmbus_monitor_page; - /* * Private, VM Bus functions */ Modified: stable/10/sys/dev/hyperv/vmbus/hyperv.c ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/hyperv.c Tue Oct 11 07:50:09 2016 (r307025) +++ stable/10/sys/dev/hyperv/vmbus/hyperv.c Tue Oct 11 08:01:43 2016 (r307026) @@ -116,9 +116,9 @@ hypercall_signal_event(bus_addr_t monprm } int -hyperv_guid2str(const struct hv_guid *guid, char *buf, size_t sz) +hyperv_guid2str(const struct hyperv_guid *guid, char *buf, size_t sz) { - const uint8_t *d = guid->data; + const uint8_t *d = guid->hv_guid; return snprintf(buf, sz, "%02x%02x%02x%02x-" "%02x%02x-%02x%02x-%02x%02x-" Modified: stable/10/sys/dev/hyperv/vmbus/vmbus.c ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/vmbus.c Tue Oct 11 07:50:09 2016 (r307025) +++ stable/10/sys/dev/hyperv/vmbus/vmbus.c Tue Oct 11 08:01:43 2016 (r307026) @@ -1131,11 +1131,12 @@ vmbus_get_version_method(device_t bus, d } static int -vmbus_probe_guid_method(device_t bus, device_t dev, const struct hv_guid *guid) +vmbus_probe_guid_method(device_t bus, device_t dev, + const struct hyperv_guid *guid) { const struct hv_vmbus_channel *chan = vmbus_get_channel(dev); - if (memcmp(&chan->ch_guid_type, guid, sizeof(struct hv_guid)) == 0) + if (memcmp(&chan->ch_guid_type, guid, sizeof(struct hyperv_guid)) == 0) return 0; return ENXIO; } Modified: stable/10/sys/dev/hyperv/vmbus/vmbus_if.m ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/vmbus_if.m Tue Oct 11 07:50:09 2016 (r307025) +++ stable/10/sys/dev/hyperv/vmbus/vmbus_if.m Tue Oct 11 08:01:43 2016 (r307026) @@ -32,7 +32,7 @@ INTERFACE vmbus; HEADER { - struct hv_guid; + struct hyperv_guid; }; METHOD uint32_t get_version { @@ -43,5 +43,5 @@ METHOD uint32_t get_version { METHOD int probe_guid { device_t bus; device_t dev; - const struct hv_guid *guid; + const struct hyperv_guid *guid; }; Modified: stable/10/sys/dev/hyperv/vmbus/vmbus_reg.h ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/vmbus_reg.h Tue Oct 11 07:50:09 2016 (r307025) +++ stable/10/sys/dev/hyperv/vmbus/vmbus_reg.h Tue Oct 11 08:01:43 2016 (r307026) @@ -31,6 +31,7 @@ #include #include +#include /* XXX for hyperv_guid */ /* * Hyper-V SynIC message format. @@ -117,11 +118,14 @@ struct vmbus_gpa_range { /* * Channel messages - * - Embedded in vmbus_message.msg_data, e.g. response. + * - Embedded in vmbus_message.msg_data, e.g. response and notification. * - Embedded in hypercall_postmsg_in.hc_data, e.g. request. */ +#define VMBUS_CHANMSG_TYPE_CHOFFER 1 /* NOTE */ +#define VMBUS_CHANMSG_TYPE_CHRESCIND 2 /* NOTE */ #define VMBUS_CHANMSG_TYPE_CHREQUEST 3 /* REQ */ +#define VMBUS_CHANMSG_TYPE_CHOFFER_DONE 4 /* NOTE */ #define VMBUS_CHANMSG_TYPE_CHOPEN 5 /* REQ */ #define VMBUS_CHANMSG_TYPE_CHOPEN_RESP 6 /* RESP */ #define VMBUS_CHANMSG_TYPE_CHCLOSE 7 /* REQ */ @@ -134,6 +138,7 @@ struct vmbus_gpa_range { #define VMBUS_CHANMSG_TYPE_CONNECT 14 /* REQ */ #define VMBUS_CHANMSG_TYPE_CONNECT_RESP 15 /* RESP */ #define VMBUS_CHANMSG_TYPE_DISCONNECT 16 /* REQ */ +#define VMBUS_CHANMSG_TYPE_MAX 22 struct vmbus_chanmsg_hdr { uint32_t chm_type; /* VMBUS_CHANMSG_TYPE_ */ @@ -241,4 +246,33 @@ struct vmbus_chanmsg_chfree { uint32_t chm_chanid; } __packed; +/* VMBUS_CHANMSG_TYPE_CHRESCIND */ +struct vmbus_chanmsg_chrescind { + struct vmbus_chanmsg_hdr chm_hdr; + uint32_t chm_chanid; +} __packed; + +/* VMBUS_CHANMSG_TYPE_CHOFFER */ +struct vmbus_chanmsg_choffer { + struct vmbus_chanmsg_hdr chm_hdr; + struct hyperv_guid chm_chtype; + struct hyperv_guid chm_chinst; + uint64_t chm_chlat; /* unit: 100ns */ + uint32_t chm_chrev; + uint32_t chm_svrctx_sz; + uint16_t chm_chflags; + uint16_t chm_mmio_sz; /* unit: MB */ + uint8_t chm_udata[120]; + uint16_t chm_subidx; + uint16_t chm_rsvd; + uint32_t chm_chanid; + uint8_t chm_montrig; + uint8_t chm_flags1; /* VMBUS_CHOFFER_FLAG1_ */ + uint16_t chm_flags2; + uint32_t chm_connid; +} __packed; +CTASSERT(sizeof(struct vmbus_chanmsg_choffer) <= VMBUS_MSG_DSIZE_MAX); + +#define VMBUS_CHOFFER_FLAG1_HASMNF 0x01 + #endif /* !_VMBUS_REG_H_ */ From owner-svn-src-all@freebsd.org Tue Oct 11 08:14:13 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 0CD30C0DA58; Tue, 11 Oct 2016 08:14:13 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id C4C8E21B; Tue, 11 Oct 2016 08:14:12 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9B8EB9V026680; Tue, 11 Oct 2016 08:14:11 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9B8EBnw026673; Tue, 11 Oct 2016 08:14:11 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610110814.u9B8EBnw026673@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Tue, 11 Oct 2016 08:14:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307027 - in stable/10/sys/dev/hyperv: include netvsc vmbus X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Oct 2016 08:14:13 -0000 Author: sephe Date: Tue Oct 11 08:14:11 2016 New Revision: 307027 URL: https://svnweb.freebsd.org/changeset/base/307027 Log: MFC 302808-302815 302808 hyperv/vmbus: Alloc/Free monitor param in vmbus channel alloc/free. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7101 302809 hyperv/vmbus: Move device register and channel free to the caller. This paves the way for more cleanup/disentangle. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7102 302810 hyperv/vmbus: Move new channel scan notification to device register And nuke now unnecessary function indirection. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7103 302811 hyperv/vmbus: Cleanup vmbus_chan_msgproc_choffer Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7104 302812 hyperv/vmbus: Nuke the channel open state. Channel is either opened or not-opened. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7105 302813 hyperv/vmbus: Cleanup vmbus_chan_add() Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7106 302814 hyperv/vmbus: Use sub-channel index to detect primary channel In case that VMBUS_CHAN_ISPRIMARY is needed in the early place of channel setup. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7108 302815 hyperv/vmbus: Only add primary channels to vmbus channel list - Make the vmbus_chan_add more straightforward. - Partially fix the hv_vmbus_release_unattached_channels(). Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7109 Modified: stable/10/sys/dev/hyperv/include/hyperv.h stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.c stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c stable/10/sys/dev/hyperv/vmbus/hv_channel.c stable/10/sys/dev/hyperv/vmbus/hv_channel_mgmt.c stable/10/sys/dev/hyperv/vmbus/hv_vmbus_priv.h stable/10/sys/dev/hyperv/vmbus/vmbus.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/hyperv/include/hyperv.h ============================================================================== --- stable/10/sys/dev/hyperv/include/hyperv.h Tue Oct 11 08:01:43 2016 (r307026) +++ stable/10/sys/dev/hyperv/include/hyperv.h Tue Oct 11 08:14:11 2016 (r307027) @@ -244,18 +244,9 @@ typedef struct { typedef void (*hv_vmbus_pfn_channel_callback)(void *context); -typedef enum { - HV_CHANNEL_OFFER_STATE, - HV_CHANNEL_OPENING_STATE, - HV_CHANNEL_OPEN_STATE, - HV_CHANNEL_OPENED_STATE, - HV_CHANNEL_CLOSING_NONDESTRUCTIVE_STATE, -} hv_vmbus_channel_state; - typedef struct hv_vmbus_channel { device_t ch_dev; struct vmbus_softc *vmbus_sc; - hv_vmbus_channel_state state; uint32_t ch_flags; /* VMBUS_CHAN_FLAG_ */ uint32_t ch_id; /* channel id */ @@ -337,14 +328,15 @@ typedef struct hv_vmbus_channel { struct task ch_detach_task; TAILQ_ENTRY(hv_vmbus_channel) ch_link; uint32_t ch_subidx; /* subchan index */ - + volatile uint32_t ch_stflags; /* atomic-op */ + /* VMBUS_CHAN_ST_ */ struct hyperv_guid ch_guid_type; struct hyperv_guid ch_guid_inst; struct sysctl_ctx_list ch_sysctl_ctx; } hv_vmbus_channel; -#define HV_VMBUS_CHAN_ISPRIMARY(chan) ((chan)->primary_channel == NULL) +#define VMBUS_CHAN_ISPRIMARY(chan) ((chan)->ch_subidx == 0) #define VMBUS_CHAN_FLAG_HASMNF 0x0001 /* @@ -357,6 +349,9 @@ typedef struct hv_vmbus_channel { */ #define VMBUS_CHAN_FLAG_BATCHREAD 0x0002 +#define VMBUS_CHAN_ST_OPENED_SHIFT 0 +#define VMBUS_CHAN_ST_OPENED (1 << VMBUS_CHAN_ST_OPENED_SHIFT) + static inline void hv_set_channel_read_state(hv_vmbus_channel* channel, boolean_t on) { Modified: stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.c Tue Oct 11 08:01:43 2016 (r307026) +++ stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.c Tue Oct 11 08:14:11 2016 (r307027) @@ -718,11 +718,6 @@ hv_nv_on_device_remove(struct hn_softc * /* Now, we can close the channel safely */ - if (!destroy_channel) { - sc->hn_prichan->state = - HV_CHANNEL_CLOSING_NONDESTRUCTIVE_STATE; - } - free(sc->hn_prichan->hv_chan_rdbuf, M_NETVSC); hv_vmbus_channel_close(sc->hn_prichan); Modified: stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Tue Oct 11 08:01:43 2016 (r307026) +++ stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Tue Oct 11 08:14:11 2016 (r307027) @@ -3013,7 +3013,7 @@ static void hn_subchan_attach(struct hn_softc *sc, struct hv_vmbus_channel *chan) { - KASSERT(!HV_VMBUS_CHAN_ISPRIMARY(chan), + KASSERT(!VMBUS_CHAN_ISPRIMARY(chan), ("subchannel callback on primary channel")); KASSERT(chan->ch_subidx > 0, ("invalid channel subidx %u", Modified: stable/10/sys/dev/hyperv/vmbus/hv_channel.c ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/hv_channel.c Tue Oct 11 08:01:43 2016 (r307026) +++ stable/10/sys/dev/hyperv/vmbus/hv_channel.c Tue Oct 11 08:14:11 2016 (r307027) @@ -191,17 +191,9 @@ hv_vmbus_channel_open( return EINVAL; } - mtx_lock(&new_channel->sc_lock); - if (new_channel->state == HV_CHANNEL_OPEN_STATE) { - new_channel->state = HV_CHANNEL_OPENING_STATE; - } else { - mtx_unlock(&new_channel->sc_lock); - if(bootverbose) - printf("VMBUS: Trying to open channel <%p> which in " - "%d state.\n", new_channel, new_channel->state); - return (EINVAL); - } - mtx_unlock(&new_channel->sc_lock); + if (atomic_testandset_int(&new_channel->ch_stflags, + VMBUS_CHAN_ST_OPENED_SHIFT)) + panic("double-open chan%u", new_channel->ch_id); new_channel->on_channel_callback = pfn_on_channel_callback; new_channel->channel_callback_context = context; @@ -223,8 +215,10 @@ hv_vmbus_channel_open( M_DEVBUF, M_ZERO, 0UL, BUS_SPACE_MAXADDR, PAGE_SIZE, 0); KASSERT(out != NULL, ("Error VMBUS: contigmalloc failed to allocate Ring Buffer!")); - if (out == NULL) - return (ENOMEM); + if (out == NULL) { + ret = ENOMEM; + goto failed; + } in = ((uint8_t *) out + send_ring_buffer_size); @@ -265,7 +259,8 @@ hv_vmbus_channel_open( device_printf(sc->vmbus_dev, "can not get msg hypercall for chopen(chan%u)\n", new_channel->ch_id); - return ENXIO; + ret = ENXIO; + goto failed; } req = vmbus_msghc_dataptr(mh); @@ -284,7 +279,7 @@ hv_vmbus_channel_open( "chopen(chan%u) msg hypercall exec failed: %d\n", new_channel->ch_id, ret); vmbus_msghc_put(sc, mh); - return ret; + goto failed; } msg = vmbus_msghc_wait_result(sc, mh); @@ -294,17 +289,20 @@ hv_vmbus_channel_open( vmbus_msghc_put(sc, mh); if (status == 0) { - new_channel->state = HV_CHANNEL_OPENED_STATE; if (bootverbose) { device_printf(sc->vmbus_dev, "chan%u opened\n", new_channel->ch_id); } - } else { - device_printf(sc->vmbus_dev, "failed to open chan%u\n", - new_channel->ch_id); - ret = ENXIO; + return 0; } - return (ret); + + device_printf(sc->vmbus_dev, "failed to open chan%u\n", + new_channel->ch_id); + ret = ENXIO; + +failed: + atomic_clear_int(&new_channel->ch_stflags, VMBUS_CHAN_ST_OPENED); + return ret; } /** @@ -487,7 +485,9 @@ hv_vmbus_channel_close_internal(hv_vmbus struct taskqueue *rxq = channel->rxq; int error; - channel->state = HV_CHANNEL_OPEN_STATE; + /* TODO: stringent check */ + atomic_clear_int(&channel->ch_stflags, VMBUS_CHAN_ST_OPENED); + sysctl_ctx_free(&channel->ch_sysctl_ctx); /* @@ -563,7 +563,7 @@ hv_vmbus_channel_close(hv_vmbus_channel */ TAILQ_FOREACH(sub_channel, &channel->sc_list_anchor, sc_list_entry) { - if (sub_channel->state != HV_CHANNEL_OPENED_STATE) + if ((sub_channel->ch_stflags & VMBUS_CHAN_ST_OPENED) == 0) continue; hv_vmbus_channel_close_internal(sub_channel); } Modified: stable/10/sys/dev/hyperv/vmbus/hv_channel_mgmt.c ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/hv_channel_mgmt.c Tue Oct 11 08:01:43 2016 (r307026) +++ stable/10/sys/dev/hyperv/vmbus/hv_channel_mgmt.c Tue Oct 11 08:14:11 2016 (r307027) @@ -43,15 +43,12 @@ __FBSDID("$FreeBSD$"); typedef void (*vmbus_chanmsg_proc_t) (struct vmbus_softc *, const struct vmbus_message *); -static struct hv_vmbus_channel *hv_vmbus_allocate_channel(struct vmbus_softc *); -static void vmbus_channel_on_offer_internal(struct vmbus_softc *, - const struct vmbus_chanmsg_choffer *); static void vmbus_chan_detach_task(void *, int); -static void vmbus_channel_on_offer(struct vmbus_softc *, - const struct vmbus_message *); static void vmbus_channel_on_offers_delivered(struct vmbus_softc *, const struct vmbus_message *); +static void vmbus_chan_msgproc_choffer(struct vmbus_softc *, + const struct vmbus_message *); static void vmbus_chan_msgproc_chrescind(struct vmbus_softc *, const struct vmbus_message *); @@ -66,7 +63,7 @@ static void vmbus_chan_msgproc_chrescind static const vmbus_chanmsg_proc_t vmbus_chanmsg_process[VMBUS_CHANMSG_TYPE_MAX] = { - VMBUS_CHANMSG_PROC(CHOFFER, vmbus_channel_on_offer), + VMBUS_CHANMSG_PROC(CHOFFER, vmbus_chan_msgproc_choffer), VMBUS_CHANMSG_PROC(CHRESCIND, vmbus_chan_msgproc_chrescind), VMBUS_CHANMSG_PROC(CHOFFER_DONE,vmbus_channel_on_offers_delivered), @@ -79,146 +76,125 @@ vmbus_chanmsg_process[VMBUS_CHANMSG_TYPE #undef VMBUS_CHANMSG_PROC_WAKEUP #undef VMBUS_CHANMSG_PROC -/** - * @brief Allocate and initialize a vmbus channel object - */ static struct hv_vmbus_channel * -hv_vmbus_allocate_channel(struct vmbus_softc *sc) +vmbus_chan_alloc(struct vmbus_softc *sc) { - struct hv_vmbus_channel *channel; + struct hv_vmbus_channel *chan; - channel = malloc(sizeof(*channel), M_DEVBUF, M_WAITOK | M_ZERO); - channel->vmbus_sc = sc; + chan = malloc(sizeof(*chan), M_DEVBUF, M_WAITOK | M_ZERO); - mtx_init(&channel->sc_lock, "vmbus multi channel", NULL, MTX_DEF); - TAILQ_INIT(&channel->sc_list_anchor); - TASK_INIT(&channel->ch_detach_task, 0, vmbus_chan_detach_task, channel); + chan->ch_monprm = hyperv_dmamem_alloc(bus_get_dma_tag(sc->vmbus_dev), + HYPERCALL_PARAM_ALIGN, 0, sizeof(struct hyperv_mon_param), + &chan->ch_monprm_dma, BUS_DMA_WAITOK | BUS_DMA_ZERO); + if (chan->ch_monprm == NULL) { + device_printf(sc->vmbus_dev, "monprm alloc failed\n"); + free(chan, M_DEVBUF); + return NULL; + } - return (channel); + chan->vmbus_sc = sc; + mtx_init(&chan->sc_lock, "vmbus multi channel", NULL, MTX_DEF); + TAILQ_INIT(&chan->sc_list_anchor); + TASK_INIT(&chan->ch_detach_task, 0, vmbus_chan_detach_task, chan); + + return chan; } -/** - * @brief Release the resources used by the vmbus channel object - */ -void -hv_vmbus_free_vmbus_channel(hv_vmbus_channel* channel) +static void +vmbus_chan_free(struct hv_vmbus_channel *chan) { - mtx_destroy(&channel->sc_lock); - free(channel, M_DEVBUF); + /* TODO: assert sub-channel list is empty */ + /* TODO: asset no longer on the primary channel's sub-channel list */ + /* TODO: asset no longer on the vmbus channel list */ + hyperv_dmamem_free(&chan->ch_monprm_dma, chan->ch_monprm); + mtx_destroy(&chan->sc_lock); + free(chan, M_DEVBUF); } -/** - * @brief Process the offer by creating a channel/device - * associated with this offer - */ -static void -vmbus_channel_process_offer(hv_vmbus_channel *new_channel) +static int +vmbus_chan_add(struct hv_vmbus_channel *newchan) { - struct vmbus_softc *sc = new_channel->vmbus_sc; - hv_vmbus_channel* channel; + struct vmbus_softc *sc = newchan->vmbus_sc; + struct hv_vmbus_channel *prichan; - /* - * Make sure this is a new offer - */ - mtx_lock(&sc->vmbus_chlist_lock); - if (new_channel->ch_id == 0) { + if (newchan->ch_id == 0) { /* - * XXX channel0 will not be processed; skip it. + * XXX + * Chan0 will neither be processed nor should be offered; + * skip it. */ - printf("VMBUS: got channel0 offer\n"); - } else { - sc->vmbus_chmap[new_channel->ch_id] = new_channel; + device_printf(sc->vmbus_dev, "got chan0 offer, discard\n"); + return EINVAL; + } else if (newchan->ch_id >= VMBUS_CHAN_MAX) { + device_printf(sc->vmbus_dev, "invalid chan%u offer\n", + newchan->ch_id); + return EINVAL; } + sc->vmbus_chmap[newchan->ch_id] = newchan; - TAILQ_FOREACH(channel, &sc->vmbus_chlist, ch_link) { - if (memcmp(&channel->ch_guid_type, &new_channel->ch_guid_type, + if (bootverbose) { + device_printf(sc->vmbus_dev, "chan%u subidx%u offer\n", + newchan->ch_id, newchan->ch_subidx); + } + + mtx_lock(&sc->vmbus_chlist_lock); + TAILQ_FOREACH(prichan, &sc->vmbus_chlist, ch_link) { + if (memcmp(&prichan->ch_guid_type, &newchan->ch_guid_type, sizeof(struct hyperv_guid)) == 0 && - memcmp(&channel->ch_guid_inst, &new_channel->ch_guid_inst, + memcmp(&prichan->ch_guid_inst, &newchan->ch_guid_inst, sizeof(struct hyperv_guid)) == 0) break; } - - if (channel == NULL) { - /* Install the new primary channel */ - TAILQ_INSERT_TAIL(&sc->vmbus_chlist, new_channel, ch_link); - } - mtx_unlock(&sc->vmbus_chlist_lock); - - if (bootverbose) { - char logstr[64]; - - logstr[0] = '\0'; - if (channel != NULL) { - snprintf(logstr, sizeof(logstr), ", primary chan%u", - channel->ch_id); + if (VMBUS_CHAN_ISPRIMARY(newchan)) { + if (prichan == NULL) { + /* Install the new primary channel */ + TAILQ_INSERT_TAIL(&sc->vmbus_chlist, newchan, ch_link); + mtx_unlock(&sc->vmbus_chlist_lock); + return 0; + } else { + mtx_unlock(&sc->vmbus_chlist_lock); + device_printf(sc->vmbus_dev, "duplicated primary " + "chan%u\n", newchan->ch_id); + return EINVAL; } - device_printf(sc->vmbus_dev, "chan%u subchanid%u offer%s\n", - new_channel->ch_id, - new_channel->ch_subidx, logstr); - } - - if (channel != NULL) { - /* - * Check if this is a sub channel. - */ - if (new_channel->ch_subidx != 0) { - /* - * It is a sub channel offer, process it. - */ - new_channel->primary_channel = channel; - new_channel->ch_dev = channel->ch_dev; - mtx_lock(&channel->sc_lock); - TAILQ_INSERT_TAIL(&channel->sc_list_anchor, - new_channel, sc_list_entry); - mtx_unlock(&channel->sc_lock); - - /* - * Insert the new channel to the end of the global - * channel list. - * - * NOTE: - * The new sub-channel MUST be inserted AFTER it's - * primary channel, so that the primary channel will - * be found in the above loop for its baby siblings. - */ - mtx_lock(&sc->vmbus_chlist_lock); - TAILQ_INSERT_TAIL(&sc->vmbus_chlist, new_channel, - ch_link); + } else { /* Sub-channel */ + if (prichan == NULL) { mtx_unlock(&sc->vmbus_chlist_lock); - - new_channel->state = HV_CHANNEL_OPEN_STATE; - - /* - * Bump up sub-channel count and notify anyone that is - * interested in this sub-channel, after this sub-channel - * is setup. - */ - mtx_lock(&channel->sc_lock); - channel->subchan_cnt++; - mtx_unlock(&channel->sc_lock); - wakeup(channel); - - return; + device_printf(sc->vmbus_dev, "no primary chan for " + "chan%u\n", newchan->ch_id); + return EINVAL; } - - printf("VMBUS: duplicated primary channel%u\n", - new_channel->ch_id); - hv_vmbus_free_vmbus_channel(new_channel); - return; + /* + * Found the primary channel for this sub-channel and + * move on. + * + * XXX refcnt prichan + */ } + mtx_unlock(&sc->vmbus_chlist_lock); + + /* + * This is a sub-channel; link it with the primary channel. + */ + KASSERT(!VMBUS_CHAN_ISPRIMARY(newchan), + ("new channel is not sub-channel")); + KASSERT(prichan != NULL, ("no primary channel")); - new_channel->state = HV_CHANNEL_OPEN_STATE; + newchan->primary_channel = prichan; + newchan->ch_dev = prichan->ch_dev; + mtx_lock(&prichan->sc_lock); + TAILQ_INSERT_TAIL(&prichan->sc_list_anchor, newchan, sc_list_entry); /* - * Add the new device to the bus. This will kick off device-driver - * binding which eventually invokes the device driver's AddDevice() - * method. - * - * NOTE: - * Error is ignored here; don't have much to do if error really - * happens. + * Bump up sub-channel count and notify anyone that is + * interested in this sub-channel, after this sub-channel + * is setup. */ - hv_vmbus_child_device_register(new_channel); + prichan->subchan_cnt++; + mtx_unlock(&prichan->sc_lock); + wakeup(prichan); + + return 0; } void @@ -253,7 +229,7 @@ vmbus_channel_cpu_rr(struct hv_vmbus_cha } static void -vmbus_channel_select_defcpu(struct hv_vmbus_channel *chan) +vmbus_chan_cpu_default(struct hv_vmbus_channel *chan) { /* * By default, pin the channel to cpu0. Devices having @@ -263,69 +239,68 @@ vmbus_channel_select_defcpu(struct hv_vm vmbus_channel_cpu_set(chan, 0); } -/** - * @brief Handler for channel offers from Hyper-V/Azure - * - * Handler for channel offers from vmbus in parent partition. - */ static void -vmbus_channel_on_offer(struct vmbus_softc *sc, const struct vmbus_message *msg) +vmbus_chan_msgproc_choffer(struct vmbus_softc *sc, + const struct vmbus_message *msg) { - /* New channel is offered by vmbus */ - vmbus_scan_newchan(sc); + const struct vmbus_chanmsg_choffer *offer; + struct hv_vmbus_channel *chan; + int error; - vmbus_channel_on_offer_internal(sc, - (const struct vmbus_chanmsg_choffer *)msg->msg_data); -} + offer = (const struct vmbus_chanmsg_choffer *)msg->msg_data; -static void -vmbus_channel_on_offer_internal(struct vmbus_softc *sc, - const struct vmbus_chanmsg_choffer *offer) -{ - hv_vmbus_channel* new_channel; + chan = vmbus_chan_alloc(sc); + if (chan == NULL) { + device_printf(sc->vmbus_dev, "allocate chan%u failed\n", + offer->chm_chanid); + return; + } - /* - * Allocate the channel object and save this offer - */ - new_channel = hv_vmbus_allocate_channel(sc); - new_channel->ch_id = offer->chm_chanid; - new_channel->ch_subidx = offer->chm_subidx; - new_channel->ch_guid_type = offer->chm_chtype; - new_channel->ch_guid_inst = offer->chm_chinst; + chan->ch_id = offer->chm_chanid; + chan->ch_subidx = offer->chm_subidx; + chan->ch_guid_type = offer->chm_chtype; + chan->ch_guid_inst = offer->chm_chinst; /* Batch reading is on by default */ - new_channel->ch_flags |= VMBUS_CHAN_FLAG_BATCHREAD; - if (offer->chm_flags1 & VMBUS_CHOFFER_FLAG1_HASMNF) - new_channel->ch_flags |= VMBUS_CHAN_FLAG_HASMNF; + chan->ch_flags |= VMBUS_CHAN_FLAG_BATCHREAD; - new_channel->ch_monprm = hyperv_dmamem_alloc( - bus_get_dma_tag(sc->vmbus_dev), - HYPERCALL_PARAM_ALIGN, 0, sizeof(struct hyperv_mon_param), - &new_channel->ch_monprm_dma, BUS_DMA_WAITOK | BUS_DMA_ZERO); - if (new_channel->ch_monprm == NULL) { - device_printf(sc->vmbus_dev, "monprm alloc failed\n"); - /* XXX */ - mtx_destroy(&new_channel->sc_lock); - free(new_channel, M_DEVBUF); - return; - } - new_channel->ch_monprm->mp_connid = VMBUS_CONNID_EVENT; + chan->ch_monprm->mp_connid = VMBUS_CONNID_EVENT; if (sc->vmbus_version != VMBUS_VERSION_WS2008) - new_channel->ch_monprm->mp_connid = offer->chm_connid; + chan->ch_monprm->mp_connid = offer->chm_connid; - if (new_channel->ch_flags & VMBUS_CHAN_FLAG_HASMNF) { - new_channel->ch_montrig_idx = - offer->chm_montrig / VMBUS_MONTRIG_LEN; - if (new_channel->ch_montrig_idx >= VMBUS_MONTRIGS_MAX) + if (offer->chm_flags1 & VMBUS_CHOFFER_FLAG1_HASMNF) { + /* + * Setup MNF stuffs. + */ + chan->ch_flags |= VMBUS_CHAN_FLAG_HASMNF; + chan->ch_montrig_idx = offer->chm_montrig / VMBUS_MONTRIG_LEN; + if (chan->ch_montrig_idx >= VMBUS_MONTRIGS_MAX) panic("invalid monitor trigger %u", offer->chm_montrig); - new_channel->ch_montrig_mask = + chan->ch_montrig_mask = 1 << (offer->chm_montrig % VMBUS_MONTRIG_LEN); } /* Select default cpu for this channel. */ - vmbus_channel_select_defcpu(new_channel); + vmbus_chan_cpu_default(chan); - vmbus_channel_process_offer(new_channel); + error = vmbus_chan_add(chan); + if (error) { + device_printf(sc->vmbus_dev, "add chan%u failed: %d\n", + chan->ch_id, error); + vmbus_chan_free(chan); + return; + } + + if (VMBUS_CHAN_ISPRIMARY(chan)) { + /* + * Add device for this primary channel. + * + * NOTE: + * Error is ignored here; don't have much to do if error + * really happens. + */ + hv_vmbus_child_device_register(chan); + } } /* @@ -363,7 +338,7 @@ vmbus_chan_detach_task(void *xchan, int { struct hv_vmbus_channel *chan = xchan; - if (HV_VMBUS_CHAN_ISPRIMARY(chan)) { + if (VMBUS_CHAN_ISPRIMARY(chan)) { /* Only primary channel owns the device */ hv_vmbus_child_device_unregister(chan); /* NOTE: DO NOT free primary channel for now */ @@ -401,10 +376,6 @@ vmbus_chan_detach_task(void *xchan, int } } remove: - mtx_lock(&sc->vmbus_chlist_lock); - TAILQ_REMOVE(&sc->vmbus_chlist, chan, ch_link); - mtx_unlock(&sc->vmbus_chlist_lock); - mtx_lock(&pri_chan->sc_lock); TAILQ_REMOVE(&pri_chan->sc_list_anchor, chan, sc_list_entry); KASSERT(pri_chan->subchan_cnt > 0, @@ -413,7 +384,7 @@ remove: mtx_unlock(&pri_chan->sc_lock); wakeup(pri_chan); - hv_vmbus_free_vmbus_channel(chan); + vmbus_chan_free(chan); } } @@ -442,13 +413,11 @@ hv_vmbus_release_unattached_channels(str while (!TAILQ_EMPTY(&sc->vmbus_chlist)) { channel = TAILQ_FIRST(&sc->vmbus_chlist); + KASSERT(VMBUS_CHAN_ISPRIMARY(channel), ("not primary channel")); TAILQ_REMOVE(&sc->vmbus_chlist, channel, ch_link); - if (HV_VMBUS_CHAN_ISPRIMARY(channel)) { - /* Only primary channel owns the device */ - hv_vmbus_child_device_unregister(channel); - } - hv_vmbus_free_vmbus_channel(channel); + hv_vmbus_child_device_unregister(channel); + vmbus_chan_free(channel); } bzero(sc->vmbus_chmap, sizeof(struct hv_vmbus_channel *) * VMBUS_CHAN_MAX); @@ -486,7 +455,7 @@ vmbus_select_outgoing_channel(struct hv_ cur_vcpu = VMBUS_PCPU_GET(primary->vmbus_sc, vcpuid, smp_pro_id); TAILQ_FOREACH(new_channel, &primary->sc_list_anchor, sc_list_entry) { - if (new_channel->state != HV_CHANNEL_OPENED_STATE){ + if ((new_channel->ch_stflags & VMBUS_CHAN_ST_OPENED) == 0) { continue; } Modified: stable/10/sys/dev/hyperv/vmbus/hv_vmbus_priv.h ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/hv_vmbus_priv.h Tue Oct 11 08:01:43 2016 (r307026) +++ stable/10/sys/dev/hyperv/vmbus/hv_vmbus_priv.h Tue Oct 11 08:14:11 2016 (r307027) @@ -55,7 +55,6 @@ typedef struct { typedef struct { uint32_t rel_id; - hv_vmbus_channel_state state; struct hyperv_guid interface_type; struct hyperv_guid interface_instance; uint32_t monitor_id; @@ -147,7 +146,6 @@ void hv_ring_buffer_read_begin( uint32_t hv_ring_buffer_read_end( hv_vmbus_ring_buffer_info *ring_info); -void hv_vmbus_free_vmbus_channel(hv_vmbus_channel *channel); void hv_vmbus_release_unattached_channels( struct vmbus_softc *); Modified: stable/10/sys/dev/hyperv/vmbus/vmbus.c ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/vmbus.c Tue Oct 11 08:01:43 2016 (r307026) +++ stable/10/sys/dev/hyperv/vmbus/vmbus.c Tue Oct 11 08:14:11 2016 (r307027) @@ -1074,6 +1074,9 @@ hv_vmbus_child_device_register(struct hv device_t parent = sc->vmbus_dev; int error = 0; + /* New channel has been offered */ + vmbus_scan_newchan(sc); + chan->ch_dev = device_add_child(parent, NULL, -1); if (chan->ch_dev == NULL) { device_printf(parent, "device_add_child for chan%u failed\n", From owner-svn-src-all@freebsd.org Tue Oct 11 08:22:19 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B2C90C0DECD; Tue, 11 Oct 2016 08:22:19 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 8F8B5CAA; Tue, 11 Oct 2016 08:22:19 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9B8MINw030437; Tue, 11 Oct 2016 08:22:18 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9B8MIH8030431; Tue, 11 Oct 2016 08:22:18 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610110822.u9B8MIH8030431@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Tue, 11 Oct 2016 08:22:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307028 - in stable/10/sys/dev/hyperv: include vmbus X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Oct 2016 08:22:19 -0000 Author: sephe Date: Tue Oct 11 08:22:17 2016 New Revision: 307028 URL: https://svnweb.freebsd.org/changeset/base/307028 Log: MFC 302816-302818 302816 hyperv/vmbus: Release vmbus channel lock before detach devices Device detach method may sleep. While I'm here, rename the function, fix indentation and function comment. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7110 302817 hyperv/vmbus: Field renaming to reflect reality Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7111 302818 hyperv/vmbus: Fix the racy channel close. It is not safe to iterate the sub-channel list w/o lock on the close path, while it's even more difficult to hold the lock and iterate the sub-channel list. We leverage the vmbua_{get,rel}_subchan() functions to solve this dilemma. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7112 Modified: stable/10/sys/dev/hyperv/include/hyperv.h stable/10/sys/dev/hyperv/vmbus/hv_channel.c stable/10/sys/dev/hyperv/vmbus/hv_channel_mgmt.c stable/10/sys/dev/hyperv/vmbus/hv_vmbus_priv.h stable/10/sys/dev/hyperv/vmbus/vmbus.c stable/10/sys/dev/hyperv/vmbus/vmbus_var.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/hyperv/include/hyperv.h ============================================================================== --- stable/10/sys/dev/hyperv/include/hyperv.h Tue Oct 11 08:14:11 2016 (r307027) +++ stable/10/sys/dev/hyperv/include/hyperv.h Tue Oct 11 08:22:17 2016 (r307028) @@ -326,7 +326,7 @@ typedef struct hv_vmbus_channel { void *hv_chan_priv3; struct task ch_detach_task; - TAILQ_ENTRY(hv_vmbus_channel) ch_link; + TAILQ_ENTRY(hv_vmbus_channel) ch_prilink; /* primary chan link */ uint32_t ch_subidx; /* subchan index */ volatile uint32_t ch_stflags; /* atomic-op */ /* VMBUS_CHAN_ST_ */ Modified: stable/10/sys/dev/hyperv/vmbus/hv_channel.c ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/hv_channel.c Tue Oct 11 08:14:11 2016 (r307027) +++ stable/10/sys/dev/hyperv/vmbus/hv_channel.c Tue Oct 11 08:22:17 2016 (r307028) @@ -542,35 +542,40 @@ hv_vmbus_channel_close_internal(hv_vmbus M_DEVBUF); } -/** - * @brief Close the specified channel +/* + * Caller should make sure that all sub-channels have + * been added to 'chan' and all to-be-closed channels + * are not being opened. */ void -hv_vmbus_channel_close(hv_vmbus_channel *channel) +hv_vmbus_channel_close(struct hv_vmbus_channel *chan) { - hv_vmbus_channel* sub_channel; + int subchan_cnt; - if (channel->primary_channel != NULL) { + if (!VMBUS_CHAN_ISPRIMARY(chan)) { /* - * We only close multi-channels when the primary is - * closed. + * Sub-channel is closed when its primary channel + * is closed; done. */ return; } /* - * Close all multi-channels first. + * Close all sub-channels, if any. */ - TAILQ_FOREACH(sub_channel, &channel->sc_list_anchor, - sc_list_entry) { - if ((sub_channel->ch_stflags & VMBUS_CHAN_ST_OPENED) == 0) - continue; - hv_vmbus_channel_close_internal(sub_channel); + subchan_cnt = chan->subchan_cnt; + if (subchan_cnt > 0) { + struct hv_vmbus_channel **subchan; + int i; + + subchan = vmbus_get_subchan(chan, subchan_cnt); + for (i = 0; i < subchan_cnt; ++i) + hv_vmbus_channel_close_internal(subchan[i]); + vmbus_rel_subchan(subchan, subchan_cnt); } - /* - * Then close the primary channel. - */ - hv_vmbus_channel_close_internal(channel); + + /* Then close the primary channel. */ + hv_vmbus_channel_close_internal(chan); } /** Modified: stable/10/sys/dev/hyperv/vmbus/hv_channel_mgmt.c ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/hv_channel_mgmt.c Tue Oct 11 08:14:11 2016 (r307027) +++ stable/10/sys/dev/hyperv/vmbus/hv_channel_mgmt.c Tue Oct 11 08:22:17 2016 (r307028) @@ -137,8 +137,8 @@ vmbus_chan_add(struct hv_vmbus_channel * newchan->ch_id, newchan->ch_subidx); } - mtx_lock(&sc->vmbus_chlist_lock); - TAILQ_FOREACH(prichan, &sc->vmbus_chlist, ch_link) { + mtx_lock(&sc->vmbus_prichan_lock); + TAILQ_FOREACH(prichan, &sc->vmbus_prichans, ch_prilink) { if (memcmp(&prichan->ch_guid_type, &newchan->ch_guid_type, sizeof(struct hyperv_guid)) == 0 && memcmp(&prichan->ch_guid_inst, &newchan->ch_guid_inst, @@ -148,18 +148,19 @@ vmbus_chan_add(struct hv_vmbus_channel * if (VMBUS_CHAN_ISPRIMARY(newchan)) { if (prichan == NULL) { /* Install the new primary channel */ - TAILQ_INSERT_TAIL(&sc->vmbus_chlist, newchan, ch_link); - mtx_unlock(&sc->vmbus_chlist_lock); + TAILQ_INSERT_TAIL(&sc->vmbus_prichans, newchan, + ch_prilink); + mtx_unlock(&sc->vmbus_prichan_lock); return 0; } else { - mtx_unlock(&sc->vmbus_chlist_lock); + mtx_unlock(&sc->vmbus_prichan_lock); device_printf(sc->vmbus_dev, "duplicated primary " "chan%u\n", newchan->ch_id); return EINVAL; } } else { /* Sub-channel */ if (prichan == NULL) { - mtx_unlock(&sc->vmbus_chlist_lock); + mtx_unlock(&sc->vmbus_prichan_lock); device_printf(sc->vmbus_dev, "no primary chan for " "chan%u\n", newchan->ch_id); return EINVAL; @@ -171,7 +172,7 @@ vmbus_chan_add(struct hv_vmbus_channel * * XXX refcnt prichan */ } - mtx_unlock(&sc->vmbus_chlist_lock); + mtx_unlock(&sc->vmbus_prichan_lock); /* * This is a sub-channel; link it with the primary channel. @@ -401,28 +402,28 @@ vmbus_channel_on_offers_delivered(struct vmbus_scan_done(sc); } -/** - * @brief Release channels that are unattached/unconnected (i.e., no drivers associated) +/* + * Detach all devices and destroy the corresponding primary channels. */ void -hv_vmbus_release_unattached_channels(struct vmbus_softc *sc) +vmbus_chan_destroy_all(struct vmbus_softc *sc) { - hv_vmbus_channel *channel; + struct hv_vmbus_channel *chan; - mtx_lock(&sc->vmbus_chlist_lock); + mtx_lock(&sc->vmbus_prichan_lock); + while ((chan = TAILQ_FIRST(&sc->vmbus_prichans)) != NULL) { + KASSERT(VMBUS_CHAN_ISPRIMARY(chan), ("not primary channel")); + TAILQ_REMOVE(&sc->vmbus_prichans, chan, ch_prilink); + mtx_unlock(&sc->vmbus_prichan_lock); - while (!TAILQ_EMPTY(&sc->vmbus_chlist)) { - channel = TAILQ_FIRST(&sc->vmbus_chlist); - KASSERT(VMBUS_CHAN_ISPRIMARY(channel), ("not primary channel")); - TAILQ_REMOVE(&sc->vmbus_chlist, channel, ch_link); + hv_vmbus_child_device_unregister(chan); + vmbus_chan_free(chan); - hv_vmbus_child_device_unregister(channel); - vmbus_chan_free(channel); + mtx_lock(&sc->vmbus_prichan_lock); } bzero(sc->vmbus_chmap, sizeof(struct hv_vmbus_channel *) * VMBUS_CHAN_MAX); - - mtx_unlock(&sc->vmbus_chlist_lock); + mtx_unlock(&sc->vmbus_prichan_lock); } /** Modified: stable/10/sys/dev/hyperv/vmbus/hv_vmbus_priv.h ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/hv_vmbus_priv.h Tue Oct 11 08:14:11 2016 (r307027) +++ stable/10/sys/dev/hyperv/vmbus/hv_vmbus_priv.h Tue Oct 11 08:22:17 2016 (r307028) @@ -146,9 +146,6 @@ void hv_ring_buffer_read_begin( uint32_t hv_ring_buffer_read_end( hv_vmbus_ring_buffer_info *ring_info); -void hv_vmbus_release_unattached_channels( - struct vmbus_softc *); - int hv_vmbus_child_device_register( struct hv_vmbus_channel *chan); int hv_vmbus_child_device_unregister( Modified: stable/10/sys/dev/hyperv/vmbus/vmbus.c ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/vmbus.c Tue Oct 11 08:14:11 2016 (r307027) +++ stable/10/sys/dev/hyperv/vmbus/vmbus.c Tue Oct 11 08:22:17 2016 (r307028) @@ -1184,8 +1184,8 @@ vmbus_doattach(struct vmbus_softc *sc) mtx_init(&sc->vmbus_scan_lock, "vmbus scan", NULL, MTX_DEF); sc->vmbus_gpadl = VMBUS_GPADL_START; - mtx_init(&sc->vmbus_chlist_lock, "vmbus chlist", NULL, MTX_DEF); - TAILQ_INIT(&sc->vmbus_chlist); + mtx_init(&sc->vmbus_prichan_lock, "vmbus prichan", NULL, MTX_DEF); + TAILQ_INIT(&sc->vmbus_prichans); sc->vmbus_chmap = malloc( sizeof(struct hv_vmbus_channel *) * VMBUS_CHAN_MAX, M_DEVBUF, M_WAITOK | M_ZERO); @@ -1256,7 +1256,7 @@ cleanup: } free(sc->vmbus_chmap, M_DEVBUF); mtx_destroy(&sc->vmbus_scan_lock); - mtx_destroy(&sc->vmbus_chlist_lock); + mtx_destroy(&sc->vmbus_prichan_lock); return (ret); } @@ -1314,7 +1314,7 @@ vmbus_detach(device_t dev) { struct vmbus_softc *sc = device_get_softc(dev); - hv_vmbus_release_unattached_channels(sc); + vmbus_chan_destroy_all(sc); vmbus_disconnect(sc); @@ -1333,7 +1333,7 @@ vmbus_detach(device_t dev) free(sc->vmbus_chmap, M_DEVBUF); mtx_destroy(&sc->vmbus_scan_lock); - mtx_destroy(&sc->vmbus_chlist_lock); + mtx_destroy(&sc->vmbus_prichan_lock); return (0); } Modified: stable/10/sys/dev/hyperv/vmbus/vmbus_var.h ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/vmbus_var.h Tue Oct 11 08:14:11 2016 (r307027) +++ stable/10/sys/dev/hyperv/vmbus/vmbus_var.h Tue Oct 11 08:22:17 2016 (r307028) @@ -101,8 +101,9 @@ struct vmbus_softc { #define VMBUS_SCAN_CHCNT_DONE 0x80000000 uint32_t vmbus_scan_devcnt; - struct mtx vmbus_chlist_lock; - TAILQ_HEAD(, hv_vmbus_channel) vmbus_chlist; + /* Primary channels */ + struct mtx vmbus_prichan_lock; + TAILQ_HEAD(, hv_vmbus_channel) vmbus_prichans; }; #define VMBUS_FLAG_ATTACHED 0x0001 /* vmbus was attached */ @@ -137,6 +138,7 @@ void vmbus_handle_intr(struct trapframe void vmbus_et_intr(struct trapframe *); void vmbus_chan_msgproc(struct vmbus_softc *, const struct vmbus_message *); +void vmbus_chan_destroy_all(struct vmbus_softc *); struct vmbus_msghc *vmbus_msghc_get(struct vmbus_softc *, size_t); void vmbus_msghc_put(struct vmbus_softc *, struct vmbus_msghc *); From owner-svn-src-all@freebsd.org Tue Oct 11 08:29:06 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 9088EC0C0E1; Tue, 11 Oct 2016 08:29:06 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 60E1EA8; Tue, 11 Oct 2016 08:29:06 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9B8T5pH030808; Tue, 11 Oct 2016 08:29:05 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9B8T5kq030803; Tue, 11 Oct 2016 08:29:05 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610110829.u9B8T5kq030803@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Tue, 11 Oct 2016 08:29:05 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307029 - in stable/10/sys/dev/hyperv: include vmbus X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Oct 2016 08:29:06 -0000 Author: sephe Date: Tue Oct 11 08:29:04 2016 New Revision: 307029 URL: https://svnweb.freebsd.org/changeset/base/307029 Log: MFC 302819,302823 302819 hyperv/vmbus: Sub-channel related fields renaming And reorganize comment. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7113 302823 hyperv/vmbus: Move bus related message processing into vmbus. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7125 Modified: stable/10/sys/dev/hyperv/include/hyperv.h stable/10/sys/dev/hyperv/vmbus/hv_channel.c stable/10/sys/dev/hyperv/vmbus/hv_channel_mgmt.c stable/10/sys/dev/hyperv/vmbus/vmbus.c stable/10/sys/dev/hyperv/vmbus/vmbus_var.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/hyperv/include/hyperv.h ============================================================================== --- stable/10/sys/dev/hyperv/include/hyperv.h Tue Oct 11 08:22:17 2016 (r307028) +++ stable/10/sys/dev/hyperv/include/hyperv.h Tue Oct 11 08:29:04 2016 (r307029) @@ -293,30 +293,17 @@ typedef struct hv_vmbus_channel { uint32_t target_cpu; /* - * Support for multi-channels. - * The initial offer is considered the primary channel and this - * offer message will indicate if the host supports multi-channels. - * The guest is free to ask for multi-channels to be offerred and can - * open these multi-channels as a normal "primary" channel. However, - * all multi-channels will have the same type and instance guids as the - * primary channel. Requests sent on a given channel will result in a - * response on the same channel. + * If this is a primary channel, ch_subchan* fields + * contain sub-channels belonging to this primary + * channel. */ - - struct mtx sc_lock; - - /* - * Link list of all the multi-channels if this is a primary channel - */ - TAILQ_HEAD(, hv_vmbus_channel) sc_list_anchor; - TAILQ_ENTRY(hv_vmbus_channel) sc_list_entry; - int subchan_cnt; - - /* - * The primary channel this sub-channle belongs to. - * This will be NULL for the primary channel. - */ - struct hv_vmbus_channel *primary_channel; + struct mtx ch_subchan_lock; + TAILQ_HEAD(, hv_vmbus_channel) ch_subchans; + int ch_subchan_cnt; + + /* If this is a sub-channel */ + TAILQ_ENTRY(hv_vmbus_channel) ch_sublink; /* sub-channel link */ + struct hv_vmbus_channel *ch_prichan; /* owner primary chan */ /* * Driver private data Modified: stable/10/sys/dev/hyperv/vmbus/hv_channel.c ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/hv_channel.c Tue Oct 11 08:22:17 2016 (r307028) +++ stable/10/sys/dev/hyperv/vmbus/hv_channel.c Tue Oct 11 08:29:04 2016 (r307029) @@ -100,7 +100,7 @@ vmbus_channel_sysctl_create(hv_vmbus_cha uint16_t sub_ch_id; char name[16]; - hv_vmbus_channel* primary_ch = channel->primary_channel; + hv_vmbus_channel* primary_ch = channel->ch_prichan; if (primary_ch == NULL) { dev = channel->ch_dev; @@ -563,7 +563,7 @@ hv_vmbus_channel_close(struct hv_vmbus_c /* * Close all sub-channels, if any. */ - subchan_cnt = chan->subchan_cnt; + subchan_cnt = chan->ch_subchan_cnt; if (subchan_cnt > 0) { struct hv_vmbus_channel **subchan; int i; Modified: stable/10/sys/dev/hyperv/vmbus/hv_channel_mgmt.c ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/hv_channel_mgmt.c Tue Oct 11 08:22:17 2016 (r307028) +++ stable/10/sys/dev/hyperv/vmbus/hv_channel_mgmt.c Tue Oct 11 08:29:04 2016 (r307029) @@ -40,13 +40,8 @@ __FBSDID("$FreeBSD$"); #include #include -typedef void (*vmbus_chanmsg_proc_t) - (struct vmbus_softc *, const struct vmbus_message *); - static void vmbus_chan_detach_task(void *, int); -static void vmbus_channel_on_offers_delivered(struct vmbus_softc *, - const struct vmbus_message *); static void vmbus_chan_msgproc_choffer(struct vmbus_softc *, const struct vmbus_message *); static void vmbus_chan_msgproc_chrescind(struct vmbus_softc *, @@ -55,27 +50,16 @@ static void vmbus_chan_msgproc_chrescind /* * Vmbus channel message processing. */ - -#define VMBUS_CHANMSG_PROC(name, func) \ - [VMBUS_CHANMSG_TYPE_##name] = func -#define VMBUS_CHANMSG_PROC_WAKEUP(name) \ - VMBUS_CHANMSG_PROC(name, vmbus_msghc_wakeup) - static const vmbus_chanmsg_proc_t -vmbus_chanmsg_process[VMBUS_CHANMSG_TYPE_MAX] = { +vmbus_chan_msgprocs[VMBUS_CHANMSG_TYPE_MAX] = { VMBUS_CHANMSG_PROC(CHOFFER, vmbus_chan_msgproc_choffer), VMBUS_CHANMSG_PROC(CHRESCIND, vmbus_chan_msgproc_chrescind), - VMBUS_CHANMSG_PROC(CHOFFER_DONE,vmbus_channel_on_offers_delivered), VMBUS_CHANMSG_PROC_WAKEUP(CHOPEN_RESP), VMBUS_CHANMSG_PROC_WAKEUP(GPADL_CONNRESP), - VMBUS_CHANMSG_PROC_WAKEUP(GPADL_DISCONNRESP), - VMBUS_CHANMSG_PROC_WAKEUP(CONNECT_RESP) + VMBUS_CHANMSG_PROC_WAKEUP(GPADL_DISCONNRESP) }; -#undef VMBUS_CHANMSG_PROC_WAKEUP -#undef VMBUS_CHANMSG_PROC - static struct hv_vmbus_channel * vmbus_chan_alloc(struct vmbus_softc *sc) { @@ -93,8 +77,8 @@ vmbus_chan_alloc(struct vmbus_softc *sc) } chan->vmbus_sc = sc; - mtx_init(&chan->sc_lock, "vmbus multi channel", NULL, MTX_DEF); - TAILQ_INIT(&chan->sc_list_anchor); + mtx_init(&chan->ch_subchan_lock, "vmbus subchan", NULL, MTX_DEF); + TAILQ_INIT(&chan->ch_subchans); TASK_INIT(&chan->ch_detach_task, 0, vmbus_chan_detach_task, chan); return chan; @@ -107,7 +91,7 @@ vmbus_chan_free(struct hv_vmbus_channel /* TODO: asset no longer on the primary channel's sub-channel list */ /* TODO: asset no longer on the vmbus channel list */ hyperv_dmamem_free(&chan->ch_monprm_dma, chan->ch_monprm); - mtx_destroy(&chan->sc_lock); + mtx_destroy(&chan->ch_subchan_lock); free(chan, M_DEVBUF); } @@ -139,6 +123,10 @@ vmbus_chan_add(struct hv_vmbus_channel * mtx_lock(&sc->vmbus_prichan_lock); TAILQ_FOREACH(prichan, &sc->vmbus_prichans, ch_prilink) { + /* + * Sub-channel will have the same type GUID and instance + * GUID as its primary channel. + */ if (memcmp(&prichan->ch_guid_type, &newchan->ch_guid_type, sizeof(struct hyperv_guid)) == 0 && memcmp(&prichan->ch_guid_inst, &newchan->ch_guid_inst, @@ -181,18 +169,18 @@ vmbus_chan_add(struct hv_vmbus_channel * ("new channel is not sub-channel")); KASSERT(prichan != NULL, ("no primary channel")); - newchan->primary_channel = prichan; + newchan->ch_prichan = prichan; newchan->ch_dev = prichan->ch_dev; - mtx_lock(&prichan->sc_lock); - TAILQ_INSERT_TAIL(&prichan->sc_list_anchor, newchan, sc_list_entry); + mtx_lock(&prichan->ch_subchan_lock); + TAILQ_INSERT_TAIL(&prichan->ch_subchans, newchan, ch_sublink); /* * Bump up sub-channel count and notify anyone that is * interested in this sub-channel, after this sub-channel * is setup. */ - prichan->subchan_cnt++; - mtx_unlock(&prichan->sc_lock); + prichan->ch_subchan_cnt++; + mtx_unlock(&prichan->ch_subchan_lock); wakeup(prichan); return 0; @@ -345,7 +333,7 @@ vmbus_chan_detach_task(void *xchan, int /* NOTE: DO NOT free primary channel for now */ } else { struct vmbus_softc *sc = chan->vmbus_sc; - struct hv_vmbus_channel *pri_chan = chan->primary_channel; + struct hv_vmbus_channel *pri_chan = chan->ch_prichan; struct vmbus_chanmsg_chfree *req; struct vmbus_msghc *mh; int error; @@ -377,31 +365,18 @@ vmbus_chan_detach_task(void *xchan, int } } remove: - mtx_lock(&pri_chan->sc_lock); - TAILQ_REMOVE(&pri_chan->sc_list_anchor, chan, sc_list_entry); - KASSERT(pri_chan->subchan_cnt > 0, - ("invalid subchan_cnt %d", pri_chan->subchan_cnt)); - pri_chan->subchan_cnt--; - mtx_unlock(&pri_chan->sc_lock); + mtx_lock(&pri_chan->ch_subchan_lock); + TAILQ_REMOVE(&pri_chan->ch_subchans, chan, ch_sublink); + KASSERT(pri_chan->ch_subchan_cnt > 0, + ("invalid subchan_cnt %d", pri_chan->ch_subchan_cnt)); + pri_chan->ch_subchan_cnt--; + mtx_unlock(&pri_chan->ch_subchan_lock); wakeup(pri_chan); vmbus_chan_free(chan); } } -/** - * - * @brief Invoked when all offers have been delivered. - */ -static void -vmbus_channel_on_offers_delivered(struct vmbus_softc *sc, - const struct vmbus_message *msg __unused) -{ - - /* No more new channels for the channel request. */ - vmbus_scan_done(sc); -} - /* * Detach all devices and destroy the corresponding primary channels. */ @@ -445,7 +420,7 @@ vmbus_select_outgoing_channel(struct hv_ int cur_vcpu = 0; int smp_pro_id = PCPU_GET(cpuid); - if (TAILQ_EMPTY(&primary->sc_list_anchor)) { + if (TAILQ_EMPTY(&primary->ch_subchans)) { return outgoing_channel; } @@ -455,7 +430,8 @@ vmbus_select_outgoing_channel(struct hv_ cur_vcpu = VMBUS_PCPU_GET(primary->vmbus_sc, vcpuid, smp_pro_id); - TAILQ_FOREACH(new_channel, &primary->sc_list_anchor, sc_list_entry) { + /* XXX need lock */ + TAILQ_FOREACH(new_channel, &primary->ch_subchans, ch_sublink) { if ((new_channel->ch_stflags & VMBUS_CHAN_ST_OPENED) == 0) { continue; } @@ -491,13 +467,13 @@ vmbus_get_subchan(struct hv_vmbus_channe ret = malloc(subchan_cnt * sizeof(struct hv_vmbus_channel *), M_TEMP, M_WAITOK); - mtx_lock(&pri_chan->sc_lock); + mtx_lock(&pri_chan->ch_subchan_lock); - while (pri_chan->subchan_cnt < subchan_cnt) - mtx_sleep(pri_chan, &pri_chan->sc_lock, 0, "subch", 0); + while (pri_chan->ch_subchan_cnt < subchan_cnt) + mtx_sleep(pri_chan, &pri_chan->ch_subchan_lock, 0, "subch", 0); i = 0; - TAILQ_FOREACH(chan, &pri_chan->sc_list_anchor, sc_list_entry) { + TAILQ_FOREACH(chan, &pri_chan->ch_subchans, ch_sublink) { /* TODO: refcnt chan */ ret[i] = chan; @@ -506,9 +482,9 @@ vmbus_get_subchan(struct hv_vmbus_channe break; } KASSERT(i == subchan_cnt, ("invalid subchan count %d, should be %d", - pri_chan->subchan_cnt, subchan_cnt)); + pri_chan->ch_subchan_cnt, subchan_cnt)); - mtx_unlock(&pri_chan->sc_lock); + mtx_unlock(&pri_chan->ch_subchan_lock); return ret; } @@ -523,10 +499,10 @@ vmbus_rel_subchan(struct hv_vmbus_channe void vmbus_drain_subchan(struct hv_vmbus_channel *pri_chan) { - mtx_lock(&pri_chan->sc_lock); - while (pri_chan->subchan_cnt > 0) - mtx_sleep(pri_chan, &pri_chan->sc_lock, 0, "dsubch", 0); - mtx_unlock(&pri_chan->sc_lock); + mtx_lock(&pri_chan->ch_subchan_lock); + while (pri_chan->ch_subchan_cnt > 0) + mtx_sleep(pri_chan, &pri_chan->ch_subchan_lock, 0, "dsubch", 0); + mtx_unlock(&pri_chan->ch_subchan_lock); } void @@ -536,13 +512,10 @@ vmbus_chan_msgproc(struct vmbus_softc *s uint32_t msg_type; msg_type = ((const struct vmbus_chanmsg_hdr *)msg->msg_data)->chm_type; - if (msg_type >= VMBUS_CHANMSG_TYPE_MAX) { - device_printf(sc->vmbus_dev, "unknown message type 0x%x\n", - msg_type); - return; - } + KASSERT(msg_type < VMBUS_CHANMSG_TYPE_MAX, + ("invalid message type %u", msg_type)); - msg_proc = vmbus_chanmsg_process[msg_type]; + msg_proc = vmbus_chan_msgprocs[msg_type]; if (msg_proc != NULL) msg_proc(sc, msg); } Modified: stable/10/sys/dev/hyperv/vmbus/vmbus.c ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/vmbus.c Tue Oct 11 08:22:17 2016 (r307028) +++ stable/10/sys/dev/hyperv/vmbus/vmbus.c Tue Oct 11 08:29:04 2016 (r307029) @@ -98,7 +98,12 @@ static int vmbus_req_channels(struct v static void vmbus_disconnect(struct vmbus_softc *); static int vmbus_scan(struct vmbus_softc *); static void vmbus_scan_wait(struct vmbus_softc *); +static void vmbus_scan_newchan(struct vmbus_softc *); static void vmbus_scan_newdev(struct vmbus_softc *); +static void vmbus_scan_done(struct vmbus_softc *, + const struct vmbus_message *); +static void vmbus_chanmsg_handle(struct vmbus_softc *, + const struct vmbus_message *); static int vmbus_sysctl_version(SYSCTL_HANDLER_ARGS); @@ -122,6 +127,12 @@ static const uint32_t vmbus_version[] = VMBUS_VERSION_WS2008 }; +static const vmbus_chanmsg_proc_t +vmbus_chanmsg_handlers[VMBUS_CHANMSG_TYPE_MAX] = { + VMBUS_CHANMSG_PROC(CHOFFER_DONE, vmbus_scan_done), + VMBUS_CHANMSG_PROC_WAKEUP(CONNECT_RESP) +}; + static struct vmbus_msghc * vmbus_msghc_alloc(bus_dma_tag_t parent_dtag) { @@ -480,7 +491,7 @@ vmbus_req_channels(struct vmbus_softc *s return error; } -void +static void vmbus_scan_newchan(struct vmbus_softc *sc) { mtx_lock(&sc->vmbus_scan_lock); @@ -489,8 +500,9 @@ vmbus_scan_newchan(struct vmbus_softc *s mtx_unlock(&sc->vmbus_scan_lock); } -void -vmbus_scan_done(struct vmbus_softc *sc) +static void +vmbus_scan_done(struct vmbus_softc *sc, + const struct vmbus_message *msg __unused) { mtx_lock(&sc->vmbus_scan_lock); sc->vmbus_scan_chcnt |= VMBUS_SCAN_CHCNT_DONE; @@ -560,6 +572,27 @@ vmbus_scan(struct vmbus_softc *sc) } static void +vmbus_chanmsg_handle(struct vmbus_softc *sc, const struct vmbus_message *msg) +{ + vmbus_chanmsg_proc_t msg_proc; + uint32_t msg_type; + + msg_type = ((const struct vmbus_chanmsg_hdr *)msg->msg_data)->chm_type; + if (msg_type >= VMBUS_CHANMSG_TYPE_MAX) { + device_printf(sc->vmbus_dev, "unknown message type 0x%x\n", + msg_type); + return; + } + + msg_proc = vmbus_chanmsg_handlers[msg_type]; + if (msg_proc != NULL) + msg_proc(sc, msg); + + /* Channel specific processing */ + vmbus_chan_msgproc(sc, msg); +} + +static void vmbus_msg_task(void *xsc, int pending __unused) { struct vmbus_softc *sc = xsc; @@ -572,7 +605,7 @@ vmbus_msg_task(void *xsc, int pending __ break; } else if (msg->msg_type == HYPERV_MSGTYPE_CHANNEL) { /* Channel message */ - vmbus_chan_msgproc(sc, + vmbus_chanmsg_handle(sc, __DEVOLATILE(const struct vmbus_message *, msg)); } Modified: stable/10/sys/dev/hyperv/vmbus/vmbus_var.h ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/vmbus_var.h Tue Oct 11 08:22:17 2016 (r307028) +++ stable/10/sys/dev/hyperv/vmbus/vmbus_var.h Tue Oct 11 08:29:04 2016 (r307029) @@ -51,6 +51,17 @@ #define VMBUS_CONNID_MESSAGE 1 #define VMBUS_CONNID_EVENT 2 +struct vmbus_message; +struct vmbus_softc; + +typedef void (*vmbus_chanmsg_proc_t)(struct vmbus_softc *, + const struct vmbus_message *); + +#define VMBUS_CHANMSG_PROC(name, func) \ + [VMBUS_CHANMSG_TYPE_##name] = func +#define VMBUS_CHANMSG_PROC_WAKEUP(name) \ + VMBUS_CHANMSG_PROC(name, vmbus_msghc_wakeup) + struct vmbus_pcpu_data { u_long *intr_cnt; /* Hyper-V interrupt counter */ struct vmbus_message *message; /* shared messages */ @@ -150,9 +161,6 @@ const struct vmbus_message *vmbus_msghc_ void vmbus_msghc_wakeup(struct vmbus_softc *, const struct vmbus_message *); void vmbus_msghc_reset(struct vmbus_msghc *, size_t); -void vmbus_scan_done(struct vmbus_softc *); -void vmbus_scan_newchan(struct vmbus_softc *); - uint32_t vmbus_gpadl_alloc(struct vmbus_softc *); #endif /* !_VMBUS_VAR_H_ */ From owner-svn-src-all@freebsd.org Tue Oct 11 08:41:28 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D40B1C0C453; Tue, 11 Oct 2016 08:41:28 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id A034F987; Tue, 11 Oct 2016 08:41:28 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9B8fRPD037395; Tue, 11 Oct 2016 08:41:27 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9B8fRCm037391; Tue, 11 Oct 2016 08:41:27 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610110841.u9B8fRCm037391@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Tue, 11 Oct 2016 08:41:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307030 - in stable/10/sys: conf dev/hyperv/vmbus modules/hyperv/vmbus X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Oct 2016 08:41:28 -0000 Author: sephe Date: Tue Oct 11 08:41:27 2016 New Revision: 307030 URL: https://svnweb.freebsd.org/changeset/base/307030 Log: MFC 302864 hyperv/vmbus: Merge hv_channel_mgmt.c into hv_channel.c Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7126 Deleted: stable/10/sys/dev/hyperv/vmbus/hv_channel_mgmt.c Modified: stable/10/sys/conf/files.amd64 stable/10/sys/conf/files.i386 stable/10/sys/dev/hyperv/vmbus/hv_channel.c stable/10/sys/modules/hyperv/vmbus/Makefile Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/conf/files.amd64 ============================================================================== --- stable/10/sys/conf/files.amd64 Tue Oct 11 08:29:04 2016 (r307029) +++ stable/10/sys/conf/files.amd64 Tue Oct 11 08:41:27 2016 (r307030) @@ -272,7 +272,6 @@ dev/hyperv/utilities/hv_shutdown.c opt dev/hyperv/utilities/hv_timesync.c optional hyperv dev/hyperv/utilities/hv_util.c optional hyperv dev/hyperv/vmbus/hv_channel.c optional hyperv -dev/hyperv/vmbus/hv_channel_mgmt.c optional hyperv dev/hyperv/vmbus/hv_ring_buffer.c optional hyperv dev/hyperv/vmbus/hyperv.c optional hyperv dev/hyperv/vmbus/hyperv_busdma.c optional hyperv Modified: stable/10/sys/conf/files.i386 ============================================================================== --- stable/10/sys/conf/files.i386 Tue Oct 11 08:29:04 2016 (r307029) +++ stable/10/sys/conf/files.i386 Tue Oct 11 08:41:27 2016 (r307030) @@ -249,7 +249,6 @@ dev/hyperv/utilities/hv_shutdown.c opt dev/hyperv/utilities/hv_timesync.c optional hyperv dev/hyperv/utilities/hv_util.c optional hyperv dev/hyperv/vmbus/hv_channel.c optional hyperv -dev/hyperv/vmbus/hv_channel_mgmt.c optional hyperv dev/hyperv/vmbus/hv_ring_buffer.c optional hyperv dev/hyperv/vmbus/hyperv.c optional hyperv dev/hyperv/vmbus/hyperv_busdma.c optional hyperv Modified: stable/10/sys/dev/hyperv/vmbus/hv_channel.c ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/hv_channel.c Tue Oct 11 08:29:04 2016 (r307029) +++ stable/10/sys/dev/hyperv/vmbus/hv_channel.c Tue Oct 11 08:41:27 2016 (r307030) @@ -53,8 +53,28 @@ __FBSDID("$FreeBSD$"); static void vmbus_chan_send_event(hv_vmbus_channel* channel); static void vmbus_chan_update_evtflagcnt(struct vmbus_softc *, const struct hv_vmbus_channel *); + static void vmbus_chan_task(void *, int); static void vmbus_chan_task_nobatch(void *, int); +static void vmbus_chan_detach_task(void *, int); + +static void vmbus_chan_msgproc_choffer(struct vmbus_softc *, + const struct vmbus_message *); +static void vmbus_chan_msgproc_chrescind(struct vmbus_softc *, + const struct vmbus_message *); + +/* + * Vmbus channel message processing. + */ +static const vmbus_chanmsg_proc_t +vmbus_chan_msgprocs[VMBUS_CHANMSG_TYPE_MAX] = { + VMBUS_CHANMSG_PROC(CHOFFER, vmbus_chan_msgproc_choffer), + VMBUS_CHANMSG_PROC(CHRESCIND, vmbus_chan_msgproc_chrescind), + + VMBUS_CHANMSG_PROC_WAKEUP(CHOPEN_RESP), + VMBUS_CHANMSG_PROC_WAKEUP(GPADL_CONNRESP), + VMBUS_CHANMSG_PROC_WAKEUP(GPADL_DISCONNRESP) +}; /** * @brief Trigger an event notification on the specified channel @@ -984,3 +1004,463 @@ vmbus_chan_update_evtflagcnt(struct vmbu } } } + +static struct hv_vmbus_channel * +vmbus_chan_alloc(struct vmbus_softc *sc) +{ + struct hv_vmbus_channel *chan; + + chan = malloc(sizeof(*chan), M_DEVBUF, M_WAITOK | M_ZERO); + + chan->ch_monprm = hyperv_dmamem_alloc(bus_get_dma_tag(sc->vmbus_dev), + HYPERCALL_PARAM_ALIGN, 0, sizeof(struct hyperv_mon_param), + &chan->ch_monprm_dma, BUS_DMA_WAITOK | BUS_DMA_ZERO); + if (chan->ch_monprm == NULL) { + device_printf(sc->vmbus_dev, "monprm alloc failed\n"); + free(chan, M_DEVBUF); + return NULL; + } + + chan->vmbus_sc = sc; + mtx_init(&chan->ch_subchan_lock, "vmbus subchan", NULL, MTX_DEF); + TAILQ_INIT(&chan->ch_subchans); + TASK_INIT(&chan->ch_detach_task, 0, vmbus_chan_detach_task, chan); + + return chan; +} + +static void +vmbus_chan_free(struct hv_vmbus_channel *chan) +{ + /* TODO: assert sub-channel list is empty */ + /* TODO: asset no longer on the primary channel's sub-channel list */ + /* TODO: asset no longer on the vmbus channel list */ + hyperv_dmamem_free(&chan->ch_monprm_dma, chan->ch_monprm); + mtx_destroy(&chan->ch_subchan_lock); + free(chan, M_DEVBUF); +} + +static int +vmbus_chan_add(struct hv_vmbus_channel *newchan) +{ + struct vmbus_softc *sc = newchan->vmbus_sc; + struct hv_vmbus_channel *prichan; + + if (newchan->ch_id == 0) { + /* + * XXX + * Chan0 will neither be processed nor should be offered; + * skip it. + */ + device_printf(sc->vmbus_dev, "got chan0 offer, discard\n"); + return EINVAL; + } else if (newchan->ch_id >= VMBUS_CHAN_MAX) { + device_printf(sc->vmbus_dev, "invalid chan%u offer\n", + newchan->ch_id); + return EINVAL; + } + sc->vmbus_chmap[newchan->ch_id] = newchan; + + if (bootverbose) { + device_printf(sc->vmbus_dev, "chan%u subidx%u offer\n", + newchan->ch_id, newchan->ch_subidx); + } + + mtx_lock(&sc->vmbus_prichan_lock); + TAILQ_FOREACH(prichan, &sc->vmbus_prichans, ch_prilink) { + /* + * Sub-channel will have the same type GUID and instance + * GUID as its primary channel. + */ + if (memcmp(&prichan->ch_guid_type, &newchan->ch_guid_type, + sizeof(struct hyperv_guid)) == 0 && + memcmp(&prichan->ch_guid_inst, &newchan->ch_guid_inst, + sizeof(struct hyperv_guid)) == 0) + break; + } + if (VMBUS_CHAN_ISPRIMARY(newchan)) { + if (prichan == NULL) { + /* Install the new primary channel */ + TAILQ_INSERT_TAIL(&sc->vmbus_prichans, newchan, + ch_prilink); + mtx_unlock(&sc->vmbus_prichan_lock); + return 0; + } else { + mtx_unlock(&sc->vmbus_prichan_lock); + device_printf(sc->vmbus_dev, "duplicated primary " + "chan%u\n", newchan->ch_id); + return EINVAL; + } + } else { /* Sub-channel */ + if (prichan == NULL) { + mtx_unlock(&sc->vmbus_prichan_lock); + device_printf(sc->vmbus_dev, "no primary chan for " + "chan%u\n", newchan->ch_id); + return EINVAL; + } + /* + * Found the primary channel for this sub-channel and + * move on. + * + * XXX refcnt prichan + */ + } + mtx_unlock(&sc->vmbus_prichan_lock); + + /* + * This is a sub-channel; link it with the primary channel. + */ + KASSERT(!VMBUS_CHAN_ISPRIMARY(newchan), + ("new channel is not sub-channel")); + KASSERT(prichan != NULL, ("no primary channel")); + + newchan->ch_prichan = prichan; + newchan->ch_dev = prichan->ch_dev; + + mtx_lock(&prichan->ch_subchan_lock); + TAILQ_INSERT_TAIL(&prichan->ch_subchans, newchan, ch_sublink); + /* + * Bump up sub-channel count and notify anyone that is + * interested in this sub-channel, after this sub-channel + * is setup. + */ + prichan->ch_subchan_cnt++; + mtx_unlock(&prichan->ch_subchan_lock); + wakeup(prichan); + + return 0; +} + +void +vmbus_channel_cpu_set(struct hv_vmbus_channel *chan, int cpu) +{ + KASSERT(cpu >= 0 && cpu < mp_ncpus, ("invalid cpu %d", cpu)); + + if (chan->vmbus_sc->vmbus_version == VMBUS_VERSION_WS2008 || + chan->vmbus_sc->vmbus_version == VMBUS_VERSION_WIN7) { + /* Only cpu0 is supported */ + cpu = 0; + } + + chan->target_cpu = cpu; + chan->target_vcpu = VMBUS_PCPU_GET(chan->vmbus_sc, vcpuid, cpu); + + if (bootverbose) { + printf("vmbus_chan%u: assigned to cpu%u [vcpu%u]\n", + chan->ch_id, + chan->target_cpu, chan->target_vcpu); + } +} + +void +vmbus_channel_cpu_rr(struct hv_vmbus_channel *chan) +{ + static uint32_t vmbus_chan_nextcpu; + int cpu; + + cpu = atomic_fetchadd_int(&vmbus_chan_nextcpu, 1) % mp_ncpus; + vmbus_channel_cpu_set(chan, cpu); +} + +static void +vmbus_chan_cpu_default(struct hv_vmbus_channel *chan) +{ + /* + * By default, pin the channel to cpu0. Devices having + * special channel-cpu mapping requirement should call + * vmbus_channel_cpu_{set,rr}(). + */ + vmbus_channel_cpu_set(chan, 0); +} + +static void +vmbus_chan_msgproc_choffer(struct vmbus_softc *sc, + const struct vmbus_message *msg) +{ + const struct vmbus_chanmsg_choffer *offer; + struct hv_vmbus_channel *chan; + int error; + + offer = (const struct vmbus_chanmsg_choffer *)msg->msg_data; + + chan = vmbus_chan_alloc(sc); + if (chan == NULL) { + device_printf(sc->vmbus_dev, "allocate chan%u failed\n", + offer->chm_chanid); + return; + } + + chan->ch_id = offer->chm_chanid; + chan->ch_subidx = offer->chm_subidx; + chan->ch_guid_type = offer->chm_chtype; + chan->ch_guid_inst = offer->chm_chinst; + + /* Batch reading is on by default */ + chan->ch_flags |= VMBUS_CHAN_FLAG_BATCHREAD; + + chan->ch_monprm->mp_connid = VMBUS_CONNID_EVENT; + if (sc->vmbus_version != VMBUS_VERSION_WS2008) + chan->ch_monprm->mp_connid = offer->chm_connid; + + if (offer->chm_flags1 & VMBUS_CHOFFER_FLAG1_HASMNF) { + /* + * Setup MNF stuffs. + */ + chan->ch_flags |= VMBUS_CHAN_FLAG_HASMNF; + chan->ch_montrig_idx = offer->chm_montrig / VMBUS_MONTRIG_LEN; + if (chan->ch_montrig_idx >= VMBUS_MONTRIGS_MAX) + panic("invalid monitor trigger %u", offer->chm_montrig); + chan->ch_montrig_mask = + 1 << (offer->chm_montrig % VMBUS_MONTRIG_LEN); + } + + /* Select default cpu for this channel. */ + vmbus_chan_cpu_default(chan); + + error = vmbus_chan_add(chan); + if (error) { + device_printf(sc->vmbus_dev, "add chan%u failed: %d\n", + chan->ch_id, error); + vmbus_chan_free(chan); + return; + } + + if (VMBUS_CHAN_ISPRIMARY(chan)) { + /* + * Add device for this primary channel. + * + * NOTE: + * Error is ignored here; don't have much to do if error + * really happens. + */ + hv_vmbus_child_device_register(chan); + } +} + +/* + * XXX pretty broken; need rework. + */ +static void +vmbus_chan_msgproc_chrescind(struct vmbus_softc *sc, + const struct vmbus_message *msg) +{ + const struct vmbus_chanmsg_chrescind *note; + struct hv_vmbus_channel *chan; + + note = (const struct vmbus_chanmsg_chrescind *)msg->msg_data; + if (note->chm_chanid > VMBUS_CHAN_MAX) { + device_printf(sc->vmbus_dev, "invalid rescinded chan%u\n", + note->chm_chanid); + return; + } + + if (bootverbose) { + device_printf(sc->vmbus_dev, "chan%u rescinded\n", + note->chm_chanid); + } + + chan = sc->vmbus_chmap[note->chm_chanid]; + if (chan == NULL) + return; + sc->vmbus_chmap[note->chm_chanid] = NULL; + + taskqueue_enqueue(taskqueue_thread, &chan->ch_detach_task); +} + +static void +vmbus_chan_detach_task(void *xchan, int pending __unused) +{ + struct hv_vmbus_channel *chan = xchan; + + if (VMBUS_CHAN_ISPRIMARY(chan)) { + /* Only primary channel owns the device */ + hv_vmbus_child_device_unregister(chan); + /* NOTE: DO NOT free primary channel for now */ + } else { + struct vmbus_softc *sc = chan->vmbus_sc; + struct hv_vmbus_channel *pri_chan = chan->ch_prichan; + struct vmbus_chanmsg_chfree *req; + struct vmbus_msghc *mh; + int error; + + mh = vmbus_msghc_get(sc, sizeof(*req)); + if (mh == NULL) { + device_printf(sc->vmbus_dev, + "can not get msg hypercall for chfree(chan%u)\n", + chan->ch_id); + goto remove; + } + + req = vmbus_msghc_dataptr(mh); + req->chm_hdr.chm_type = VMBUS_CHANMSG_TYPE_CHFREE; + req->chm_chanid = chan->ch_id; + + error = vmbus_msghc_exec_noresult(mh); + vmbus_msghc_put(sc, mh); + + if (error) { + device_printf(sc->vmbus_dev, + "chfree(chan%u) failed: %d", + chan->ch_id, error); + /* NOTE: Move on! */ + } else { + if (bootverbose) { + device_printf(sc->vmbus_dev, "chan%u freed\n", + chan->ch_id); + } + } +remove: + mtx_lock(&pri_chan->ch_subchan_lock); + TAILQ_REMOVE(&pri_chan->ch_subchans, chan, ch_sublink); + KASSERT(pri_chan->ch_subchan_cnt > 0, + ("invalid subchan_cnt %d", pri_chan->ch_subchan_cnt)); + pri_chan->ch_subchan_cnt--; + mtx_unlock(&pri_chan->ch_subchan_lock); + wakeup(pri_chan); + + vmbus_chan_free(chan); + } +} + +/* + * Detach all devices and destroy the corresponding primary channels. + */ +void +vmbus_chan_destroy_all(struct vmbus_softc *sc) +{ + struct hv_vmbus_channel *chan; + + mtx_lock(&sc->vmbus_prichan_lock); + while ((chan = TAILQ_FIRST(&sc->vmbus_prichans)) != NULL) { + KASSERT(VMBUS_CHAN_ISPRIMARY(chan), ("not primary channel")); + TAILQ_REMOVE(&sc->vmbus_prichans, chan, ch_prilink); + mtx_unlock(&sc->vmbus_prichan_lock); + + hv_vmbus_child_device_unregister(chan); + vmbus_chan_free(chan); + + mtx_lock(&sc->vmbus_prichan_lock); + } + bzero(sc->vmbus_chmap, + sizeof(struct hv_vmbus_channel *) * VMBUS_CHAN_MAX); + mtx_unlock(&sc->vmbus_prichan_lock); +} + +/** + * @brief Select the best outgoing channel + * + * The channel whose vcpu binding is closest to the currect vcpu will + * be selected. + * If no multi-channel, always select primary channel + * + * @param primary - primary channel + */ +struct hv_vmbus_channel * +vmbus_select_outgoing_channel(struct hv_vmbus_channel *primary) +{ + hv_vmbus_channel *new_channel = NULL; + hv_vmbus_channel *outgoing_channel = primary; + int old_cpu_distance = 0; + int new_cpu_distance = 0; + int cur_vcpu = 0; + int smp_pro_id = PCPU_GET(cpuid); + + if (TAILQ_EMPTY(&primary->ch_subchans)) { + return outgoing_channel; + } + + if (smp_pro_id >= MAXCPU) { + return outgoing_channel; + } + + cur_vcpu = VMBUS_PCPU_GET(primary->vmbus_sc, vcpuid, smp_pro_id); + + /* XXX need lock */ + TAILQ_FOREACH(new_channel, &primary->ch_subchans, ch_sublink) { + if ((new_channel->ch_stflags & VMBUS_CHAN_ST_OPENED) == 0) { + continue; + } + + if (new_channel->target_vcpu == cur_vcpu){ + return new_channel; + } + + old_cpu_distance = ((outgoing_channel->target_vcpu > cur_vcpu) ? + (outgoing_channel->target_vcpu - cur_vcpu) : + (cur_vcpu - outgoing_channel->target_vcpu)); + + new_cpu_distance = ((new_channel->target_vcpu > cur_vcpu) ? + (new_channel->target_vcpu - cur_vcpu) : + (cur_vcpu - new_channel->target_vcpu)); + + if (old_cpu_distance < new_cpu_distance) { + continue; + } + + outgoing_channel = new_channel; + } + + return(outgoing_channel); +} + +struct hv_vmbus_channel ** +vmbus_get_subchan(struct hv_vmbus_channel *pri_chan, int subchan_cnt) +{ + struct hv_vmbus_channel **ret, *chan; + int i; + + ret = malloc(subchan_cnt * sizeof(struct hv_vmbus_channel *), M_TEMP, + M_WAITOK); + + mtx_lock(&pri_chan->ch_subchan_lock); + + while (pri_chan->ch_subchan_cnt < subchan_cnt) + mtx_sleep(pri_chan, &pri_chan->ch_subchan_lock, 0, "subch", 0); + + i = 0; + TAILQ_FOREACH(chan, &pri_chan->ch_subchans, ch_sublink) { + /* TODO: refcnt chan */ + ret[i] = chan; + + ++i; + if (i == subchan_cnt) + break; + } + KASSERT(i == subchan_cnt, ("invalid subchan count %d, should be %d", + pri_chan->ch_subchan_cnt, subchan_cnt)); + + mtx_unlock(&pri_chan->ch_subchan_lock); + + return ret; +} + +void +vmbus_rel_subchan(struct hv_vmbus_channel **subchan, int subchan_cnt __unused) +{ + + free(subchan, M_TEMP); +} + +void +vmbus_drain_subchan(struct hv_vmbus_channel *pri_chan) +{ + mtx_lock(&pri_chan->ch_subchan_lock); + while (pri_chan->ch_subchan_cnt > 0) + mtx_sleep(pri_chan, &pri_chan->ch_subchan_lock, 0, "dsubch", 0); + mtx_unlock(&pri_chan->ch_subchan_lock); +} + +void +vmbus_chan_msgproc(struct vmbus_softc *sc, const struct vmbus_message *msg) +{ + vmbus_chanmsg_proc_t msg_proc; + uint32_t msg_type; + + msg_type = ((const struct vmbus_chanmsg_hdr *)msg->msg_data)->chm_type; + KASSERT(msg_type < VMBUS_CHANMSG_TYPE_MAX, + ("invalid message type %u", msg_type)); + + msg_proc = vmbus_chan_msgprocs[msg_type]; + if (msg_proc != NULL) + msg_proc(sc, msg); +} Modified: stable/10/sys/modules/hyperv/vmbus/Makefile ============================================================================== --- stable/10/sys/modules/hyperv/vmbus/Makefile Tue Oct 11 08:29:04 2016 (r307029) +++ stable/10/sys/modules/hyperv/vmbus/Makefile Tue Oct 11 08:41:27 2016 (r307030) @@ -5,7 +5,6 @@ KMOD= hv_vmbus SRCS= hv_channel.c \ - hv_channel_mgmt.c \ hv_ring_buffer.c \ hyperv.c \ hyperv_busdma.c \ From owner-svn-src-all@freebsd.org Tue Oct 11 08:48:37 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E70BDC0C605; Tue, 11 Oct 2016 08:48:37 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id C370BCDE; Tue, 11 Oct 2016 08:48:37 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9B8mar7038329; Tue, 11 Oct 2016 08:48:36 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9B8maju038324; Tue, 11 Oct 2016 08:48:36 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610110848.u9B8maju038324@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Tue, 11 Oct 2016 08:48:36 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307031 - stable/10/sys/dev/hyperv/vmbus X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Oct 2016 08:48:38 -0000 Author: sephe Date: Tue Oct 11 08:48:36 2016 New Revision: 307031 URL: https://svnweb.freebsd.org/changeset/base/307031 Log: MFC 302867-302870 302867 hyperv/vmbus: Remove unused struct Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7127 302868 hyperv/vmbus: Function rename Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7129 302869 hyperv/vmbus: Remove unused function definition/declaration. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7131 302870 hyperv/vmbus: Use iovec for bufring scatter/gather list. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7134 Modified: stable/10/sys/dev/hyperv/vmbus/hv_channel.c stable/10/sys/dev/hyperv/vmbus/hv_ring_buffer.c stable/10/sys/dev/hyperv/vmbus/hv_vmbus_priv.h stable/10/sys/dev/hyperv/vmbus/vmbus.c stable/10/sys/dev/hyperv/vmbus/vmbus_var.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/hyperv/vmbus/hv_channel.c ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/hv_channel.c Tue Oct 11 08:41:27 2016 (r307030) +++ stable/10/sys/dev/hyperv/vmbus/hv_channel.c Tue Oct 11 08:48:36 2016 (r307031) @@ -616,7 +616,7 @@ hv_vmbus_channel_send_packet( uint64_t aligned_data; uint32_t packet_len_aligned; boolean_t need_sig; - hv_vmbus_sg_buffer_list buffer_list[3]; + struct iovec iov[3]; packet_len = sizeof(hv_vm_packet_descriptor) + buffer_len; packet_len_aligned = HV_ALIGN_UP(packet_len, sizeof(uint64_t)); @@ -630,17 +630,16 @@ hv_vmbus_channel_send_packet( desc.length8 = (uint16_t) (packet_len_aligned >> 3); desc.transaction_id = request_id; - buffer_list[0].data = &desc; - buffer_list[0].length = sizeof(hv_vm_packet_descriptor); + iov[0].iov_base = &desc; + iov[0].iov_len = sizeof(hv_vm_packet_descriptor); - buffer_list[1].data = buffer; - buffer_list[1].length = buffer_len; + iov[1].iov_base = buffer; + iov[1].iov_len = buffer_len; - buffer_list[2].data = &aligned_data; - buffer_list[2].length = packet_len_aligned - packet_len; + iov[2].iov_base = &aligned_data; + iov[2].iov_len = packet_len_aligned - packet_len; - ret = hv_ring_buffer_write(&channel->outbound, buffer_list, 3, - &need_sig); + ret = hv_ring_buffer_write(&channel->outbound, iov, 3, &need_sig); /* TODO: We should determine if this is optional */ if (ret == 0 && need_sig) @@ -668,7 +667,7 @@ hv_vmbus_channel_send_packet_pagebuffer( uint32_t packet_len; uint32_t page_buflen; uint32_t packetLen_aligned; - hv_vmbus_sg_buffer_list buffer_list[4]; + struct iovec iov[4]; hv_vmbus_channel_packet_page_buffer desc; uint32_t descSize; uint64_t alignedData = 0; @@ -694,20 +693,19 @@ hv_vmbus_channel_send_packet_pagebuffer( desc.transaction_id = request_id; desc.range_count = page_count; - buffer_list[0].data = &desc; - buffer_list[0].length = descSize; + iov[0].iov_base = &desc; + iov[0].iov_len = descSize; - buffer_list[1].data = page_buffers; - buffer_list[1].length = page_buflen; + iov[1].iov_base = page_buffers; + iov[1].iov_len = page_buflen; - buffer_list[2].data = buffer; - buffer_list[2].length = buffer_len; + iov[2].iov_base = buffer; + iov[2].iov_len = buffer_len; - buffer_list[3].data = &alignedData; - buffer_list[3].length = packetLen_aligned - packet_len; + iov[3].iov_base = &alignedData; + iov[3].iov_len = packetLen_aligned - packet_len; - ret = hv_ring_buffer_write(&channel->outbound, buffer_list, 4, - &need_sig); + ret = hv_ring_buffer_write(&channel->outbound, iov, 4, &need_sig); /* TODO: We should determine if this is optional */ if (ret == 0 && need_sig) @@ -735,7 +733,7 @@ hv_vmbus_channel_send_packet_multipagebu uint32_t packet_len_aligned; uint32_t pfn_count; uint64_t aligned_data = 0; - hv_vmbus_sg_buffer_list buffer_list[3]; + struct iovec iov[3]; hv_vmbus_channel_packet_multipage_buffer desc; pfn_count = @@ -772,17 +770,16 @@ hv_vmbus_channel_send_packet_multipagebu memcpy(desc.range.pfn_array, multi_page_buffer->pfn_array, pfn_count * sizeof(uint64_t)); - buffer_list[0].data = &desc; - buffer_list[0].length = desc_size; + iov[0].iov_base = &desc; + iov[0].iov_len = desc_size; - buffer_list[1].data = buffer; - buffer_list[1].length = buffer_len; + iov[1].iov_base = buffer; + iov[1].iov_len = buffer_len; - buffer_list[2].data = &aligned_data; - buffer_list[2].length = packet_len_aligned - packet_len; + iov[2].iov_base = &aligned_data; + iov[2].iov_len = packet_len_aligned - packet_len; - ret = hv_ring_buffer_write(&channel->outbound, buffer_list, 3, - &need_sig); + ret = hv_ring_buffer_write(&channel->outbound, iov, 3, &need_sig); /* TODO: We should determine if this is optional */ if (ret == 0 && need_sig) @@ -1233,7 +1230,7 @@ vmbus_chan_msgproc_choffer(struct vmbus_ * Error is ignored here; don't have much to do if error * really happens. */ - hv_vmbus_child_device_register(chan); + vmbus_add_child(chan); } } @@ -1274,7 +1271,7 @@ vmbus_chan_detach_task(void *xchan, int if (VMBUS_CHAN_ISPRIMARY(chan)) { /* Only primary channel owns the device */ - hv_vmbus_child_device_unregister(chan); + vmbus_delete_child(chan); /* NOTE: DO NOT free primary channel for now */ } else { struct vmbus_softc *sc = chan->vmbus_sc; @@ -1336,7 +1333,7 @@ vmbus_chan_destroy_all(struct vmbus_soft TAILQ_REMOVE(&sc->vmbus_prichans, chan, ch_prilink); mtx_unlock(&sc->vmbus_prichan_lock); - hv_vmbus_child_device_unregister(chan); + vmbus_delete_child(chan); vmbus_chan_free(chan); mtx_lock(&sc->vmbus_prichan_lock); Modified: stable/10/sys/dev/hyperv/vmbus/hv_ring_buffer.c ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/hv_ring_buffer.c Tue Oct 11 08:41:27 2016 (r307030) +++ stable/10/sys/dev/hyperv/vmbus/hv_ring_buffer.c Tue Oct 11 08:48:36 2016 (r307031) @@ -254,7 +254,7 @@ hv_ring_buffer_needsig_on_write( static uint32_t copy_to_ring_buffer( hv_vmbus_ring_buffer_info* ring_info, uint32_t start_write_offset, - char* src, + const uint8_t *src, uint32_t src_len); static uint32_t copy_from_ring_buffer( @@ -263,16 +263,6 @@ static uint32_t copy_from_ring_buffer( uint32_t dest_len, uint32_t start_read_offset); - -/** - * @brief Get the interrupt mask for the specified ring buffer. - */ -uint32_t -hv_vmbus_get_ring_buffer_interrupt_mask(hv_vmbus_ring_buffer_info *rbi) -{ - return rbi->ring_buffer->interrupt_mask; -} - /** * @brief Initialize the ring buffer. */ @@ -309,8 +299,8 @@ void hv_ring_buffer_cleanup(hv_vmbus_rin int hv_ring_buffer_write( hv_vmbus_ring_buffer_info* out_ring_info, - hv_vmbus_sg_buffer_list sg_buffers[], - uint32_t sg_buffer_count, + const struct iovec iov[], + uint32_t iovlen, boolean_t *need_sig) { int i = 0; @@ -322,8 +312,8 @@ hv_ring_buffer_write( volatile uint32_t next_write_location; uint64_t prev_indices = 0; - for (i = 0; i < sg_buffer_count; i++) { - total_bytes_to_write += sg_buffers[i].length; + for (i = 0; i < iovlen; i++) { + total_bytes_to_write += iov[i].iov_len; } total_bytes_to_write += sizeof(uint64_t); @@ -352,10 +342,9 @@ hv_ring_buffer_write( old_write_location = next_write_location; - for (i = 0; i < sg_buffer_count; i++) { + for (i = 0; i < iovlen; i++) { next_write_location = copy_to_ring_buffer(out_ring_info, - next_write_location, (char *) sg_buffers[i].data, - sg_buffers[i].length); + next_write_location, iov[i].iov_base, iov[i].iov_len); } /* @@ -494,11 +483,11 @@ hv_ring_buffer_read( * * Assume there is enough room. Handles wrap-around in dest case only! */ -uint32_t +static uint32_t copy_to_ring_buffer( hv_vmbus_ring_buffer_info* ring_info, uint32_t start_write_offset, - char* src, + const uint8_t *src, uint32_t src_len) { char *ring_buffer = get_ring_buffer(ring_info); Modified: stable/10/sys/dev/hyperv/vmbus/hv_vmbus_priv.h ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/hv_vmbus_priv.h Tue Oct 11 08:41:27 2016 (r307030) +++ stable/10/sys/dev/hyperv/vmbus/hv_vmbus_priv.h Tue Oct 11 08:48:36 2016 (r307031) @@ -35,39 +35,12 @@ #include #include #include +#include #include struct vmbus_softc; -typedef struct { - void* data; - uint32_t length; -} hv_vmbus_sg_buffer_list; - -typedef struct { - uint32_t current_interrupt_mask; - uint32_t current_read_index; - uint32_t current_write_index; - uint32_t bytes_avail_to_read; - uint32_t bytes_avail_to_write; -} hv_vmbus_ring_buffer_debug_info; - -typedef struct { - uint32_t rel_id; - struct hyperv_guid interface_type; - struct hyperv_guid interface_instance; - uint32_t monitor_id; - uint32_t server_monitor_pending; - uint32_t server_monitor_latency; - uint32_t server_monitor_connection_id; - uint32_t client_monitor_pending; - uint32_t client_monitor_latency; - uint32_t client_monitor_connection_id; - hv_vmbus_ring_buffer_debug_info inbound; - hv_vmbus_ring_buffer_debug_info outbound; -} hv_vmbus_channel_debug_info; - /* * The format must be the same as hv_vm_data_gpa_direct */ @@ -118,8 +91,8 @@ void hv_ring_buffer_cleanup( int hv_ring_buffer_write( hv_vmbus_ring_buffer_info *ring_info, - hv_vmbus_sg_buffer_list sg_buffers[], - uint32_t sg_buff_count, + const struct iovec iov[], + uint32_t iovlen, boolean_t *need_sig); int hv_ring_buffer_peek( @@ -133,22 +106,10 @@ int hv_ring_buffer_read( uint32_t buffer_len, uint32_t offset); -uint32_t hv_vmbus_get_ring_buffer_interrupt_mask( - hv_vmbus_ring_buffer_info *ring_info); - -void hv_vmbus_dump_ring_info( - hv_vmbus_ring_buffer_info *ring_info, - char *prefix); - void hv_ring_buffer_read_begin( hv_vmbus_ring_buffer_info *ring_info); uint32_t hv_ring_buffer_read_end( hv_vmbus_ring_buffer_info *ring_info); -int hv_vmbus_child_device_register( - struct hv_vmbus_channel *chan); -int hv_vmbus_child_device_unregister( - struct hv_vmbus_channel *chan); - #endif /* __HYPERV_PRIV_H__ */ Modified: stable/10/sys/dev/hyperv/vmbus/vmbus.c ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/vmbus.c Tue Oct 11 08:41:27 2016 (r307030) +++ stable/10/sys/dev/hyperv/vmbus/vmbus.c Tue Oct 11 08:48:36 2016 (r307031) @@ -1101,7 +1101,7 @@ vmbus_child_pnpinfo_str(device_t dev, de } int -hv_vmbus_child_device_register(struct hv_vmbus_channel *chan) +vmbus_add_child(struct hv_vmbus_channel *chan) { struct vmbus_softc *sc = chan->vmbus_sc; device_t parent = sc->vmbus_dev; @@ -1126,7 +1126,7 @@ done: } int -hv_vmbus_child_device_unregister(struct hv_vmbus_channel *chan) +vmbus_delete_child(struct hv_vmbus_channel *chan) { int error; Modified: stable/10/sys/dev/hyperv/vmbus/vmbus_var.h ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/vmbus_var.h Tue Oct 11 08:41:27 2016 (r307030) +++ stable/10/sys/dev/hyperv/vmbus/vmbus_var.h Tue Oct 11 08:48:36 2016 (r307031) @@ -145,6 +145,8 @@ struct vmbus_msghc; void vmbus_event_proc(struct vmbus_softc *, int); void vmbus_event_proc_compat(struct vmbus_softc *, int); void vmbus_handle_intr(struct trapframe *); +int vmbus_add_child(struct hv_vmbus_channel *); +int vmbus_delete_child(struct hv_vmbus_channel *); void vmbus_et_intr(struct trapframe *); From owner-svn-src-all@freebsd.org Tue Oct 11 08:52:28 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 9F9DEC0C7D2; Tue, 11 Oct 2016 08:52:28 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 763E4BF; Tue, 11 Oct 2016 08:52:28 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9B8qRjJ041799; Tue, 11 Oct 2016 08:52:27 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9B8qRnN041797; Tue, 11 Oct 2016 08:52:27 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610110852.u9B8qRnN041797@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Tue, 11 Oct 2016 08:52:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307032 - in stable/10/sys/dev/hyperv: include vmbus X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Oct 2016 08:52:28 -0000 Author: sephe Date: Tue Oct 11 08:52:27 2016 New Revision: 307032 URL: https://svnweb.freebsd.org/changeset/base/307032 Log: MFC 302871,302872 302871 hyperv/vmbus: Add vmbus_chan_gpadl_connect, which takes GPA physaddr Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7139 302872 hyperv/vmbus: Busdma-fy channel bufring. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7140 Modified: stable/10/sys/dev/hyperv/include/hyperv.h stable/10/sys/dev/hyperv/vmbus/hv_channel.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/hyperv/include/hyperv.h ============================================================================== --- stable/10/sys/dev/hyperv/include/hyperv.h Tue Oct 11 08:48:36 2016 (r307031) +++ stable/10/sys/dev/hyperv/include/hyperv.h Tue Oct 11 08:52:27 2016 (r307032) @@ -257,13 +257,6 @@ typedef struct hv_vmbus_channel { int ch_montrig_idx; /* MNF trig index */ uint32_t ch_montrig_mask;/* MNF trig mask */ - uint32_t ring_buffer_gpadl_handle; - /* - * Allocated memory for ring buffer - */ - void* ring_buffer_pages; - unsigned long ring_buffer_size; - uint32_t ring_buffer_page_count; /* * send to parent */ @@ -312,6 +305,10 @@ typedef struct hv_vmbus_channel { void *hv_chan_priv2; void *hv_chan_priv3; + void *ch_bufring; /* TX+RX bufrings */ + struct hyperv_dma ch_bufring_dma; + uint32_t ch_bufring_gpadl; + struct task ch_detach_task; TAILQ_ENTRY(hv_vmbus_channel) ch_prilink; /* primary chan link */ uint32_t ch_subidx; /* subchan index */ @@ -409,6 +406,9 @@ int hv_vmbus_channel_teardown_gpdal( hv_vmbus_channel* channel, uint32_t gpadl_handle); +int vmbus_chan_gpadl_connect(struct hv_vmbus_channel *chan, + bus_addr_t paddr, int size, uint32_t *gpadl); + struct hv_vmbus_channel* vmbus_select_outgoing_channel(struct hv_vmbus_channel *promary); void vmbus_channel_cpu_set(struct hv_vmbus_channel *chan, int cpu); Modified: stable/10/sys/dev/hyperv/vmbus/hv_channel.c ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/hv_channel.c Tue Oct 11 08:48:36 2016 (r307031) +++ stable/10/sys/dev/hyperv/vmbus/hv_channel.c Tue Oct 11 08:52:27 2016 (r307032) @@ -45,6 +45,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include #include @@ -202,7 +203,7 @@ hv_vmbus_channel_open( struct vmbus_msghc *mh; uint32_t status; int ret = 0; - void *in, *out; + uint8_t *br; if (user_data_len > VMBUS_CHANMSG_CHOPEN_UDATA_SIZE) { device_printf(sc->vmbus_dev, @@ -210,6 +211,10 @@ hv_vmbus_channel_open( user_data_len, new_channel->ch_id); return EINVAL; } + KASSERT((send_ring_buffer_size & PAGE_MASK) == 0, + ("send bufring size is not multiple page")); + KASSERT((recv_ring_buffer_size & PAGE_MASK) == 0, + ("recv bufring size is not multiple page")); if (atomic_testandset_int(&new_channel->ch_stflags, VMBUS_CHAN_ST_OPENED_SHIFT)) @@ -230,46 +235,43 @@ hv_vmbus_channel_open( vmbus_chan_task_nobatch, new_channel); } - /* Allocate the ring buffer */ - out = contigmalloc((send_ring_buffer_size + recv_ring_buffer_size), - M_DEVBUF, M_ZERO, 0UL, BUS_SPACE_MAXADDR, PAGE_SIZE, 0); - KASSERT(out != NULL, - ("Error VMBUS: contigmalloc failed to allocate Ring Buffer!")); - if (out == NULL) { + /* + * Allocate the TX+RX bufrings. + * XXX should use ch_dev dtag + */ + br = hyperv_dmamem_alloc(bus_get_dma_tag(sc->vmbus_dev), + PAGE_SIZE, 0, send_ring_buffer_size + recv_ring_buffer_size, + &new_channel->ch_bufring_dma, BUS_DMA_WAITOK | BUS_DMA_ZERO); + if (br == NULL) { + device_printf(sc->vmbus_dev, "bufring allocation failed\n"); ret = ENOMEM; goto failed; } + new_channel->ch_bufring = br; - in = ((uint8_t *) out + send_ring_buffer_size); - - new_channel->ring_buffer_pages = out; - new_channel->ring_buffer_page_count = (send_ring_buffer_size + - recv_ring_buffer_size) >> PAGE_SHIFT; - new_channel->ring_buffer_size = send_ring_buffer_size + - recv_ring_buffer_size; - - hv_vmbus_ring_buffer_init( - &new_channel->outbound, - out, - send_ring_buffer_size); - - hv_vmbus_ring_buffer_init( - &new_channel->inbound, - in, - recv_ring_buffer_size); + /* TX bufring comes first */ + hv_vmbus_ring_buffer_init(&new_channel->outbound, + br, send_ring_buffer_size); + /* RX bufring immediately follows TX bufring */ + hv_vmbus_ring_buffer_init(&new_channel->inbound, + br + send_ring_buffer_size, recv_ring_buffer_size); /* Create sysctl tree for this channel */ vmbus_channel_sysctl_create(new_channel); - /** - * Establish the gpadl for the ring buffer + /* + * Connect the bufrings, both RX and TX, to this channel. */ - new_channel->ring_buffer_gpadl_handle = 0; - - ret = hv_vmbus_channel_establish_gpadl(new_channel, - new_channel->outbound.ring_buffer, + ret = vmbus_chan_gpadl_connect(new_channel, + new_channel->ch_bufring_dma.hv_paddr, send_ring_buffer_size + recv_ring_buffer_size, - &new_channel->ring_buffer_gpadl_handle); + &new_channel->ch_bufring_gpadl); + if (ret != 0) { + device_printf(sc->vmbus_dev, + "failed to connect bufring GPADL to chan%u\n", + new_channel->ch_id); + goto failed; + } /* * Open channel w/ the bufring GPADL on the target CPU. @@ -287,7 +289,7 @@ hv_vmbus_channel_open( req->chm_hdr.chm_type = VMBUS_CHANMSG_TYPE_CHOPEN; req->chm_chanid = new_channel->ch_id; req->chm_openid = new_channel->ch_id; - req->chm_gpadl = new_channel->ring_buffer_gpadl_handle; + req->chm_gpadl = new_channel->ch_bufring_gpadl; req->chm_vcpuid = new_channel->target_vcpu; req->chm_rxbr_pgofs = send_ring_buffer_size >> PAGE_SHIFT; if (user_data_len) @@ -321,6 +323,16 @@ hv_vmbus_channel_open( ret = ENXIO; failed: + if (new_channel->ch_bufring_gpadl) { + hv_vmbus_channel_teardown_gpdal(new_channel, + new_channel->ch_bufring_gpadl); + new_channel->ch_bufring_gpadl = 0; + } + if (new_channel->ch_bufring != NULL) { + hyperv_dmamem_free(&new_channel->ch_bufring_dma, + new_channel->ch_bufring); + new_channel->ch_bufring = NULL; + } atomic_clear_int(&new_channel->ch_stflags, VMBUS_CHAN_ST_OPENED); return ret; } @@ -330,26 +342,33 @@ failed: */ int hv_vmbus_channel_establish_gpadl(struct hv_vmbus_channel *channel, - void *contig_buffer, uint32_t size, uint32_t *gpadl0) + void *contig_buffer, uint32_t size, uint32_t *gpadl) { - struct vmbus_softc *sc = channel->vmbus_sc; + return vmbus_chan_gpadl_connect(channel, + hv_get_phys_addr(contig_buffer), size, gpadl); +} + +int +vmbus_chan_gpadl_connect(struct hv_vmbus_channel *chan, bus_addr_t paddr, + int size, uint32_t *gpadl0) +{ + struct vmbus_softc *sc = chan->vmbus_sc; struct vmbus_msghc *mh; struct vmbus_chanmsg_gpadl_conn *req; const struct vmbus_message *msg; size_t reqsz; uint32_t gpadl, status; int page_count, range_len, i, cnt, error; - uint64_t page_id, paddr; + uint64_t page_id; /* * Preliminary checks. */ KASSERT((size & PAGE_MASK) == 0, - ("invalid GPA size %u, not multiple page size", size)); + ("invalid GPA size %d, not multiple page size", size)); page_count = size >> PAGE_SHIFT; - paddr = hv_get_phys_addr(contig_buffer); KASSERT((paddr & PAGE_MASK) == 0, ("GPA is not page aligned %jx", (uintmax_t)paddr)); page_id = paddr >> PAGE_SHIFT; @@ -390,13 +409,13 @@ hv_vmbus_channel_establish_gpadl(struct if (mh == NULL) { device_printf(sc->vmbus_dev, "can not get msg hypercall for gpadl->chan%u\n", - channel->ch_id); + chan->ch_id); return EIO; } req = vmbus_msghc_dataptr(mh); req->chm_hdr.chm_type = VMBUS_CHANMSG_TYPE_GPADL_CONN; - req->chm_chanid = channel->ch_id; + req->chm_chanid = chan->ch_id; req->chm_gpadl = gpadl; req->chm_range_len = range_len; req->chm_range_cnt = 1; @@ -409,7 +428,7 @@ hv_vmbus_channel_establish_gpadl(struct if (error) { device_printf(sc->vmbus_dev, "gpadl->chan%u msg hypercall exec failed: %d\n", - channel->ch_id, error); + chan->ch_id, error); vmbus_msghc_put(sc, mh); return error; } @@ -445,12 +464,12 @@ hv_vmbus_channel_establish_gpadl(struct if (status != 0) { device_printf(sc->vmbus_dev, "gpadl->chan%u failed: " - "status %u\n", channel->ch_id, status); + "status %u\n", chan->ch_id, status); return EIO; } else { if (bootverbose) { device_printf(sc->vmbus_dev, "gpadl->chan%u " - "succeeded\n", channel->ch_id); + "succeeded\n", chan->ch_id); } } return 0; @@ -547,9 +566,10 @@ hv_vmbus_channel_close_internal(hv_vmbus } /* Tear down the gpadl for the channel's ring buffer */ - if (channel->ring_buffer_gpadl_handle) { + if (channel->ch_bufring_gpadl) { hv_vmbus_channel_teardown_gpdal(channel, - channel->ring_buffer_gpadl_handle); + channel->ch_bufring_gpadl); + channel->ch_bufring_gpadl = 0; } /* TODO: Send a msg to release the childRelId */ @@ -558,8 +578,11 @@ hv_vmbus_channel_close_internal(hv_vmbus hv_ring_buffer_cleanup(&channel->outbound); hv_ring_buffer_cleanup(&channel->inbound); - contigfree(channel->ring_buffer_pages, channel->ring_buffer_size, - M_DEVBUF); + if (channel->ch_bufring != NULL) { + hyperv_dmamem_free(&channel->ch_bufring_dma, + channel->ch_bufring); + channel->ch_bufring = NULL; + } } /* From owner-svn-src-all@freebsd.org Tue Oct 11 09:02:56 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 8A31DC0CD18; Tue, 11 Oct 2016 09:02:56 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4D0A1982; Tue, 11 Oct 2016 09:02:56 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9B92t0O045904; Tue, 11 Oct 2016 09:02:55 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9B92tkh045901; Tue, 11 Oct 2016 09:02:55 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610110902.u9B92tkh045901@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Tue, 11 Oct 2016 09:02:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307033 - in stable/10/sys/dev/hyperv: include vmbus X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Oct 2016 09:02:56 -0000 Author: sephe Date: Tue Oct 11 09:02:55 2016 New Revision: 307033 URL: https://svnweb.freebsd.org/changeset/base/307033 Log: MFC 302873,302874 302873 hyperv/vmbus: Set vcpuid to 0, if MSR_HV_VP_INDEX does not exist. Mainly for compatibility. While I'm here, rename cpuid related fields in hv_vmbus_channel. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7141 302874 hyperv/vmbus: Field rename Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7146 Modified: stable/10/sys/dev/hyperv/include/hyperv.h stable/10/sys/dev/hyperv/vmbus/hv_channel.c stable/10/sys/dev/hyperv/vmbus/vmbus.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/hyperv/include/hyperv.h ============================================================================== --- stable/10/sys/dev/hyperv/include/hyperv.h Tue Oct 11 08:52:27 2016 (r307032) +++ stable/10/sys/dev/hyperv/include/hyperv.h Tue Oct 11 09:02:55 2016 (r307033) @@ -242,7 +242,7 @@ typedef struct { uint32_t ring_data_size; /* ring_size */ } hv_vmbus_ring_buffer_info; -typedef void (*hv_vmbus_pfn_channel_callback)(void *context); +typedef void (*vmbus_chan_callback_t)(void *); typedef struct hv_vmbus_channel { device_t ch_dev; @@ -266,24 +266,21 @@ typedef struct hv_vmbus_channel { */ hv_vmbus_ring_buffer_info inbound; - struct taskqueue * rxq; - struct task channel_task; - hv_vmbus_pfn_channel_callback on_channel_callback; - void* channel_callback_context; + struct taskqueue *ch_tq; + struct task ch_task; + vmbus_chan_callback_t ch_cb; + void *ch_cbarg; struct hyperv_mon_param *ch_monprm; struct hyperv_dma ch_monprm_dma; + int ch_cpuid; /* owner cpu */ /* - * From Win8, this field specifies the target virtual process - * on which to deliver the interupt from the host to guest. - * Before Win8, all channel interrupts would only be - * delivered on cpu 0. Setting this value to 0 would preserve - * the earlier behavior. - */ - uint32_t target_vcpu; - /* The corresponding CPUID in the guest */ - uint32_t target_cpu; + * Virtual cpuid for ch_cpuid; it is used to communicate cpuid + * related information w/ Hyper-V. If MSR_HV_VP_INDEX does not + * exist, ch_vcpuid will always be 0 for compatibility. + */ + uint32_t ch_vcpuid; /* * If this is a primary channel, ch_subchan* fields @@ -365,9 +362,8 @@ int hv_vmbus_channel_open( uint32_t recv_ring_buffer_size, void* user_data, uint32_t user_data_len, - hv_vmbus_pfn_channel_callback - pfn_on_channel_callback, - void* context); + vmbus_chan_callback_t cb, + void *cbarg); void hv_vmbus_channel_close(hv_vmbus_channel *channel); Modified: stable/10/sys/dev/hyperv/vmbus/hv_channel.c ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/hv_channel.c Tue Oct 11 08:52:27 2016 (r307032) +++ stable/10/sys/dev/hyperv/vmbus/hv_channel.c Tue Oct 11 09:02:55 2016 (r307033) @@ -157,7 +157,7 @@ vmbus_channel_sysctl_create(hv_vmbus_cha &channel->ch_id, 0, "channel id"); } SYSCTL_ADD_UINT(ctx, SYSCTL_CHILDREN(devch_id_sysctl), OID_AUTO, - "cpu", CTLFLAG_RD, &channel->target_cpu, 0, "owner CPU id"); + "cpu", CTLFLAG_RD, &channel->ch_cpuid, 0, "owner CPU id"); SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(devch_id_sysctl), OID_AUTO, "monitor_allocated", CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_MPSAFE, channel, 0, vmbus_channel_sysctl_monalloc, "I", @@ -193,8 +193,8 @@ hv_vmbus_channel_open( uint32_t recv_ring_buffer_size, void* user_data, uint32_t user_data_len, - hv_vmbus_pfn_channel_callback pfn_on_channel_callback, - void* context) + vmbus_chan_callback_t cb, + void *cbarg) { struct vmbus_softc *sc = new_channel->vmbus_sc; const struct vmbus_chanmsg_chopen_resp *resp; @@ -220,19 +220,19 @@ hv_vmbus_channel_open( VMBUS_CHAN_ST_OPENED_SHIFT)) panic("double-open chan%u", new_channel->ch_id); - new_channel->on_channel_callback = pfn_on_channel_callback; - new_channel->channel_callback_context = context; + new_channel->ch_cb = cb; + new_channel->ch_cbarg = cbarg; vmbus_chan_update_evtflagcnt(sc, new_channel); - new_channel->rxq = VMBUS_PCPU_GET(new_channel->vmbus_sc, event_tq, - new_channel->target_cpu); + new_channel->ch_tq = VMBUS_PCPU_GET(new_channel->vmbus_sc, event_tq, + new_channel->ch_cpuid); if (new_channel->ch_flags & VMBUS_CHAN_FLAG_BATCHREAD) { - TASK_INIT(&new_channel->channel_task, 0, - vmbus_chan_task, new_channel); + TASK_INIT(&new_channel->ch_task, 0, vmbus_chan_task, + new_channel); } else { - TASK_INIT(&new_channel->channel_task, 0, - vmbus_chan_task_nobatch, new_channel); + TASK_INIT(&new_channel->ch_task, 0, vmbus_chan_task_nobatch, + new_channel); } /* @@ -290,7 +290,7 @@ hv_vmbus_channel_open( req->chm_chanid = new_channel->ch_id; req->chm_openid = new_channel->ch_id; req->chm_gpadl = new_channel->ch_bufring_gpadl; - req->chm_vcpuid = new_channel->target_vcpu; + req->chm_vcpuid = new_channel->ch_vcpuid; req->chm_rxbr_pgofs = send_ring_buffer_size >> PAGE_SHIFT; if (user_data_len) memcpy(req->chm_udata, user_data, user_data_len); @@ -521,7 +521,7 @@ hv_vmbus_channel_close_internal(hv_vmbus struct vmbus_softc *sc = channel->vmbus_sc; struct vmbus_msghc *mh; struct vmbus_chanmsg_chclose *req; - struct taskqueue *rxq = channel->rxq; + struct taskqueue *tq = channel->ch_tq; int error; /* TODO: stringent check */ @@ -530,11 +530,11 @@ hv_vmbus_channel_close_internal(hv_vmbus sysctl_ctx_free(&channel->ch_sysctl_ctx); /* - * set rxq to NULL to avoid more requests be scheduled + * Set ch_tq to NULL to avoid more requests be scheduled */ - channel->rxq = NULL; - taskqueue_drain(rxq, &channel->channel_task); - channel->on_channel_callback = NULL; + channel->ch_tq = NULL; + taskqueue_drain(tq, &channel->ch_task); + channel->ch_cb = NULL; /** * Send a closing message @@ -895,11 +895,8 @@ static void vmbus_chan_task(void *xchan, int pending __unused) { struct hv_vmbus_channel *chan = xchan; - void (*callback)(void *); - void *arg; - - arg = chan->channel_callback_context; - callback = chan->on_channel_callback; + vmbus_chan_callback_t cb = chan->ch_cb; + void *cbarg = chan->ch_cbarg; /* * Optimize host to guest signaling by ensuring: @@ -916,7 +913,7 @@ vmbus_chan_task(void *xchan, int pending for (;;) { uint32_t left; - callback(arg); + cb(cbarg); left = hv_ring_buffer_read_end(&chan->inbound); if (left == 0) { @@ -932,7 +929,7 @@ vmbus_chan_task_nobatch(void *xchan, int { struct hv_vmbus_channel *chan = xchan; - chan->on_channel_callback(chan->channel_callback_context); + chan->ch_cb(chan->ch_cbarg); } static __inline void @@ -961,12 +958,12 @@ vmbus_event_flags_proc(struct vmbus_soft channel = sc->vmbus_chmap[chid_base + chid_ofs]; /* if channel is closed or closing */ - if (channel == NULL || channel->rxq == NULL) + if (channel == NULL || channel->ch_tq == NULL) continue; if (channel->ch_flags & VMBUS_CHAN_FLAG_BATCHREAD) hv_ring_buffer_read_begin(&channel->inbound); - taskqueue_enqueue(channel->rxq, &channel->channel_task); + taskqueue_enqueue(channel->ch_tq, &channel->ch_task); } } } @@ -1005,7 +1002,7 @@ vmbus_chan_update_evtflagcnt(struct vmbu int flag_cnt; flag_cnt = (chan->ch_id / VMBUS_EVTFLAG_LEN) + 1; - flag_cnt_ptr = VMBUS_PCPU_PTR(sc, event_flags_cnt, chan->target_cpu); + flag_cnt_ptr = VMBUS_PCPU_PTR(sc, event_flags_cnt, chan->ch_cpuid); for (;;) { int old_flag_cnt; @@ -1017,8 +1014,7 @@ vmbus_chan_update_evtflagcnt(struct vmbu if (bootverbose) { device_printf(sc->vmbus_dev, "channel%u update cpu%d flag_cnt to %d\n", - chan->ch_id, - chan->target_cpu, flag_cnt); + chan->ch_id, chan->ch_cpuid, flag_cnt); } break; } @@ -1162,13 +1158,12 @@ vmbus_channel_cpu_set(struct hv_vmbus_ch cpu = 0; } - chan->target_cpu = cpu; - chan->target_vcpu = VMBUS_PCPU_GET(chan->vmbus_sc, vcpuid, cpu); + chan->ch_cpuid = cpu; + chan->ch_vcpuid = VMBUS_PCPU_GET(chan->vmbus_sc, vcpuid, cpu); if (bootverbose) { printf("vmbus_chan%u: assigned to cpu%u [vcpu%u]\n", - chan->ch_id, - chan->target_cpu, chan->target_vcpu); + chan->ch_id, chan->ch_cpuid, chan->ch_vcpuid); } } @@ -1401,17 +1396,17 @@ vmbus_select_outgoing_channel(struct hv_ continue; } - if (new_channel->target_vcpu == cur_vcpu){ + if (new_channel->ch_vcpuid == cur_vcpu){ return new_channel; } - old_cpu_distance = ((outgoing_channel->target_vcpu > cur_vcpu) ? - (outgoing_channel->target_vcpu - cur_vcpu) : - (cur_vcpu - outgoing_channel->target_vcpu)); - - new_cpu_distance = ((new_channel->target_vcpu > cur_vcpu) ? - (new_channel->target_vcpu - cur_vcpu) : - (cur_vcpu - new_channel->target_vcpu)); + old_cpu_distance = ((outgoing_channel->ch_vcpuid > cur_vcpu) ? + (outgoing_channel->ch_vcpuid - cur_vcpu) : + (cur_vcpu - outgoing_channel->ch_vcpuid)); + + new_cpu_distance = ((new_channel->ch_vcpuid > cur_vcpu) ? + (new_channel->ch_vcpuid - cur_vcpu) : + (cur_vcpu - new_channel->ch_vcpuid)); if (old_cpu_distance < new_cpu_distance) { continue; Modified: stable/10/sys/dev/hyperv/vmbus/vmbus.c ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/vmbus.c Tue Oct 11 08:52:27 2016 (r307032) +++ stable/10/sys/dev/hyperv/vmbus/vmbus.c Tue Oct 11 09:02:55 2016 (r307033) @@ -726,19 +726,11 @@ vmbus_synic_setup(void *xsc) uint32_t sint; if (hyperv_features & CPUID_HV_MSR_VP_INDEX) { - /* - * Save virtual processor id. - */ + /* Save virtual processor id. */ VMBUS_PCPU_GET(sc, vcpuid, cpu) = rdmsr(MSR_HV_VP_INDEX); } else { - /* - * XXX - * Virtual processoor id is only used by a pretty broken - * channel selection code from storvsc. It's nothing - * critical even if CPUID_HV_MSR_VP_INDEX is not set; keep - * moving on. - */ - VMBUS_PCPU_GET(sc, vcpuid, cpu) = cpu; + /* Set virtual processor id to 0 for compatibility. */ + VMBUS_PCPU_GET(sc, vcpuid, cpu) = 0; } /* From owner-svn-src-all@freebsd.org Tue Oct 11 09:11:25 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D148CC0CEF4; Tue, 11 Oct 2016 09:11:25 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 6E7B3D8A; Tue, 11 Oct 2016 09:11:25 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9B9BOaU048914; Tue, 11 Oct 2016 09:11:24 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9B9BNmd048898; Tue, 11 Oct 2016 09:11:23 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610110911.u9B9BNmd048898@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Tue, 11 Oct 2016 09:11:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307034 - in stable/10/sys/dev/hyperv: include netvsc storvsc utilities vmbus X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Oct 2016 09:11:26 -0000 Author: sephe Date: Tue Oct 11 09:11:23 2016 New Revision: 307034 URL: https://svnweb.freebsd.org/changeset/base/307034 Log: MFC 302875,302876,302878-302881 302875 hyperv/vmbus: Redefine channel packet. The channel packet header will be shared w/ PRP (physical region page) list channel packet and SG (scatter gather) list channel packet. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7155 302876 hyperv/vmbus: Rework sglist sending. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7156 302878 hyeprv/vmbus: Rework prplist sending. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7175 302879 hyperv/vmbus: Move channel packet flags definition to vmbus.h Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7176 302880 hyperv/vmbus: Move channel packet types definition to vmbus.h Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7177 302881 hyperv/vmbus: Cleanup channel sending Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7178 Added: stable/10/sys/dev/hyperv/include/vmbus.h - copied, changed from r302876, head/sys/dev/hyperv/include/vmbus.h Modified: stable/10/sys/dev/hyperv/include/hyperv.h stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.c stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.c stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.h stable/10/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c stable/10/sys/dev/hyperv/utilities/hv_heartbeat.c stable/10/sys/dev/hyperv/utilities/hv_kvp.c stable/10/sys/dev/hyperv/utilities/hv_shutdown.c stable/10/sys/dev/hyperv/utilities/hv_timesync.c stable/10/sys/dev/hyperv/vmbus/hv_channel.c stable/10/sys/dev/hyperv/vmbus/hv_vmbus_priv.h stable/10/sys/dev/hyperv/vmbus/vmbus_reg.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/hyperv/include/hyperv.h ============================================================================== --- stable/10/sys/dev/hyperv/include/hyperv.h Tue Oct 11 09:02:55 2016 (r307033) +++ stable/10/sys/dev/hyperv/include/hyperv.h Tue Oct 11 09:11:23 2016 (r307034) @@ -82,19 +82,6 @@ typedef uint8_t hv_bool_uint8_t; #define VMBUS_VERSION_MAJOR(ver) (((uint32_t)(ver)) >> 16) #define VMBUS_VERSION_MINOR(ver) (((uint32_t)(ver)) & 0xffff) -#define HV_MAX_PAGE_BUFFER_COUNT 32 -#define HV_MAX_MULTIPAGE_BUFFER_COUNT 32 - -#define HV_ALIGN_UP(value, align) \ - (((value) & (align-1)) ? \ - (((value) + (align-1)) & ~(align-1) ) : (value)) - -#define HV_ALIGN_DOWN(value, align) ( (value) & ~(align-1) ) - -#define HV_NUM_PAGES_SPANNED(addr, len) \ - ((HV_ALIGN_UP(addr+len, PAGE_SIZE) - \ - HV_ALIGN_DOWN(addr, PAGE_SIZE)) >> PAGE_SHIFT ) - struct hyperv_guid { uint8_t hv_guid[16]; } __packed; @@ -125,25 +112,6 @@ typedef struct { hv_vm_transfer_page ranges[1]; } __packed hv_vm_transfer_page_packet_header; -typedef enum { - HV_VMBUS_PACKET_TYPE_INVALID = 0x0, - HV_VMBUS_PACKET_TYPES_SYNCH = 0x1, - HV_VMBUS_PACKET_TYPE_ADD_TRANSFER_PAGE_SET = 0x2, - HV_VMBUS_PACKET_TYPE_REMOVE_TRANSFER_PAGE_SET = 0x3, - HV_VMBUS_PACKET_TYPE_ESTABLISH_GPADL = 0x4, - HV_VMBUS_PACKET_TYPE_TEAR_DOWN_GPADL = 0x5, - HV_VMBUS_PACKET_TYPE_DATA_IN_BAND = 0x6, - HV_VMBUS_PACKET_TYPE_DATA_USING_TRANSFER_PAGES = 0x7, - HV_VMBUS_PACKET_TYPE_DATA_USING_GPADL = 0x8, - HV_VMBUS_PACKET_TYPE_DATA_USING_GPA_DIRECT = 0x9, - HV_VMBUS_PACKET_TYPE_CANCEL_REQUEST = 0xa, - HV_VMBUS_PACKET_TYPE_COMPLETION = 0xb, - HV_VMBUS_PACKET_TYPE_DATA_USING_ADDITIONAL_PACKETS = 0xc, - HV_VMBUS_PACKET_TYPE_ADDITIONAL_DATA = 0xd -} hv_vmbus_packet_type; - -#define HV_VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED 1 - #define HW_MACADDR_LEN 6 /* @@ -225,18 +193,6 @@ typedef struct { } __packed hv_vmbus_ring_buffer; typedef struct { - int length; - int offset; - uint64_t pfn; -} __packed hv_vmbus_page_buffer; - -typedef struct { - int length; - int offset; - uint64_t pfn_array[HV_MAX_MULTIPAGE_BUFFER_COUNT]; -} __packed hv_vmbus_multipage_buffer; - -typedef struct { hv_vmbus_ring_buffer* ring_buffer; struct mtx ring_lock; uint32_t ring_data_size; /* ring_size */ @@ -372,23 +328,8 @@ int hv_vmbus_channel_send_packet( void* buffer, uint32_t buffer_len, uint64_t request_id, - hv_vmbus_packet_type type, - uint32_t flags); - -int hv_vmbus_channel_send_packet_pagebuffer( - hv_vmbus_channel* channel, - hv_vmbus_page_buffer page_buffers[], - uint32_t page_count, - void* buffer, - uint32_t buffer_len, - uint64_t request_id); - -int hv_vmbus_channel_send_packet_multipagebuffer( - hv_vmbus_channel* channel, - hv_vmbus_multipage_buffer* multi_page_buffer, - void* buffer, - uint32_t buffer_len, - uint64_t request_id); + uint16_t type, + uint16_t flags); int hv_vmbus_channel_establish_gpadl( hv_vmbus_channel* channel, Copied and modified: stable/10/sys/dev/hyperv/include/vmbus.h (from r302876, head/sys/dev/hyperv/include/vmbus.h) ============================================================================== --- head/sys/dev/hyperv/include/vmbus.h Fri Jul 15 06:29:19 2016 (r302876, copy source) +++ stable/10/sys/dev/hyperv/include/vmbus.h Tue Oct 11 09:11:23 2016 (r307034) @@ -31,6 +31,15 @@ #include +/* + * GPA stuffs. + */ +struct vmbus_gpa_range { + uint32_t gpa_len; + uint32_t gpa_ofs; + uint64_t gpa_page[0]; +} __packed; + /* This is actually vmbus_gpa_range.gpa_page[1] */ struct vmbus_gpa { uint32_t gpa_len; @@ -38,12 +47,23 @@ struct vmbus_gpa { uint64_t gpa_page; } __packed; -#define VMBUS_CHAN_SGLIST_MAX 32 +#define VMBUS_CHANPKT_TYPE_INBAND 0x0006 +#define VMBUS_CHANPKT_TYPE_RXBUF 0x0007 +#define VMBUS_CHANPKT_TYPE_GPA 0x0009 +#define VMBUS_CHANPKT_TYPE_COMP 0x000b + +#define VMBUS_CHANPKT_FLAG_RC 0x0001 /* report completion */ + +#define VMBUS_CHAN_SGLIST_MAX 32 +#define VMBUS_CHAN_PRPLIST_MAX 32 struct hv_vmbus_channel; int vmbus_chan_send_sglist(struct hv_vmbus_channel *chan, struct vmbus_gpa sg[], int sglen, void *data, int dlen, uint64_t xactid); +int vmbus_chan_send_prplist(struct hv_vmbus_channel *chan, + struct vmbus_gpa_range *prp, int prp_cnt, void *data, int dlen, + uint64_t xactid); #endif /* !_VMBUS_H_ */ Modified: stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.c Tue Oct 11 09:02:55 2016 (r307033) +++ stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.c Tue Oct 11 09:11:23 2016 (r307034) @@ -184,8 +184,7 @@ hv_nv_init_rx_buffer_with_net_vsp(struct ret = hv_vmbus_channel_send_packet(sc->hn_prichan, init_pkt, sizeof(nvsp_msg), (uint64_t)(uintptr_t)init_pkt, - HV_VMBUS_PACKET_TYPE_DATA_IN_BAND, - HV_VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED); + VMBUS_CHANPKT_TYPE_INBAND, VMBUS_CHANPKT_FLAG_RC); if (ret != 0) { goto cleanup; } @@ -278,8 +277,7 @@ hv_nv_init_send_buffer_with_net_vsp(stru ret = hv_vmbus_channel_send_packet(sc->hn_prichan, init_pkt, sizeof(nvsp_msg), (uint64_t)init_pkt, - HV_VMBUS_PACKET_TYPE_DATA_IN_BAND, - HV_VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED); + VMBUS_CHANPKT_TYPE_INBAND, VMBUS_CHANPKT_FLAG_RC); if (ret != 0) { goto cleanup; } @@ -339,7 +337,7 @@ hv_nv_destroy_rx_buffer(netvsc_dev *net_ ret = hv_vmbus_channel_send_packet(net_dev->sc->hn_prichan, revoke_pkt, sizeof(nvsp_msg), (uint64_t)(uintptr_t)revoke_pkt, - HV_VMBUS_PACKET_TYPE_DATA_IN_BAND, 0); + VMBUS_CHANPKT_TYPE_INBAND, 0); /* * If we failed here, we might as well return and have a leak @@ -407,7 +405,7 @@ hv_nv_destroy_send_buffer(netvsc_dev *ne ret = hv_vmbus_channel_send_packet(net_dev->sc->hn_prichan, revoke_pkt, sizeof(nvsp_msg), (uint64_t)(uintptr_t)revoke_pkt, - HV_VMBUS_PACKET_TYPE_DATA_IN_BAND, 0); + VMBUS_CHANPKT_TYPE_INBAND, 0); /* * If we failed here, we might as well return and have a leak * rather than continue and a bugchk @@ -473,8 +471,7 @@ hv_nv_negotiate_nvsp_protocol(struct hn_ /* Send the init request */ ret = hv_vmbus_channel_send_packet(sc->hn_prichan, init_pkt, sizeof(nvsp_msg), (uint64_t)(uintptr_t)init_pkt, - HV_VMBUS_PACKET_TYPE_DATA_IN_BAND, - HV_VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED); + VMBUS_CHANPKT_TYPE_INBAND, VMBUS_CHANPKT_FLAG_RC); if (ret != 0) return (-1); @@ -517,7 +514,7 @@ hv_nv_send_ndis_config(struct hn_softc * /* Send the configuration packet */ ret = hv_vmbus_channel_send_packet(sc->hn_prichan, init_pkt, sizeof(nvsp_msg), (uint64_t)(uintptr_t)init_pkt, - HV_VMBUS_PACKET_TYPE_DATA_IN_BAND, 0); + VMBUS_CHANPKT_TYPE_INBAND, 0); if (ret != 0) return (-EINVAL); @@ -596,15 +593,14 @@ hv_nv_connect_to_vsp(struct hn_softc *sc ret = hv_vmbus_channel_send_packet(sc->hn_prichan, init_pkt, sizeof(nvsp_msg), (uint64_t)(uintptr_t)init_pkt, - HV_VMBUS_PACKET_TYPE_DATA_IN_BAND, 0); + VMBUS_CHANPKT_TYPE_INBAND, 0); if (ret != 0) { goto cleanup; } /* * TODO: BUGBUG - We have to wait for the above msg since the netvsp * uses KMCL which acknowledges packet (completion packet) - * since our Vmbus always set the - * HV_VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED flag + * since our Vmbus always set the VMBUS_CHANPKT_FLAG_RC flag */ /* sema_wait(&NetVscChannel->channel_init_sema); */ @@ -815,15 +811,13 @@ hv_nv_on_send(struct hv_vmbus_channel *c send_msg.msgs.vers_1_msgs.send_rndis_pkt.send_buf_section_size = pkt->send_buf_section_size; - if (pkt->page_buf_count) { - ret = hv_vmbus_channel_send_packet_pagebuffer(chan, - pkt->page_buffers, pkt->page_buf_count, + if (pkt->gpa_cnt) { + ret = vmbus_chan_send_sglist(chan, pkt->gpa, pkt->gpa_cnt, &send_msg, sizeof(nvsp_msg), (uint64_t)(uintptr_t)pkt); } else { ret = hv_vmbus_channel_send_packet(chan, &send_msg, sizeof(nvsp_msg), (uint64_t)(uintptr_t)pkt, - HV_VMBUS_PACKET_TYPE_DATA_IN_BAND, - HV_VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED); + VMBUS_CHANPKT_TYPE_INBAND, VMBUS_CHANPKT_FLAG_RC); } return (ret); @@ -852,7 +846,7 @@ hv_nv_on_receive(netvsc_dev *net_dev, st * All inbound packets other than send completion should be * xfer page packet. */ - if (pkt->type != HV_VMBUS_PACKET_TYPE_DATA_USING_TRANSFER_PAGES) { + if (pkt->type != VMBUS_CHANPKT_TYPE_RXBUF) { device_printf(dev, "packet type %d is invalid!\n", pkt->type); return; } @@ -923,7 +917,7 @@ hv_nv_on_receive_completion(struct hv_vm retry_send_cmplt: /* Send the completion */ ret = hv_vmbus_channel_send_packet(chan, &rx_comp_msg, - sizeof(nvsp_msg), tid, HV_VMBUS_PACKET_TYPE_COMPLETION, 0); + sizeof(nvsp_msg), tid, VMBUS_CHANPKT_TYPE_COMP, 0); if (ret == 0) { /* success */ /* no-op */ @@ -1008,14 +1002,14 @@ hv_nv_on_channel_callback(void *xchan) if (bytes_rxed > 0) { desc = (hv_vm_packet_descriptor *)buffer; switch (desc->type) { - case HV_VMBUS_PACKET_TYPE_COMPLETION: + case VMBUS_CHANPKT_TYPE_COMP: hv_nv_on_send_completion(net_dev, chan, desc); break; - case HV_VMBUS_PACKET_TYPE_DATA_USING_TRANSFER_PAGES: + case VMBUS_CHANPKT_TYPE_RXBUF: hv_nv_on_receive(net_dev, sc, chan, desc); break; - case HV_VMBUS_PACKET_TYPE_DATA_IN_BAND: + case VMBUS_CHANPKT_TYPE_INBAND: hv_nv_send_table(sc, desc); break; default: Modified: stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h Tue Oct 11 09:02:55 2016 (r307033) +++ stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h Tue Oct 11 09:11:23 2016 (r307034) @@ -57,6 +57,7 @@ #include #include +#include #define HN_USE_TXDESC_BUFRING @@ -1082,8 +1083,6 @@ struct hv_vmbus_channel; typedef void (*pfn_on_send_rx_completion)(struct hv_vmbus_channel *, void *); #define NETVSC_DEVICE_RING_BUFFER_SIZE (128 * PAGE_SIZE) -#define NETVSC_PACKET_MAXPAGE 32 - #define NETVSC_VLAN_PRIO_MASK 0xe000 #define NETVSC_VLAN_PRIO_SHIFT 13 @@ -1132,8 +1131,8 @@ typedef struct netvsc_packet_ { void *rndis_mesg; uint32_t tot_data_buf_len; void *data; - uint32_t page_buf_count; - hv_vmbus_page_buffer page_buffers[NETVSC_PACKET_MAXPAGE]; + uint32_t gpa_cnt; + struct vmbus_gpa gpa[VMBUS_CHAN_SGLIST_MAX]; } netvsc_packet; typedef struct { Modified: stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Tue Oct 11 09:02:55 2016 (r307033) +++ stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Tue Oct 11 09:11:23 2016 (r307034) @@ -156,7 +156,7 @@ __FBSDID("$FreeBSD$"); #define HN_TX_DATA_MAXSIZE IP_MAXPACKET #define HN_TX_DATA_SEGSIZE PAGE_SIZE #define HN_TX_DATA_SEGCNT_MAX \ - (NETVSC_PACKET_MAXPAGE - HV_RF_NUM_TX_RESERVED_PAGE_BUFS) + (VMBUS_CHAN_SGLIST_MAX - HV_RF_NUM_TX_RESERVED_PAGE_BUFS) #define HN_DIRECT_TX_SIZE_DEF 128 @@ -1015,7 +1015,7 @@ hn_encap(struct hn_tx_ring *txr, struct packet->send_buf_section_idx = send_buf_section_idx; packet->send_buf_section_size = packet->tot_data_buf_len; - packet->page_buf_count = 0; + packet->gpa_cnt = 0; txr->hn_tx_chimney++; goto done; } @@ -1041,24 +1041,24 @@ hn_encap(struct hn_tx_ring *txr, struct } *m_head0 = m_head; - packet->page_buf_count = nsegs + HV_RF_NUM_TX_RESERVED_PAGE_BUFS; + packet->gpa_cnt = nsegs + HV_RF_NUM_TX_RESERVED_PAGE_BUFS; /* send packet with page buffer */ - packet->page_buffers[0].pfn = atop(txd->rndis_msg_paddr); - packet->page_buffers[0].offset = txd->rndis_msg_paddr & PAGE_MASK; - packet->page_buffers[0].length = rndis_msg_size; + packet->gpa[0].gpa_page = atop(txd->rndis_msg_paddr); + packet->gpa[0].gpa_ofs = txd->rndis_msg_paddr & PAGE_MASK; + packet->gpa[0].gpa_len = rndis_msg_size; /* * Fill the page buffers with mbuf info starting at index * HV_RF_NUM_TX_RESERVED_PAGE_BUFS. */ for (i = 0; i < nsegs; ++i) { - hv_vmbus_page_buffer *pb = &packet->page_buffers[ + struct vmbus_gpa *gpa = &packet->gpa[ i + HV_RF_NUM_TX_RESERVED_PAGE_BUFS]; - pb->pfn = atop(segs[i].ds_addr); - pb->offset = segs[i].ds_addr & PAGE_MASK; - pb->length = segs[i].ds_len; + gpa->gpa_page = atop(segs[i].ds_addr); + gpa->gpa_ofs = segs[i].ds_addr & PAGE_MASK; + gpa->gpa_len = segs[i].ds_len; } packet->send_buf_section_idx = Modified: stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.c Tue Oct 11 09:02:55 2016 (r307033) +++ stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.c Tue Oct 11 09:11:23 2016 (r307034) @@ -249,26 +249,23 @@ hv_rf_send_request(rndis_device *device, packet->is_data_pkt = FALSE; packet->tot_data_buf_len = request->request_msg.msg_len; - packet->page_buf_count = 1; + packet->gpa_cnt = 1; - packet->page_buffers[0].pfn = + packet->gpa[0].gpa_page = hv_get_phys_addr(&request->request_msg) >> PAGE_SHIFT; - packet->page_buffers[0].length = request->request_msg.msg_len; - packet->page_buffers[0].offset = + packet->gpa[0].gpa_len = request->request_msg.msg_len; + packet->gpa[0].gpa_ofs = (unsigned long)&request->request_msg & (PAGE_SIZE - 1); - if (packet->page_buffers[0].offset + - packet->page_buffers[0].length > PAGE_SIZE) { - packet->page_buf_count = 2; - packet->page_buffers[0].length = - PAGE_SIZE - packet->page_buffers[0].offset; - packet->page_buffers[1].pfn = + if (packet->gpa[0].gpa_ofs + packet->gpa[0].gpa_len > PAGE_SIZE) { + packet->gpa_cnt = 2; + packet->gpa[0].gpa_len = PAGE_SIZE - packet->gpa[0].gpa_ofs; + packet->gpa[1].gpa_page = hv_get_phys_addr((char*)&request->request_msg + - packet->page_buffers[0].length) >> PAGE_SHIFT; - packet->page_buffers[1].offset = 0; - packet->page_buffers[1].length = - request->request_msg.msg_len - - packet->page_buffers[0].length; + packet->gpa[0].gpa_len) >> PAGE_SHIFT; + packet->gpa[1].gpa_ofs = 0; + packet->gpa[1].gpa_len = request->request_msg.msg_len - + packet->gpa[0].gpa_len; } packet->compl.send.send_completion_context = request; /* packet */ @@ -290,7 +287,7 @@ hv_rf_send_request(rndis_device *device, memcpy(dest, &request->request_msg, request->request_msg.msg_len); packet->send_buf_section_idx = send_buf_section_idx; packet->send_buf_section_size = packet->tot_data_buf_len; - packet->page_buf_count = 0; + packet->gpa_cnt = 0; goto sendit; } /* Failed to allocate chimney send buffer; move on */ @@ -1172,8 +1169,7 @@ hv_rf_on_device_add(struct hn_softc *sc, ret = hv_vmbus_channel_send_packet(sc->hn_prichan, init_pkt, sizeof(nvsp_msg), (uint64_t)(uintptr_t)init_pkt, - HV_VMBUS_PACKET_TYPE_DATA_IN_BAND, - HV_VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED); + VMBUS_CHANPKT_TYPE_INBAND, VMBUS_CHANPKT_FLAG_RC); if (ret != 0) { device_printf(dev, "Fail to allocate subchannel\n"); goto out; Modified: stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.h ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.h Tue Oct 11 09:02:55 2016 (r307033) +++ stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.h Tue Oct 11 09:11:23 2016 (r307034) @@ -74,7 +74,6 @@ typedef struct rndis_request_ { /* Simplify allocation by having a netvsc packet inline */ netvsc_packet pkt; - hv_vmbus_page_buffer buffer; /* * The max request size is sizeof(rndis_msg) + PAGE_SIZE. Modified: stable/10/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c ============================================================================== --- stable/10/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c Tue Oct 11 09:02:55 2016 (r307033) +++ stable/10/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c Tue Oct 11 09:11:23 2016 (r307034) @@ -72,6 +72,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include "hv_vstorage.h" #include "vmbus_if.h" @@ -100,7 +101,7 @@ struct hv_sgl_page_pool{ boolean_t is_init; } g_hv_sgl_page_pool; -#define STORVSC_MAX_SG_PAGE_CNT STORVSC_MAX_IO_REQUESTS * HV_MAX_MULTIPAGE_BUFFER_COUNT +#define STORVSC_MAX_SG_PAGE_CNT STORVSC_MAX_IO_REQUESTS * VMBUS_CHAN_PRPLIST_MAX enum storvsc_request_type { WRITE_TYPE, @@ -108,10 +109,16 @@ enum storvsc_request_type { UNKNOWN_TYPE }; +struct hvs_gpa_range { + struct vmbus_gpa_range gpa_range; + uint64_t gpa_page[VMBUS_CHAN_PRPLIST_MAX]; +} __packed; + struct hv_storvsc_request { LIST_ENTRY(hv_storvsc_request) link; struct vstor_packet vstor_packet; - hv_vmbus_multipage_buffer data_buf; + int prp_cnt; + struct hvs_gpa_range prp_list; void *sense_data; uint8_t sense_info_len; uint8_t retries; @@ -354,8 +361,8 @@ storvsc_send_multichannel_request(struct vstor_packet, VSTOR_PKT_SIZE, (uint64_t)(uintptr_t)request, - HV_VMBUS_PACKET_TYPE_DATA_IN_BAND, - HV_VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED); + VMBUS_CHANPKT_TYPE_INBAND, + VMBUS_CHANPKT_FLAG_RC); /* wait for 5 seconds */ ret = sema_timedwait(&request->synch_sema, 5 * hz); @@ -425,8 +432,8 @@ hv_storvsc_channel_init(struct storvsc_s vstor_packet, VSTOR_PKT_SIZE, (uint64_t)(uintptr_t)request, - HV_VMBUS_PACKET_TYPE_DATA_IN_BAND, - HV_VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED); + VMBUS_CHANPKT_TYPE_INBAND, + VMBUS_CHANPKT_FLAG_RC); if (ret != 0) goto cleanup; @@ -459,8 +466,8 @@ hv_storvsc_channel_init(struct storvsc_s vstor_packet, VSTOR_PKT_SIZE, (uint64_t)(uintptr_t)request, - HV_VMBUS_PACKET_TYPE_DATA_IN_BAND, - HV_VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED); + VMBUS_CHANPKT_TYPE_INBAND, + VMBUS_CHANPKT_FLAG_RC); if (ret != 0) goto cleanup; @@ -502,8 +509,8 @@ hv_storvsc_channel_init(struct storvsc_s vstor_packet, VSTOR_PKT_SIZE, (uint64_t)(uintptr_t)request, - HV_VMBUS_PACKET_TYPE_DATA_IN_BAND, - HV_VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED); + VMBUS_CHANPKT_TYPE_INBAND, + VMBUS_CHANPKT_FLAG_RC); if ( ret != 0) goto cleanup; @@ -538,8 +545,8 @@ hv_storvsc_channel_init(struct storvsc_s vstor_packet, VSTOR_PKT_SIZE, (uint64_t)(uintptr_t)request, - HV_VMBUS_PACKET_TYPE_DATA_IN_BAND, - HV_VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED); + VMBUS_CHANPKT_TYPE_INBAND, + VMBUS_CHANPKT_FLAG_RC); if (ret != 0) { goto cleanup; @@ -628,8 +635,8 @@ hv_storvsc_host_reset(struct storvsc_sof vstor_packet, VSTOR_PKT_SIZE, (uint64_t)(uintptr_t)&sc->hs_reset_req, - HV_VMBUS_PACKET_TYPE_DATA_IN_BAND, - HV_VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED); + VMBUS_CHANPKT_TYPE_INBAND, + VMBUS_CHANPKT_FLAG_RC); if (ret != 0) { goto cleanup; @@ -675,29 +682,26 @@ hv_storvsc_io_request(struct storvsc_sof vstor_packet->u.vm_srb.sense_info_len = sense_buffer_size; - vstor_packet->u.vm_srb.transfer_len = request->data_buf.length; + vstor_packet->u.vm_srb.transfer_len = + request->prp_list.gpa_range.gpa_len; vstor_packet->operation = VSTOR_OPERATION_EXECUTESRB; outgoing_channel = vmbus_select_outgoing_channel(sc->hs_chan); mtx_unlock(&request->softc->hs_lock); - if (request->data_buf.length) { - ret = hv_vmbus_channel_send_packet_multipagebuffer( - outgoing_channel, - &request->data_buf, - vstor_packet, - VSTOR_PKT_SIZE, - (uint64_t)(uintptr_t)request); - + if (request->prp_list.gpa_range.gpa_len) { + ret = vmbus_chan_send_prplist(outgoing_channel, + &request->prp_list.gpa_range, request->prp_cnt, + vstor_packet, VSTOR_PKT_SIZE, (uint64_t)(uintptr_t)request); } else { ret = hv_vmbus_channel_send_packet( outgoing_channel, vstor_packet, VSTOR_PKT_SIZE, (uint64_t)(uintptr_t)request, - HV_VMBUS_PACKET_TYPE_DATA_IN_BAND, - HV_VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED); + VMBUS_CHANPKT_TYPE_INBAND, + VMBUS_CHANPKT_FLAG_RC); } mtx_lock(&request->softc->hs_lock); @@ -956,7 +960,7 @@ storvsc_attach(device_t dev) /* * Pre-create SG list, each SG list with - * HV_MAX_MULTIPAGE_BUFFER_COUNT segments, each + * VMBUS_CHAN_PRPLIST_MAX segments, each * segment has one page buffer */ for (i = 0; i < STORVSC_MAX_IO_REQUESTS; i++) { @@ -964,10 +968,10 @@ storvsc_attach(device_t dev) M_DEVBUF, M_WAITOK|M_ZERO); sgl_node->sgl_data = - sglist_alloc(HV_MAX_MULTIPAGE_BUFFER_COUNT, + sglist_alloc(VMBUS_CHAN_PRPLIST_MAX, M_WAITOK|M_ZERO); - for (j = 0; j < HV_MAX_MULTIPAGE_BUFFER_COUNT; j++) { + for (j = 0; j < VMBUS_CHAN_PRPLIST_MAX; j++) { tmp_buff = malloc(PAGE_SIZE, M_DEVBUF, M_WAITOK|M_ZERO); @@ -1054,7 +1058,7 @@ cleanup: while (!LIST_EMPTY(&g_hv_sgl_page_pool.free_sgl_list)) { sgl_node = LIST_FIRST(&g_hv_sgl_page_pool.free_sgl_list); LIST_REMOVE(sgl_node, link); - for (j = 0; j < HV_MAX_MULTIPAGE_BUFFER_COUNT; j++) { + for (j = 0; j < VMBUS_CHAN_PRPLIST_MAX; j++) { if (NULL != (void*)sgl_node->sgl_data->sg_segs[j].ss_paddr) { free((void*)sgl_node->sgl_data->sg_segs[j].ss_paddr, M_DEVBUF); @@ -1117,7 +1121,7 @@ storvsc_detach(device_t dev) while (!LIST_EMPTY(&g_hv_sgl_page_pool.free_sgl_list)) { sgl_node = LIST_FIRST(&g_hv_sgl_page_pool.free_sgl_list); LIST_REMOVE(sgl_node, link); - for (j = 0; j < HV_MAX_MULTIPAGE_BUFFER_COUNT; j++){ + for (j = 0; j < VMBUS_CHAN_PRPLIST_MAX; j++){ if (NULL != (void*)sgl_node->sgl_data->sg_segs[j].ss_paddr) { free((void*)sgl_node->sgl_data->sg_segs[j].ss_paddr, M_DEVBUF); @@ -1668,6 +1672,7 @@ create_storvsc_request(union ccb *ccb, s uint32_t pfn_num = 0; uint32_t pfn; uint64_t not_aligned_seg_bits = 0; + struct hvs_gpa_range *prplist; /* refer to struct vmscsi_req for meanings of these two fields */ reqp->vstor_packet.u.vm_srb.port = @@ -1711,22 +1716,23 @@ create_storvsc_request(union ccb *ccb, s return (0); } - reqp->data_buf.length = csio->dxfer_len; + prplist = &reqp->prp_list; + prplist->gpa_range.gpa_len = csio->dxfer_len; switch (ccb->ccb_h.flags & CAM_DATA_MASK) { case CAM_DATA_VADDR: { bytes_to_copy = csio->dxfer_len; phys_addr = vtophys(csio->data_ptr); - reqp->data_buf.offset = phys_addr & PAGE_MASK; + prplist->gpa_range.gpa_ofs = phys_addr & PAGE_MASK; while (bytes_to_copy != 0) { int bytes, page_offset; phys_addr = - vtophys(&csio->data_ptr[reqp->data_buf.length - + vtophys(&csio->data_ptr[prplist->gpa_range.gpa_len - bytes_to_copy]); pfn = phys_addr >> PAGE_SHIFT; - reqp->data_buf.pfn_array[pfn_num] = pfn; + prplist->gpa_page[pfn_num] = pfn; page_offset = phys_addr & PAGE_MASK; bytes = min(PAGE_SIZE - page_offset, bytes_to_copy); @@ -1734,6 +1740,7 @@ create_storvsc_request(union ccb *ccb, s bytes_to_copy -= bytes; pfn_num++; } + reqp->prp_cnt = pfn_num; break; } @@ -1750,10 +1757,10 @@ create_storvsc_request(union ccb *ccb, s printf("Storvsc: get SG I/O operation, %d\n", reqp->vstor_packet.u.vm_srb.data_in); - if (storvsc_sg_count > HV_MAX_MULTIPAGE_BUFFER_COUNT){ + if (storvsc_sg_count > VMBUS_CHAN_PRPLIST_MAX){ printf("Storvsc: %d segments is too much, " "only support %d segments\n", - storvsc_sg_count, HV_MAX_MULTIPAGE_BUFFER_COUNT); + storvsc_sg_count, VMBUS_CHAN_PRPLIST_MAX); return (EINVAL); } @@ -1806,10 +1813,10 @@ create_storvsc_request(union ccb *ccb, s phys_addr = vtophys(storvsc_sglist[0].ds_addr); } - reqp->data_buf.offset = phys_addr & PAGE_MASK; + prplist->gpa_range.gpa_ofs = phys_addr & PAGE_MASK; pfn = phys_addr >> PAGE_SHIFT; - reqp->data_buf.pfn_array[0] = pfn; + prplist->gpa_page[0] = pfn; for (i = 1; i < storvsc_sg_count; i++) { if (reqp->not_aligned_seg_bits & (1 << i)) { @@ -1821,27 +1828,31 @@ create_storvsc_request(union ccb *ccb, s } pfn = phys_addr >> PAGE_SHIFT; - reqp->data_buf.pfn_array[i] = pfn; + prplist->gpa_page[i] = pfn; } + reqp->prp_cnt = i; } else { phys_addr = vtophys(storvsc_sglist[0].ds_addr); - reqp->data_buf.offset = phys_addr & PAGE_MASK; + prplist->gpa_range.gpa_ofs = phys_addr & PAGE_MASK; for (i = 0; i < storvsc_sg_count; i++) { phys_addr = vtophys(storvsc_sglist[i].ds_addr); pfn = phys_addr >> PAGE_SHIFT; - reqp->data_buf.pfn_array[i] = pfn; + prplist->gpa_page[i] = pfn; } + reqp->prp_cnt = i; /* check the last segment cross boundary or not */ offset = phys_addr & PAGE_MASK; if (offset) { + /* Add one more PRP entry */ phys_addr = vtophys(storvsc_sglist[i-1].ds_addr + PAGE_SIZE - offset); pfn = phys_addr >> PAGE_SHIFT; - reqp->data_buf.pfn_array[i] = pfn; + prplist->gpa_page[i] = pfn; + reqp->prp_cnt++; } reqp->bounce_sgl_count = 0; Modified: stable/10/sys/dev/hyperv/utilities/hv_heartbeat.c ============================================================================== --- stable/10/sys/dev/hyperv/utilities/hv_heartbeat.c Tue Oct 11 09:02:55 2016 (r307033) +++ stable/10/sys/dev/hyperv/utilities/hv_heartbeat.c Tue Oct 11 09:11:23 2016 (r307034) @@ -35,6 +35,7 @@ #include #include +#include #include "hv_util.h" #include "vmbus_if.h" @@ -87,7 +88,7 @@ hv_heartbeat_cb(void *context) HV_ICMSGHDRFLAG_RESPONSE; hv_vmbus_channel_send_packet(channel, buf, recvlen, requestid, - HV_VMBUS_PACKET_TYPE_DATA_IN_BAND, 0); + VMBUS_CHANPKT_TYPE_INBAND, 0); } } Modified: stable/10/sys/dev/hyperv/utilities/hv_kvp.c ============================================================================== --- stable/10/sys/dev/hyperv/utilities/hv_kvp.c Tue Oct 11 09:02:55 2016 (r307033) +++ stable/10/sys/dev/hyperv/utilities/hv_kvp.c Tue Oct 11 09:11:23 2016 (r307034) @@ -578,7 +578,7 @@ hv_kvp_respond_host(hv_kvp_sc *sc, int e error = hv_vmbus_channel_send_packet(sc->util_sc.channel, sc->rcv_buf, sc->host_msg_len, sc->host_msg_id, - HV_VMBUS_PACKET_TYPE_DATA_IN_BAND, 0); + VMBUS_CHANPKT_TYPE_INBAND, 0); if (error) hv_kvp_log_info("%s: hv_kvp_respond_host: sendpacket error:%d\n", Modified: stable/10/sys/dev/hyperv/utilities/hv_shutdown.c ============================================================================== --- stable/10/sys/dev/hyperv/utilities/hv_shutdown.c Tue Oct 11 09:02:55 2016 (r307033) +++ stable/10/sys/dev/hyperv/utilities/hv_shutdown.c Tue Oct 11 09:11:23 2016 (r307034) @@ -40,6 +40,7 @@ #include #include +#include #include "hv_util.h" #include "vmbus_if.h" @@ -106,7 +107,7 @@ hv_shutdown_cb(void *context) hv_vmbus_channel_send_packet(channel, buf, recv_len, request_id, - HV_VMBUS_PACKET_TYPE_DATA_IN_BAND, 0); + VMBUS_CHANPKT_TYPE_INBAND, 0); } if (execute_shutdown) Modified: stable/10/sys/dev/hyperv/utilities/hv_timesync.c ============================================================================== --- stable/10/sys/dev/hyperv/utilities/hv_timesync.c Tue Oct 11 09:02:55 2016 (r307033) +++ stable/10/sys/dev/hyperv/utilities/hv_timesync.c Tue Oct 11 09:11:23 2016 (r307034) @@ -40,6 +40,7 @@ #include #include +#include #include "hv_util.h" #include "vmbus_if.h" @@ -164,7 +165,7 @@ hv_timesync_cb(void *context) hv_vmbus_channel_send_packet(channel, time_buf, recvlen, requestId, - HV_VMBUS_PACKET_TYPE_DATA_IN_BAND, 0); + VMBUS_CHANPKT_TYPE_INBAND, 0); } } Modified: stable/10/sys/dev/hyperv/vmbus/hv_channel.c ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/hv_channel.c Tue Oct 11 09:02:55 2016 (r307033) +++ stable/10/sys/dev/hyperv/vmbus/hv_channel.c Tue Oct 11 09:11:23 2016 (r307034) @@ -621,194 +621,119 @@ hv_vmbus_channel_close(struct hv_vmbus_c hv_vmbus_channel_close_internal(chan); } -/** - * @brief Send the specified buffer on the given channel - */ int -hv_vmbus_channel_send_packet( - hv_vmbus_channel* channel, - void* buffer, - uint32_t buffer_len, - uint64_t request_id, - hv_vmbus_packet_type type, - uint32_t flags) +hv_vmbus_channel_send_packet(struct hv_vmbus_channel *chan, + void *data, uint32_t dlen, uint64_t xactid, uint16_t type, uint16_t flags) { - int ret = 0; - hv_vm_packet_descriptor desc; - uint32_t packet_len; - uint64_t aligned_data; - uint32_t packet_len_aligned; - boolean_t need_sig; - struct iovec iov[3]; - - packet_len = sizeof(hv_vm_packet_descriptor) + buffer_len; - packet_len_aligned = HV_ALIGN_UP(packet_len, sizeof(uint64_t)); - aligned_data = 0; - - /* Setup the descriptor */ - desc.type = type; /* HV_VMBUS_PACKET_TYPE_DATA_IN_BAND; */ - desc.flags = flags; /* HV_VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED */ - /* in 8-bytes granularity */ - desc.data_offset8 = sizeof(hv_vm_packet_descriptor) >> 3; - desc.length8 = (uint16_t) (packet_len_aligned >> 3); - desc.transaction_id = request_id; - - iov[0].iov_base = &desc; - iov[0].iov_len = sizeof(hv_vm_packet_descriptor); - - iov[1].iov_base = buffer; - iov[1].iov_len = buffer_len; - - iov[2].iov_base = &aligned_data; - iov[2].iov_len = packet_len_aligned - packet_len; - - ret = hv_ring_buffer_write(&channel->outbound, iov, 3, &need_sig); - - /* TODO: We should determine if this is optional */ - if (ret == 0 && need_sig) - vmbus_chan_send_event(channel); - - return (ret); + struct vmbus_chanpkt pkt; + int pktlen, pad_pktlen, hlen, error; + uint64_t pad = 0; + struct iovec iov[3]; + boolean_t send_evt; + + hlen = sizeof(pkt); + pktlen = hlen + dlen; + pad_pktlen = roundup2(pktlen, VMBUS_CHANPKT_SIZE_ALIGN); + + pkt.cp_hdr.cph_type = type; + pkt.cp_hdr.cph_flags = flags; + pkt.cp_hdr.cph_data_ofs = hlen >> VMBUS_CHANPKT_SIZE_SHIFT; + pkt.cp_hdr.cph_len = pad_pktlen >> VMBUS_CHANPKT_SIZE_SHIFT; + pkt.cp_hdr.cph_xactid = xactid; + + iov[0].iov_base = &pkt; + iov[0].iov_len = hlen; + iov[1].iov_base = data; + iov[1].iov_len = dlen; + iov[2].iov_base = &pad; + iov[2].iov_len = pad_pktlen - pktlen; + + error = hv_ring_buffer_write(&chan->outbound, iov, 3, &send_evt); + if (!error && send_evt) + vmbus_chan_send_event(chan); + return error; } -/** - * @brief Send a range of single-page buffer packets using - * a GPADL Direct packet type - */ int -hv_vmbus_channel_send_packet_pagebuffer( - hv_vmbus_channel* channel, - hv_vmbus_page_buffer page_buffers[], - uint32_t page_count, - void* buffer, - uint32_t buffer_len, - uint64_t request_id) +vmbus_chan_send_sglist(struct hv_vmbus_channel *chan, + struct vmbus_gpa sg[], int sglen, void *data, int dlen, uint64_t xactid) { - - int ret = 0; - boolean_t need_sig; - uint32_t packet_len; - uint32_t page_buflen; - uint32_t packetLen_aligned; - struct iovec iov[4]; - hv_vmbus_channel_packet_page_buffer desc; - uint32_t descSize; - uint64_t alignedData = 0; - - if (page_count > HV_MAX_PAGE_BUFFER_COUNT) - return (EINVAL); - - /* - * Adjust the size down since hv_vmbus_channel_packet_page_buffer - * is the largest size we support - */ - descSize = __offsetof(hv_vmbus_channel_packet_page_buffer, range); - page_buflen = sizeof(hv_vmbus_page_buffer) * page_count; - packet_len = descSize + page_buflen + buffer_len; - packetLen_aligned = HV_ALIGN_UP(packet_len, sizeof(uint64_t)); - - /* Setup the descriptor */ - desc.type = HV_VMBUS_PACKET_TYPE_DATA_USING_GPA_DIRECT; - desc.flags = HV_VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED; - /* in 8-bytes granularity */ - desc.data_offset8 = (descSize + page_buflen) >> 3; - desc.length8 = (uint16_t) (packetLen_aligned >> 3); - desc.transaction_id = request_id; - desc.range_count = page_count; - - iov[0].iov_base = &desc; - iov[0].iov_len = descSize; - - iov[1].iov_base = page_buffers; - iov[1].iov_len = page_buflen; - - iov[2].iov_base = buffer; - iov[2].iov_len = buffer_len; - - iov[3].iov_base = &alignedData; - iov[3].iov_len = packetLen_aligned - packet_len; - - ret = hv_ring_buffer_write(&channel->outbound, iov, 4, &need_sig); - - /* TODO: We should determine if this is optional */ - if (ret == 0 && need_sig) - vmbus_chan_send_event(channel); - - return (ret); + struct vmbus_chanpkt_sglist pkt; + int pktlen, pad_pktlen, hlen, error; + struct iovec iov[4]; + boolean_t send_evt; + uint64_t pad = 0; + + KASSERT(sglen < VMBUS_CHAN_SGLIST_MAX, + ("invalid sglist len %d", sglen)); + + hlen = __offsetof(struct vmbus_chanpkt_sglist, cp_gpa[sglen]); + pktlen = hlen + dlen; + pad_pktlen = roundup2(pktlen, VMBUS_CHANPKT_SIZE_ALIGN); + + pkt.cp_hdr.cph_type = VMBUS_CHANPKT_TYPE_GPA; + pkt.cp_hdr.cph_flags = VMBUS_CHANPKT_FLAG_RC; + pkt.cp_hdr.cph_data_ofs = hlen >> VMBUS_CHANPKT_SIZE_SHIFT; + pkt.cp_hdr.cph_len = pad_pktlen >> VMBUS_CHANPKT_SIZE_SHIFT; + pkt.cp_hdr.cph_xactid = xactid; + pkt.cp_rsvd = 0; + pkt.cp_gpa_cnt = sglen; + + iov[0].iov_base = &pkt; + iov[0].iov_len = sizeof(pkt); + iov[1].iov_base = sg; + iov[1].iov_len = sizeof(struct vmbus_gpa) * sglen; + iov[2].iov_base = data; + iov[2].iov_len = dlen; + iov[3].iov_base = &pad; + iov[3].iov_len = pad_pktlen - pktlen; + + error = hv_ring_buffer_write(&chan->outbound, iov, 4, &send_evt); + if (!error && send_evt) + vmbus_chan_send_event(chan); + return error; } -/** - * @brief Send a multi-page buffer packet using a GPADL Direct packet type - */ int -hv_vmbus_channel_send_packet_multipagebuffer( - hv_vmbus_channel* channel, - hv_vmbus_multipage_buffer* multi_page_buffer, - void* buffer, - uint32_t buffer_len, - uint64_t request_id) -{ - - int ret = 0; - uint32_t desc_size; - boolean_t need_sig; - uint32_t packet_len; - uint32_t packet_len_aligned; - uint32_t pfn_count; - uint64_t aligned_data = 0; - struct iovec iov[3]; - hv_vmbus_channel_packet_multipage_buffer desc; - - pfn_count = - HV_NUM_PAGES_SPANNED( - multi_page_buffer->offset, - multi_page_buffer->length); - - if ((pfn_count == 0) || (pfn_count > HV_MAX_MULTIPAGE_BUFFER_COUNT)) - return (EINVAL); - /* - * Adjust the size down since hv_vmbus_channel_packet_multipage_buffer - * is the largest size we support - */ - desc_size = - sizeof(hv_vmbus_channel_packet_multipage_buffer) - - ((HV_MAX_MULTIPAGE_BUFFER_COUNT - pfn_count) * - sizeof(uint64_t)); *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-all@freebsd.org Tue Oct 11 09:19:31 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 69848C0B3CE; Tue, 11 Oct 2016 09:19:31 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 394F63B0; Tue, 11 Oct 2016 09:19:31 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9B9JUk0049882; Tue, 11 Oct 2016 09:19:30 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9B9JUlv049881; Tue, 11 Oct 2016 09:19:30 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610110919.u9B9JUlv049881@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Tue, 11 Oct 2016 09:19:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307035 - stable/10/sys/conf X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Oct 2016 09:19:31 -0000 Author: sephe Date: Tue Oct 11 09:19:30 2016 New Revision: 307035 URL: https://svnweb.freebsd.org/changeset/base/307035 Log: build: Add vmbus_if.m This is a direct commit, which reflects the difference between current and 10-stable. Sponsored by: Microsoft Modified: stable/10/sys/conf/kmod.mk Modified: stable/10/sys/conf/kmod.mk ============================================================================== --- stable/10/sys/conf/kmod.mk Tue Oct 11 09:11:23 2016 (r307034) +++ stable/10/sys/conf/kmod.mk Tue Oct 11 09:19:30 2016 (r307035) @@ -364,6 +364,7 @@ CFLAGS+= ${CONF_CFLAGS} MFILES?= dev/acpica/acpi_if.m dev/acpi_support/acpi_wmi_if.m \ dev/agp/agp_if.m dev/ata/ata_if.m dev/eisa/eisa_if.m \ dev/fb/fb_if.m dev/gpio/gpio_if.m dev/gpio/gpiobus_if.m \ + dev/hyperv/vmbus/vmbus_if.m \ dev/iicbus/iicbb_if.m dev/iicbus/iicbus_if.m \ dev/mmc/mmcbr_if.m dev/mmc/mmcbus_if.m \ dev/mii/miibus_if.m dev/mvs/mvs_if.m dev/ofw/ofw_bus_if.m \ From owner-svn-src-all@freebsd.org Tue Oct 11 11:45:13 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D4754C0DC26; Tue, 11 Oct 2016 11:45:13 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 9F6DD9DB; Tue, 11 Oct 2016 11:45:13 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9BBjCSI005774; Tue, 11 Oct 2016 11:45:12 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9BBjC1x005773; Tue, 11 Oct 2016 11:45:12 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201610111145.u9BBjC1x005773@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Tue, 11 Oct 2016 11:45:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307036 - head/lib/libc/gen X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Oct 2016 11:45:13 -0000 Author: kib Date: Tue Oct 11 11:45:12 2016 New Revision: 307036 URL: https://svnweb.freebsd.org/changeset/base/307036 Log: Fill msg_len for the initial element of msgvec. Submitted by: Daniel Salzman MFC after: 3 days Modified: head/lib/libc/gen/recvmmsg.c Modified: head/lib/libc/gen/recvmmsg.c ============================================================================== --- head/lib/libc/gen/recvmmsg.c Tue Oct 11 09:19:30 2016 (r307035) +++ head/lib/libc/gen/recvmmsg.c Tue Oct 11 11:45:12 2016 (r307036) @@ -69,6 +69,8 @@ recvmmsg(int s, struct mmsghdr *__restri if (ret == -1) return (ret); + msgvec[0].msg_len = ret; + /* * Do non-blocking receive for second and later messages if * WAITFORONE is set. From owner-svn-src-all@freebsd.org Tue Oct 11 11:46:03 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B661CC0DC72; Tue, 11 Oct 2016 11:46:03 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 86993B69; Tue, 11 Oct 2016 11:46:03 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9BBk290005846; Tue, 11 Oct 2016 11:46:02 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9BBk2cF005845; Tue, 11 Oct 2016 11:46:02 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201610111146.u9BBk2cF005845@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Tue, 11 Oct 2016 11:46:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307037 - head/lib/libc/gen X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Oct 2016 11:46:03 -0000 Author: kib Date: Tue Oct 11 11:46:02 2016 New Revision: 307037 URL: https://svnweb.freebsd.org/changeset/base/307037 Log: Correct indent. Sponsored by: The FreeBSD Foundation MFC after: 3 days Modified: head/lib/libc/gen/recvmmsg.c Modified: head/lib/libc/gen/recvmmsg.c ============================================================================== --- head/lib/libc/gen/recvmmsg.c Tue Oct 11 11:45:12 2016 (r307036) +++ head/lib/libc/gen/recvmmsg.c Tue Oct 11 11:46:02 2016 (r307037) @@ -83,10 +83,9 @@ recvmmsg(int s, struct mmsghdr *__restri ret = __sys_recvmsg(s, &msgvec[i].msg_hdr, flags); if (ret == -1) { /* We have received messages. Let caller know - * about the data received, socket - * error is returned on next - * invocation. - */ + * about the data received, socket error is + * returned on next invocation. + */ return (rcvd); } From owner-svn-src-all@freebsd.org Tue Oct 11 13:08:49 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id BEAF7C0C089; Tue, 11 Oct 2016 13:08:49 +0000 (UTC) (envelope-from arybchik@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 7FDBD199; Tue, 11 Oct 2016 13:08:49 +0000 (UTC) (envelope-from arybchik@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9BD8mHp035586; Tue, 11 Oct 2016 13:08:48 GMT (envelope-from arybchik@FreeBSD.org) Received: (from arybchik@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9BD8mog035585; Tue, 11 Oct 2016 13:08:48 GMT (envelope-from arybchik@FreeBSD.org) Message-Id: <201610111308.u9BD8mog035585@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: arybchik set sender to arybchik@FreeBSD.org using -f From: Andrew Rybchenko Date: Tue, 11 Oct 2016 13:08:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307038 - head/sys/dev/sfxge/common X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Oct 2016 13:08:49 -0000 Author: arybchik Date: Tue Oct 11 13:08:48 2016 New Revision: 307038 URL: https://svnweb.freebsd.org/changeset/base/307038 Log: sfxge(4): update external port mapping for Medford Extend the mapping table for external port numbering to support port modes which output to the second external port only. Where supported, map from the current port mode rather than inferring from all the available modes. Updated comments for clarity. Submitted by: Richard Houldsworth Sponsored by: Solarflare Communications, Inc. MFC after: 2 days Differential Revision: https://reviews.freebsd.org/D8210 Modified: head/sys/dev/sfxge/common/ef10_nic.c Modified: head/sys/dev/sfxge/common/ef10_nic.c ============================================================================== --- head/sys/dev/sfxge/common/ef10_nic.c Tue Oct 11 11:46:02 2016 (r307037) +++ head/sys/dev/sfxge/common/ef10_nic.c Tue Oct 11 13:08:48 2016 (r307038) @@ -1099,41 +1099,50 @@ fail1: /* - * The external port mapping is a one-based numbering of the external - * connectors on the board. It does not distinguish off-board separated - * outputs such as multi-headed cables. - * The number of ports that map to each external port connector - * on the board is determined by the chip family and the port modes to - * which the NIC can be configured. The mapping table lists modes with - * port numbering requirements in increasing order. + * Table of mapping schemes from port number to the number of the external + * connector on the board. The external numbering does not distinguish + * off-board separated outputs such as from multi-headed cables. + * + * The count of adjacent port numbers that map to each external port + * and the offset in the numbering, is determined by the chip family and + * current port mode. + * + * For the Huntington family, the current port mode cannot be discovered, + * so the mapping used is instead the last match in the table to the full + * set of port modes to which the NIC can be configured. Therefore the + * ordering of entries in the the mapping table is significant. */ static struct { efx_family_t family; uint32_t modes_mask; - uint32_t stride; + int32_t count; + int32_t offset; } __ef10_external_port_mappings[] = { - /* Supported modes requiring 1 output per port */ + /* Supported modes with 1 output per external port */ { EFX_FAMILY_HUNTINGTON, (1 << TLV_PORT_MODE_10G) | (1 << TLV_PORT_MODE_10G_10G) | (1 << TLV_PORT_MODE_10G_10G_10G_10G), + 1, 1 }, { EFX_FAMILY_MEDFORD, (1 << TLV_PORT_MODE_10G) | (1 << TLV_PORT_MODE_10G_10G), + 1, 1 }, - /* Supported modes requiring 2 outputs per port */ + /* Supported modes with 2 outputs per external port */ { EFX_FAMILY_HUNTINGTON, (1 << TLV_PORT_MODE_40G) | (1 << TLV_PORT_MODE_40G_40G) | (1 << TLV_PORT_MODE_40G_10G_10G) | (1 << TLV_PORT_MODE_10G_10G_40G), - 2 + 2, + 1 }, { EFX_FAMILY_MEDFORD, @@ -1142,15 +1151,22 @@ static struct { (1 << TLV_PORT_MODE_40G_10G_10G) | (1 << TLV_PORT_MODE_10G_10G_40G) | (1 << TLV_PORT_MODE_10G_10G_10G_10G_Q1_Q2), - 2 + 2, + 1 }, - /* Supported modes requiring 4 outputs per port */ + /* Supported modes with 4 outputs per external port */ { EFX_FAMILY_MEDFORD, (1 << TLV_PORT_MODE_10G_10G_10G_10G_Q) | - (1 << TLV_PORT_MODE_10G_10G_10G_10G_Q1) | + (1 << TLV_PORT_MODE_10G_10G_10G_10G_Q1), + 4, + 1, + }, + { + EFX_FAMILY_MEDFORD, (1 << TLV_PORT_MODE_10G_10G_10G_10G_Q2), - 4 + 4, + 2 }, }; @@ -1164,11 +1180,26 @@ ef10_external_port_mapping( int i; uint32_t port_modes; uint32_t matches; - uint32_t stride = 1; /* default 1-1 mapping */ - - if ((rc = efx_mcdi_get_port_modes(enp, &port_modes, NULL)) != 0) { - /* No port mode information available - use default mapping */ - goto out; + uint32_t current; + int32_t count = 1; /* Default 1-1 mapping */ + int32_t offset = 1; /* Default starting external port number */ + + if ((rc = efx_mcdi_get_port_modes(enp, &port_modes, ¤t)) != 0) { + /* + * No current port mode information + * - infer mapping from available modes + */ + if ((rc = efx_mcdi_get_port_modes(enp, + &port_modes, NULL)) != 0) { + /* + * No port mode information available + * - use default mapping + */ + goto out; + } + } else { + /* Only need to scan the current mode */ + port_modes = 1 << current; } /* @@ -1182,7 +1213,8 @@ ef10_external_port_mapping( matches = (__ef10_external_port_mappings[i].modes_mask & port_modes); if (matches != 0) { - stride = __ef10_external_port_mappings[i].stride; + count = __ef10_external_port_mappings[i].count; + offset = __ef10_external_port_mappings[i].offset; port_modes &= ~matches; } } @@ -1196,9 +1228,9 @@ ef10_external_port_mapping( out: /* * Scale as required by last matched mode and then convert to - * one-based numbering + * correctly offset numbering */ - *external_portp = (uint8_t)(port / stride) + 1; + *external_portp = (uint8_t)((port / count) + offset); return (0); fail1: From owner-svn-src-all@freebsd.org Tue Oct 11 13:22:38 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 8C171C0C3B5; Tue, 11 Oct 2016 13:22:38 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 553E3B9A; Tue, 11 Oct 2016 13:22:38 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9BDMbF5043135; Tue, 11 Oct 2016 13:22:37 GMT (envelope-from emaste@FreeBSD.org) Received: (from emaste@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9BDMbxT043134; Tue, 11 Oct 2016 13:22:37 GMT (envelope-from emaste@FreeBSD.org) Message-Id: <201610111322.u9BDMbxT043134@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: emaste set sender to emaste@FreeBSD.org using -f From: Ed Maste Date: Tue, 11 Oct 2016 13:22:37 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307039 - stable/11/release/doc/share/xml X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Oct 2016 13:22:38 -0000 Author: emaste Date: Tue Oct 11 13:22:37 2016 New Revision: 307039 URL: https://svnweb.freebsd.org/changeset/base/307039 Log: Add Cavium sponsor entity Modified: stable/11/release/doc/share/xml/sponsor.ent Modified: stable/11/release/doc/share/xml/sponsor.ent ============================================================================== --- stable/11/release/doc/share/xml/sponsor.ent Tue Oct 11 13:08:48 2016 (r307038) +++ stable/11/release/doc/share/xml/sponsor.ent Tue Oct 11 13:22:37 2016 (r307039) @@ -11,6 +11,7 @@ + From owner-svn-src-all@freebsd.org Tue Oct 11 13:30:41 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 20E24C0C4B5; Tue, 11 Oct 2016 13:30:41 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id E6E2FE10; Tue, 11 Oct 2016 13:30:40 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9BDUemU043447; Tue, 11 Oct 2016 13:30:40 GMT (envelope-from emaste@FreeBSD.org) Received: (from emaste@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9BDUekl043446; Tue, 11 Oct 2016 13:30:40 GMT (envelope-from emaste@FreeBSD.org) Message-Id: <201610111330.u9BDUekl043446@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: emaste set sender to emaste@FreeBSD.org using -f From: Ed Maste Date: Tue, 11 Oct 2016 13:30:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307040 - head/release/doc/share/xml X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Oct 2016 13:30:41 -0000 Author: emaste Date: Tue Oct 11 13:30:39 2016 New Revision: 307040 URL: https://svnweb.freebsd.org/changeset/base/307040 Log: Add Cavium sponsor entity Modified: head/release/doc/share/xml/sponsor.ent Modified: head/release/doc/share/xml/sponsor.ent ============================================================================== --- head/release/doc/share/xml/sponsor.ent Tue Oct 11 13:22:37 2016 (r307039) +++ head/release/doc/share/xml/sponsor.ent Tue Oct 11 13:30:39 2016 (r307040) @@ -11,6 +11,7 @@ + From owner-svn-src-all@freebsd.org Tue Oct 11 14:08:54 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A9FF4C0D41E; Tue, 11 Oct 2016 14:08:54 +0000 (UTC) (envelope-from sbruno@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 69069174C; Tue, 11 Oct 2016 14:08:54 +0000 (UTC) (envelope-from sbruno@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9BE8rfu058458; Tue, 11 Oct 2016 14:08:53 GMT (envelope-from sbruno@FreeBSD.org) Received: (from sbruno@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9BE8rHp058457; Tue, 11 Oct 2016 14:08:53 GMT (envelope-from sbruno@FreeBSD.org) Message-Id: <201610111408.u9BE8rHp058457@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sbruno set sender to sbruno@FreeBSD.org using -f From: Sean Bruno Date: Tue, 11 Oct 2016 14:08:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307041 - head/sys/kern X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Oct 2016 14:08:54 -0000 Author: sbruno Date: Tue Oct 11 14:08:53 2016 New Revision: 307041 URL: https://svnweb.freebsd.org/changeset/base/307041 Log: Fix bug where malloc(.., M_NOWAIT) return value is not checked, Change to M_WAITOK and move outside the mutex Submitted by: shurd Reviewed by: mmacy@nextbsd.org MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D7649 Modified: head/sys/kern/subr_gtaskqueue.c Modified: head/sys/kern/subr_gtaskqueue.c ============================================================================== --- head/sys/kern/subr_gtaskqueue.c Tue Oct 11 13:30:39 2016 (r307040) +++ head/sys/kern/subr_gtaskqueue.c Tue Oct 11 14:08:53 2016 (r307041) @@ -728,7 +728,7 @@ taskqgroup_bind(struct taskqgroup *qgrou * one. */ for (i = 0; i < qgroup->tqg_cnt; i++) { - gtask = malloc(sizeof (*gtask), M_DEVBUF, M_NOWAIT); + gtask = malloc(sizeof (*gtask), M_DEVBUF, M_WAITOK); GTASK_INIT(>ask->bt_task, 0, 0, taskqgroup_binder, gtask); gtask->bt_cpuid = qgroup->tqg_queue[i].tgc_cpu; grouptaskqueue_enqueue(qgroup->tqg_queue[i].tgc_taskq, @@ -827,11 +827,11 @@ _taskqgroup_adjust(struct taskqgroup *qg for (i = cnt; i < old_cnt; i++) taskqgroup_cpu_remove(qgroup, i); + taskqgroup_bind(qgroup); + mtx_lock(&qgroup->tqg_lock); qgroup->tqg_adjusting = 0; - taskqgroup_bind(qgroup); - return (0); } From owner-svn-src-all@freebsd.org Tue Oct 11 15:27:41 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 0893EC0D8F3; Tue, 11 Oct 2016 15:27:41 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id C0B6BEE9; Tue, 11 Oct 2016 15:27:40 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9BFRd1r090146; Tue, 11 Oct 2016 15:27:39 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9BFRdPG090145; Tue, 11 Oct 2016 15:27:39 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201610111527.u9BFRdPG090145@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Tue, 11 Oct 2016 15:27:39 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307042 - head/sys/cam X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Oct 2016 15:27:41 -0000 Author: mav Date: Tue Oct 11 15:27:39 2016 New Revision: 307042 URL: https://svnweb.freebsd.org/changeset/base/307042 Log: Fix copy/paste bug in r306747. Submitted by: emaste, pfg MFC after: 3 days Modified: head/sys/cam/cam_compat.c Modified: head/sys/cam/cam_compat.c ============================================================================== --- head/sys/cam/cam_compat.c Tue Oct 11 14:08:53 2016 (r307041) +++ head/sys/cam/cam_compat.c Tue Oct 11 15:27:39 2016 (r307042) @@ -228,7 +228,7 @@ cam_compat_handle_0x17(struct cdev *dev, cts = &ccb->cts; cts17 = (struct ccb_trans_settings_0x17 *)hdr17; - cts17->type = cts17->type; + cts17->type = cts->type; cts17->protocol = cts->protocol; cts17->protocol_version = cts->protocol_version; cts17->transport = cts->transport; @@ -335,7 +335,7 @@ cam_compat_handle_0x18(struct cdev *dev, cts = &ccb->cts; cts18 = (struct ccb_trans_settings_0x18 *)hdr18; - cts18->type = cts18->type; + cts18->type = cts->type; cts18->protocol = cts->protocol; cts18->protocol_version = cts->protocol_version; cts18->transport = cts->transport; From owner-svn-src-all@freebsd.org Tue Oct 11 15:39:43 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 3E5A4C0DBA4; Tue, 11 Oct 2016 15:39:43 +0000 (UTC) (envelope-from yaneurabeya@gmail.com) Received: from mail-pf0-x22c.google.com (mail-pf0-x22c.google.com [IPv6:2607:f8b0:400e:c00::22c]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 0E41616D3; Tue, 11 Oct 2016 15:39:43 +0000 (UTC) (envelope-from yaneurabeya@gmail.com) Received: by mail-pf0-x22c.google.com with SMTP id e6so4321413pfk.3; Tue, 11 Oct 2016 08:39:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=4WZztBL4BoA+13Xr4WiV7rLfTAdGBJobymVABe7kZow=; b=pxI8+VRYWaZJc7qz79PhaT/koYTR64cInkuRhkqMrkkPjfT0YN6oHsLgDbOW8UVUkk hq4NCeSkVBbg0Qc2etVBEksku8jhuF0YZePLgomEMESXnalUTu5+3RVBp8WnC85YrFdr Ts5wETud3NB0/LzdIXCcL3iquTOAlcvjZ5Jr03HavvctWbss8+xJJMrClS0DOPEUuU/D 53r7qlancpMsrsB/fGHePrzRn5ueSwi9hn4S2nzRhPkwW1m0VNUAJeOubtj7UsN0eLzi C1Xenokj11ZFJyt1TB5IU0Uji/dNWVcKVAscntNyh4Mp7CkIwbeeibB3UiX6tMncmoST 0Asg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=4WZztBL4BoA+13Xr4WiV7rLfTAdGBJobymVABe7kZow=; b=gG/XY1QHMe6Do4lMF6kNB0mPL4+etUmeHqR0mEVvaidQ3RblSQKYOcyXEIjnKvXjGk 2QN4n2qNjpODkFVWWKU2Og7jaZgXE5/FlbyKML2Yo0/Wsdrjt4ZYFTlu3wqi2Z40/OLF 81sL7lA76C7V6YgPAxFPi8iMiiYWkchKIRU4aNF9tEZF+Ha6NPatkYhzHM1hpDrdfgLi wkm0H//+nmi2if+xC7dva52VQsIISvL68DxVyeQ+GMtA1TvyO2z9CJafGDPjQ9mIHNW7 VaA+NXDp97226Ch8RrlP6c4tXrawVuM+8d5r/hOMY5GVdCelze6YCMRowQKmvy+Z/hWE 45YQ== X-Gm-Message-State: AA6/9RmordRrZdVRSTHw/G9JOkEmYJ4juo18QXqclvrtYdkKAFzPY93HMxzxADCwFq5+qg== X-Received: by 10.99.156.10 with SMTP id f10mr1973754pge.123.1476200382292; Tue, 11 Oct 2016 08:39:42 -0700 (PDT) Received: from fuji-wireless.local (c-73-19-52-228.hsd1.wa.comcast.net. [73.19.52.228]) by smtp.gmail.com with ESMTPSA id n2sm4947283pfa.75.2016.10.11.08.39.41 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 11 Oct 2016 08:39:41 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 9.3 \(3124\)) Subject: Re: svn commit: r307042 - head/sys/cam From: "Ngie Cooper (yaneurabeya)" In-Reply-To: <201610111527.u9BFRdPG090145@repo.freebsd.org> Date: Tue, 11 Oct 2016 08:40:24 -0700 Cc: src-committers , svn-src-all@freebsd.org, svn-src-head@freebsd.org Content-Transfer-Encoding: quoted-printable Message-Id: <0103086C-F7CE-4B56-8AF8-164403642AF2@gmail.com> References: <201610111527.u9BFRdPG090145@repo.freebsd.org> To: Alexander Motin X-Mailer: Apple Mail (2.3124) X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Oct 2016 15:39:43 -0000 > On Oct 11, 2016, at 8:27 AM, Alexander Motin wrote: >=20 > Author: mav > Date: Tue Oct 11 15:27:39 2016 > New Revision: 307042 > URL: https://svnweb.freebsd.org/changeset/base/307042 >=20 > Log: > Fix copy/paste bug in r306747. >=20 > Submitted by: emaste, pfg > MFC after: 3 days Also, Coverity (I=E2=80=99ve marked the CIDs fixed): CID: 1364119, 1364120 Thanks, -Ngie= From owner-svn-src-all@freebsd.org Tue Oct 11 15:55:46 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 6ABE2C0D01C; Tue, 11 Oct 2016 15:55:46 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 3A242FC; Tue, 11 Oct 2016 15:55:46 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9BFtjrZ001680; Tue, 11 Oct 2016 15:55:45 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9BFtjSH001679; Tue, 11 Oct 2016 15:55:45 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201610111555.u9BFtjSH001679@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Tue, 11 Oct 2016 15:55:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307043 - head X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Oct 2016 15:55:46 -0000 Author: kib Date: Tue Oct 11 15:55:45 2016 New Revision: 307043 URL: https://svnweb.freebsd.org/changeset/base/307043 Log: Remove mqtest{3,4} from the obsoleted list. Reported by: O. Hartmann Sponsored by: The FreeBSD Foundation MFC after: 3 days Modified: head/ObsoleteFiles.inc Modified: head/ObsoleteFiles.inc ============================================================================== --- head/ObsoleteFiles.inc Tue Oct 11 15:27:39 2016 (r307042) +++ head/ObsoleteFiles.inc Tue Oct 11 15:55:45 2016 (r307043) @@ -482,9 +482,6 @@ OLD_FILES+=usr/lib/clang/3.7.0/lib/freeb OLD_DIRS+=usr/lib/clang/3.7.0/lib/freebsd OLD_DIRS+=usr/lib/clang/3.7.0/lib OLD_DIRS+=usr/lib/clang/3.7.0 -# 20151201: mqueue tests 3 and 4 disabled -OLD_FILES+=usr/tests/sys/mqueue/mqtest3 -OLD_FILES+=usr/tests/sys/mqueue/mqtest4 # 20151130: libelf moved from /usr/lib to /lib (libkvm dependency in r291406) OLD_LIBS+=usr/lib/libelf.so.2 # 20151115: Fox bad upgrade scheme From owner-svn-src-all@freebsd.org Tue Oct 11 16:12:14 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 2179DC0D6F2; Tue, 11 Oct 2016 16:12:14 +0000 (UTC) (envelope-from gnn@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id CC5B0174; Tue, 11 Oct 2016 16:12:13 +0000 (UTC) (envelope-from gnn@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9BGCCmT009776; Tue, 11 Oct 2016 16:12:12 GMT (envelope-from gnn@FreeBSD.org) Received: (from gnn@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9BGCCuW009775; Tue, 11 Oct 2016 16:12:12 GMT (envelope-from gnn@FreeBSD.org) Message-Id: <201610111612.u9BGCCuW009775@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: gnn set sender to gnn@FreeBSD.org using -f From: "George V. Neville-Neil" Date: Tue, 11 Oct 2016 16:12:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307044 - head/cddl/contrib/opensolaris/lib/libdtrace/common X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Oct 2016 16:12:14 -0000 Author: gnn Date: Tue Oct 11 16:12:12 2016 New Revision: 307044 URL: https://svnweb.freebsd.org/changeset/base/307044 Log: Corrected non-portable reuse of va_list in dt_printf() Submitted by: Graeme Jenkinson Reviewed by: markj MFC after: 2 weeks Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D8157 Modified: head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_subr.c Modified: head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_subr.c ============================================================================== --- head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_subr.c Tue Oct 11 15:55:45 2016 (r307043) +++ head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_subr.c Tue Oct 11 16:12:12 2016 (r307044) @@ -581,6 +581,7 @@ int dt_printf(dtrace_hdl_t *dtp, FILE *fp, const char *format, ...) { va_list ap; + va_list ap2; int n; #ifndef illumos @@ -605,11 +606,13 @@ dt_printf(dtrace_hdl_t *dtp, FILE *fp, c len = dtp->dt_sprintf_buflen - len; assert(len >= 0); - if ((n = vsnprintf(buf, len, format, ap)) < 0) + va_copy(ap2, ap); + if ((n = vsnprintf(buf, len, format, ap2)) < 0) n = dt_set_errno(dtp, errno); + va_end(ap2); va_end(ap); - + return (n); } @@ -640,11 +643,14 @@ dt_printf(dtrace_hdl_t *dtp, FILE *fp, c dtp->dt_buffered_buf[0] = '\0'; } - if ((needed = vsnprintf(NULL, 0, format, ap)) < 0) { + va_copy(ap2, ap); + if ((needed = vsnprintf(NULL, 0, format, ap2)) < 0) { rval = dt_set_errno(dtp, errno); + va_end(ap2); va_end(ap); return (rval); } + va_end(ap2); if (needed == 0) { va_end(ap); @@ -670,12 +676,15 @@ dt_printf(dtrace_hdl_t *dtp, FILE *fp, c dtp->dt_buffered_size <<= 1; } + va_copy(ap2, ap); if (vsnprintf(&dtp->dt_buffered_buf[dtp->dt_buffered_offs], - avail, format, ap) < 0) { + avail, format, ap2) < 0) { rval = dt_set_errno(dtp, errno); + va_end(ap2); va_end(ap); return (rval); } + va_end(ap2); dtp->dt_buffered_offs += needed; assert(dtp->dt_buffered_buf[dtp->dt_buffered_offs] == '\0'); @@ -683,8 +692,10 @@ dt_printf(dtrace_hdl_t *dtp, FILE *fp, c return (0); } - n = vfprintf(fp, format, ap); + va_copy(ap2, ap); + n = vfprintf(fp, format, ap2); fflush(fp); + va_end(ap2); va_end(ap); if (n < 0) { From owner-svn-src-all@freebsd.org Tue Oct 11 16:27:00 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 3FDC7C0DD1E; Tue, 11 Oct 2016 16:27:00 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id ECF25C72; Tue, 11 Oct 2016 16:26:59 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9BGQxsa013906; Tue, 11 Oct 2016 16:26:59 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9BGQxGd013905; Tue, 11 Oct 2016 16:26:59 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201610111626.u9BGQxGd013905@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Tue, 11 Oct 2016 16:26:59 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307045 - stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Oct 2016 16:27:00 -0000 Author: mav Date: Tue Oct 11 16:26:58 2016 New Revision: 307045 URL: https://svnweb.freebsd.org/changeset/base/307045 Log: MFC r305193: MFV r302642: 6876 Stack corruption after importing a pool with a too-long name illumos/illumos-gate@c971037baa5d64dfecf6d87ed602fc3116ebec41 https://github.com/illumos/illumos-gate/commit/c971037baa5d64dfecf6d87ed602fc3116ebec41 https://www.illumos.org/issues/6876 Calling dsl_dataset_name on a dataset with a 256 byte buffer is asking for trouble. We should check every dataset on import, using a 1024 byte buffer and checking each time to see if the dataset's new name is longer than 256 bytes. Reviewed by: Prakash Surya Reviewed by: Dan Kimmel Reviewed by: George Wilson Reviewed by: Yuri Pankov Approved by: Richard Lowe Author: Paul Dagnelie Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c ============================================================================== --- stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c Tue Oct 11 16:12:12 2016 (r307044) +++ stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c Tue Oct 11 16:26:58 2016 (r307045) @@ -1996,6 +1996,19 @@ spa_load_verify_cb(spa_t *spa, zilog_t * return (0); } +/* ARGSUSED */ +int +verify_dataset_name_len(dsl_pool_t *dp, dsl_dataset_t *ds, void *arg) +{ + char namebuf[MAXPATHLEN]; + dsl_dataset_name(ds, namebuf); + if (strlen(namebuf) > MAXNAMELEN) { + return (SET_ERROR(ENAMETOOLONG)); + } + + return (0); +} + static int spa_load_verify(spa_t *spa) { @@ -2010,6 +2023,14 @@ spa_load_verify(spa_t *spa) if (policy.zrp_request & ZPOOL_NEVER_REWIND) return (0); + dsl_pool_config_enter(spa->spa_dsl_pool, FTAG); + error = dmu_objset_find_dp(spa->spa_dsl_pool, + spa->spa_dsl_pool->dp_root_dir_obj, verify_dataset_name_len, NULL, + DS_FIND_CHILDREN); + dsl_pool_config_exit(spa->spa_dsl_pool, FTAG); + if (error != 0) + return (error); + rio = zio_root(spa, NULL, &sle, ZIO_FLAG_CANFAIL | ZIO_FLAG_SPECULATIVE); From owner-svn-src-all@freebsd.org Tue Oct 11 16:29:45 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 9D258C0DE28; Tue, 11 Oct 2016 16:29:45 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 777D3E76; Tue, 11 Oct 2016 16:29:45 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9BGTiXH014075; Tue, 11 Oct 2016 16:29:44 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9BGThn2014065; Tue, 11 Oct 2016 16:29:43 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201610111629.u9BGThn2014065@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Tue, 11 Oct 2016 16:29:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307046 - in stable/11: cddl/contrib/opensolaris/cmd/zfs cddl/contrib/opensolaris/lib/libzfs/common sys/cddl/contrib/opensolaris/uts/common/fs/zfs sys/cddl/contrib/opensolaris/uts/commo... X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Oct 2016 16:29:45 -0000 Author: mav Date: Tue Oct 11 16:29:43 2016 New Revision: 307046 URL: https://svnweb.freebsd.org/changeset/base/307046 Log: MFC r305195: MFV r302643: 6902 speed up listing of snapshots if requesting name only and sorting by name This was our change from the beginning, so just reduce the upstream diff. Modified: stable/11/cddl/contrib/opensolaris/cmd/zfs/zfs_iter.c stable/11/cddl/contrib/opensolaris/cmd/zfs/zfs_iter.h stable/11/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs.h stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_impl.h stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_iter.c stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zfs_ioctl.h stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c Directory Properties: stable/11/ (props changed) Modified: stable/11/cddl/contrib/opensolaris/cmd/zfs/zfs_iter.c ============================================================================== --- stable/11/cddl/contrib/opensolaris/cmd/zfs/zfs_iter.c Tue Oct 11 16:26:58 2016 (r307045) +++ stable/11/cddl/contrib/opensolaris/cmd/zfs/zfs_iter.c Tue Oct 11 16:29:43 2016 (r307046) @@ -21,8 +21,7 @@ /* * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2012 Pawel Jakub Dawidek . - * All rights reserved. + * Copyright (c) 2012 Pawel Jakub Dawidek. All rights reserved. * Copyright 2013 Nexenta Systems, Inc. All rights reserved. * Copyright (c) 2013 by Delphix. All rights reserved. */ @@ -320,8 +319,8 @@ zfs_sort(const void *larg, const void *r } else if (psc->sc_prop == ZFS_PROP_NAME) { lvalid = rvalid = B_TRUE; - (void) strlcpy(lbuf, zfs_get_name(l), sizeof(lbuf)); - (void) strlcpy(rbuf, zfs_get_name(r), sizeof(rbuf)); + (void) strlcpy(lbuf, zfs_get_name(l), sizeof (lbuf)); + (void) strlcpy(rbuf, zfs_get_name(r), sizeof (rbuf)); lstr = lbuf; rstr = rbuf; Modified: stable/11/cddl/contrib/opensolaris/cmd/zfs/zfs_iter.h ============================================================================== --- stable/11/cddl/contrib/opensolaris/cmd/zfs/zfs_iter.h Tue Oct 11 16:26:58 2016 (r307045) +++ stable/11/cddl/contrib/opensolaris/cmd/zfs/zfs_iter.h Tue Oct 11 16:29:43 2016 (r307046) @@ -22,6 +22,7 @@ /* * Copyright 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. + * Copyright (c) 2011-2012 Pawel Jakub Dawidek. All rights reserved. * Copyright 2013 Nexenta Systems, Inc. All rights reserved. */ Modified: stable/11/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c ============================================================================== --- stable/11/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c Tue Oct 11 16:26:58 2016 (r307045) +++ stable/11/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c Tue Oct 11 16:29:43 2016 (r307046) @@ -24,8 +24,7 @@ * Copyright (c) 2011, 2015 by Delphix. All rights reserved. * Copyright 2012 Milan Jurik. All rights reserved. * Copyright (c) 2012, Joyent, Inc. All rights reserved. - * Copyright (c) 2011-2012 Pawel Jakub Dawidek . - * All rights reserved. + * Copyright (c) 2011-2012 Pawel Jakub Dawidek. All rights reserved. * Copyright (c) 2012 Martin Matuska . All rights reserved. * Copyright (c) 2013 Steven Hartland. All rights reserved. * Copyright 2013 Nexenta Systems, Inc. All rights reserved. @@ -3009,7 +3008,7 @@ print_dataset(zfs_handle_t *zhp, list_cb if (pl->pl_prop == ZFS_PROP_NAME) { (void) strlcpy(property, zfs_get_name(zhp), - sizeof(property)); + sizeof (property)); propstr = property; right_justify = zfs_prop_align_right(pl->pl_prop); } else if (pl->pl_prop != ZPROP_INVAL) { Modified: stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs.h ============================================================================== --- stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs.h Tue Oct 11 16:26:58 2016 (r307045) +++ stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs.h Tue Oct 11 16:29:43 2016 (r307046) @@ -21,8 +21,7 @@ /* * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2011 Pawel Jakub Dawidek . - * All rights reserved. + * Copyright (c) 2011 Pawel Jakub Dawidek. All rights reserved. * Copyright (c) 2011, 2015 by Delphix. All rights reserved. * Copyright (c) 2012, Joyent, Inc. All rights reserved. * Copyright (c) 2012 Martin Matuska . All rights reserved. Modified: stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c ============================================================================== --- stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c Tue Oct 11 16:26:58 2016 (r307045) +++ stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c Tue Oct 11 16:29:43 2016 (r307046) @@ -24,9 +24,8 @@ * Copyright (c) 2013, Joyent, Inc. All rights reserved. * Copyright (c) 2011, 2015 by Delphix. All rights reserved. * Copyright (c) 2012 DEY Storage Systems, Inc. All rights reserved. - * Copyright (c) 2011-2012 Pawel Jakub Dawidek . - * All rights reserved. - * Copyright (c) 2012 Martin Matuska . All rights reserved. + * Copyright (c) 2011-2012 Pawel Jakub Dawidek. All rights reserved. + * Copyright (c) 2013 Martin Matuska. All rights reserved. * Copyright (c) 2013 Steven Hartland. All rights reserved. * Copyright 2013 Nexenta Systems, Inc. All rights reserved. * Copyright (c) 2014 Integros [integros.com] Modified: stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_impl.h ============================================================================== --- stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_impl.h Tue Oct 11 16:26:58 2016 (r307045) +++ stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_impl.h Tue Oct 11 16:29:43 2016 (r307046) @@ -21,8 +21,7 @@ /* * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2011 Pawel Jakub Dawidek . - * All rights reserved. + * Copyright (c) 2011 Pawel Jakub Dawidek. All rights reserved. * Copyright (c) 2013 by Delphix. All rights reserved. * Copyright (c) 2013 Martin Matuska . All rights reserved. */ Modified: stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_iter.c ============================================================================== --- stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_iter.c Tue Oct 11 16:26:58 2016 (r307045) +++ stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_iter.c Tue Oct 11 16:29:43 2016 (r307046) @@ -22,8 +22,7 @@ /* * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2013, 2015 by Delphix. All rights reserved. - * Copyright (c) 2012 Pawel Jakub Dawidek . - * All rights reserved. + * Copyright (c) 2012 Pawel Jakub Dawidek. All rights reserved. * Copyright 2014 Nexenta Systems, Inc. All rights reserved. */ Modified: stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c ============================================================================== --- stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c Tue Oct 11 16:26:58 2016 (r307045) +++ stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c Tue Oct 11 16:29:43 2016 (r307046) @@ -23,8 +23,7 @@ * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2011, 2015 by Delphix. All rights reserved. * Copyright (c) 2012, Joyent, Inc. All rights reserved. - * Copyright (c) 2012 Pawel Jakub Dawidek . - * All rights reserved. + * Copyright (c) 2012 Pawel Jakub Dawidek. All rights reserved. * Copyright (c) 2013 Steven Hartland. All rights reserved. * Copyright 2015, OmniTI Computer Consulting, Inc. All rights reserved. * Copyright (c) 2014 Integros [integros.com] Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zfs_ioctl.h ============================================================================== --- stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zfs_ioctl.h Tue Oct 11 16:26:58 2016 (r307045) +++ stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zfs_ioctl.h Tue Oct 11 16:29:43 2016 (r307046) @@ -20,6 +20,7 @@ */ /* * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011-2012 Pawel Jakub Dawidek. All rights reserved. * Copyright (c) 2012, 2015 by Delphix. All rights reserved. * Copyright 2016 RackTop Systems. * Copyright (c) 2014 Integros [integros.com] Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c ============================================================================== --- stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c Tue Oct 11 16:26:58 2016 (r307045) +++ stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c Tue Oct 11 16:29:43 2016 (r307046) @@ -21,8 +21,7 @@ /* * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2011-2012 Pawel Jakub Dawidek . - * All rights reserved. + * Copyright (c) 2011-2012 Pawel Jakub Dawidek. All rights reserved. * Copyright 2013 Martin Matuska . All rights reserved. * Copyright 2014 Xin Li . All rights reserved. * Copyright 2015, OmniTI Computer Consulting, Inc. All rights reserved. From owner-svn-src-all@freebsd.org Tue Oct 11 16:30:51 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 5A952C0DEA3; Tue, 11 Oct 2016 16:30:51 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 2E7246E; Tue, 11 Oct 2016 16:30:51 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9BGUooS014860; Tue, 11 Oct 2016 16:30:50 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9BGUoP4014856; Tue, 11 Oct 2016 16:30:50 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201610111630.u9BGUoP4014856@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Tue, 11 Oct 2016 16:30:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307047 - in stable/11/sys/cddl/contrib/opensolaris/uts/common: fs/zfs sys/sysevent X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Oct 2016 16:30:51 -0000 Author: mav Date: Tue Oct 11 16:30:49 2016 New Revision: 307047 URL: https://svnweb.freebsd.org/changeset/base/307047 Log: MFC r305198: MFV r302647: 6922 Emit ESC_ZFS_VDEV_REMOVE_AUX after removing an aux device illumos/illumos-gate@63364b0ee2604783e7a55f8425888867768eafa4 https://github.com/illumos/illumos-gate/commit/63364b0ee2604783e7a55f84258888677 68eafa4 https://www.illumos.org/issues/6922 ZFS does not do a config_sync after removing an aux (spare, log, or cache) device. AFAICT this isn't being done because it is slow and was deemed unnecessary. However, it should be such a rare operation that speed doesn't matter, and not doing it results in two problems: 1) It is theoretically possible to remove an aux device from one pool and attach it to another, then lose power. When power is restored, both pools woul d think that they own the aux device. 2) Removal of the aux device doesn't send any useful sysevents to userland. Reviewed by: George Wilson Reviewed by: Matthew Ahrens Approved by: Dan McDonald Author: Alan Somers Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c stable/11/sys/cddl/contrib/opensolaris/uts/common/sys/sysevent/eventdefs.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c ============================================================================== --- stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c Tue Oct 11 16:29:43 2016 (r307046) +++ stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c Tue Oct 11 16:30:49 2016 (r307047) @@ -5773,6 +5773,7 @@ spa_vdev_remove(spa_t *spa, uint64_t gui } else { error = SET_ERROR(EBUSY); } + spa_event_notify(spa, vd, ESC_ZFS_VDEV_REMOVE_AUX); } else if (spa->spa_l2cache.sav_vdevs != NULL && nvlist_lookup_nvlist_array(spa->spa_l2cache.sav_config, ZPOOL_CONFIG_L2CACHE, &l2cache, &nl2cache) == 0 && @@ -5784,6 +5785,7 @@ spa_vdev_remove(spa_t *spa, uint64_t gui ZPOOL_CONFIG_L2CACHE, l2cache, nl2cache, nv); spa_load_l2cache(spa); spa->spa_l2cache.sav_sync = B_TRUE; + spa_event_notify(spa, vd, ESC_ZFS_VDEV_REMOVE_AUX); } else if (vd != NULL && vd->vdev_islog) { ASSERT(!locked); ASSERT(vd == vd->vdev_top); @@ -5822,6 +5824,7 @@ spa_vdev_remove(spa_t *spa, uint64_t gui */ spa_vdev_remove_from_namespace(spa, vd); + spa_event_notify(spa, vd, ESC_ZFS_VDEV_REMOVE_DEV); } else if (vd != NULL) { /* * Normal vdevs cannot be removed (yet). @@ -5835,7 +5838,7 @@ spa_vdev_remove(spa_t *spa, uint64_t gui } if (!locked) - return (spa_vdev_exit(spa, NULL, txg, error)); + error = spa_vdev_exit(spa, NULL, txg, error); return (error); } Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/sys/sysevent/eventdefs.h ============================================================================== --- stable/11/sys/cddl/contrib/opensolaris/uts/common/sys/sysevent/eventdefs.h Tue Oct 11 16:29:43 2016 (r307046) +++ stable/11/sys/cddl/contrib/opensolaris/uts/common/sys/sysevent/eventdefs.h Tue Oct 11 16:30:49 2016 (r307047) @@ -249,6 +249,8 @@ extern "C" { #define ESC_ZFS_RESILVER_START "ESC_ZFS_resilver_start" #define ESC_ZFS_RESILVER_FINISH "ESC_ZFS_resilver_finish" #define ESC_ZFS_VDEV_REMOVE "ESC_ZFS_vdev_remove" +#define ESC_ZFS_VDEV_REMOVE_AUX "ESC_ZFS_vdev_remove_aux" +#define ESC_ZFS_VDEV_REMOVE_DEV "ESC_ZFS_vdev_remove_dev" #define ESC_ZFS_POOL_CREATE "ESC_ZFS_pool_create" #define ESC_ZFS_POOL_DESTROY "ESC_ZFS_pool_destroy" #define ESC_ZFS_POOL_IMPORT "ESC_ZFS_pool_import" From owner-svn-src-all@freebsd.org Tue Oct 11 16:31:56 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 907B6C0DF30; Tue, 11 Oct 2016 16:31:56 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 6D5252D3; Tue, 11 Oct 2016 16:31:56 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9BGVtfu015548; Tue, 11 Oct 2016 16:31:55 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9BGVt3u015547; Tue, 11 Oct 2016 16:31:55 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201610111631.u9BGVt3u015547@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Tue, 11 Oct 2016 16:31:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307048 - stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Oct 2016 16:31:56 -0000 Author: mav Date: Tue Oct 11 16:31:55 2016 New Revision: 307048 URL: https://svnweb.freebsd.org/changeset/base/307048 Log: MFC r305199: MFV r302648: 7019 zfsdev_ioctl skips secpolicy when FKIOCTL is set Note that the bulk of the upstream change is not applicable to FreeBSD and the affected files are not even in the vendor area. illumos/illumos-gate@45b1747515a17db45e8971501ee84a26bdff37b2 https://github.com/illumos/illumos-gate/commit/45b1747515a17db45e8971501ee84a26bdff37b2 https://www.illumos.org/issues/7019 Currently zfsdev_ioctl, when confronted by a request with the FKIOCTL flag set, skips all processing of secpolicy functions. This means that ZFS is not doing any kind of verification of the credentials or access rights of the caller and assuming that (as it is an in-kernel client) all such checks have already been done. This turns out to be quite a dangerous assumption, especially with respect to sdev. In general I don't think it's particularly reasonable to offload this enforcement of access rights onto other kernel subsystems when ZFS has some particular local semantics in this area (delegated datasets etc) and does not provide any kind of API to allow other subsystems to avoid code duplication when doing it. ZFS should apply its normal access policy to requests from within the kernel, and callers should take care to give it the correct credentials and call it from the correct context in order to get the results they need. You can observe the currently unfortunate consequences of this bug in any non- global zone that has access to /dev/zvol or any subset of it via sdev profiles. In particular, a zone used to contain a KVM or similar which has a single zvol passed through to it using a Reviewed by: Richard Lowe Reviewed by: Matthew Ahrens Approved by: Dan McDonald Author: Alex Wilson Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c ============================================================================== --- stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c Tue Oct 11 16:30:49 2016 (r307047) +++ stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c Tue Oct 11 16:31:55 2016 (r307048) @@ -26,7 +26,7 @@ * Copyright 2014 Xin Li . All rights reserved. * Copyright 2015, OmniTI Computer Consulting, Inc. All rights reserved. * Copyright 2015 Nexenta Systems, Inc. All rights reserved. - * Copyright (c) 2014, Joyent, Inc. All rights reserved. + * Copyright (c) 2014, 2016 Joyent, Inc. All rights reserved. * Copyright (c) 2011, 2015 by Delphix. All rights reserved. * Copyright (c) 2013 by Saso Kiselkov. All rights reserved. * Copyright (c) 2013 Steven Hartland. All rights reserved. @@ -6359,7 +6359,7 @@ zfsdev_ioctl(struct cdev *dev, u_long zc break; } - if (error == 0 && !(flag & FKIOCTL)) + if (error == 0) error = vec->zvec_secpolicy(zc, innvl, cr); if (error != 0) From owner-svn-src-all@freebsd.org Tue Oct 11 16:32:51 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 2DB26C0C077; Tue, 11 Oct 2016 16:32:51 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id EFFD07F7; Tue, 11 Oct 2016 16:32:50 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9BGWo4T017831; Tue, 11 Oct 2016 16:32:50 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9BGWnQZ017825; Tue, 11 Oct 2016 16:32:49 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201610111632.u9BGWnQZ017825@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Tue, 11 Oct 2016 16:32:49 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307049 - in stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs: . sys X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Oct 2016 16:32:51 -0000 Author: mav Date: Tue Oct 11 16:32:49 2016 New Revision: 307049 URL: https://svnweb.freebsd.org/changeset/base/307049 Log: MFC r305200: MFV r302651: 7054 dmu_tx_hold_t should use refcount_t to track space illumos/illumos-gate@0c779ad424a92a84d1e07d47cab7f8009189202b https://github.com/illumos/illumos-gate/commit/0c779ad424a92a84d1e07d47cab7f8009 189202b https://www.illumos.org/issues/7054 upstream: ee0003de7d3e598499be7ac3fe6b61efcc47cb7f DLPX-40399 dmu_tx_hold_t should use refcount_t to track space Reviewed by: George Wilson Reviewed by: Paul Dagnelie Reviewed by: Igor Kozhukhov Approved by: Dan McDonald Author: Matthew Ahrens Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_tx.c stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dmu_tx.h stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zap.h stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zap_impl.h stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zap.c stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zap_micro.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_tx.c ============================================================================== --- stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_tx.c Tue Oct 11 16:31:55 2016 (r307048) +++ stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_tx.c Tue Oct 11 16:32:49 2016 (r307049) @@ -129,6 +129,12 @@ dmu_tx_hold_object_impl(dmu_tx_t *tx, ob txh = kmem_zalloc(sizeof (dmu_tx_hold_t), KM_SLEEP); txh->txh_tx = tx; txh->txh_dnode = dn; + refcount_create(&txh->txh_space_towrite); + refcount_create(&txh->txh_space_tofree); + refcount_create(&txh->txh_space_tooverwrite); + refcount_create(&txh->txh_space_tounref); + refcount_create(&txh->txh_memory_tohold); + refcount_create(&txh->txh_fudge); #ifdef ZFS_DEBUG txh->txh_type = type; txh->txh_arg1 = arg1; @@ -201,12 +207,18 @@ dmu_tx_count_twig(dmu_tx_hold_t *txh, dn freeable = (bp && (freeable || dsl_dataset_block_freeable(ds, bp, bp->blk_birth))); - if (freeable) - txh->txh_space_tooverwrite += space; - else - txh->txh_space_towrite += space; - if (bp) - txh->txh_space_tounref += bp_get_dsize(os->os_spa, bp); + if (freeable) { + (void) refcount_add_many(&txh->txh_space_tooverwrite, + space, FTAG); + } else { + (void) refcount_add_many(&txh->txh_space_towrite, + space, FTAG); + } + + if (bp) { + (void) refcount_add_many(&txh->txh_space_tounref, + bp_get_dsize(os->os_spa, bp), FTAG); + } dmu_tx_count_twig(txh, dn, parent, level + 1, blkid >> epbs, freeable, history); @@ -336,8 +348,11 @@ dmu_tx_count_write(dmu_tx_hold_t *txh, u bits = 64 - min_bs; epbs = min_ibs - SPA_BLKPTRSHIFT; for (bits -= epbs * (nlvls - 1); - bits >= 0; bits -= epbs) - txh->txh_fudge += 1ULL << max_ibs; + bits >= 0; bits -= epbs) { + (void) refcount_add_many( + &txh->txh_fudge, + 1ULL << max_ibs, FTAG); + } goto out; } off += delta; @@ -353,7 +368,8 @@ dmu_tx_count_write(dmu_tx_hold_t *txh, u */ start = P2ALIGN(off, 1ULL << max_bs); end = P2ROUNDUP(off + len, 1ULL << max_bs) - 1; - txh->txh_space_towrite += end - start + 1; + (void) refcount_add_many(&txh->txh_space_towrite, + end - start + 1, FTAG); start >>= min_bs; end >>= min_bs; @@ -368,18 +384,21 @@ dmu_tx_count_write(dmu_tx_hold_t *txh, u start >>= epbs; end >>= epbs; ASSERT3U(end, >=, start); - txh->txh_space_towrite += (end - start + 1) << max_ibs; + (void) refcount_add_many(&txh->txh_space_towrite, + (end - start + 1) << max_ibs, FTAG); if (start != 0) { /* * We also need a new blkid=0 indirect block * to reference any existing file data. */ - txh->txh_space_towrite += 1ULL << max_ibs; + (void) refcount_add_many(&txh->txh_space_towrite, + 1ULL << max_ibs, FTAG); } } out: - if (txh->txh_space_towrite + txh->txh_space_tooverwrite > + if (refcount_count(&txh->txh_space_towrite) + + refcount_count(&txh->txh_space_tooverwrite) > 2 * DMU_MAX_ACCESS) err = SET_ERROR(EFBIG); @@ -398,12 +417,15 @@ dmu_tx_count_dnode(dmu_tx_hold_t *txh) if (dn && dn->dn_dbuf->db_blkptr && dsl_dataset_block_freeable(dn->dn_objset->os_dsl_dataset, dn->dn_dbuf->db_blkptr, dn->dn_dbuf->db_blkptr->blk_birth)) { - txh->txh_space_tooverwrite += space; - txh->txh_space_tounref += space; + (void) refcount_add_many(&txh->txh_space_tooverwrite, + space, FTAG); + (void) refcount_add_many(&txh->txh_space_tounref, space, FTAG); } else { - txh->txh_space_towrite += space; - if (dn && dn->dn_dbuf->db_blkptr) - txh->txh_space_tounref += space; + (void) refcount_add_many(&txh->txh_space_towrite, space, FTAG); + if (dn && dn->dn_dbuf->db_blkptr) { + (void) refcount_add_many(&txh->txh_space_tounref, + space, FTAG); + } } } @@ -525,7 +547,8 @@ dmu_tx_count_free(dmu_tx_hold_t *txh, ui break; } - txh->txh_memory_tohold += dbuf->db.db_size; + (void) refcount_add_many(&txh->txh_memory_tohold, + dbuf->db.db_size, FTAG); /* * We don't check memory_tohold against DMU_MAX_ACCESS because @@ -578,20 +601,23 @@ dmu_tx_count_free(dmu_tx_hold_t *txh, ui (dn->dn_indblkshift - SPA_BLKPTRSHIFT); while (level++ < maxlevel) { - txh->txh_memory_tohold += MAX(MIN(blkcnt, nl1blks), 1) - << dn->dn_indblkshift; + (void) refcount_add_many(&txh->txh_memory_tohold, + MAX(MIN(blkcnt, nl1blks), 1) << dn->dn_indblkshift, + FTAG); blkcnt = 1 + (blkcnt >> epbs); } } /* account for new level 1 indirect blocks that might show up */ if (skipped > 0) { - txh->txh_fudge += skipped << dn->dn_indblkshift; + (void) refcount_add_many(&txh->txh_fudge, + skipped << dn->dn_indblkshift, FTAG); skipped = MIN(skipped, DMU_MAX_DELETEBLKCNT >> epbs); - txh->txh_memory_tohold += skipped << dn->dn_indblkshift; + (void) refcount_add_many(&txh->txh_memory_tohold, + skipped << dn->dn_indblkshift, FTAG); } - txh->txh_space_tofree += space; - txh->txh_space_tounref += unref; + (void) refcount_add_many(&txh->txh_space_tofree, space, FTAG); + (void) refcount_add_many(&txh->txh_space_tounref, unref, FTAG); } /* @@ -617,7 +643,10 @@ dmu_tx_mark_netfree(dmu_tx_t *tx) * cause overflows when doing math with these values (e.g. in * dmu_tx_try_assign()). */ - txh->txh_space_tofree = txh->txh_space_tounref = 1024 * 1024 * 1024; + (void) refcount_add_many(&txh->txh_space_tofree, + 1024 * 1024 * 1024, FTAG); + (void) refcount_add_many(&txh->txh_space_tounref, + 1024 * 1024 * 1024, FTAG); } void @@ -717,9 +746,7 @@ dmu_tx_hold_zap(dmu_tx_t *tx, uint64_t o { dmu_tx_hold_t *txh; dnode_t *dn; - dsl_dataset_phys_t *ds_phys; - uint64_t nblocks; - int epbs, err; + int err; ASSERT(tx->tx_txg == 0); @@ -762,12 +789,17 @@ dmu_tx_hold_zap(dmu_tx_t *tx, uint64_t o */ bp = &dn->dn_phys->dn_blkptr[0]; if (dsl_dataset_block_freeable(dn->dn_objset->os_dsl_dataset, - bp, bp->blk_birth)) - txh->txh_space_tooverwrite += MZAP_MAX_BLKSZ; - else - txh->txh_space_towrite += MZAP_MAX_BLKSZ; - if (!BP_IS_HOLE(bp)) - txh->txh_space_tounref += MZAP_MAX_BLKSZ; + bp, bp->blk_birth)) { + (void) refcount_add_many(&txh->txh_space_tooverwrite, + MZAP_MAX_BLKSZ, FTAG); + } else { + (void) refcount_add_many(&txh->txh_space_towrite, + MZAP_MAX_BLKSZ, FTAG); + } + if (!BP_IS_HOLE(bp)) { + (void) refcount_add_many(&txh->txh_space_tounref, + MZAP_MAX_BLKSZ, FTAG); + } return; } @@ -789,15 +821,29 @@ dmu_tx_hold_zap(dmu_tx_t *tx, uint64_t o /* * If the modified blocks are scattered to the four winds, - * we'll have to modify an indirect twig for each. + * we'll have to modify an indirect twig for each. We can make + * modifications at up to 3 locations: + * - header block at the beginning of the object + * - target leaf block + * - end of the object, where we might need to write: + * - a new leaf block if the target block needs to be split + * - the new pointer table, if it is growing + * - the new cookie table, if it is growing */ - epbs = dn->dn_indblkshift - SPA_BLKPTRSHIFT; - ds_phys = dsl_dataset_phys(dn->dn_objset->os_dsl_dataset); - for (nblocks = dn->dn_maxblkid >> epbs; nblocks != 0; nblocks >>= epbs) - if (ds_phys->ds_prev_snap_obj) - txh->txh_space_towrite += 3 << dn->dn_indblkshift; - else - txh->txh_space_tooverwrite += 3 << dn->dn_indblkshift; + int epbs = dn->dn_indblkshift - SPA_BLKPTRSHIFT; + dsl_dataset_phys_t *ds_phys = + dsl_dataset_phys(dn->dn_objset->os_dsl_dataset); + for (int lvl = 1; lvl < dn->dn_nlevels; lvl++) { + uint64_t num_indirects = 1 + (dn->dn_maxblkid >> (epbs * lvl)); + uint64_t spc = MIN(3, num_indirects) << dn->dn_indblkshift; + if (ds_phys->ds_prev_snap_obj != 0) { + (void) refcount_add_many(&txh->txh_space_towrite, + spc, FTAG); + } else { + (void) refcount_add_many(&txh->txh_space_tooverwrite, + spc, FTAG); + } + } } void @@ -822,7 +868,7 @@ dmu_tx_hold_space(dmu_tx_t *tx, uint64_t txh = dmu_tx_hold_object_impl(tx, tx->tx_objset, DMU_NEW_OBJECT, THT_SPACE, space, 0); - txh->txh_space_towrite += space; + (void) refcount_add_many(&txh->txh_space_towrite, space, FTAG); } int @@ -1175,12 +1221,12 @@ dmu_tx_try_assign(dmu_tx_t *tx, txg_how_ (void) refcount_add(&dn->dn_tx_holds, tx); mutex_exit(&dn->dn_mtx); } - towrite += txh->txh_space_towrite; - tofree += txh->txh_space_tofree; - tooverwrite += txh->txh_space_tooverwrite; - tounref += txh->txh_space_tounref; - tohold += txh->txh_memory_tohold; - fudge += txh->txh_fudge; + towrite += refcount_count(&txh->txh_space_towrite); + tofree += refcount_count(&txh->txh_space_tofree); + tooverwrite += refcount_count(&txh->txh_space_tooverwrite); + tounref += refcount_count(&txh->txh_space_tounref); + tohold += refcount_count(&txh->txh_memory_tohold); + fudge += refcount_count(&txh->txh_fudge); } /* @@ -1383,24 +1429,59 @@ dmu_tx_willuse_space(dmu_tx_t *tx, int64 #endif } -void -dmu_tx_commit(dmu_tx_t *tx) +static void +dmu_tx_destroy(dmu_tx_t *tx) { dmu_tx_hold_t *txh; + while ((txh = list_head(&tx->tx_holds)) != NULL) { + dnode_t *dn = txh->txh_dnode; + + list_remove(&tx->tx_holds, txh); + refcount_destroy_many(&txh->txh_space_towrite, + refcount_count(&txh->txh_space_towrite)); + refcount_destroy_many(&txh->txh_space_tofree, + refcount_count(&txh->txh_space_tofree)); + refcount_destroy_many(&txh->txh_space_tooverwrite, + refcount_count(&txh->txh_space_tooverwrite)); + refcount_destroy_many(&txh->txh_space_tounref, + refcount_count(&txh->txh_space_tounref)); + refcount_destroy_many(&txh->txh_memory_tohold, + refcount_count(&txh->txh_memory_tohold)); + refcount_destroy_many(&txh->txh_fudge, + refcount_count(&txh->txh_fudge)); + kmem_free(txh, sizeof (dmu_tx_hold_t)); + if (dn != NULL) + dnode_rele(dn, tx); + } + + list_destroy(&tx->tx_callbacks); + list_destroy(&tx->tx_holds); +#ifdef ZFS_DEBUG + refcount_destroy_many(&tx->tx_space_written, + refcount_count(&tx->tx_space_written)); + refcount_destroy_many(&tx->tx_space_freed, + refcount_count(&tx->tx_space_freed)); +#endif + kmem_free(tx, sizeof (dmu_tx_t)); +} + +void +dmu_tx_commit(dmu_tx_t *tx) +{ ASSERT(tx->tx_txg != 0); /* * Go through the transaction's hold list and remove holds on * associated dnodes, notifying waiters if no holds remain. */ - while (txh = list_head(&tx->tx_holds)) { + for (dmu_tx_hold_t *txh = list_head(&tx->tx_holds); txh != NULL; + txh = list_next(&tx->tx_holds, txh)) { dnode_t *dn = txh->txh_dnode; - list_remove(&tx->tx_holds, txh); - kmem_free(txh, sizeof (dmu_tx_hold_t)); if (dn == NULL) continue; + mutex_enter(&dn->dn_mtx); ASSERT3U(dn->dn_assigned_txg, ==, tx->tx_txg); @@ -1409,7 +1490,6 @@ dmu_tx_commit(dmu_tx_t *tx) cv_broadcast(&dn->dn_notxholds); } mutex_exit(&dn->dn_mtx); - dnode_rele(dn, tx); } if (tx->tx_tempreserve_cookie) @@ -1421,51 +1501,26 @@ dmu_tx_commit(dmu_tx_t *tx) if (tx->tx_anyobj == FALSE) txg_rele_to_sync(&tx->tx_txgh); - list_destroy(&tx->tx_callbacks); - list_destroy(&tx->tx_holds); #ifdef ZFS_DEBUG dprintf("towrite=%llu written=%llu tofree=%llu freed=%llu\n", tx->tx_space_towrite, refcount_count(&tx->tx_space_written), tx->tx_space_tofree, refcount_count(&tx->tx_space_freed)); - refcount_destroy_many(&tx->tx_space_written, - refcount_count(&tx->tx_space_written)); - refcount_destroy_many(&tx->tx_space_freed, - refcount_count(&tx->tx_space_freed)); #endif - kmem_free(tx, sizeof (dmu_tx_t)); + dmu_tx_destroy(tx); } void dmu_tx_abort(dmu_tx_t *tx) { - dmu_tx_hold_t *txh; - ASSERT(tx->tx_txg == 0); - while (txh = list_head(&tx->tx_holds)) { - dnode_t *dn = txh->txh_dnode; - - list_remove(&tx->tx_holds, txh); - kmem_free(txh, sizeof (dmu_tx_hold_t)); - if (dn != NULL) - dnode_rele(dn, tx); - } - /* * Call any registered callbacks with an error code. */ if (!list_is_empty(&tx->tx_callbacks)) dmu_tx_do_callbacks(&tx->tx_callbacks, ECANCELED); - list_destroy(&tx->tx_callbacks); - list_destroy(&tx->tx_holds); -#ifdef ZFS_DEBUG - refcount_destroy_many(&tx->tx_space_written, - refcount_count(&tx->tx_space_written)); - refcount_destroy_many(&tx->tx_space_freed, - refcount_count(&tx->tx_space_freed)); -#endif - kmem_free(tx, sizeof (dmu_tx_t)); + dmu_tx_destroy(tx); } uint64_t @@ -1504,7 +1559,7 @@ dmu_tx_do_callbacks(list_t *cb_list, int { dmu_tx_callback_t *dcb; - while (dcb = list_head(cb_list)) { + while ((dcb = list_head(cb_list)) != NULL) { list_remove(cb_list, dcb); dcb->dcb_func(dcb->dcb_data, error); kmem_free(dcb, sizeof (dmu_tx_callback_t)); @@ -1562,18 +1617,24 @@ dmu_tx_hold_spill(dmu_tx_t *tx, uint64_t /* If blkptr doesn't exist then add space to towrite */ if (!(dn->dn_phys->dn_flags & DNODE_FLAG_SPILL_BLKPTR)) { - txh->txh_space_towrite += SPA_OLD_MAXBLOCKSIZE; + (void) refcount_add_many(&txh->txh_space_towrite, + SPA_OLD_MAXBLOCKSIZE, FTAG); } else { blkptr_t *bp; bp = &dn->dn_phys->dn_spill; if (dsl_dataset_block_freeable(dn->dn_objset->os_dsl_dataset, - bp, bp->blk_birth)) - txh->txh_space_tooverwrite += SPA_OLD_MAXBLOCKSIZE; - else - txh->txh_space_towrite += SPA_OLD_MAXBLOCKSIZE; - if (!BP_IS_HOLE(bp)) - txh->txh_space_tounref += SPA_OLD_MAXBLOCKSIZE; + bp, bp->blk_birth)) { + (void) refcount_add_many(&txh->txh_space_tooverwrite, + SPA_OLD_MAXBLOCKSIZE, FTAG); + } else { + (void) refcount_add_many(&txh->txh_space_towrite, + SPA_OLD_MAXBLOCKSIZE, FTAG); + } + if (!BP_IS_HOLE(bp)) { + (void) refcount_add_many(&txh->txh_space_tounref, + SPA_OLD_MAXBLOCKSIZE, FTAG); + } } } Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dmu_tx.h ============================================================================== --- stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dmu_tx.h Tue Oct 11 16:31:55 2016 (r307048) +++ stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dmu_tx.h Tue Oct 11 16:32:49 2016 (r307049) @@ -23,7 +23,7 @@ * Use is subject to license terms. */ /* - * Copyright (c) 2013 by Delphix. All rights reserved. + * Copyright (c) 2012, 2015 by Delphix. All rights reserved. */ #ifndef _SYS_DMU_TX_H @@ -101,12 +101,12 @@ typedef struct dmu_tx_hold { dmu_tx_t *txh_tx; list_node_t txh_node; struct dnode *txh_dnode; - uint64_t txh_space_towrite; - uint64_t txh_space_tofree; - uint64_t txh_space_tooverwrite; - uint64_t txh_space_tounref; - uint64_t txh_memory_tohold; - uint64_t txh_fudge; + refcount_t txh_space_towrite; + refcount_t txh_space_tofree; + refcount_t txh_space_tooverwrite; + refcount_t txh_space_tounref; + refcount_t txh_memory_tohold; + refcount_t txh_fudge; #ifdef ZFS_DEBUG enum dmu_tx_hold_type txh_type; uint64_t txh_arg1; Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zap.h ============================================================================== --- stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zap.h Tue Oct 11 16:31:55 2016 (r307048) +++ stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zap.h Tue Oct 11 16:32:49 2016 (r307049) @@ -20,7 +20,7 @@ */ /* * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2012 by Delphix. All rights reserved. + * Copyright (c) 2012, 2015 by Delphix. All rights reserved. */ #ifndef _SYS_ZAP_H @@ -80,6 +80,7 @@ */ #include +#include #ifdef __cplusplus extern "C" { @@ -217,7 +218,7 @@ int zap_prefetch_uint64(objset_t *os, ui int key_numints); int zap_count_write(objset_t *os, uint64_t zapobj, const char *name, - int add, uint64_t *towrite, uint64_t *tooverwrite); + int add, refcount_t *towrite, refcount_t *tooverwrite); /* * Create an attribute with the given name and value. Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zap_impl.h ============================================================================== --- stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zap_impl.h Tue Oct 11 16:31:55 2016 (r307048) +++ stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zap_impl.h Tue Oct 11 16:32:49 2016 (r307049) @@ -20,6 +20,7 @@ */ /* * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2015 by Delphix. All rights reserved. * Copyright (c) 2014 Spectra Logic Corporation, All rights reserved. * Copyright (c) 2014 Integros [integros.com] */ @@ -213,8 +214,8 @@ int fzap_lookup(zap_name_t *zn, uint64_t integer_size, uint64_t num_integers, void *buf, char *realname, int rn_len, boolean_t *normalization_conflictp); void fzap_prefetch(zap_name_t *zn); -int fzap_count_write(zap_name_t *zn, int add, uint64_t *towrite, - uint64_t *tooverwrite); +int fzap_count_write(zap_name_t *zn, int add, refcount_t *towrite, + refcount_t *tooverwrite); int fzap_add(zap_name_t *zn, uint64_t integer_size, uint64_t num_integers, const void *val, dmu_tx_t *tx); int fzap_update(zap_name_t *zn, Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zap.c ============================================================================== --- stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zap.c Tue Oct 11 16:31:55 2016 (r307048) +++ stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zap.c Tue Oct 11 16:32:49 2016 (r307049) @@ -1342,8 +1342,8 @@ fzap_get_stats(zap_t *zap, zap_stats_t * } int -fzap_count_write(zap_name_t *zn, int add, uint64_t *towrite, - uint64_t *tooverwrite) +fzap_count_write(zap_name_t *zn, int add, refcount_t *towrite, + refcount_t *tooverwrite) { zap_t *zap = zn->zn_zap; zap_leaf_t *l; @@ -1353,9 +1353,11 @@ fzap_count_write(zap_name_t *zn, int add * Account for the header block of the fatzap. */ if (!add && dmu_buf_freeable(zap->zap_dbuf)) { - *tooverwrite += zap->zap_dbuf->db_size; + (void) refcount_add_many(tooverwrite, + zap->zap_dbuf->db_size, FTAG); } else { - *towrite += zap->zap_dbuf->db_size; + (void) refcount_add_many(towrite, + zap->zap_dbuf->db_size, FTAG); } /* @@ -1367,10 +1369,13 @@ fzap_count_write(zap_name_t *zn, int add * could extend the table. */ if (add) { - if (zap_f_phys(zap)->zap_ptrtbl.zt_blk == 0) - *towrite += zap->zap_dbuf->db_size; - else - *towrite += (zap->zap_dbuf->db_size * 3); + if (zap_f_phys(zap)->zap_ptrtbl.zt_blk == 0) { + (void) refcount_add_many(towrite, + zap->zap_dbuf->db_size, FTAG); + } else { + (void) refcount_add_many(towrite, + zap->zap_dbuf->db_size * 3, FTAG); + } } /* @@ -1383,13 +1388,14 @@ fzap_count_write(zap_name_t *zn, int add } if (!add && dmu_buf_freeable(l->l_dbuf)) { - *tooverwrite += l->l_dbuf->db_size; + (void) refcount_add_many(tooverwrite, l->l_dbuf->db_size, FTAG); } else { /* * If this an add operation, the leaf block could split. * Hence, we need to account for an additional leaf block. */ - *towrite += (add ? 2 : 1) * l->l_dbuf->db_size; + (void) refcount_add_many(towrite, + (add ? 2 : 1) * l->l_dbuf->db_size, FTAG); } zap_put_leaf(l); Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zap_micro.c ============================================================================== --- stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zap_micro.c Tue Oct 11 16:31:55 2016 (r307048) +++ stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zap_micro.c Tue Oct 11 16:32:49 2016 (r307049) @@ -20,7 +20,7 @@ */ /* * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2011, 2014 by Delphix. All rights reserved. + * Copyright (c) 2011, 2015 by Delphix. All rights reserved. * Copyright (c) 2014 Spectra Logic Corporation, All rights reserved. * Copyright (c) 2014 Integros [integros.com] */ @@ -1414,7 +1414,7 @@ zap_get_stats(objset_t *os, uint64_t zap int zap_count_write(objset_t *os, uint64_t zapobj, const char *name, int add, - uint64_t *towrite, uint64_t *tooverwrite) + refcount_t *towrite, refcount_t *tooverwrite) { zap_t *zap; int err = 0; @@ -1424,14 +1424,15 @@ zap_count_write(objset_t *os, uint64_t z * be affected in this operation. So, account for the worst case : * - 3 blocks overwritten: target leaf, ptrtbl block, header block * - 4 new blocks written if adding: - * - 2 blocks for possibly split leaves, - * - 2 grown ptrtbl blocks + * - 2 blocks for possibly split leaves, + * - 2 grown ptrtbl blocks * * This also accomodates the case where an add operation to a fairly * large microzap results in a promotion to fatzap. */ if (name == NULL) { - *towrite += (3 + (add ? 4 : 0)) * SPA_OLD_MAXBLOCKSIZE; + (void) refcount_add_many(towrite, + (3 + (add ? 4 : 0)) * SPA_OLD_MAXBLOCKSIZE, FTAG); return (err); } @@ -1455,7 +1456,8 @@ zap_count_write(objset_t *os, uint64_t z /* * We treat this case as similar to (name == NULL) */ - *towrite += (3 + (add ? 4 : 0)) * SPA_OLD_MAXBLOCKSIZE; + (void) refcount_add_many(towrite, + (3 + (add ? 4 : 0)) * SPA_OLD_MAXBLOCKSIZE, FTAG); } } else { /* @@ -1473,13 +1475,17 @@ zap_count_write(objset_t *os, uint64_t z * 4 new blocks written : 2 new split leaf, 2 grown * ptrtbl blocks */ - if (dmu_buf_freeable(zap->zap_dbuf)) - *tooverwrite += MZAP_MAX_BLKSZ; - else - *towrite += MZAP_MAX_BLKSZ; + if (dmu_buf_freeable(zap->zap_dbuf)) { + (void) refcount_add_many(tooverwrite, + MZAP_MAX_BLKSZ, FTAG); + } else { + (void) refcount_add_many(towrite, + MZAP_MAX_BLKSZ, FTAG); + } if (add) { - *towrite += 4 * MZAP_MAX_BLKSZ; + (void) refcount_add_many(towrite, + 4 * MZAP_MAX_BLKSZ, FTAG); } } From owner-svn-src-all@freebsd.org Tue Oct 11 16:33:45 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 8E4DAC0C0E6; Tue, 11 Oct 2016 16:33:45 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 5B953964; Tue, 11 Oct 2016 16:33:45 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9BGXiBt017944; Tue, 11 Oct 2016 16:33:44 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9BGXhrB017936; Tue, 11 Oct 2016 16:33:43 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201610111633.u9BGXhrB017936@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Tue, 11 Oct 2016 16:33:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307050 - in stable/11: cddl/contrib/opensolaris/lib/libzfs/common sys/cddl/contrib/opensolaris/common/zfs X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Oct 2016 16:33:45 -0000 Author: mav Date: Tue Oct 11 16:33:43 2016 New Revision: 307050 URL: https://svnweb.freebsd.org/changeset/base/307050 Log: MFC r305207: MFV r302659: 6931 lib/libzfs: cleanup gcc warnings illumos/illumos-gate@88f61dee20b358671b1b643e9d1dbf220a1d69be https://github.com/illumos/illumos-gate/commit/88f61dee20b358671b1b643e9d1dbf220a1d69be https://www.illumos.org/issues/6931 need cleanup: CERRWARN += -_gcc=-Wno-switch CERRWARN += -_gcc=-Wno-parentheses CERRWARN += -_gcc=-Wno-unused-function Reviewed by: Matthew Ahrens Approved by: Robert Mustacchi Author: Igor Kozhukhov Modified: stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_changelist.c stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_diff.c stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_mount.c stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_pool.c stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_util.c stable/11/sys/cddl/contrib/opensolaris/common/zfs/zfs_deleg.c Directory Properties: stable/11/ (props changed) Modified: stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_changelist.c ============================================================================== --- stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_changelist.c Tue Oct 11 16:32:49 2016 (r307049) +++ stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_changelist.c Tue Oct 11 16:33:43 2016 (r307050) @@ -24,9 +24,9 @@ * Use is subject to license terms. * * Portions Copyright 2007 Ramprakash Jelari - * * Copyright (c) 2011 Pawel Jakub Dawidek . * All rights reserved. + * Copyright 2016 Igor Kozhukhov */ #include @@ -136,6 +136,9 @@ changelist_prefix(prop_changelist_t *clp case ZFS_PROP_SHARESMB: (void) zfs_unshare_smb(cn->cn_handle, NULL); break; + + default: + break; } } } Modified: stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c ============================================================================== --- stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c Tue Oct 11 16:32:49 2016 (r307049) +++ stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c Tue Oct 11 16:33:43 2016 (r307050) @@ -29,6 +29,7 @@ * Copyright (c) 2013 Steven Hartland. All rights reserved. * Copyright 2013 Nexenta Systems, Inc. All rights reserved. * Copyright (c) 2014 Integros [integros.com] + * Copyright 2016 Igor Kozhukhov */ #include @@ -78,55 +79,18 @@ zfs_type_to_name(zfs_type_t type) return (dgettext(TEXT_DOMAIN, "snapshot")); case ZFS_TYPE_VOLUME: return (dgettext(TEXT_DOMAIN, "volume")); + case ZFS_TYPE_POOL: + return (dgettext(TEXT_DOMAIN, "pool")); + case ZFS_TYPE_BOOKMARK: + return (dgettext(TEXT_DOMAIN, "bookmark")); + default: + assert(!"unhandled zfs_type_t"); } return (NULL); } /* - * Given a path and mask of ZFS types, return a string describing this dataset. - * This is used when we fail to open a dataset and we cannot get an exact type. - * We guess what the type would have been based on the path and the mask of - * acceptable types. - */ -static const char * -path_to_str(const char *path, int types) -{ - /* - * When given a single type, always report the exact type. - */ - if (types == ZFS_TYPE_SNAPSHOT) - return (dgettext(TEXT_DOMAIN, "snapshot")); - if (types == ZFS_TYPE_FILESYSTEM) - return (dgettext(TEXT_DOMAIN, "filesystem")); - if (types == ZFS_TYPE_VOLUME) - return (dgettext(TEXT_DOMAIN, "volume")); - - /* - * The user is requesting more than one type of dataset. If this is the - * case, consult the path itself. If we're looking for a snapshot, and - * a '@' is found, then report it as "snapshot". Otherwise, remove the - * snapshot attribute and try again. - */ - if (types & ZFS_TYPE_SNAPSHOT) { - if (strchr(path, '@') != NULL) - return (dgettext(TEXT_DOMAIN, "snapshot")); - return (path_to_str(path, types & ~ZFS_TYPE_SNAPSHOT)); - } - - /* - * The user has requested either filesystems or volumes. - * We have no way of knowing a priori what type this would be, so always - * report it as "filesystem" or "volume", our two primitive types. - */ - if (types & ZFS_TYPE_FILESYSTEM) - return (dgettext(TEXT_DOMAIN, "filesystem")); - - assert(types & ZFS_TYPE_VOLUME); - return (dgettext(TEXT_DOMAIN, "volume")); -} - -/* * Validate a ZFS path. This is used even before trying to open the dataset, to * provide a more meaningful error message. We call zfs_error_aux() to * explain exactly why the name was not valid. @@ -187,6 +151,11 @@ zfs_validate_name(libzfs_handle_t *hdl, zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, "reserved disk name")); break; + + default: + zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, + "(%d) not defined"), why); + break; } } @@ -769,7 +738,8 @@ libzfs_mnttab_fini(libzfs_handle_t *hdl) void *cookie = NULL; mnttab_node_t *mtn; - while (mtn = avl_destroy_nodes(&hdl->libzfs_mnttab_cache, &cookie)) { + while ((mtn = avl_destroy_nodes(&hdl->libzfs_mnttab_cache, &cookie)) + != NULL) { free(mtn->mtn_mt.mnt_special); free(mtn->mtn_mt.mnt_mountp); free(mtn->mtn_mt.mnt_fstype); @@ -841,7 +811,8 @@ libzfs_mnttab_remove(libzfs_handle_t *hd mnttab_node_t *ret; find.mtn_mt.mnt_special = (char *)fsname; - if (ret = avl_find(&hdl->libzfs_mnttab_cache, (void *)&find, NULL)) { + if ((ret = avl_find(&hdl->libzfs_mnttab_cache, (void *)&find, NULL)) + != NULL) { avl_remove(&hdl->libzfs_mnttab_cache, ret); free(ret->mtn_mt.mnt_special); free(ret->mtn_mt.mnt_mountp); @@ -1193,6 +1164,13 @@ badlabel: "component of '%s' is too long"), propname); break; + + default: + zfs_error_aux(hdl, + dgettext(TEXT_DOMAIN, + "(%d) not defined"), + why); + break; } (void) zfs_error(hdl, EZFS_BADPROP, errbuf); goto error; @@ -1311,12 +1289,17 @@ badlabel: } break; + case ZFS_PROP_UTF8ONLY: chosen_utf = (int)intval; break; + case ZFS_PROP_NORMALIZE: chosen_normal = (int)intval; break; + + default: + break; } /* @@ -1365,6 +1348,9 @@ badlabel: goto error; } break; + + default: + break; } } } @@ -1974,6 +1960,9 @@ get_numeric_property(zfs_handle_t *zhp, mntopt_on = MNTOPT_NBMAND; mntopt_off = MNTOPT_NONBMAND; break; + + default: + break; } /* @@ -3151,7 +3140,7 @@ create_parents(libzfs_handle_t *hdl, cha * up to the prefixlen-long one. */ for (cp = target + prefixlen + 1; - cp = strchr(cp, '/'); *cp = '/', cp++) { + (cp = strchr(cp, '/')) != NULL; *cp = '/', cp++) { *cp = '\0'; @@ -3914,7 +3903,7 @@ int zfs_rename(zfs_handle_t *zhp, const char *source, const char *target, renameflags_t flags) { - int ret; + int ret = 0; zfs_cmd_t zc = { 0 }; char *delim; prop_changelist_t *cl = NULL; Modified: stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_diff.c ============================================================================== --- stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_diff.c Tue Oct 11 16:32:49 2016 (r307049) +++ stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_diff.c Tue Oct 11 16:33:43 2016 (r307050) @@ -23,6 +23,7 @@ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. * Copyright 2015 Nexenta Systems, Inc. All rights reserved. * Copyright 2016 Joyent, Inc. + * Copyright 2016 Igor Kozhukhov */ /* @@ -353,7 +354,7 @@ write_inuse_diffs(FILE *fp, differ_info_ int err; for (o = dr->ddr_first; o <= dr->ddr_last; o++) { - if (err = write_inuse_diffs_one(fp, di, o)) + if ((err = write_inuse_diffs_one(fp, di, o)) != 0) return (err); } return (0); Modified: stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_mount.c ============================================================================== --- stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_mount.c Tue Oct 11 16:32:49 2016 (r307049) +++ stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_mount.c Tue Oct 11 16:33:43 2016 (r307050) @@ -22,6 +22,7 @@ /* * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2014 by Delphix. All rights reserved. + * Copyright 2016 Igor Kozhukhov */ /* @@ -475,7 +476,8 @@ zfs_is_shared_proto(zfs_handle_t *zhp, c if (!zfs_is_mounted(zhp, &mountpoint)) return (SHARED_NOT_SHARED); - if (rc = is_shared(zhp->zfs_hdl, mountpoint, proto)) { + if ((rc = is_shared(zhp->zfs_hdl, mountpoint, proto)) + != SHARED_NOT_SHARED) { if (where != NULL) *where = mountpoint; else Modified: stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_pool.c ============================================================================== --- stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_pool.c Tue Oct 11 16:32:49 2016 (r307049) +++ stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_pool.c Tue Oct 11 16:33:43 2016 (r307050) @@ -24,6 +24,7 @@ * Copyright (c) 2011, 2015 by Delphix. All rights reserved. * Copyright (c) 2013, Joyent, Inc. All rights reserved. * Copyright 2016 Nexenta Systems, Inc. + * Copyright 2016 Igor Kozhukhov */ #include @@ -199,6 +200,9 @@ zpool_state_to_name(vdev_state_t state, return (gettext("DEGRADED")); case VDEV_STATE_HEALTHY: return (gettext("ONLINE")); + + default: + break; } return (gettext("UNKNOWN")); @@ -635,6 +639,11 @@ zpool_valid_proplist(libzfs_handle_t *hd goto error; } break; + + default: + zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, + "property '%s'(%d) not defined"), propname, prop); + break; } } @@ -943,6 +952,10 @@ zpool_name_valid(libzfs_handle_t *hdl, b "multiple '@' delimiters in name")); break; + default: + zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, + "(%d) not defined"), why); + break; } } return (B_FALSE); Modified: stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c ============================================================================== --- stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c Tue Oct 11 16:32:49 2016 (r307049) +++ stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c Tue Oct 11 16:33:43 2016 (r307050) @@ -27,6 +27,7 @@ * Copyright (c) 2013 Steven Hartland. All rights reserved. * Copyright 2015, OmniTI Computer Consulting, Inc. All rights reserved. * Copyright (c) 2014 Integros [integros.com] + * Copyright 2016 Igor Kozhukhov */ #include @@ -1182,8 +1183,8 @@ dump_snapshot(zfs_handle_t *zhp, void *a pa.pa_fd = sdd->outfd; pa.pa_parsable = sdd->parsable; - if (err = pthread_create(&tid, NULL, - send_progress_thread, &pa)) { + if ((err = pthread_create(&tid, NULL, + send_progress_thread, &pa)) != 0) { zfs_close(zhp); return (err); } @@ -1661,7 +1662,7 @@ zfs_send(zfs_handle_t *zhp, const char * if (flags->dedup && !flags->dryrun) { featureflags |= (DMU_BACKUP_FEATURE_DEDUP | DMU_BACKUP_FEATURE_DEDUPPROPS); - if (err = pipe(pipefd)) { + if ((err = pipe(pipefd)) != 0) { zfs_error_aux(zhp->zfs_hdl, strerror(errno)); return (zfs_error(zhp->zfs_hdl, EZFS_PIPEFAILED, errbuf)); @@ -1669,7 +1670,7 @@ zfs_send(zfs_handle_t *zhp, const char * dda.outputfd = outfd; dda.inputfd = pipefd[1]; dda.dedup_hdl = zhp->zfs_hdl; - if (err = pthread_create(&tid, NULL, cksummer, &dda)) { + if ((err = pthread_create(&tid, NULL, cksummer, &dda)) != 0) { (void) close(pipefd[0]); (void) close(pipefd[1]); zfs_error_aux(zhp->zfs_hdl, strerror(errno)); Modified: stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_util.c ============================================================================== --- stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_util.c Tue Oct 11 16:32:49 2016 (r307049) +++ stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_util.c Tue Oct 11 16:33:43 2016 (r307050) @@ -23,6 +23,7 @@ * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2013, Joyent, Inc. All rights reserved. * Copyright (c) 2011, 2015 by Delphix. All rights reserved. + * Copyright 2016 Igor Kozhukhov */ /* @@ -1062,6 +1063,10 @@ zprop_print_one_property(const char *nam case ZPROP_SRC_RECEIVED: str = "received"; break; + + default: + str = NULL; + assert(!"unhandled zprop_source_t"); } break; Modified: stable/11/sys/cddl/contrib/opensolaris/common/zfs/zfs_deleg.c ============================================================================== --- stable/11/sys/cddl/contrib/opensolaris/common/zfs/zfs_deleg.c Tue Oct 11 16:32:49 2016 (r307049) +++ stable/11/sys/cddl/contrib/opensolaris/common/zfs/zfs_deleg.c Tue Oct 11 16:33:43 2016 (r307050) @@ -22,6 +22,7 @@ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright 2010 Nexenta Systems, Inc. All rights reserved. * Copyright (c) 2013 by Delphix. All rights reserved. + * Copyright 2016 Igor Kozhukhov */ #include @@ -177,8 +178,9 @@ zfs_deleg_verify_nvlist(nvlist_t *nvp) nvpair_name(perm_name)); if (error) return (-1); - } while (perm_name = nvlist_next_nvpair(perms, perm_name)); - } while (who = nvlist_next_nvpair(nvp, who)); + } while ((perm_name = nvlist_next_nvpair(perms, perm_name)) + != NULL); + } while ((who = nvlist_next_nvpair(nvp, who)) != NULL); return (0); } From owner-svn-src-all@freebsd.org Tue Oct 11 16:38:40 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D01B8C0C222; Tue, 11 Oct 2016 16:38:40 +0000 (UTC) (envelope-from gjb@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id A1BCAB9A; Tue, 11 Oct 2016 16:38:40 +0000 (UTC) (envelope-from gjb@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9BGcdus018193; Tue, 11 Oct 2016 16:38:39 GMT (envelope-from gjb@FreeBSD.org) Received: (from gjb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9BGcdP3018192; Tue, 11 Oct 2016 16:38:39 GMT (envelope-from gjb@FreeBSD.org) Message-Id: <201610111638.u9BGcdP3018192@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: gjb set sender to gjb@FreeBSD.org using -f From: Glen Barber Date: Tue, 11 Oct 2016 16:38:39 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307051 - stable/11/sys/conf X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Oct 2016 16:38:40 -0000 Author: gjb Date: Tue Oct 11 16:38:39 2016 New Revision: 307051 URL: https://svnweb.freebsd.org/changeset/base/307051 Log: Switch stable/11 to -STABLE following the release. Reminded by: Piotr Smyrak Sponsored by: The FreeBSD Foundation Modified: stable/11/sys/conf/newvers.sh Modified: stable/11/sys/conf/newvers.sh ============================================================================== --- stable/11/sys/conf/newvers.sh Tue Oct 11 16:33:43 2016 (r307050) +++ stable/11/sys/conf/newvers.sh Tue Oct 11 16:38:39 2016 (r307051) @@ -32,7 +32,7 @@ TYPE="FreeBSD" REVISION="11.0" -BRANCH="PRERELEASE" +BRANCH="STABLE" if [ -n "${BRANCH_OVERRIDE}" ]; then BRANCH=${BRANCH_OVERRIDE} fi From owner-svn-src-all@freebsd.org Tue Oct 11 16:46:17 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E314CC0C5F0; Tue, 11 Oct 2016 16:46:17 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 97DF5309; Tue, 11 Oct 2016 16:46:17 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9BGkGbc022272; Tue, 11 Oct 2016 16:46:16 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9BGkG4Y022271; Tue, 11 Oct 2016 16:46:16 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201610111646.u9BGkG4Y022271@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Tue, 11 Oct 2016 16:46:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307052 - stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Oct 2016 16:46:18 -0000 Author: mav Date: Tue Oct 11 16:46:16 2016 New Revision: 307052 URL: https://svnweb.freebsd.org/changeset/base/307052 Log: MFC r305193: MFV r302642: 6876 Stack corruption after importing a pool with a too-long name illumos/illumos-gate@c971037baa5d64dfecf6d87ed602fc3116ebec41 https://github.com/illumos/illumos-gate/commit/c971037baa5d64dfecf6d87ed602fc3116ebec41 https://www.illumos.org/issues/6876 Calling dsl_dataset_name on a dataset with a 256 byte buffer is asking for trouble. We should check every dataset on import, using a 1024 byte buffer and checking each time to see if the dataset's new name is longer than 256 bytes. Reviewed by: Prakash Surya Reviewed by: Dan Kimmel Reviewed by: George Wilson Reviewed by: Yuri Pankov Approved by: Richard Lowe Author: Paul Dagnelie Modified: stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c ============================================================================== --- stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c Tue Oct 11 16:38:39 2016 (r307051) +++ stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c Tue Oct 11 16:46:16 2016 (r307052) @@ -1975,6 +1975,19 @@ spa_load_verify_cb(spa_t *spa, zilog_t * return (0); } +/* ARGSUSED */ +int +verify_dataset_name_len(dsl_pool_t *dp, dsl_dataset_t *ds, void *arg) +{ + char namebuf[MAXPATHLEN]; + dsl_dataset_name(ds, namebuf); + if (strlen(namebuf) > MAXNAMELEN) { + return (SET_ERROR(ENAMETOOLONG)); + } + + return (0); +} + static int spa_load_verify(spa_t *spa) { @@ -1989,6 +2002,14 @@ spa_load_verify(spa_t *spa) if (policy.zrp_request & ZPOOL_NEVER_REWIND) return (0); + dsl_pool_config_enter(spa->spa_dsl_pool, FTAG); + error = dmu_objset_find_dp(spa->spa_dsl_pool, + spa->spa_dsl_pool->dp_root_dir_obj, verify_dataset_name_len, NULL, + DS_FIND_CHILDREN); + dsl_pool_config_exit(spa->spa_dsl_pool, FTAG); + if (error != 0) + return (error); + rio = zio_root(spa, NULL, &sle, ZIO_FLAG_CANFAIL | ZIO_FLAG_SPECULATIVE); From owner-svn-src-all@freebsd.org Tue Oct 11 16:47:23 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 4B8EAC0C69E; Tue, 11 Oct 2016 16:47:23 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 24F5A6A2; Tue, 11 Oct 2016 16:47:23 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9BGlMsi022374; Tue, 11 Oct 2016 16:47:22 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9BGlLjE022364; Tue, 11 Oct 2016 16:47:21 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201610111647.u9BGlLjE022364@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Tue, 11 Oct 2016 16:47:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307053 - in stable/10: cddl/contrib/opensolaris/cmd/zfs cddl/contrib/opensolaris/lib/libzfs/common sys/cddl/contrib/opensolaris/uts/common/fs/zfs sys/cddl/contrib/opensolaris/uts/commo... X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Oct 2016 16:47:23 -0000 Author: mav Date: Tue Oct 11 16:47:21 2016 New Revision: 307053 URL: https://svnweb.freebsd.org/changeset/base/307053 Log: MFC r305195: MFV r302643: 6902 speed up listing of snapshots if requesting name only and sorting by name This was our change from the beginning, so just reduce the upstream diff. Modified: stable/10/cddl/contrib/opensolaris/cmd/zfs/zfs_iter.c stable/10/cddl/contrib/opensolaris/cmd/zfs/zfs_iter.h stable/10/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs.h stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_impl.h stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_iter.c stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zfs_ioctl.h stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c Directory Properties: stable/10/ (props changed) Modified: stable/10/cddl/contrib/opensolaris/cmd/zfs/zfs_iter.c ============================================================================== --- stable/10/cddl/contrib/opensolaris/cmd/zfs/zfs_iter.c Tue Oct 11 16:46:16 2016 (r307052) +++ stable/10/cddl/contrib/opensolaris/cmd/zfs/zfs_iter.c Tue Oct 11 16:47:21 2016 (r307053) @@ -21,8 +21,7 @@ /* * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2012 Pawel Jakub Dawidek . - * All rights reserved. + * Copyright (c) 2012 Pawel Jakub Dawidek. All rights reserved. * Copyright 2013 Nexenta Systems, Inc. All rights reserved. * Copyright (c) 2013 by Delphix. All rights reserved. */ @@ -320,8 +319,8 @@ zfs_sort(const void *larg, const void *r } else if (psc->sc_prop == ZFS_PROP_NAME) { lvalid = rvalid = B_TRUE; - (void) strlcpy(lbuf, zfs_get_name(l), sizeof(lbuf)); - (void) strlcpy(rbuf, zfs_get_name(r), sizeof(rbuf)); + (void) strlcpy(lbuf, zfs_get_name(l), sizeof (lbuf)); + (void) strlcpy(rbuf, zfs_get_name(r), sizeof (rbuf)); lstr = lbuf; rstr = rbuf; Modified: stable/10/cddl/contrib/opensolaris/cmd/zfs/zfs_iter.h ============================================================================== --- stable/10/cddl/contrib/opensolaris/cmd/zfs/zfs_iter.h Tue Oct 11 16:46:16 2016 (r307052) +++ stable/10/cddl/contrib/opensolaris/cmd/zfs/zfs_iter.h Tue Oct 11 16:47:21 2016 (r307053) @@ -22,6 +22,7 @@ /* * Copyright 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. + * Copyright (c) 2011-2012 Pawel Jakub Dawidek. All rights reserved. * Copyright 2013 Nexenta Systems, Inc. All rights reserved. */ Modified: stable/10/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c ============================================================================== --- stable/10/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c Tue Oct 11 16:46:16 2016 (r307052) +++ stable/10/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c Tue Oct 11 16:47:21 2016 (r307053) @@ -24,8 +24,7 @@ * Copyright (c) 2011, 2015 by Delphix. All rights reserved. * Copyright 2012 Milan Jurik. All rights reserved. * Copyright (c) 2012, Joyent, Inc. All rights reserved. - * Copyright (c) 2011-2012 Pawel Jakub Dawidek . - * All rights reserved. + * Copyright (c) 2011-2012 Pawel Jakub Dawidek. All rights reserved. * Copyright (c) 2012 Martin Matuska . All rights reserved. * Copyright (c) 2013 Steven Hartland. All rights reserved. * Copyright 2013 Nexenta Systems, Inc. All rights reserved. @@ -3008,7 +3007,7 @@ print_dataset(zfs_handle_t *zhp, list_cb if (pl->pl_prop == ZFS_PROP_NAME) { (void) strlcpy(property, zfs_get_name(zhp), - sizeof(property)); + sizeof (property)); propstr = property; right_justify = zfs_prop_align_right(pl->pl_prop); } else if (pl->pl_prop != ZPROP_INVAL) { Modified: stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs.h ============================================================================== --- stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs.h Tue Oct 11 16:46:16 2016 (r307052) +++ stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs.h Tue Oct 11 16:47:21 2016 (r307053) @@ -21,8 +21,7 @@ /* * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2011 Pawel Jakub Dawidek . - * All rights reserved. + * Copyright (c) 2011 Pawel Jakub Dawidek. All rights reserved. * Copyright (c) 2011, 2015 by Delphix. All rights reserved. * Copyright (c) 2012, Joyent, Inc. All rights reserved. * Copyright (c) 2012 Martin Matuska . All rights reserved. Modified: stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c ============================================================================== --- stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c Tue Oct 11 16:46:16 2016 (r307052) +++ stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c Tue Oct 11 16:47:21 2016 (r307053) @@ -24,9 +24,8 @@ * Copyright (c) 2013, Joyent, Inc. All rights reserved. * Copyright (c) 2011, 2015 by Delphix. All rights reserved. * Copyright (c) 2012 DEY Storage Systems, Inc. All rights reserved. - * Copyright (c) 2011-2012 Pawel Jakub Dawidek . - * All rights reserved. - * Copyright (c) 2012 Martin Matuska . All rights reserved. + * Copyright (c) 2011-2012 Pawel Jakub Dawidek. All rights reserved. + * Copyright (c) 2013 Martin Matuska. All rights reserved. * Copyright (c) 2013 Steven Hartland. All rights reserved. * Copyright 2013 Nexenta Systems, Inc. All rights reserved. * Copyright (c) 2014 Integros [integros.com] Modified: stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_impl.h ============================================================================== --- stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_impl.h Tue Oct 11 16:46:16 2016 (r307052) +++ stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_impl.h Tue Oct 11 16:47:21 2016 (r307053) @@ -21,8 +21,7 @@ /* * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2011 Pawel Jakub Dawidek . - * All rights reserved. + * Copyright (c) 2011 Pawel Jakub Dawidek. All rights reserved. * Copyright (c) 2013 by Delphix. All rights reserved. * Copyright (c) 2013 Martin Matuska . All rights reserved. */ Modified: stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_iter.c ============================================================================== --- stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_iter.c Tue Oct 11 16:46:16 2016 (r307052) +++ stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_iter.c Tue Oct 11 16:47:21 2016 (r307053) @@ -22,8 +22,7 @@ /* * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2013, 2015 by Delphix. All rights reserved. - * Copyright (c) 2012 Pawel Jakub Dawidek . - * All rights reserved. + * Copyright (c) 2012 Pawel Jakub Dawidek. All rights reserved. * Copyright 2014 Nexenta Systems, Inc. All rights reserved. */ Modified: stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c ============================================================================== --- stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c Tue Oct 11 16:46:16 2016 (r307052) +++ stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c Tue Oct 11 16:47:21 2016 (r307053) @@ -23,8 +23,7 @@ * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2011, 2015 by Delphix. All rights reserved. * Copyright (c) 2012, Joyent, Inc. All rights reserved. - * Copyright (c) 2012 Pawel Jakub Dawidek . - * All rights reserved. + * Copyright (c) 2012 Pawel Jakub Dawidek. All rights reserved. * Copyright (c) 2013 Steven Hartland. All rights reserved. * Copyright 2015, OmniTI Computer Consulting, Inc. All rights reserved. * Copyright (c) 2014 Integros [integros.com] Modified: stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zfs_ioctl.h ============================================================================== --- stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zfs_ioctl.h Tue Oct 11 16:46:16 2016 (r307052) +++ stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zfs_ioctl.h Tue Oct 11 16:47:21 2016 (r307053) @@ -20,6 +20,7 @@ */ /* * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011-2012 Pawel Jakub Dawidek. All rights reserved. * Copyright (c) 2012, 2015 by Delphix. All rights reserved. * Copyright 2016 RackTop Systems. * Copyright (c) 2014 Integros [integros.com] Modified: stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c ============================================================================== --- stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c Tue Oct 11 16:46:16 2016 (r307052) +++ stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c Tue Oct 11 16:47:21 2016 (r307053) @@ -21,8 +21,7 @@ /* * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2011-2012 Pawel Jakub Dawidek . - * All rights reserved. + * Copyright (c) 2011-2012 Pawel Jakub Dawidek. All rights reserved. * Copyright 2013 Martin Matuska . All rights reserved. * Copyright 2014 Xin Li . All rights reserved. * Copyright 2015, OmniTI Computer Consulting, Inc. All rights reserved. From owner-svn-src-all@freebsd.org Tue Oct 11 16:48:14 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 224BCC0C7B0; Tue, 11 Oct 2016 16:48:14 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id EDE31878; Tue, 11 Oct 2016 16:48:13 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9BGmDJf022461; Tue, 11 Oct 2016 16:48:13 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9BGmCbS022457; Tue, 11 Oct 2016 16:48:12 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201610111648.u9BGmCbS022457@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Tue, 11 Oct 2016 16:48:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307054 - in stable/10/sys/cddl/contrib/opensolaris: common/zfs uts/common/fs/zfs uts/common/fs/zfs/sys X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Oct 2016 16:48:14 -0000 Author: mav Date: Tue Oct 11 16:48:12 2016 New Revision: 307054 URL: https://svnweb.freebsd.org/changeset/base/307054 Log: MFC r305197: MFV r302646: 6980 6902 causes zfs send to break due to 32-bit/64-bit struct mismatch illumos/illumos-gate@ea4a67f462de0a39a9adea8197bcdef849de5371 https://github.com/illumos/illumos-gate/commit/ea4a67f462de0a39a9adea8197bcdef84 9de5371 https://www.illumos.org/issues/6980 doing zfs send -i snap1 snap2 >testfile results in internal error: Invalid argument Abort (core dumped) Reviewed by: Paul Dagnelie Reviewed by: George Wilson Approved by: Robert Mustacchi Author: Matthew Ahrens Modified: stable/10/sys/cddl/contrib/opensolaris/common/zfs/zfs_ioctl_compat.c stable/10/sys/cddl/contrib/opensolaris/common/zfs/zfs_ioctl_compat.h stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zfs_ioctl.h stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/cddl/contrib/opensolaris/common/zfs/zfs_ioctl_compat.c ============================================================================== --- stable/10/sys/cddl/contrib/opensolaris/common/zfs/zfs_ioctl_compat.c Tue Oct 11 16:47:21 2016 (r307053) +++ stable/10/sys/cddl/contrib/opensolaris/common/zfs/zfs_ioctl_compat.c Tue Oct 11 16:48:12 2016 (r307054) @@ -55,8 +55,52 @@ zfs_cmd_compat_get(zfs_cmd_t *zc, caddr_ zfs_cmd_zcmd_t *zcmd_c; zfs_cmd_edbp_t *edbp_c; zfs_cmd_resume_t *resume_c; + zfs_cmd_inlanes_t *inlanes_c; switch (cflag) { + case ZFS_CMD_COMPAT_INLANES: + inlanes_c = (void *)addr; + /* zc */ + strlcpy(zc->zc_name, inlanes_c->zc_name, MAXPATHLEN); + strlcpy(zc->zc_value, inlanes_c->zc_value, MAXPATHLEN * 2); + strlcpy(zc->zc_string, inlanes_c->zc_string, MAXPATHLEN); + +#define FIELD_COPY(field) zc->field = inlanes_c->field + FIELD_COPY(zc_nvlist_src); + FIELD_COPY(zc_nvlist_src_size); + FIELD_COPY(zc_nvlist_dst); + FIELD_COPY(zc_nvlist_dst_size); + FIELD_COPY(zc_nvlist_dst_filled); + FIELD_COPY(zc_pad2); + FIELD_COPY(zc_history); + FIELD_COPY(zc_guid); + FIELD_COPY(zc_nvlist_conf); + FIELD_COPY(zc_nvlist_conf_size); + FIELD_COPY(zc_cookie); + FIELD_COPY(zc_objset_type); + FIELD_COPY(zc_perm_action); + FIELD_COPY(zc_history_len); + FIELD_COPY(zc_history_offset); + FIELD_COPY(zc_obj); + FIELD_COPY(zc_iflags); + FIELD_COPY(zc_share); + FIELD_COPY(zc_jailid); + FIELD_COPY(zc_objset_stats); + FIELD_COPY(zc_begin_record); + FIELD_COPY(zc_inject_record); + FIELD_COPY(zc_defer_destroy); + FIELD_COPY(zc_flags); + FIELD_COPY(zc_action_handle); + FIELD_COPY(zc_cleanup_fd); + FIELD_COPY(zc_simple); + FIELD_COPY(zc_resumable); + FIELD_COPY(zc_sendobj); + FIELD_COPY(zc_fromobj); + FIELD_COPY(zc_createtxg); + FIELD_COPY(zc_stat); +#undef FIELD_COPY + break; + case ZFS_CMD_COMPAT_RESUME: resume_c = (void *)addr; /* zc */ @@ -434,8 +478,50 @@ zfs_cmd_compat_put(zfs_cmd_t *zc, caddr_ zfs_cmd_zcmd_t *zcmd_c; zfs_cmd_edbp_t *edbp_c; zfs_cmd_resume_t *resume_c; + zfs_cmd_inlanes_t *inlanes_c; switch (cflag) { + case ZFS_CMD_COMPAT_INLANES: + inlanes_c = (void *)addr; + strlcpy(inlanes_c->zc_name, zc->zc_name, MAXPATHLEN); + strlcpy(inlanes_c->zc_value, zc->zc_value, MAXPATHLEN * 2); + strlcpy(inlanes_c->zc_string, zc->zc_string, MAXPATHLEN); + +#define FIELD_COPY(field) inlanes_c->field = zc->field + FIELD_COPY(zc_nvlist_src); + FIELD_COPY(zc_nvlist_src_size); + FIELD_COPY(zc_nvlist_dst); + FIELD_COPY(zc_nvlist_dst_size); + FIELD_COPY(zc_nvlist_dst_filled); + FIELD_COPY(zc_pad2); + FIELD_COPY(zc_history); + FIELD_COPY(zc_guid); + FIELD_COPY(zc_nvlist_conf); + FIELD_COPY(zc_nvlist_conf_size); + FIELD_COPY(zc_cookie); + FIELD_COPY(zc_objset_type); + FIELD_COPY(zc_perm_action); + FIELD_COPY(zc_history_len); + FIELD_COPY(zc_history_offset); + FIELD_COPY(zc_obj); + FIELD_COPY(zc_iflags); + FIELD_COPY(zc_share); + FIELD_COPY(zc_jailid); + FIELD_COPY(zc_objset_stats); + FIELD_COPY(zc_begin_record); + FIELD_COPY(zc_inject_record); + FIELD_COPY(zc_defer_destroy); + FIELD_COPY(zc_flags); + FIELD_COPY(zc_action_handle); + FIELD_COPY(zc_cleanup_fd); + FIELD_COPY(zc_simple); + FIELD_COPY(zc_sendobj); + FIELD_COPY(zc_fromobj); + FIELD_COPY(zc_createtxg); + FIELD_COPY(zc_stat); +#undef FIELD_COPY + break; + case ZFS_CMD_COMPAT_RESUME: resume_c = (void *)addr; strlcpy(resume_c->zc_name, zc->zc_name, MAXPATHLEN); @@ -987,6 +1073,12 @@ zcmd_ioctl_compat(int fd, int request, z zp.zfs_cmd_size = sizeof(zfs_cmd_t); zp.zfs_ioctl_version = ZFS_IOCVER_CURRENT; return (ioctl(fd, ncmd, &zp)); + case ZFS_CMD_COMPAT_INLANES: + ncmd = _IOWR('Z', request, struct zfs_iocparm); + zp.zfs_cmd = (uint64_t)zc; + zp.zfs_cmd_size = sizeof(zfs_cmd_inlanes_t); + zp.zfs_ioctl_version = ZFS_IOCVER_INLANES; + return (ioctl(fd, ncmd, &zp)); case ZFS_CMD_COMPAT_RESUME: ncmd = _IOWR('Z', request, struct zfs_iocparm); zp.zfs_cmd = (uint64_t)zc; @@ -1104,7 +1196,7 @@ zfs_ioctl_compat_innvl(zfs_cmd_t *zc, nv if (cflag == ZFS_CMD_COMPAT_NONE || cflag == ZFS_CMD_COMPAT_LZC || cflag == ZFS_CMD_COMPAT_ZCMD || cflag == ZFS_CMD_COMPAT_EDBP || - cflag == ZFS_CMD_COMPAT_RESUME) + cflag == ZFS_CMD_COMPAT_RESUME || cflag == ZFS_CMD_COMPAT_INLANES) goto out; switch (vec) { @@ -1257,7 +1349,7 @@ zfs_ioctl_compat_outnvl(zfs_cmd_t *zc, n if (cflag == ZFS_CMD_COMPAT_NONE || cflag == ZFS_CMD_COMPAT_LZC || cflag == ZFS_CMD_COMPAT_ZCMD || cflag == ZFS_CMD_COMPAT_EDBP || - cflag == ZFS_CMD_COMPAT_RESUME) + cflag == ZFS_CMD_COMPAT_RESUME || cflag == ZFS_CMD_COMPAT_INLANES) return (outnvl); switch (vec) { Modified: stable/10/sys/cddl/contrib/opensolaris/common/zfs/zfs_ioctl_compat.h ============================================================================== --- stable/10/sys/cddl/contrib/opensolaris/common/zfs/zfs_ioctl_compat.h Tue Oct 11 16:47:21 2016 (r307053) +++ stable/10/sys/cddl/contrib/opensolaris/common/zfs/zfs_ioctl_compat.h Tue Oct 11 16:48:12 2016 (r307054) @@ -54,7 +54,8 @@ extern "C" { #define ZFS_IOCVER_EDBP 4 #define ZFS_IOCVER_RESUME 5 #define ZFS_IOCVER_INLANES 6 -#define ZFS_IOCVER_CURRENT ZFS_IOCVER_INLANES +#define ZFS_IOCVER_PAD 7 +#define ZFS_IOCVER_CURRENT ZFS_IOCVER_PAD /* compatibility conversion flag */ #define ZFS_CMD_COMPAT_NONE 0 @@ -65,6 +66,7 @@ extern "C" { #define ZFS_CMD_COMPAT_ZCMD 5 #define ZFS_CMD_COMPAT_EDBP 6 #define ZFS_CMD_COMPAT_RESUME 7 +#define ZFS_CMD_COMPAT_INLANES 8 #define ZFS_IOC_COMPAT_PASS 254 #define ZFS_IOC_COMPAT_FAIL 255 @@ -355,6 +357,49 @@ typedef struct zfs_cmd_resume { zfs_stat_t zc_stat; } zfs_cmd_resume_t; +typedef struct zfs_cmd_inlanes { + char zc_name[MAXPATHLEN]; /* name of pool or dataset */ + uint64_t zc_nvlist_src; /* really (char *) */ + uint64_t zc_nvlist_src_size; + uint64_t zc_nvlist_dst; /* really (char *) */ + uint64_t zc_nvlist_dst_size; + boolean_t zc_nvlist_dst_filled; /* put an nvlist in dst? */ + int zc_pad2; + + /* + * The following members are for legacy ioctls which haven't been + * converted to the new method. + */ + uint64_t zc_history; /* really (char *) */ + char zc_value[MAXPATHLEN * 2]; + char zc_string[MAXNAMELEN]; + uint64_t zc_guid; + uint64_t zc_nvlist_conf; /* really (char *) */ + uint64_t zc_nvlist_conf_size; + uint64_t zc_cookie; + uint64_t zc_objset_type; + uint64_t zc_perm_action; + uint64_t zc_history_len; + uint64_t zc_history_offset; + uint64_t zc_obj; + uint64_t zc_iflags; /* internal to zfs(7fs) */ + zfs_share_t zc_share; + uint64_t zc_jailid; + dmu_objset_stats_t zc_objset_stats; + dmu_replay_record_t zc_begin_record; + zinject_record_t zc_inject_record; + uint32_t zc_defer_destroy; + uint32_t zc_flags; + uint64_t zc_action_handle; + int zc_cleanup_fd; + uint8_t zc_simple; + boolean_t zc_resumable; + uint64_t zc_sendobj; + uint64_t zc_fromobj; + uint64_t zc_createtxg; + zfs_stat_t zc_stat; +} zfs_cmd_inlanes_t; + #ifdef _KERNEL unsigned static long zfs_ioctl_v15_to_v28[] = { 0, /* 0 ZFS_IOC_POOL_CREATE */ Modified: stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zfs_ioctl.h ============================================================================== --- stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zfs_ioctl.h Tue Oct 11 16:47:21 2016 (r307053) +++ stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zfs_ioctl.h Tue Oct 11 16:48:12 2016 (r307054) @@ -353,6 +353,12 @@ typedef enum zfs_case { ZFS_CASE_MIXED } zfs_case_t; +/* + * Note: this struct must have the same layout in 32-bit and 64-bit, so + * that 32-bit processes (like /sbin/zfs) can pass it to the 64-bit + * kernel. Therefore, we add padding to it so that no "hidden" padding + * is automatically added on 64-bit (but not on 32-bit). + */ typedef struct zfs_cmd { char zc_name[MAXPATHLEN]; /* name of pool or dataset */ uint64_t zc_nvlist_src; /* really (char *) */ @@ -389,7 +395,9 @@ typedef struct zfs_cmd { uint64_t zc_action_handle; int zc_cleanup_fd; uint8_t zc_simple; + uint8_t zc_pad3[3]; boolean_t zc_resumable; + uint32_t zc_pad4; uint64_t zc_sendobj; uint64_t zc_fromobj; uint64_t zc_createtxg; Modified: stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c ============================================================================== --- stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c Tue Oct 11 16:47:21 2016 (r307053) +++ stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c Tue Oct 11 16:48:12 2016 (r307054) @@ -6251,6 +6251,14 @@ zfsdev_ioctl(struct cdev *dev, u_long zc goto out; } break; + case ZFS_IOCVER_INLANES: + if (zc_iocparm->zfs_cmd_size != sizeof(zfs_cmd_inlanes_t)) { + error = SET_ERROR(EFAULT); + goto out; + } + compat = B_TRUE; + cflag = ZFS_CMD_COMPAT_INLANES; + break; case ZFS_IOCVER_RESUME: if (zc_iocparm->zfs_cmd_size != sizeof(zfs_cmd_resume_t)) { error = SET_ERROR(EFAULT); From owner-svn-src-all@freebsd.org Tue Oct 11 16:49:17 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C197CC0C840; Tue, 11 Oct 2016 16:49:17 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 9C0259EC; Tue, 11 Oct 2016 16:49:17 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9BGnG8r022549; Tue, 11 Oct 2016 16:49:16 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9BGnGTv022547; Tue, 11 Oct 2016 16:49:16 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201610111649.u9BGnGTv022547@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Tue, 11 Oct 2016 16:49:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307055 - in stable/10/sys/cddl/contrib/opensolaris/uts/common: fs/zfs sys/sysevent X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Oct 2016 16:49:17 -0000 Author: mav Date: Tue Oct 11 16:49:16 2016 New Revision: 307055 URL: https://svnweb.freebsd.org/changeset/base/307055 Log: MFC r305198: MFV r302647: 6922 Emit ESC_ZFS_VDEV_REMOVE_AUX after removing an aux device illumos/illumos-gate@63364b0ee2604783e7a55f8425888867768eafa4 https://github.com/illumos/illumos-gate/commit/63364b0ee2604783e7a55f84258888677 68eafa4 https://www.illumos.org/issues/6922 ZFS does not do a config_sync after removing an aux (spare, log, or cache) device. AFAICT this isn't being done because it is slow and was deemed unnecessary. However, it should be such a rare operation that speed doesn't matter, and not doing it results in two problems: 1) It is theoretically possible to remove an aux device from one pool and attach it to another, then lose power. When power is restored, both pools woul d think that they own the aux device. 2) Removal of the aux device doesn't send any useful sysevents to userland. Reviewed by: George Wilson Reviewed by: Matthew Ahrens Approved by: Dan McDonald Author: Alan Somers Modified: stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c stable/10/sys/cddl/contrib/opensolaris/uts/common/sys/sysevent/eventdefs.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c ============================================================================== --- stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c Tue Oct 11 16:48:12 2016 (r307054) +++ stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c Tue Oct 11 16:49:16 2016 (r307055) @@ -5680,6 +5680,7 @@ spa_vdev_remove(spa_t *spa, uint64_t gui } else { error = SET_ERROR(EBUSY); } + spa_event_notify(spa, vd, ESC_ZFS_VDEV_REMOVE_AUX); } else if (spa->spa_l2cache.sav_vdevs != NULL && nvlist_lookup_nvlist_array(spa->spa_l2cache.sav_config, ZPOOL_CONFIG_L2CACHE, &l2cache, &nl2cache) == 0 && @@ -5691,6 +5692,7 @@ spa_vdev_remove(spa_t *spa, uint64_t gui ZPOOL_CONFIG_L2CACHE, l2cache, nl2cache, nv); spa_load_l2cache(spa); spa->spa_l2cache.sav_sync = B_TRUE; + spa_event_notify(spa, vd, ESC_ZFS_VDEV_REMOVE_AUX); } else if (vd != NULL && vd->vdev_islog) { ASSERT(!locked); ASSERT(vd == vd->vdev_top); @@ -5729,6 +5731,7 @@ spa_vdev_remove(spa_t *spa, uint64_t gui */ spa_vdev_remove_from_namespace(spa, vd); + spa_event_notify(spa, vd, ESC_ZFS_VDEV_REMOVE_DEV); } else if (vd != NULL) { /* * Normal vdevs cannot be removed (yet). @@ -5742,7 +5745,7 @@ spa_vdev_remove(spa_t *spa, uint64_t gui } if (!locked) - return (spa_vdev_exit(spa, NULL, txg, error)); + error = spa_vdev_exit(spa, NULL, txg, error); return (error); } Modified: stable/10/sys/cddl/contrib/opensolaris/uts/common/sys/sysevent/eventdefs.h ============================================================================== --- stable/10/sys/cddl/contrib/opensolaris/uts/common/sys/sysevent/eventdefs.h Tue Oct 11 16:48:12 2016 (r307054) +++ stable/10/sys/cddl/contrib/opensolaris/uts/common/sys/sysevent/eventdefs.h Tue Oct 11 16:49:16 2016 (r307055) @@ -249,6 +249,8 @@ extern "C" { #define ESC_ZFS_RESILVER_START "ESC_ZFS_resilver_start" #define ESC_ZFS_RESILVER_FINISH "ESC_ZFS_resilver_finish" #define ESC_ZFS_VDEV_REMOVE "ESC_ZFS_vdev_remove" +#define ESC_ZFS_VDEV_REMOVE_AUX "ESC_ZFS_vdev_remove_aux" +#define ESC_ZFS_VDEV_REMOVE_DEV "ESC_ZFS_vdev_remove_dev" #define ESC_ZFS_POOL_CREATE "ESC_ZFS_pool_create" #define ESC_ZFS_POOL_DESTROY "ESC_ZFS_pool_destroy" #define ESC_ZFS_POOL_IMPORT "ESC_ZFS_pool_import" From owner-svn-src-all@freebsd.org Tue Oct 11 16:50:47 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 0689CC0C94E; Tue, 11 Oct 2016 16:50:47 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id D7B70C58; Tue, 11 Oct 2016 16:50:46 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9BGok6A022679; Tue, 11 Oct 2016 16:50:46 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9BGokIb022678; Tue, 11 Oct 2016 16:50:46 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201610111650.u9BGokIb022678@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Tue, 11 Oct 2016 16:50:46 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307056 - stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Oct 2016 16:50:47 -0000 Author: mav Date: Tue Oct 11 16:50:45 2016 New Revision: 307056 URL: https://svnweb.freebsd.org/changeset/base/307056 Log: MFC r305199: MFV r302648: 7019 zfsdev_ioctl skips secpolicy when FKIOCTL is set Note that the bulk of the upstream change is not applicable to FreeBSD and the affected files are not even in the vendor area. illumos/illumos-gate@45b1747515a17db45e8971501ee84a26bdff37b2 https://github.com/illumos/illumos-gate/commit/45b1747515a17db45e8971501ee84a26bdff37b2 https://www.illumos.org/issues/7019 Currently zfsdev_ioctl, when confronted by a request with the FKIOCTL flag set, skips all processing of secpolicy functions. This means that ZFS is not doing any kind of verification of the credentials or access rights of the caller and assuming that (as it is an in-kernel client) all such checks have already been done. This turns out to be quite a dangerous assumption, especially with respect to sdev. In general I don't think it's particularly reasonable to offload this enforcement of access rights onto other kernel subsystems when ZFS has some particular local semantics in this area (delegated datasets etc) and does not provide any kind of API to allow other subsystems to avoid code duplication when doing it. ZFS should apply its normal access policy to requests from within the kernel, and callers should take care to give it the correct credentials and call it from the correct context in order to get the results they need. You can observe the currently unfortunate consequences of this bug in any non- global zone that has access to /dev/zvol or any subset of it via sdev profiles. In particular, a zone used to contain a KVM or similar which has a single zvol passed through to it using a Reviewed by: Richard Lowe Reviewed by: Matthew Ahrens Approved by: Dan McDonald Author: Alex Wilson Modified: stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c ============================================================================== --- stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c Tue Oct 11 16:49:16 2016 (r307055) +++ stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c Tue Oct 11 16:50:45 2016 (r307056) @@ -26,7 +26,7 @@ * Copyright 2014 Xin Li . All rights reserved. * Copyright 2015, OmniTI Computer Consulting, Inc. All rights reserved. * Copyright 2015 Nexenta Systems, Inc. All rights reserved. - * Copyright (c) 2014, Joyent, Inc. All rights reserved. + * Copyright (c) 2014, 2016 Joyent, Inc. All rights reserved. * Copyright (c) 2011, 2015 by Delphix. All rights reserved. * Copyright (c) 2013 by Saso Kiselkov. All rights reserved. * Copyright (c) 2013 Steven Hartland. All rights reserved. @@ -6366,7 +6366,7 @@ zfsdev_ioctl(struct cdev *dev, u_long zc break; } - if (error == 0 && !(flag & FKIOCTL)) + if (error == 0) error = vec->zvec_secpolicy(zc, innvl, cr); if (error != 0) From owner-svn-src-all@freebsd.org Tue Oct 11 16:52:59 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 67CA1C0CC0B; Tue, 11 Oct 2016 16:52:59 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 35E8EE; Tue, 11 Oct 2016 16:52:59 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9BGqwM5026183; Tue, 11 Oct 2016 16:52:58 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9BGqvRd026177; Tue, 11 Oct 2016 16:52:57 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201610111652.u9BGqvRd026177@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Tue, 11 Oct 2016 16:52:57 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307057 - in stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs: . sys X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Oct 2016 16:52:59 -0000 Author: mav Date: Tue Oct 11 16:52:57 2016 New Revision: 307057 URL: https://svnweb.freebsd.org/changeset/base/307057 Log: MFC r305200: MFV r302651: 7054 dmu_tx_hold_t should use refcount_t to track space illumos/illumos-gate@0c779ad424a92a84d1e07d47cab7f8009189202b https://github.com/illumos/illumos-gate/commit/0c779ad424a92a84d1e07d47cab7f8009 189202b https://www.illumos.org/issues/7054 upstream: ee0003de7d3e598499be7ac3fe6b61efcc47cb7f DLPX-40399 dmu_tx_hold_t should use refcount_t to track space Reviewed by: George Wilson Reviewed by: Paul Dagnelie Reviewed by: Igor Kozhukhov Approved by: Dan McDonald Author: Matthew Ahrens Modified: stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_tx.c stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dmu_tx.h stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zap.h stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zap_impl.h stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zap.c stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zap_micro.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_tx.c ============================================================================== --- stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_tx.c Tue Oct 11 16:50:45 2016 (r307056) +++ stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_tx.c Tue Oct 11 16:52:57 2016 (r307057) @@ -129,6 +129,12 @@ dmu_tx_hold_object_impl(dmu_tx_t *tx, ob txh = kmem_zalloc(sizeof (dmu_tx_hold_t), KM_SLEEP); txh->txh_tx = tx; txh->txh_dnode = dn; + refcount_create(&txh->txh_space_towrite); + refcount_create(&txh->txh_space_tofree); + refcount_create(&txh->txh_space_tooverwrite); + refcount_create(&txh->txh_space_tounref); + refcount_create(&txh->txh_memory_tohold); + refcount_create(&txh->txh_fudge); #ifdef ZFS_DEBUG txh->txh_type = type; txh->txh_arg1 = arg1; @@ -201,12 +207,18 @@ dmu_tx_count_twig(dmu_tx_hold_t *txh, dn freeable = (bp && (freeable || dsl_dataset_block_freeable(ds, bp, bp->blk_birth))); - if (freeable) - txh->txh_space_tooverwrite += space; - else - txh->txh_space_towrite += space; - if (bp) - txh->txh_space_tounref += bp_get_dsize(os->os_spa, bp); + if (freeable) { + (void) refcount_add_many(&txh->txh_space_tooverwrite, + space, FTAG); + } else { + (void) refcount_add_many(&txh->txh_space_towrite, + space, FTAG); + } + + if (bp) { + (void) refcount_add_many(&txh->txh_space_tounref, + bp_get_dsize(os->os_spa, bp), FTAG); + } dmu_tx_count_twig(txh, dn, parent, level + 1, blkid >> epbs, freeable, history); @@ -336,8 +348,11 @@ dmu_tx_count_write(dmu_tx_hold_t *txh, u bits = 64 - min_bs; epbs = min_ibs - SPA_BLKPTRSHIFT; for (bits -= epbs * (nlvls - 1); - bits >= 0; bits -= epbs) - txh->txh_fudge += 1ULL << max_ibs; + bits >= 0; bits -= epbs) { + (void) refcount_add_many( + &txh->txh_fudge, + 1ULL << max_ibs, FTAG); + } goto out; } off += delta; @@ -353,7 +368,8 @@ dmu_tx_count_write(dmu_tx_hold_t *txh, u */ start = P2ALIGN(off, 1ULL << max_bs); end = P2ROUNDUP(off + len, 1ULL << max_bs) - 1; - txh->txh_space_towrite += end - start + 1; + (void) refcount_add_many(&txh->txh_space_towrite, + end - start + 1, FTAG); start >>= min_bs; end >>= min_bs; @@ -368,18 +384,21 @@ dmu_tx_count_write(dmu_tx_hold_t *txh, u start >>= epbs; end >>= epbs; ASSERT3U(end, >=, start); - txh->txh_space_towrite += (end - start + 1) << max_ibs; + (void) refcount_add_many(&txh->txh_space_towrite, + (end - start + 1) << max_ibs, FTAG); if (start != 0) { /* * We also need a new blkid=0 indirect block * to reference any existing file data. */ - txh->txh_space_towrite += 1ULL << max_ibs; + (void) refcount_add_many(&txh->txh_space_towrite, + 1ULL << max_ibs, FTAG); } } out: - if (txh->txh_space_towrite + txh->txh_space_tooverwrite > + if (refcount_count(&txh->txh_space_towrite) + + refcount_count(&txh->txh_space_tooverwrite) > 2 * DMU_MAX_ACCESS) err = SET_ERROR(EFBIG); @@ -398,12 +417,15 @@ dmu_tx_count_dnode(dmu_tx_hold_t *txh) if (dn && dn->dn_dbuf->db_blkptr && dsl_dataset_block_freeable(dn->dn_objset->os_dsl_dataset, dn->dn_dbuf->db_blkptr, dn->dn_dbuf->db_blkptr->blk_birth)) { - txh->txh_space_tooverwrite += space; - txh->txh_space_tounref += space; + (void) refcount_add_many(&txh->txh_space_tooverwrite, + space, FTAG); + (void) refcount_add_many(&txh->txh_space_tounref, space, FTAG); } else { - txh->txh_space_towrite += space; - if (dn && dn->dn_dbuf->db_blkptr) - txh->txh_space_tounref += space; + (void) refcount_add_many(&txh->txh_space_towrite, space, FTAG); + if (dn && dn->dn_dbuf->db_blkptr) { + (void) refcount_add_many(&txh->txh_space_tounref, + space, FTAG); + } } } @@ -525,7 +547,8 @@ dmu_tx_count_free(dmu_tx_hold_t *txh, ui break; } - txh->txh_memory_tohold += dbuf->db.db_size; + (void) refcount_add_many(&txh->txh_memory_tohold, + dbuf->db.db_size, FTAG); /* * We don't check memory_tohold against DMU_MAX_ACCESS because @@ -578,20 +601,23 @@ dmu_tx_count_free(dmu_tx_hold_t *txh, ui (dn->dn_indblkshift - SPA_BLKPTRSHIFT); while (level++ < maxlevel) { - txh->txh_memory_tohold += MAX(MIN(blkcnt, nl1blks), 1) - << dn->dn_indblkshift; + (void) refcount_add_many(&txh->txh_memory_tohold, + MAX(MIN(blkcnt, nl1blks), 1) << dn->dn_indblkshift, + FTAG); blkcnt = 1 + (blkcnt >> epbs); } } /* account for new level 1 indirect blocks that might show up */ if (skipped > 0) { - txh->txh_fudge += skipped << dn->dn_indblkshift; + (void) refcount_add_many(&txh->txh_fudge, + skipped << dn->dn_indblkshift, FTAG); skipped = MIN(skipped, DMU_MAX_DELETEBLKCNT >> epbs); - txh->txh_memory_tohold += skipped << dn->dn_indblkshift; + (void) refcount_add_many(&txh->txh_memory_tohold, + skipped << dn->dn_indblkshift, FTAG); } - txh->txh_space_tofree += space; - txh->txh_space_tounref += unref; + (void) refcount_add_many(&txh->txh_space_tofree, space, FTAG); + (void) refcount_add_many(&txh->txh_space_tounref, unref, FTAG); } /* @@ -617,7 +643,10 @@ dmu_tx_mark_netfree(dmu_tx_t *tx) * cause overflows when doing math with these values (e.g. in * dmu_tx_try_assign()). */ - txh->txh_space_tofree = txh->txh_space_tounref = 1024 * 1024 * 1024; + (void) refcount_add_many(&txh->txh_space_tofree, + 1024 * 1024 * 1024, FTAG); + (void) refcount_add_many(&txh->txh_space_tounref, + 1024 * 1024 * 1024, FTAG); } void @@ -717,9 +746,7 @@ dmu_tx_hold_zap(dmu_tx_t *tx, uint64_t o { dmu_tx_hold_t *txh; dnode_t *dn; - dsl_dataset_phys_t *ds_phys; - uint64_t nblocks; - int epbs, err; + int err; ASSERT(tx->tx_txg == 0); @@ -762,12 +789,17 @@ dmu_tx_hold_zap(dmu_tx_t *tx, uint64_t o */ bp = &dn->dn_phys->dn_blkptr[0]; if (dsl_dataset_block_freeable(dn->dn_objset->os_dsl_dataset, - bp, bp->blk_birth)) - txh->txh_space_tooverwrite += MZAP_MAX_BLKSZ; - else - txh->txh_space_towrite += MZAP_MAX_BLKSZ; - if (!BP_IS_HOLE(bp)) - txh->txh_space_tounref += MZAP_MAX_BLKSZ; + bp, bp->blk_birth)) { + (void) refcount_add_many(&txh->txh_space_tooverwrite, + MZAP_MAX_BLKSZ, FTAG); + } else { + (void) refcount_add_many(&txh->txh_space_towrite, + MZAP_MAX_BLKSZ, FTAG); + } + if (!BP_IS_HOLE(bp)) { + (void) refcount_add_many(&txh->txh_space_tounref, + MZAP_MAX_BLKSZ, FTAG); + } return; } @@ -789,15 +821,29 @@ dmu_tx_hold_zap(dmu_tx_t *tx, uint64_t o /* * If the modified blocks are scattered to the four winds, - * we'll have to modify an indirect twig for each. + * we'll have to modify an indirect twig for each. We can make + * modifications at up to 3 locations: + * - header block at the beginning of the object + * - target leaf block + * - end of the object, where we might need to write: + * - a new leaf block if the target block needs to be split + * - the new pointer table, if it is growing + * - the new cookie table, if it is growing */ - epbs = dn->dn_indblkshift - SPA_BLKPTRSHIFT; - ds_phys = dsl_dataset_phys(dn->dn_objset->os_dsl_dataset); - for (nblocks = dn->dn_maxblkid >> epbs; nblocks != 0; nblocks >>= epbs) - if (ds_phys->ds_prev_snap_obj) - txh->txh_space_towrite += 3 << dn->dn_indblkshift; - else - txh->txh_space_tooverwrite += 3 << dn->dn_indblkshift; + int epbs = dn->dn_indblkshift - SPA_BLKPTRSHIFT; + dsl_dataset_phys_t *ds_phys = + dsl_dataset_phys(dn->dn_objset->os_dsl_dataset); + for (int lvl = 1; lvl < dn->dn_nlevels; lvl++) { + uint64_t num_indirects = 1 + (dn->dn_maxblkid >> (epbs * lvl)); + uint64_t spc = MIN(3, num_indirects) << dn->dn_indblkshift; + if (ds_phys->ds_prev_snap_obj != 0) { + (void) refcount_add_many(&txh->txh_space_towrite, + spc, FTAG); + } else { + (void) refcount_add_many(&txh->txh_space_tooverwrite, + spc, FTAG); + } + } } void @@ -822,7 +868,7 @@ dmu_tx_hold_space(dmu_tx_t *tx, uint64_t txh = dmu_tx_hold_object_impl(tx, tx->tx_objset, DMU_NEW_OBJECT, THT_SPACE, space, 0); - txh->txh_space_towrite += space; + (void) refcount_add_many(&txh->txh_space_towrite, space, FTAG); } int @@ -1175,12 +1221,12 @@ dmu_tx_try_assign(dmu_tx_t *tx, txg_how_ (void) refcount_add(&dn->dn_tx_holds, tx); mutex_exit(&dn->dn_mtx); } - towrite += txh->txh_space_towrite; - tofree += txh->txh_space_tofree; - tooverwrite += txh->txh_space_tooverwrite; - tounref += txh->txh_space_tounref; - tohold += txh->txh_memory_tohold; - fudge += txh->txh_fudge; + towrite += refcount_count(&txh->txh_space_towrite); + tofree += refcount_count(&txh->txh_space_tofree); + tooverwrite += refcount_count(&txh->txh_space_tooverwrite); + tounref += refcount_count(&txh->txh_space_tounref); + tohold += refcount_count(&txh->txh_memory_tohold); + fudge += refcount_count(&txh->txh_fudge); } /* @@ -1383,24 +1429,59 @@ dmu_tx_willuse_space(dmu_tx_t *tx, int64 #endif } -void -dmu_tx_commit(dmu_tx_t *tx) +static void +dmu_tx_destroy(dmu_tx_t *tx) { dmu_tx_hold_t *txh; + while ((txh = list_head(&tx->tx_holds)) != NULL) { + dnode_t *dn = txh->txh_dnode; + + list_remove(&tx->tx_holds, txh); + refcount_destroy_many(&txh->txh_space_towrite, + refcount_count(&txh->txh_space_towrite)); + refcount_destroy_many(&txh->txh_space_tofree, + refcount_count(&txh->txh_space_tofree)); + refcount_destroy_many(&txh->txh_space_tooverwrite, + refcount_count(&txh->txh_space_tooverwrite)); + refcount_destroy_many(&txh->txh_space_tounref, + refcount_count(&txh->txh_space_tounref)); + refcount_destroy_many(&txh->txh_memory_tohold, + refcount_count(&txh->txh_memory_tohold)); + refcount_destroy_many(&txh->txh_fudge, + refcount_count(&txh->txh_fudge)); + kmem_free(txh, sizeof (dmu_tx_hold_t)); + if (dn != NULL) + dnode_rele(dn, tx); + } + + list_destroy(&tx->tx_callbacks); + list_destroy(&tx->tx_holds); +#ifdef ZFS_DEBUG + refcount_destroy_many(&tx->tx_space_written, + refcount_count(&tx->tx_space_written)); + refcount_destroy_many(&tx->tx_space_freed, + refcount_count(&tx->tx_space_freed)); +#endif + kmem_free(tx, sizeof (dmu_tx_t)); +} + +void +dmu_tx_commit(dmu_tx_t *tx) +{ ASSERT(tx->tx_txg != 0); /* * Go through the transaction's hold list and remove holds on * associated dnodes, notifying waiters if no holds remain. */ - while (txh = list_head(&tx->tx_holds)) { + for (dmu_tx_hold_t *txh = list_head(&tx->tx_holds); txh != NULL; + txh = list_next(&tx->tx_holds, txh)) { dnode_t *dn = txh->txh_dnode; - list_remove(&tx->tx_holds, txh); - kmem_free(txh, sizeof (dmu_tx_hold_t)); if (dn == NULL) continue; + mutex_enter(&dn->dn_mtx); ASSERT3U(dn->dn_assigned_txg, ==, tx->tx_txg); @@ -1409,7 +1490,6 @@ dmu_tx_commit(dmu_tx_t *tx) cv_broadcast(&dn->dn_notxholds); } mutex_exit(&dn->dn_mtx); - dnode_rele(dn, tx); } if (tx->tx_tempreserve_cookie) @@ -1421,51 +1501,26 @@ dmu_tx_commit(dmu_tx_t *tx) if (tx->tx_anyobj == FALSE) txg_rele_to_sync(&tx->tx_txgh); - list_destroy(&tx->tx_callbacks); - list_destroy(&tx->tx_holds); #ifdef ZFS_DEBUG dprintf("towrite=%llu written=%llu tofree=%llu freed=%llu\n", tx->tx_space_towrite, refcount_count(&tx->tx_space_written), tx->tx_space_tofree, refcount_count(&tx->tx_space_freed)); - refcount_destroy_many(&tx->tx_space_written, - refcount_count(&tx->tx_space_written)); - refcount_destroy_many(&tx->tx_space_freed, - refcount_count(&tx->tx_space_freed)); #endif - kmem_free(tx, sizeof (dmu_tx_t)); + dmu_tx_destroy(tx); } void dmu_tx_abort(dmu_tx_t *tx) { - dmu_tx_hold_t *txh; - ASSERT(tx->tx_txg == 0); - while (txh = list_head(&tx->tx_holds)) { - dnode_t *dn = txh->txh_dnode; - - list_remove(&tx->tx_holds, txh); - kmem_free(txh, sizeof (dmu_tx_hold_t)); - if (dn != NULL) - dnode_rele(dn, tx); - } - /* * Call any registered callbacks with an error code. */ if (!list_is_empty(&tx->tx_callbacks)) dmu_tx_do_callbacks(&tx->tx_callbacks, ECANCELED); - list_destroy(&tx->tx_callbacks); - list_destroy(&tx->tx_holds); -#ifdef ZFS_DEBUG - refcount_destroy_many(&tx->tx_space_written, - refcount_count(&tx->tx_space_written)); - refcount_destroy_many(&tx->tx_space_freed, - refcount_count(&tx->tx_space_freed)); -#endif - kmem_free(tx, sizeof (dmu_tx_t)); + dmu_tx_destroy(tx); } uint64_t @@ -1504,7 +1559,7 @@ dmu_tx_do_callbacks(list_t *cb_list, int { dmu_tx_callback_t *dcb; - while (dcb = list_head(cb_list)) { + while ((dcb = list_head(cb_list)) != NULL) { list_remove(cb_list, dcb); dcb->dcb_func(dcb->dcb_data, error); kmem_free(dcb, sizeof (dmu_tx_callback_t)); @@ -1562,18 +1617,24 @@ dmu_tx_hold_spill(dmu_tx_t *tx, uint64_t /* If blkptr doesn't exist then add space to towrite */ if (!(dn->dn_phys->dn_flags & DNODE_FLAG_SPILL_BLKPTR)) { - txh->txh_space_towrite += SPA_OLD_MAXBLOCKSIZE; + (void) refcount_add_many(&txh->txh_space_towrite, + SPA_OLD_MAXBLOCKSIZE, FTAG); } else { blkptr_t *bp; bp = &dn->dn_phys->dn_spill; if (dsl_dataset_block_freeable(dn->dn_objset->os_dsl_dataset, - bp, bp->blk_birth)) - txh->txh_space_tooverwrite += SPA_OLD_MAXBLOCKSIZE; - else - txh->txh_space_towrite += SPA_OLD_MAXBLOCKSIZE; - if (!BP_IS_HOLE(bp)) - txh->txh_space_tounref += SPA_OLD_MAXBLOCKSIZE; + bp, bp->blk_birth)) { + (void) refcount_add_many(&txh->txh_space_tooverwrite, + SPA_OLD_MAXBLOCKSIZE, FTAG); + } else { + (void) refcount_add_many(&txh->txh_space_towrite, + SPA_OLD_MAXBLOCKSIZE, FTAG); + } + if (!BP_IS_HOLE(bp)) { + (void) refcount_add_many(&txh->txh_space_tounref, + SPA_OLD_MAXBLOCKSIZE, FTAG); + } } } Modified: stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dmu_tx.h ============================================================================== --- stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dmu_tx.h Tue Oct 11 16:50:45 2016 (r307056) +++ stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dmu_tx.h Tue Oct 11 16:52:57 2016 (r307057) @@ -23,7 +23,7 @@ * Use is subject to license terms. */ /* - * Copyright (c) 2013 by Delphix. All rights reserved. + * Copyright (c) 2012, 2015 by Delphix. All rights reserved. */ #ifndef _SYS_DMU_TX_H @@ -101,12 +101,12 @@ typedef struct dmu_tx_hold { dmu_tx_t *txh_tx; list_node_t txh_node; struct dnode *txh_dnode; - uint64_t txh_space_towrite; - uint64_t txh_space_tofree; - uint64_t txh_space_tooverwrite; - uint64_t txh_space_tounref; - uint64_t txh_memory_tohold; - uint64_t txh_fudge; + refcount_t txh_space_towrite; + refcount_t txh_space_tofree; + refcount_t txh_space_tooverwrite; + refcount_t txh_space_tounref; + refcount_t txh_memory_tohold; + refcount_t txh_fudge; #ifdef ZFS_DEBUG enum dmu_tx_hold_type txh_type; uint64_t txh_arg1; Modified: stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zap.h ============================================================================== --- stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zap.h Tue Oct 11 16:50:45 2016 (r307056) +++ stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zap.h Tue Oct 11 16:52:57 2016 (r307057) @@ -20,7 +20,7 @@ */ /* * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2012 by Delphix. All rights reserved. + * Copyright (c) 2012, 2015 by Delphix. All rights reserved. */ #ifndef _SYS_ZAP_H @@ -80,6 +80,7 @@ */ #include +#include #ifdef __cplusplus extern "C" { @@ -217,7 +218,7 @@ int zap_prefetch_uint64(objset_t *os, ui int key_numints); int zap_count_write(objset_t *os, uint64_t zapobj, const char *name, - int add, uint64_t *towrite, uint64_t *tooverwrite); + int add, refcount_t *towrite, refcount_t *tooverwrite); /* * Create an attribute with the given name and value. Modified: stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zap_impl.h ============================================================================== --- stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zap_impl.h Tue Oct 11 16:50:45 2016 (r307056) +++ stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zap_impl.h Tue Oct 11 16:52:57 2016 (r307057) @@ -20,6 +20,7 @@ */ /* * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2015 by Delphix. All rights reserved. * Copyright (c) 2014 Spectra Logic Corporation, All rights reserved. * Copyright (c) 2014 Integros [integros.com] */ @@ -213,8 +214,8 @@ int fzap_lookup(zap_name_t *zn, uint64_t integer_size, uint64_t num_integers, void *buf, char *realname, int rn_len, boolean_t *normalization_conflictp); void fzap_prefetch(zap_name_t *zn); -int fzap_count_write(zap_name_t *zn, int add, uint64_t *towrite, - uint64_t *tooverwrite); +int fzap_count_write(zap_name_t *zn, int add, refcount_t *towrite, + refcount_t *tooverwrite); int fzap_add(zap_name_t *zn, uint64_t integer_size, uint64_t num_integers, const void *val, dmu_tx_t *tx); int fzap_update(zap_name_t *zn, Modified: stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zap.c ============================================================================== --- stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zap.c Tue Oct 11 16:50:45 2016 (r307056) +++ stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zap.c Tue Oct 11 16:52:57 2016 (r307057) @@ -1335,8 +1335,8 @@ fzap_get_stats(zap_t *zap, zap_stats_t * } int -fzap_count_write(zap_name_t *zn, int add, uint64_t *towrite, - uint64_t *tooverwrite) +fzap_count_write(zap_name_t *zn, int add, refcount_t *towrite, + refcount_t *tooverwrite) { zap_t *zap = zn->zn_zap; zap_leaf_t *l; @@ -1346,9 +1346,11 @@ fzap_count_write(zap_name_t *zn, int add * Account for the header block of the fatzap. */ if (!add && dmu_buf_freeable(zap->zap_dbuf)) { - *tooverwrite += zap->zap_dbuf->db_size; + (void) refcount_add_many(tooverwrite, + zap->zap_dbuf->db_size, FTAG); } else { - *towrite += zap->zap_dbuf->db_size; + (void) refcount_add_many(towrite, + zap->zap_dbuf->db_size, FTAG); } /* @@ -1360,10 +1362,13 @@ fzap_count_write(zap_name_t *zn, int add * could extend the table. */ if (add) { - if (zap_f_phys(zap)->zap_ptrtbl.zt_blk == 0) - *towrite += zap->zap_dbuf->db_size; - else - *towrite += (zap->zap_dbuf->db_size * 3); + if (zap_f_phys(zap)->zap_ptrtbl.zt_blk == 0) { + (void) refcount_add_many(towrite, + zap->zap_dbuf->db_size, FTAG); + } else { + (void) refcount_add_many(towrite, + zap->zap_dbuf->db_size * 3, FTAG); + } } /* @@ -1376,13 +1381,14 @@ fzap_count_write(zap_name_t *zn, int add } if (!add && dmu_buf_freeable(l->l_dbuf)) { - *tooverwrite += l->l_dbuf->db_size; + (void) refcount_add_many(tooverwrite, l->l_dbuf->db_size, FTAG); } else { /* * If this an add operation, the leaf block could split. * Hence, we need to account for an additional leaf block. */ - *towrite += (add ? 2 : 1) * l->l_dbuf->db_size; + (void) refcount_add_many(towrite, + (add ? 2 : 1) * l->l_dbuf->db_size, FTAG); } zap_put_leaf(l); Modified: stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zap_micro.c ============================================================================== --- stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zap_micro.c Tue Oct 11 16:50:45 2016 (r307056) +++ stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zap_micro.c Tue Oct 11 16:52:57 2016 (r307057) @@ -20,7 +20,7 @@ */ /* * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2011, 2014 by Delphix. All rights reserved. + * Copyright (c) 2011, 2015 by Delphix. All rights reserved. * Copyright (c) 2014 Spectra Logic Corporation, All rights reserved. * Copyright (c) 2014 Integros [integros.com] */ @@ -1396,7 +1396,7 @@ zap_get_stats(objset_t *os, uint64_t zap int zap_count_write(objset_t *os, uint64_t zapobj, const char *name, int add, - uint64_t *towrite, uint64_t *tooverwrite) + refcount_t *towrite, refcount_t *tooverwrite) { zap_t *zap; int err = 0; @@ -1406,14 +1406,15 @@ zap_count_write(objset_t *os, uint64_t z * be affected in this operation. So, account for the worst case : * - 3 blocks overwritten: target leaf, ptrtbl block, header block * - 4 new blocks written if adding: - * - 2 blocks for possibly split leaves, - * - 2 grown ptrtbl blocks + * - 2 blocks for possibly split leaves, + * - 2 grown ptrtbl blocks * * This also accomodates the case where an add operation to a fairly * large microzap results in a promotion to fatzap. */ if (name == NULL) { - *towrite += (3 + (add ? 4 : 0)) * SPA_OLD_MAXBLOCKSIZE; + (void) refcount_add_many(towrite, + (3 + (add ? 4 : 0)) * SPA_OLD_MAXBLOCKSIZE, FTAG); return (err); } @@ -1437,7 +1438,8 @@ zap_count_write(objset_t *os, uint64_t z /* * We treat this case as similar to (name == NULL) */ - *towrite += (3 + (add ? 4 : 0)) * SPA_OLD_MAXBLOCKSIZE; + (void) refcount_add_many(towrite, + (3 + (add ? 4 : 0)) * SPA_OLD_MAXBLOCKSIZE, FTAG); } } else { /* @@ -1455,13 +1457,17 @@ zap_count_write(objset_t *os, uint64_t z * 4 new blocks written : 2 new split leaf, 2 grown * ptrtbl blocks */ - if (dmu_buf_freeable(zap->zap_dbuf)) - *tooverwrite += MZAP_MAX_BLKSZ; - else - *towrite += MZAP_MAX_BLKSZ; + if (dmu_buf_freeable(zap->zap_dbuf)) { + (void) refcount_add_many(tooverwrite, + MZAP_MAX_BLKSZ, FTAG); + } else { + (void) refcount_add_many(towrite, + MZAP_MAX_BLKSZ, FTAG); + } if (add) { - *towrite += 4 * MZAP_MAX_BLKSZ; + (void) refcount_add_many(towrite, + 4 * MZAP_MAX_BLKSZ, FTAG); } } From owner-svn-src-all@freebsd.org Tue Oct 11 16:53:52 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 17BE3C0CCB9; Tue, 11 Oct 2016 16:53:52 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id D97201D0; Tue, 11 Oct 2016 16:53:51 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9BGrod6026274; Tue, 11 Oct 2016 16:53:50 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9BGro3O026266; Tue, 11 Oct 2016 16:53:50 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201610111653.u9BGro3O026266@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Tue, 11 Oct 2016 16:53:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307058 - in stable/10: cddl/contrib/opensolaris/lib/libzfs/common sys/cddl/contrib/opensolaris/common/zfs X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Oct 2016 16:53:52 -0000 Author: mav Date: Tue Oct 11 16:53:50 2016 New Revision: 307058 URL: https://svnweb.freebsd.org/changeset/base/307058 Log: MFC r305207: MFV r302659: 6931 lib/libzfs: cleanup gcc warnings illumos/illumos-gate@88f61dee20b358671b1b643e9d1dbf220a1d69be https://github.com/illumos/illumos-gate/commit/88f61dee20b358671b1b643e9d1dbf220a1d69be https://www.illumos.org/issues/6931 need cleanup: CERRWARN += -_gcc=-Wno-switch CERRWARN += -_gcc=-Wno-parentheses CERRWARN += -_gcc=-Wno-unused-function Reviewed by: Matthew Ahrens Approved by: Robert Mustacchi Author: Igor Kozhukhov Modified: stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_changelist.c stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_diff.c stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_mount.c stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_pool.c stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_util.c stable/10/sys/cddl/contrib/opensolaris/common/zfs/zfs_deleg.c Directory Properties: stable/10/ (props changed) Modified: stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_changelist.c ============================================================================== --- stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_changelist.c Tue Oct 11 16:52:57 2016 (r307057) +++ stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_changelist.c Tue Oct 11 16:53:50 2016 (r307058) @@ -24,9 +24,9 @@ * Use is subject to license terms. * * Portions Copyright 2007 Ramprakash Jelari - * * Copyright (c) 2011 Pawel Jakub Dawidek . * All rights reserved. + * Copyright 2016 Igor Kozhukhov */ #include @@ -136,6 +136,9 @@ changelist_prefix(prop_changelist_t *clp case ZFS_PROP_SHARESMB: (void) zfs_unshare_smb(cn->cn_handle, NULL); break; + + default: + break; } } } Modified: stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c ============================================================================== --- stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c Tue Oct 11 16:52:57 2016 (r307057) +++ stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c Tue Oct 11 16:53:50 2016 (r307058) @@ -29,6 +29,7 @@ * Copyright (c) 2013 Steven Hartland. All rights reserved. * Copyright 2013 Nexenta Systems, Inc. All rights reserved. * Copyright (c) 2014 Integros [integros.com] + * Copyright 2016 Igor Kozhukhov */ #include @@ -78,55 +79,18 @@ zfs_type_to_name(zfs_type_t type) return (dgettext(TEXT_DOMAIN, "snapshot")); case ZFS_TYPE_VOLUME: return (dgettext(TEXT_DOMAIN, "volume")); + case ZFS_TYPE_POOL: + return (dgettext(TEXT_DOMAIN, "pool")); + case ZFS_TYPE_BOOKMARK: + return (dgettext(TEXT_DOMAIN, "bookmark")); + default: + assert(!"unhandled zfs_type_t"); } return (NULL); } /* - * Given a path and mask of ZFS types, return a string describing this dataset. - * This is used when we fail to open a dataset and we cannot get an exact type. - * We guess what the type would have been based on the path and the mask of - * acceptable types. - */ -static const char * -path_to_str(const char *path, int types) -{ - /* - * When given a single type, always report the exact type. - */ - if (types == ZFS_TYPE_SNAPSHOT) - return (dgettext(TEXT_DOMAIN, "snapshot")); - if (types == ZFS_TYPE_FILESYSTEM) - return (dgettext(TEXT_DOMAIN, "filesystem")); - if (types == ZFS_TYPE_VOLUME) - return (dgettext(TEXT_DOMAIN, "volume")); - - /* - * The user is requesting more than one type of dataset. If this is the - * case, consult the path itself. If we're looking for a snapshot, and - * a '@' is found, then report it as "snapshot". Otherwise, remove the - * snapshot attribute and try again. - */ - if (types & ZFS_TYPE_SNAPSHOT) { - if (strchr(path, '@') != NULL) - return (dgettext(TEXT_DOMAIN, "snapshot")); - return (path_to_str(path, types & ~ZFS_TYPE_SNAPSHOT)); - } - - /* - * The user has requested either filesystems or volumes. - * We have no way of knowing a priori what type this would be, so always - * report it as "filesystem" or "volume", our two primitive types. - */ - if (types & ZFS_TYPE_FILESYSTEM) - return (dgettext(TEXT_DOMAIN, "filesystem")); - - assert(types & ZFS_TYPE_VOLUME); - return (dgettext(TEXT_DOMAIN, "volume")); -} - -/* * Validate a ZFS path. This is used even before trying to open the dataset, to * provide a more meaningful error message. We call zfs_error_aux() to * explain exactly why the name was not valid. @@ -187,6 +151,11 @@ zfs_validate_name(libzfs_handle_t *hdl, zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, "reserved disk name")); break; + + default: + zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, + "(%d) not defined"), why); + break; } } @@ -769,7 +738,8 @@ libzfs_mnttab_fini(libzfs_handle_t *hdl) void *cookie = NULL; mnttab_node_t *mtn; - while (mtn = avl_destroy_nodes(&hdl->libzfs_mnttab_cache, &cookie)) { + while ((mtn = avl_destroy_nodes(&hdl->libzfs_mnttab_cache, &cookie)) + != NULL) { free(mtn->mtn_mt.mnt_special); free(mtn->mtn_mt.mnt_mountp); free(mtn->mtn_mt.mnt_fstype); @@ -841,7 +811,8 @@ libzfs_mnttab_remove(libzfs_handle_t *hd mnttab_node_t *ret; find.mtn_mt.mnt_special = (char *)fsname; - if (ret = avl_find(&hdl->libzfs_mnttab_cache, (void *)&find, NULL)) { + if ((ret = avl_find(&hdl->libzfs_mnttab_cache, (void *)&find, NULL)) + != NULL) { avl_remove(&hdl->libzfs_mnttab_cache, ret); free(ret->mtn_mt.mnt_special); free(ret->mtn_mt.mnt_mountp); @@ -1193,6 +1164,13 @@ badlabel: "component of '%s' is too long"), propname); break; + + default: + zfs_error_aux(hdl, + dgettext(TEXT_DOMAIN, + "(%d) not defined"), + why); + break; } (void) zfs_error(hdl, EZFS_BADPROP, errbuf); goto error; @@ -1311,12 +1289,17 @@ badlabel: } break; + case ZFS_PROP_UTF8ONLY: chosen_utf = (int)intval; break; + case ZFS_PROP_NORMALIZE: chosen_normal = (int)intval; break; + + default: + break; } /* @@ -1365,6 +1348,9 @@ badlabel: goto error; } break; + + default: + break; } } } @@ -1968,6 +1954,9 @@ get_numeric_property(zfs_handle_t *zhp, mntopt_on = MNTOPT_NBMAND; mntopt_off = MNTOPT_NONBMAND; break; + + default: + break; } /* @@ -3145,7 +3134,7 @@ create_parents(libzfs_handle_t *hdl, cha * up to the prefixlen-long one. */ for (cp = target + prefixlen + 1; - cp = strchr(cp, '/'); *cp = '/', cp++) { + (cp = strchr(cp, '/')) != NULL; *cp = '/', cp++) { *cp = '\0'; @@ -3908,7 +3897,7 @@ int zfs_rename(zfs_handle_t *zhp, const char *source, const char *target, renameflags_t flags) { - int ret; + int ret = 0; zfs_cmd_t zc = { 0 }; char *delim; prop_changelist_t *cl = NULL; Modified: stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_diff.c ============================================================================== --- stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_diff.c Tue Oct 11 16:52:57 2016 (r307057) +++ stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_diff.c Tue Oct 11 16:53:50 2016 (r307058) @@ -23,6 +23,7 @@ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. * Copyright 2015 Nexenta Systems, Inc. All rights reserved. * Copyright 2016 Joyent, Inc. + * Copyright 2016 Igor Kozhukhov */ /* @@ -353,7 +354,7 @@ write_inuse_diffs(FILE *fp, differ_info_ int err; for (o = dr->ddr_first; o <= dr->ddr_last; o++) { - if (err = write_inuse_diffs_one(fp, di, o)) + if ((err = write_inuse_diffs_one(fp, di, o)) != 0) return (err); } return (0); Modified: stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_mount.c ============================================================================== --- stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_mount.c Tue Oct 11 16:52:57 2016 (r307057) +++ stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_mount.c Tue Oct 11 16:53:50 2016 (r307058) @@ -22,6 +22,7 @@ /* * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2014 by Delphix. All rights reserved. + * Copyright 2016 Igor Kozhukhov */ /* @@ -475,7 +476,8 @@ zfs_is_shared_proto(zfs_handle_t *zhp, c if (!zfs_is_mounted(zhp, &mountpoint)) return (SHARED_NOT_SHARED); - if (rc = is_shared(zhp->zfs_hdl, mountpoint, proto)) { + if ((rc = is_shared(zhp->zfs_hdl, mountpoint, proto)) + != SHARED_NOT_SHARED) { if (where != NULL) *where = mountpoint; else Modified: stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_pool.c ============================================================================== --- stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_pool.c Tue Oct 11 16:52:57 2016 (r307057) +++ stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_pool.c Tue Oct 11 16:53:50 2016 (r307058) @@ -24,6 +24,7 @@ * Copyright (c) 2011, 2015 by Delphix. All rights reserved. * Copyright (c) 2013, Joyent, Inc. All rights reserved. * Copyright 2016 Nexenta Systems, Inc. + * Copyright 2016 Igor Kozhukhov */ #include @@ -199,6 +200,9 @@ zpool_state_to_name(vdev_state_t state, return (gettext("DEGRADED")); case VDEV_STATE_HEALTHY: return (gettext("ONLINE")); + + default: + break; } return (gettext("UNKNOWN")); @@ -635,6 +639,11 @@ zpool_valid_proplist(libzfs_handle_t *hd goto error; } break; + + default: + zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, + "property '%s'(%d) not defined"), propname, prop); + break; } } @@ -943,6 +952,10 @@ zpool_name_valid(libzfs_handle_t *hdl, b "multiple '@' delimiters in name")); break; + default: + zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, + "(%d) not defined"), why); + break; } } return (B_FALSE); Modified: stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c ============================================================================== --- stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c Tue Oct 11 16:52:57 2016 (r307057) +++ stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c Tue Oct 11 16:53:50 2016 (r307058) @@ -27,6 +27,7 @@ * Copyright (c) 2013 Steven Hartland. All rights reserved. * Copyright 2015, OmniTI Computer Consulting, Inc. All rights reserved. * Copyright (c) 2014 Integros [integros.com] + * Copyright 2016 Igor Kozhukhov */ #include @@ -1182,8 +1183,8 @@ dump_snapshot(zfs_handle_t *zhp, void *a pa.pa_fd = sdd->outfd; pa.pa_parsable = sdd->parsable; - if (err = pthread_create(&tid, NULL, - send_progress_thread, &pa)) { + if ((err = pthread_create(&tid, NULL, + send_progress_thread, &pa)) != 0) { zfs_close(zhp); return (err); } @@ -1661,7 +1662,7 @@ zfs_send(zfs_handle_t *zhp, const char * if (flags->dedup && !flags->dryrun) { featureflags |= (DMU_BACKUP_FEATURE_DEDUP | DMU_BACKUP_FEATURE_DEDUPPROPS); - if (err = pipe(pipefd)) { + if ((err = pipe(pipefd)) != 0) { zfs_error_aux(zhp->zfs_hdl, strerror(errno)); return (zfs_error(zhp->zfs_hdl, EZFS_PIPEFAILED, errbuf)); @@ -1669,7 +1670,7 @@ zfs_send(zfs_handle_t *zhp, const char * dda.outputfd = outfd; dda.inputfd = pipefd[1]; dda.dedup_hdl = zhp->zfs_hdl; - if (err = pthread_create(&tid, NULL, cksummer, &dda)) { + if ((err = pthread_create(&tid, NULL, cksummer, &dda)) != 0) { (void) close(pipefd[0]); (void) close(pipefd[1]); zfs_error_aux(zhp->zfs_hdl, strerror(errno)); Modified: stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_util.c ============================================================================== --- stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_util.c Tue Oct 11 16:52:57 2016 (r307057) +++ stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_util.c Tue Oct 11 16:53:50 2016 (r307058) @@ -23,6 +23,7 @@ * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2013, Joyent, Inc. All rights reserved. * Copyright (c) 2011, 2015 by Delphix. All rights reserved. + * Copyright 2016 Igor Kozhukhov */ /* @@ -1062,6 +1063,10 @@ zprop_print_one_property(const char *nam case ZPROP_SRC_RECEIVED: str = "received"; break; + + default: + str = NULL; + assert(!"unhandled zprop_source_t"); } break; Modified: stable/10/sys/cddl/contrib/opensolaris/common/zfs/zfs_deleg.c ============================================================================== --- stable/10/sys/cddl/contrib/opensolaris/common/zfs/zfs_deleg.c Tue Oct 11 16:52:57 2016 (r307057) +++ stable/10/sys/cddl/contrib/opensolaris/common/zfs/zfs_deleg.c Tue Oct 11 16:53:50 2016 (r307058) @@ -22,6 +22,7 @@ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright 2010 Nexenta Systems, Inc. All rights reserved. * Copyright (c) 2013 by Delphix. All rights reserved. + * Copyright 2016 Igor Kozhukhov */ #include @@ -177,8 +178,9 @@ zfs_deleg_verify_nvlist(nvlist_t *nvp) nvpair_name(perm_name)); if (error) return (-1); - } while (perm_name = nvlist_next_nvpair(perms, perm_name)); - } while (who = nvlist_next_nvpair(nvp, who)); + } while ((perm_name = nvlist_next_nvpair(perms, perm_name)) + != NULL); + } while ((who = nvlist_next_nvpair(nvp, who)) != NULL); return (0); } From owner-svn-src-all@freebsd.org Tue Oct 11 17:00:30 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 4F19BC0CE37; Tue, 11 Oct 2016 17:00:30 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 11FD4796; Tue, 11 Oct 2016 17:00:30 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9BH0T1W026712; Tue, 11 Oct 2016 17:00:29 GMT (envelope-from gonzo@FreeBSD.org) Received: (from gonzo@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9BH0Trk026711; Tue, 11 Oct 2016 17:00:29 GMT (envelope-from gonzo@FreeBSD.org) Message-Id: <201610111700.u9BH0Trk026711@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: gonzo set sender to gonzo@FreeBSD.org using -f From: Oleksandr Tymoshenko Date: Tue, 11 Oct 2016 17:00:29 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307059 - head/sys/kern X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Oct 2016 17:00:30 -0000 Author: gonzo Date: Tue Oct 11 17:00:29 2016 New Revision: 307059 URL: https://svnweb.freebsd.org/changeset/base/307059 Log: INTRNG - fix MSI/MSIX release path Use isrc in attached MSI data structure instead of using map's isrc directly. map's isrc is set to NULL on IRQ deactivation which happens prior to pci_release_msi so MSI_RELEASE_MSI receives array of NULLs Reviewed by: mmel Differential Revision: https://reviews.freebsd.org/D8206 Modified: head/sys/kern/subr_intr.c Modified: head/sys/kern/subr_intr.c ============================================================================== --- head/sys/kern/subr_intr.c Tue Oct 11 16:53:50 2016 (r307058) +++ head/sys/kern/subr_intr.c Tue Oct 11 17:00:29 2016 (r307059) @@ -145,6 +145,7 @@ static u_int intrcnt_index; static struct intr_irqsrc *intr_map_get_isrc(u_int res_id); static void intr_map_set_isrc(u_int res_id, struct intr_irqsrc *isrc); +static struct intr_map_data * intr_map_get_map_data(u_int res_id); static void intr_map_copy_map_data(u_int res_id, device_t *dev, intptr_t *xref, struct intr_map_data **data); @@ -1309,6 +1310,7 @@ intr_release_msi(device_t pci, device_t { struct intr_irqsrc **isrc; struct intr_pic *pic; + struct intr_map_data_msi *msi; int i, err; pic = pic_lookup(NULL, xref); @@ -1321,8 +1323,14 @@ intr_release_msi(device_t pci, device_t isrc = malloc(sizeof(*isrc) * count, M_INTRNG, M_WAITOK); - for (i = 0; i < count; i++) - isrc[i] = intr_map_get_isrc(irqs[i]); + for (i = 0; i < count; i++) { + msi = (struct intr_map_data_msi *) + intr_map_get_map_data(irqs[i]); + KASSERT(msi->hdr.type == INTR_MAP_DATA_MSI, + ("%s: irq %d map data is not MSI", __func__, + irqs[i])); + isrc[i] = msi->isrc; + } err = MSI_RELEASE_MSI(pic->pic_dev, child, count, isrc); @@ -1369,6 +1377,7 @@ intr_release_msix(device_t pci, device_t { struct intr_irqsrc *isrc; struct intr_pic *pic; + struct intr_map_data_msi *msi; int err; pic = pic_lookup(NULL, xref); @@ -1379,7 +1388,12 @@ intr_release_msix(device_t pci, device_t ("%s: Found a non-MSI controller: %s", __func__, device_get_name(pic->pic_dev))); - isrc = intr_map_get_isrc(irq); + msi = (struct intr_map_data_msi *) + intr_map_get_map_data(irq); + KASSERT(msi->hdr.type == INTR_MAP_DATA_MSI, + ("%s: irq %d map data is not MSI", __func__, + irq)); + isrc = msi->isrc; if (isrc == NULL) { intr_unmap_irq(irq); return (EINVAL); @@ -1516,6 +1530,24 @@ intr_map_set_isrc(u_int res_id, struct i /* * Get a copy of intr_map_entry data */ +static struct intr_map_data * +intr_map_get_map_data(u_int res_id) +{ + struct intr_map_data *data; + + data = NULL; + mtx_lock(&irq_map_lock); + if (res_id >= irq_map_count || irq_map[res_id] == NULL) + panic("Attempt to copy invalid resource id: %u\n", res_id); + data = irq_map[res_id]->map_data; + mtx_unlock(&irq_map_lock); + + return (data); +} + +/* + * Get a copy of intr_map_entry data + */ static void intr_map_copy_map_data(u_int res_id, device_t *map_dev, intptr_t *map_xref, struct intr_map_data **data) From owner-svn-src-all@freebsd.org Tue Oct 11 17:11:18 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id DB25DC0D1BE; Tue, 11 Oct 2016 17:11:18 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id A18FDD8B; Tue, 11 Oct 2016 17:11:18 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9BHBHe3030409; Tue, 11 Oct 2016 17:11:17 GMT (envelope-from jhb@FreeBSD.org) Received: (from jhb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9BHBHVm030408; Tue, 11 Oct 2016 17:11:17 GMT (envelope-from jhb@FreeBSD.org) Message-Id: <201610111711.u9BHBHVm030408@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhb set sender to jhb@FreeBSD.org using -f From: John Baldwin Date: Tue, 11 Oct 2016 17:11:17 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307060 - head/usr.bin/truss X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Oct 2016 17:11:19 -0000 Author: jhb Date: Tue Oct 11 17:11:17 2016 New Revision: 307060 URL: https://svnweb.freebsd.org/changeset/base/307060 Log: Fix printf format warning. Modified: head/usr.bin/truss/syscalls.c Modified: head/usr.bin/truss/syscalls.c ============================================================================== --- head/usr.bin/truss/syscalls.c Tue Oct 11 17:00:29 2016 (r307059) +++ head/usr.bin/truss/syscalls.c Tue Oct 11 17:11:17 2016 (r307060) @@ -1924,9 +1924,9 @@ print_arg(struct syscall_args *sc, unsig cloudabi_filestat_t fsb; if (get_struct(pid, (void *)args[sc->offset], &fsb, sizeof(fsb)) != -1) - fprintf(fp, "{ %s, %lu }", + fprintf(fp, "{ %s, %ju }", xlookup(cloudabi_filetype, fsb.st_filetype), - fsb.st_size); + (uintmax_t)fsb.st_size); else fprintf(fp, "0x%lx", args[sc->offset]); break; From owner-svn-src-all@freebsd.org Tue Oct 11 17:12:28 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 5E52CC0D229; Tue, 11 Oct 2016 17:12:28 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 143BC108; Tue, 11 Oct 2016 17:12:28 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9BHCRSw033967; Tue, 11 Oct 2016 17:12:27 GMT (envelope-from emaste@FreeBSD.org) Received: (from emaste@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9BHCR9A033965; Tue, 11 Oct 2016 17:12:27 GMT (envelope-from emaste@FreeBSD.org) Message-Id: <201610111712.u9BHCR9A033965@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: emaste set sender to emaste@FreeBSD.org using -f From: Ed Maste Date: Tue, 11 Oct 2016 17:12:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307061 - in stable/11/release/doc: en_US.ISO8859-1/errata share/xml X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Oct 2016 17:12:28 -0000 Author: emaste Date: Tue Oct 11 17:12:26 2016 New Revision: 307061 URL: https://svnweb.freebsd.org/changeset/base/307061 Log: Add missing ThunderX release notes Reviewed by: gjb Differential Revision: https://reviews.freebsd.org/D8217 Modified: stable/11/release/doc/en_US.ISO8859-1/errata/article.xml stable/11/release/doc/share/xml/release.ent Modified: stable/11/release/doc/en_US.ISO8859-1/errata/article.xml ============================================================================== --- stable/11/release/doc/en_US.ISO8859-1/errata/article.xml Tue Oct 11 17:11:17 2016 (r307060) +++ stable/11/release/doc/en_US.ISO8859-1/errata/article.xml Tue Oct 11 17:12:26 2016 (r307061) @@ -168,6 +168,29 @@ boot state "Wireless support for 802.11n has been added for additional wireless network drivers." + + + Some release notes pertaining to the Cavium ThunderX + platform (the &os;/&arch.arm64; reference platform) were + omitted: + + + + Support for the Cavium + Virtualized NIC ethernet driver has been added. + + + + Support for the GICv3 and + ITS device drivers has been added. + + + + Support for PCI + Enhanced Allocation support has been added. + + + Modified: stable/11/release/doc/share/xml/release.ent ============================================================================== --- stable/11/release/doc/share/xml/release.ent Tue Oct 11 17:11:17 2016 (r307060) +++ stable/11/release/doc/share/xml/release.ent Tue Oct 11 17:12:26 2016 (r307061) @@ -70,7 +70,7 @@ - + From owner-svn-src-all@freebsd.org Tue Oct 11 17:41:14 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 577FCC0DB93; Tue, 11 Oct 2016 17:41:14 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 347DC61D; Tue, 11 Oct 2016 17:41:14 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9BHfDmM041808; Tue, 11 Oct 2016 17:41:13 GMT (envelope-from ae@FreeBSD.org) Received: (from ae@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9BHfDsr041806; Tue, 11 Oct 2016 17:41:13 GMT (envelope-from ae@FreeBSD.org) Message-Id: <201610111741.u9BHfDsr041806@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ae set sender to ae@FreeBSD.org using -f From: "Andrey V. Elsukov" Date: Tue, 11 Oct 2016 17:41:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307062 - head/sys/net X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Oct 2016 17:41:14 -0000 Author: ae Date: Tue Oct 11 17:41:13 2016 New Revision: 307062 URL: https://svnweb.freebsd.org/changeset/base/307062 Log: Make LLTABLE list lock private for if_llatbl.c Rename lock and macros to reflect that it protects V_lltables list. Modified: head/sys/net/if_llatbl.c head/sys/net/if_llatbl.h Modified: head/sys/net/if_llatbl.c ============================================================================== --- head/sys/net/if_llatbl.c Tue Oct 11 17:12:26 2016 (r307061) +++ head/sys/net/if_llatbl.c Tue Oct 11 17:41:13 2016 (r307062) @@ -66,8 +66,13 @@ static VNET_DEFINE(SLIST_HEAD(, lltable) SLIST_HEAD_INITIALIZER(lltables); #define V_lltables VNET(lltables) -struct rwlock lltable_rwlock; -RW_SYSINIT(lltable_rwlock, &lltable_rwlock, "lltable_rwlock"); +static struct rwlock lltable_list_lock; +RW_SYSINIT(lltable_list_lock, &lltable_list_lock, "lltable_list_lock"); +#define LLTABLE_LIST_RLOCK() rw_rlock(&lltable_list_lock) +#define LLTABLE_LIST_RUNLOCK() rw_runlock(&lltable_list_lock) +#define LLTABLE_LIST_WLOCK() rw_wlock(&lltable_list_lock) +#define LLTABLE_LIST_WUNLOCK() rw_wunlock(&lltable_list_lock) +#define LLTABLE_LIST_LOCK_ASSERT() rw_assert(&lltable_list_lock, RA_LOCKED) static void lltable_unlink(struct lltable *llt); static void llentries_unlink(struct lltable *llt, struct llentries *head); @@ -85,7 +90,7 @@ lltable_dump_af(struct lltable *llt, str { int error; - LLTABLE_LOCK_ASSERT(); + LLTABLE_LIST_LOCK_ASSERT(); if (llt->llt_ifp->if_flags & IFF_LOOPBACK) return (0); @@ -108,7 +113,7 @@ lltable_sysctl_dumparp(int af, struct sy struct lltable *llt; int error = 0; - LLTABLE_RLOCK(); + LLTABLE_LIST_RLOCK(); SLIST_FOREACH(llt, &V_lltables, llt_link) { if (llt->llt_af == af) { error = lltable_dump_af(llt, wr); @@ -117,7 +122,7 @@ lltable_sysctl_dumparp(int af, struct sy } } done: - LLTABLE_RUNLOCK(); + LLTABLE_LIST_RUNLOCK(); return (error); } @@ -531,7 +536,7 @@ lltable_drain(int af) struct llentry *lle; register int i; - LLTABLE_RLOCK(); + LLTABLE_LIST_RLOCK(); SLIST_FOREACH(llt, &V_lltables, llt_link) { if (llt->llt_af != af) continue; @@ -547,7 +552,7 @@ lltable_drain(int af) } } } - LLTABLE_RUNLOCK(); + LLTABLE_LIST_RUNLOCK(); } #endif @@ -591,14 +596,14 @@ lltable_prefix_free(int af, struct socka { struct lltable *llt; - LLTABLE_RLOCK(); + LLTABLE_LIST_RLOCK(); SLIST_FOREACH(llt, &V_lltables, llt_link) { if (llt->llt_af != af) continue; llt->llt_prefix_free(llt, addr, mask, flags); } - LLTABLE_RUNLOCK(); + LLTABLE_LIST_RUNLOCK(); } struct lltable * @@ -632,18 +637,18 @@ void lltable_link(struct lltable *llt) { - LLTABLE_WLOCK(); + LLTABLE_LIST_WLOCK(); SLIST_INSERT_HEAD(&V_lltables, llt, llt_link); - LLTABLE_WUNLOCK(); + LLTABLE_LIST_WUNLOCK(); } static void lltable_unlink(struct lltable *llt) { - LLTABLE_WLOCK(); + LLTABLE_LIST_WLOCK(); SLIST_REMOVE(&V_lltables, llt, lltable, llt_link); - LLTABLE_WUNLOCK(); + LLTABLE_LIST_WUNLOCK(); } @@ -739,13 +744,13 @@ lla_rt_output(struct rt_msghdr *rtm, str } /* XXX linked list may be too expensive */ - LLTABLE_RLOCK(); + LLTABLE_LIST_RLOCK(); SLIST_FOREACH(llt, &V_lltables, llt_link) { if (llt->llt_af == dst->sa_family && llt->llt_ifp == ifp) break; } - LLTABLE_RUNLOCK(); + LLTABLE_LIST_RUNLOCK(); KASSERT(llt != NULL, ("Yep, ugly hacks are bad\n")); error = 0; Modified: head/sys/net/if_llatbl.h ============================================================================== --- head/sys/net/if_llatbl.h Tue Oct 11 17:12:26 2016 (r307061) +++ head/sys/net/if_llatbl.h Tue Oct 11 17:41:13 2016 (r307062) @@ -37,17 +37,9 @@ struct ifnet; struct sysctl_req; struct rt_msghdr; struct rt_addrinfo; - struct llentry; LIST_HEAD(llentries, llentry); -extern struct rwlock lltable_rwlock; -#define LLTABLE_RLOCK() rw_rlock(&lltable_rwlock) -#define LLTABLE_RUNLOCK() rw_runlock(&lltable_rwlock) -#define LLTABLE_WLOCK() rw_wlock(&lltable_rwlock) -#define LLTABLE_WUNLOCK() rw_wunlock(&lltable_rwlock) -#define LLTABLE_LOCK_ASSERT() rw_assert(&lltable_rwlock, RA_LOCKED) - #define LLE_MAX_LINKHDR 24 /* Full IB header */ /* * Code referencing llentry must at least hold From owner-svn-src-all@freebsd.org Tue Oct 11 17:47:55 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D2A2BC0DD2A; Tue, 11 Oct 2016 17:47:55 +0000 (UTC) (envelope-from gjb@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 823D5BF1; Tue, 11 Oct 2016 17:47:55 +0000 (UTC) (envelope-from gjb@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9BHlsBf045372; Tue, 11 Oct 2016 17:47:54 GMT (envelope-from gjb@FreeBSD.org) Received: (from gjb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9BHlsbS045371; Tue, 11 Oct 2016 17:47:54 GMT (envelope-from gjb@FreeBSD.org) Message-Id: <201610111747.u9BHlsbS045371@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: gjb set sender to gjb@FreeBSD.org using -f From: Glen Barber Date: Tue, 11 Oct 2016 17:47:54 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307063 - stable/11/release/doc/en_US.ISO8859-1/errata X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Oct 2016 17:47:55 -0000 Author: gjb Date: Tue Oct 11 17:47:54 2016 New Revision: 307063 URL: https://svnweb.freebsd.org/changeset/base/307063 Log: Use the sponsors/vendors entities in the errata docs. Sponsored by: The FreeBSD Foundation Modified: stable/11/release/doc/en_US.ISO8859-1/errata/article.xml Modified: stable/11/release/doc/en_US.ISO8859-1/errata/article.xml ============================================================================== --- stable/11/release/doc/en_US.ISO8859-1/errata/article.xml Tue Oct 11 17:41:13 2016 (r307062) +++ stable/11/release/doc/en_US.ISO8859-1/errata/article.xml Tue Oct 11 17:47:54 2016 (r307063) @@ -4,6 +4,10 @@ %release; + +%sponsor; + +%vendor; ]> @@ -176,18 +180,21 @@ boot - Support for the Cavium - Virtualized NIC ethernet driver has been added. + Support for the Cavium Virtualized + NIC ethernet driver has been added. - Support for the GICv3 and - ITS device drivers has been added. + Support for the GICv3 and ITS device + drivers has been added. - Support for PCI - Enhanced Allocation support has been added. + Support for PCI Enhanced Allocation + support has been added. From owner-svn-src-all@freebsd.org Tue Oct 11 18:09:39 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 3E892C0D2B6; Tue, 11 Oct 2016 18:09:39 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 0E6909AF; Tue, 11 Oct 2016 18:09:38 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9BI9c64053136; Tue, 11 Oct 2016 18:09:38 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9BI9cCI053135; Tue, 11 Oct 2016 18:09:38 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201610111809.u9BI9cCI053135@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Tue, 11 Oct 2016 18:09:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307064 - head/sys/vm X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Oct 2016 18:09:39 -0000 Author: kib Date: Tue Oct 11 18:09:37 2016 New Revision: 307064 URL: https://svnweb.freebsd.org/changeset/base/307064 Log: When downgrading exclusively busied page to shared-busy state, wakeup waiters. Otherwise, owners of the shared-busy state are left blocked and might get into a deadlock. Note that the vm_page_busy_downgrade() function is not used in the tree right now. Reported and tested by: pho (previous version) Reviewed by: alc, markj Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D8195 Modified: head/sys/vm/vm_page.c Modified: head/sys/vm/vm_page.c ============================================================================== --- head/sys/vm/vm_page.c Tue Oct 11 17:47:54 2016 (r307063) +++ head/sys/vm/vm_page.c Tue Oct 11 18:09:37 2016 (r307064) @@ -655,15 +655,26 @@ void vm_page_busy_downgrade(vm_page_t m) { u_int x; + bool locked; vm_page_assert_xbusied(m); + locked = mtx_owned(vm_page_lockptr(m)); for (;;) { x = m->busy_lock; x &= VPB_BIT_WAITERS; + if (x != 0 && !locked) + vm_page_lock(m); if (atomic_cmpset_rel_int(&m->busy_lock, - VPB_SINGLE_EXCLUSIVER | x, VPB_SHARERS_WORD(1) | x)) + VPB_SINGLE_EXCLUSIVER | x, VPB_SHARERS_WORD(1))) break; + if (x != 0 && !locked) + vm_page_unlock(m); + } + if (x != 0) { + wakeup(m); + if (!locked) + vm_page_unlock(m); } } From owner-svn-src-all@freebsd.org Tue Oct 11 18:51:05 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 6F081C0D1C3; Tue, 11 Oct 2016 18:51:05 +0000 (UTC) (envelope-from jilles@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 3052C18C; Tue, 11 Oct 2016 18:51:05 +0000 (UTC) (envelope-from jilles@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9BIp45M069487; Tue, 11 Oct 2016 18:51:04 GMT (envelope-from jilles@FreeBSD.org) Received: (from jilles@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9BIp4Rb069029; Tue, 11 Oct 2016 18:51:04 GMT (envelope-from jilles@FreeBSD.org) Message-Id: <201610111851.u9BIp4Rb069029@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jilles set sender to jilles@FreeBSD.org using -f From: Jilles Tjoelker Date: Tue, 11 Oct 2016 18:51:04 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307065 - in stable/10: sys/kern tests/sys/kern X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Oct 2016 18:51:05 -0000 Author: jilles Date: Tue Oct 11 18:51:03 2016 New Revision: 307065 URL: https://svnweb.freebsd.org/changeset/base/307065 Log: wait: Do not copyout uninitialized status/rusage/wrusage. If wait4() or wait6() return 0 because of WNOHANG, the status, rusage and wrusage information should not be returned. PR: 212048 Reported by: Casey Lucas Added: stable/10/tests/sys/kern/waitpid_nohang.c - copied unchanged from r305676, head/tests/sys/kern/waitpid_nohang.c Modified: stable/10/sys/kern/kern_exit.c stable/10/tests/sys/kern/Makefile Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/kern/kern_exit.c ============================================================================== --- stable/10/sys/kern/kern_exit.c Tue Oct 11 18:09:37 2016 (r307064) +++ stable/10/sys/kern/kern_exit.c Tue Oct 11 18:51:03 2016 (r307065) @@ -785,9 +785,9 @@ sys_wait4(struct thread *td, struct wait else rup = NULL; error = kern_wait(td, uap->pid, &status, uap->options, rup); - if (uap->status != NULL && error == 0) + if (uap->status != NULL && error == 0 && td->td_retval[0] != 0) error = copyout(&status, uap->status, sizeof(status)); - if (uap->rusage != NULL && error == 0) + if (uap->rusage != NULL && error == 0 && td->td_retval[0] != 0) error = copyout(&ru, uap->rusage, sizeof(struct rusage)); return (error); } @@ -821,9 +821,9 @@ sys_wait6(struct thread *td, struct wait */ error = kern_wait6(td, idtype, id, &status, uap->options, wrup, sip); - if (uap->status != NULL && error == 0) + if (uap->status != NULL && error == 0 && td->td_retval[0] != 0) error = copyout(&status, uap->status, sizeof(status)); - if (uap->wrusage != NULL && error == 0) + if (uap->wrusage != NULL && error == 0 && td->td_retval[0] != 0) error = copyout(&wru, uap->wrusage, sizeof(wru)); if (uap->info != NULL && error == 0) error = copyout(&si, uap->info, sizeof(si)); Modified: stable/10/tests/sys/kern/Makefile ============================================================================== --- stable/10/tests/sys/kern/Makefile Tue Oct 11 18:09:37 2016 (r307064) +++ stable/10/tests/sys/kern/Makefile Tue Oct 11 18:51:03 2016 (r307065) @@ -11,6 +11,7 @@ ATF_TESTS_C+= ptrace_test ATF_TESTS_C+= unix_seqpacket_test ATF_TESTS_C+= unix_passfd_test TEST_METADATA.unix_seqpacket_test+= timeout="15" +ATF_TESTS_C+= waitpid_nohang LDADD.ptrace_test+= -lpthread LDADD.unix_seqpacket_test+= -lpthread Copied: stable/10/tests/sys/kern/waitpid_nohang.c (from r305676, head/tests/sys/kern/waitpid_nohang.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/10/tests/sys/kern/waitpid_nohang.c Tue Oct 11 18:51:03 2016 (r307065, copy of r305676, head/tests/sys/kern/waitpid_nohang.c) @@ -0,0 +1,70 @@ +/*- + * Copyright (c) 2016 Jilles Tjoelker + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include + +#include +#include +#include + +ATF_TC_WITHOUT_HEAD(waitpid_nohang); +ATF_TC_BODY(waitpid_nohang, tc) +{ + pid_t child, pid; + int status, r; + + child = fork(); + ATF_REQUIRE(child != -1); + if (child == 0) { + sleep(10); + _exit(1); + } + + status = 42; + pid = waitpid(child, &status, WNOHANG); + ATF_REQUIRE(pid == 0); + ATF_CHECK(status == 42); + + r = kill(child, SIGTERM); + ATF_REQUIRE(r == 0); + r = waitid(P_PID, child, NULL, WEXITED | WNOWAIT); + ATF_REQUIRE(r == 0); + + status = -1; + pid = waitpid(child, &status, WNOHANG); + ATF_REQUIRE(pid == child); + ATF_CHECK(WIFSIGNALED(status) && WTERMSIG(status) == SIGTERM); +} + +ATF_TP_ADD_TCS(tp) +{ + + ATF_TP_ADD_TC(tp, waitpid_nohang); + return (atf_no_error()); +} From owner-svn-src-all@freebsd.org Tue Oct 11 20:32:01 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 228F6C0DEC8; Tue, 11 Oct 2016 20:32:01 +0000 (UTC) (envelope-from br@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id D1B76F6; Tue, 11 Oct 2016 20:32:00 +0000 (UTC) (envelope-from br@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9BKVxrL009109; Tue, 11 Oct 2016 20:31:59 GMT (envelope-from br@FreeBSD.org) Received: (from br@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9BKVx8v009106; Tue, 11 Oct 2016 20:31:59 GMT (envelope-from br@FreeBSD.org) Message-Id: <201610112031.u9BKVx8v009106@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: br set sender to br@FreeBSD.org using -f From: Ruslan Bukin Date: Tue, 11 Oct 2016 20:31:59 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307066 - in head/lib/msun: . src X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Oct 2016 20:32:01 -0000 Author: br Date: Tue Oct 11 20:31:59 2016 New Revision: 307066 URL: https://svnweb.freebsd.org/changeset/base/307066 Log: Don't use fmaxl/fminl on platforms with no long double support, use fmax/fmin instead. This fixes fmaxmin test failure on MIPS64. Reviewed by: emaste Sponsored by: DARPA, AFRL Sponsored by: HEIF5 Differential Revision: https://reviews.freebsd.org/D8216 Modified: head/lib/msun/Makefile head/lib/msun/src/s_fmax.c head/lib/msun/src/s_fmin.c Modified: head/lib/msun/Makefile ============================================================================== --- head/lib/msun/Makefile Tue Oct 11 18:51:03 2016 (r307065) +++ head/lib/msun/Makefile Tue Oct 11 20:31:59 2016 (r307066) @@ -63,8 +63,8 @@ COMMON_SRCS= b_exp.c b_log.c b_tgamma.c s_exp2.c s_exp2f.c s_expm1.c s_expm1f.c s_fabsf.c s_fdim.c \ s_finite.c s_finitef.c \ s_floor.c s_floorf.c s_fma.c s_fmaf.c \ - s_fmax.c s_fmaxf.c s_fmaxl.c s_fmin.c \ - s_fminf.c s_fminl.c s_frexp.c s_frexpf.c s_ilogb.c s_ilogbf.c \ + s_fmax.c s_fmaxf.c s_fmin.c \ + s_fminf.c s_frexp.c s_frexpf.c s_ilogb.c s_ilogbf.c \ s_ilogbl.c s_isfinite.c s_isnan.c s_isnormal.c \ s_llrint.c s_llrintf.c s_llround.c s_llroundf.c s_llroundl.c \ s_log1p.c s_log1pf.c s_logb.c s_logbf.c s_lrint.c s_lrintf.c \ @@ -101,9 +101,9 @@ COMMON_SRCS+= e_acoshl.c e_acosl.c e_asi invtrig.c k_cosl.c k_sinl.c k_tanl.c \ s_asinhl.c s_atanl.c s_cbrtl.c s_ceill.c s_cosl.c s_cprojl.c \ s_csqrtl.c s_erfl.c s_exp2l.c s_expl.c s_floorl.c s_fmal.c \ - s_frexpl.c s_logbl.c s_logl.c s_nanl.c s_nextafterl.c \ - s_nexttoward.c s_remquol.c s_rintl.c s_roundl.c s_scalbnl.c \ - s_sinl.c s_tanhl.c s_tanl.c s_truncl.c w_cabsl.c + s_fmaxl.c s_fminl.c s_frexpl.c s_logbl.c s_logl.c s_nanl.c \ + s_nextafterl.c s_nexttoward.c s_remquol.c s_rintl.c s_roundl.c \ + s_scalbnl.c s_sinl.c s_tanhl.c s_tanl.c s_truncl.c w_cabsl.c .endif # C99 complex functions Modified: head/lib/msun/src/s_fmax.c ============================================================================== --- head/lib/msun/src/s_fmax.c Tue Oct 11 18:51:03 2016 (r307065) +++ head/lib/msun/src/s_fmax.c Tue Oct 11 20:31:59 2016 (r307066) @@ -27,6 +27,7 @@ #include __FBSDID("$FreeBSD$"); +#include #include #include "fpmath.h" @@ -51,3 +52,7 @@ fmax(double x, double y) return (x > y ? x : y); } + +#if (LDBL_MANT_DIG == 53) +__weak_reference(fmax, fmaxl); +#endif Modified: head/lib/msun/src/s_fmin.c ============================================================================== --- head/lib/msun/src/s_fmin.c Tue Oct 11 18:51:03 2016 (r307065) +++ head/lib/msun/src/s_fmin.c Tue Oct 11 20:31:59 2016 (r307066) @@ -27,6 +27,7 @@ #include __FBSDID("$FreeBSD$"); +#include #include #include "fpmath.h" @@ -51,3 +52,7 @@ fmin(double x, double y) return (x < y ? x : y); } + +#if (LDBL_MANT_DIG == 53) +__weak_reference(fmin, fminl); +#endif From owner-svn-src-all@freebsd.org Tue Oct 11 21:37:36 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 6965AC0ED82; Tue, 11 Oct 2016 21:37:36 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 26F7379A; Tue, 11 Oct 2016 21:37:36 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9BLbZCI033473; Tue, 11 Oct 2016 21:37:35 GMT (envelope-from gonzo@FreeBSD.org) Received: (from gonzo@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9BLbZu7033471; Tue, 11 Oct 2016 21:37:35 GMT (envelope-from gonzo@FreeBSD.org) Message-Id: <201610112137.u9BLbZu7033471@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: gonzo set sender to gonzo@FreeBSD.org using -f From: Oleksandr Tymoshenko Date: Tue, 11 Oct 2016 21:37:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307067 - head/sys/arm/broadcom/bcm2835 X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Oct 2016 21:37:36 -0000 Author: gonzo Date: Tue Oct 11 21:37:34 2016 New Revision: 307067 URL: https://svnweb.freebsd.org/changeset/base/307067 Log: Make intc driver compatible with upstream DTS - Fix compatibility strings - Properly decode upstream's two-cell interrupt specs. Our home-made dts does not have two-cell interrupts so no need to preserve backward compatibility Modified: head/sys/arm/broadcom/bcm2835/bcm2835_common.c head/sys/arm/broadcom/bcm2835/bcm2835_intr.c Modified: head/sys/arm/broadcom/bcm2835/bcm2835_common.c ============================================================================== --- head/sys/arm/broadcom/bcm2835/bcm2835_common.c Tue Oct 11 20:31:59 2016 (r307066) +++ head/sys/arm/broadcom/bcm2835/bcm2835_common.c Tue Oct 11 21:37:34 2016 (r307067) @@ -52,7 +52,8 @@ fdt_intc_decode_ic(phandle_t node, pcell int *pol) { - if (fdt_is_compatible(node, "broadcom,bcm2835-armctrl-ic")) { + if (fdt_is_compatible(node, "broadcom,bcm2835-armctrl-ic") || + fdt_is_compatible(node, "brcm,bcm2836-armctrl-ic")) { *interrupt = fdt32_to_cpu(intr[0]); *trig = INTR_TRIGGER_CONFORM; *pol = INTR_POLARITY_CONFORM; Modified: head/sys/arm/broadcom/bcm2835/bcm2835_intr.c ============================================================================== --- head/sys/arm/broadcom/bcm2835/bcm2835_intr.c Tue Oct 11 20:31:59 2016 (r307066) +++ head/sys/arm/broadcom/bcm2835/bcm2835_intr.c Tue Oct 11 21:37:34 2016 (r307067) @@ -270,6 +270,7 @@ bcm_intc_map_intr(device_t dev, struct i u_int irq; struct intr_map_data_fdt *daf; struct bcm_intc_softc *sc; + bool valid; if (data->type != INTR_MAP_DATA_FDT) return (ENOTSUP); @@ -277,8 +278,36 @@ bcm_intc_map_intr(device_t dev, struct i daf = (struct intr_map_data_fdt *)data; if (daf->ncells == 1) irq = daf->cells[0]; - else if (daf->ncells == 2) - irq = daf->cells[0] * 32 + daf->cells[1]; + else if (daf->ncells == 2) { + valid = true; + switch (daf->cells[0]) { + case 0: + irq = daf->cells[1]; + if (irq >= BANK1_START) + valid = false; + break; + case 1: + irq = daf->cells[1] + BANK1_START; + if (irq > BANK1_END) + valid = false; + break; + case 2: + irq = daf->cells[1] + BANK2_START; + if (irq > BANK2_END) + valid = false; + break; + default: + valid = false; + break; + } + + if (!valid) { + device_printf(dev, + "invalid IRQ config: bank=%d, irq=%d\n", + daf->cells[0], daf->cells[1]); + return (EINVAL); + } + } else return (EINVAL); @@ -355,7 +384,8 @@ bcm_intc_probe(device_t dev) if (!ofw_bus_status_okay(dev)) return (ENXIO); - if (!ofw_bus_is_compatible(dev, "broadcom,bcm2835-armctrl-ic")) + if (!ofw_bus_is_compatible(dev, "broadcom,bcm2835-armctrl-ic") && + !ofw_bus_is_compatible(dev, "brcm,bcm2836-armctrl-ic")) return (ENXIO); device_set_desc(dev, "BCM2835 Interrupt Controller"); return (BUS_PROBE_DEFAULT); From owner-svn-src-all@freebsd.org Tue Oct 11 21:40:16 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id ED709C0EE40; Tue, 11 Oct 2016 21:40:16 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id A2DA4958; Tue, 11 Oct 2016 21:40:16 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9BLeFQr033618; Tue, 11 Oct 2016 21:40:15 GMT (envelope-from gonzo@FreeBSD.org) Received: (from gonzo@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9BLeFaS033617; Tue, 11 Oct 2016 21:40:15 GMT (envelope-from gonzo@FreeBSD.org) Message-Id: <201610112140.u9BLeFaS033617@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: gonzo set sender to gonzo@FreeBSD.org using -f From: Oleksandr Tymoshenko Date: Tue, 11 Oct 2016 21:40:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307068 - head/sys/arm/broadcom/bcm2835 X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Oct 2016 21:40:17 -0000 Author: gonzo Date: Tue Oct 11 21:40:15 2016 New Revision: 307068 URL: https://svnweb.freebsd.org/changeset/base/307068 Log: Make Rapsberry Pi watchdog driver compatible with upstream DTS - Fix compatibility strings - Compensate the difference in base address for our custom DTS and upstream one (for backward compatibility) Modified: head/sys/arm/broadcom/bcm2835/bcm2835_wdog.c Modified: head/sys/arm/broadcom/bcm2835/bcm2835_wdog.c ============================================================================== --- head/sys/arm/broadcom/bcm2835/bcm2835_wdog.c Tue Oct 11 21:37:34 2016 (r307067) +++ head/sys/arm/broadcom/bcm2835/bcm2835_wdog.c Tue Oct 11 21:40:15 2016 (r307068) @@ -52,8 +52,8 @@ __FBSDID("$FreeBSD$"); #define BCM2835_WDOG_TIME_MASK 0x000fffff #define BCM2835_WDOG_TIME_SHIFT 0 -#define READ(_sc, _r) bus_space_read_4((_sc)->bst, (_sc)->bsh, (_r)) -#define WRITE(_sc, _r, _v) bus_space_write_4((_sc)->bst, (_sc)->bsh, (_r), (_v)) +#define READ(_sc, _r) bus_space_read_4((_sc)->bst, (_sc)->bsh, (_r) + (_sc)->regs_offset) +#define WRITE(_sc, _r, _v) bus_space_write_4((_sc)->bst, (_sc)->bsh, (_r) + (_sc)->regs_offset, (_v)) #define BCM2835_RSTC_WRCFG_CLR 0xffffffcf #define BCM2835_RSTC_WRCFG_SET 0x00000030 @@ -75,6 +75,17 @@ struct bcmwd_softc { int wdog_period; char wdog_passwd; struct mtx mtx; + int regs_offset; +}; + +#define BSD_DTB 1 +#define UPSTREAM_DTB 2 +#define UPSTREAM_DTB_REGS_OFFSET 0x1c + +static struct ofw_compat_data compat_data[] = { + {"broadcom,bcm2835-wdt", BSD_DTB}, + {"brcm,bcm2835-pm-wdt", UPSTREAM_DTB}, + {NULL, 0} }; static void bcmwd_watchdog_fn(void *private, u_int cmd, int *error); @@ -86,12 +97,12 @@ bcmwd_probe(device_t dev) if (!ofw_bus_status_okay(dev)) return (ENXIO); - if (ofw_bus_is_compatible(dev, "broadcom,bcm2835-wdt")) { - device_set_desc(dev, "BCM2708/2835 Watchdog"); - return (BUS_PROBE_DEFAULT); - } + if (ofw_bus_search_compatible(dev, compat_data)->ocd_data == 0) + return (ENXIO); + + device_set_desc(dev, "BCM2708/2835 Watchdog"); - return (ENXIO); + return (BUS_PROBE_DEFAULT); } static int @@ -119,6 +130,11 @@ bcmwd_attach(device_t dev) sc->bst = rman_get_bustag(sc->res); sc->bsh = rman_get_bushandle(sc->res); + /* compensate base address difference */ + if (ofw_bus_search_compatible(dev, compat_data)->ocd_data + == UPSTREAM_DTB) + sc->regs_offset = UPSTREAM_DTB_REGS_OFFSET; + bcmwd_lsc = sc; mtx_init(&sc->mtx, "BCM2835 Watchdog", "bcmwd", MTX_DEF); EVENTHANDLER_REGISTER(watchdog_list, bcmwd_watchdog_fn, sc, 0); From owner-svn-src-all@freebsd.org Tue Oct 11 21:59:24 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 02A3AC0B241; Tue, 11 Oct 2016 21:59:24 +0000 (UTC) (envelope-from jilles@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id AE88426F; Tue, 11 Oct 2016 21:59:23 +0000 (UTC) (envelope-from jilles@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9BLxMSa041308; Tue, 11 Oct 2016 21:59:22 GMT (envelope-from jilles@FreeBSD.org) Received: (from jilles@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9BLxMCt041306; Tue, 11 Oct 2016 21:59:22 GMT (envelope-from jilles@FreeBSD.org) Message-Id: <201610112159.u9BLxMCt041306@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jilles set sender to jilles@FreeBSD.org using -f From: Jilles Tjoelker Date: Tue, 11 Oct 2016 21:59:22 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307069 - stable/11/lib/libc/sys X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Oct 2016 21:59:24 -0000 Author: jilles Date: Tue Oct 11 21:59:22 2016 New Revision: 307069 URL: https://svnweb.freebsd.org/changeset/base/307069 Log: MFC r305628: intro(2),_exit(2): Update for reaper (procctl(PROC_REAP_ACQUIRE)). Modified: stable/11/lib/libc/sys/_exit.2 stable/11/lib/libc/sys/intro.2 Directory Properties: stable/11/ (props changed) Modified: stable/11/lib/libc/sys/_exit.2 ============================================================================== --- stable/11/lib/libc/sys/_exit.2 Tue Oct 11 21:40:15 2016 (r307068) +++ stable/11/lib/libc/sys/_exit.2 Tue Oct 11 21:59:22 2016 (r307069) @@ -28,7 +28,7 @@ .\" @(#)_exit.2 8.1 (Berkeley) 6/4/93 .\" $FreeBSD$ .\" -.Dd June 4, 1993 +.Dd September 8, 2016 .Dt EXIT 2 .Os .Sh NAME @@ -64,9 +64,11 @@ is set as defined by .Xr wait 2 . .It The parent process-ID of all of the calling process's existing child -processes are set to 1; the initialization process +processes are set to the process-ID of the calling process's reaper; +the reaper (normally the initialization process) inherits each of these processes (see +.Xr procctl 2 , .Xr init 8 and the .Sx DEFINITIONS Modified: stable/11/lib/libc/sys/intro.2 ============================================================================== --- stable/11/lib/libc/sys/intro.2 Tue Oct 11 21:40:15 2016 (r307068) +++ stable/11/lib/libc/sys/intro.2 Tue Oct 11 21:59:22 2016 (r307069) @@ -28,7 +28,7 @@ .\" @(#)intro.2 8.5 (Berkeley) 2/27/95 .\" $FreeBSD$ .\" -.Dd May 4, 2013 +.Dd September 8, 2016 .Dt INTRO 2 .Os .Sh NAME @@ -484,7 +484,10 @@ A new process is created by a currently .Xr fork 2 ) . The parent process ID of a process is initially the process ID of its creator. If the creating process exits, -the parent process ID of each child is set to the ID of a system process, +the parent process ID of each child is set to the ID of the calling process's +reaper (see +.Xr procctl 2 ) , +normally .Xr init 8 . .It Process Group Each active process is a member of a process group that is identified by @@ -533,7 +536,7 @@ when none of its members has a parent pr as the group, but is in a different process group. Note that when a process exits, the parent process for its children -is changed to be +is normally changed to be .Xr init 8 , which is in a separate session. Not all members of an orphaned process group are necessarily orphaned From owner-svn-src-all@freebsd.org Tue Oct 11 22:24:32 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 01145C0BB08; Tue, 11 Oct 2016 22:24:31 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id CC3ED1EA; Tue, 11 Oct 2016 22:24:31 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9BMOUBo053195; Tue, 11 Oct 2016 22:24:30 GMT (envelope-from imp@FreeBSD.org) Received: (from imp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9BMOUlp053188; Tue, 11 Oct 2016 22:24:30 GMT (envelope-from imp@FreeBSD.org) Message-Id: <201610112224.u9BMOUlp053188@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: imp set sender to imp@FreeBSD.org using -f From: Warner Losh Date: Tue, 11 Oct 2016 22:24:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307070 - in head/sys: amd64/amd64 conf dev/efidev i386/include modules/efirt sys X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Oct 2016 22:24:32 -0000 Author: imp Date: Tue Oct 11 22:24:30 2016 New Revision: 307070 URL: https://svnweb.freebsd.org/changeset/base/307070 Log: Create /dev/efidev to provide an ioctl interface to userland. It supports userland interfaces to UEFI Runtime Services. This is indended to the the MI portion of EFI RuntimeServices support. Differential Revision: https://reviews.freebsd.org/D8128 Reviewed by: kib@, wblock@, Ganael Laplanche Added: head/sys/dev/efidev/ head/sys/dev/efidev/efidev.c (contents, props changed) head/sys/i386/include/efi.h (contents, props changed) head/sys/sys/efiio.h (contents, props changed) Modified: head/sys/amd64/amd64/efirt.c head/sys/conf/files head/sys/modules/efirt/Makefile head/sys/sys/efi.h Modified: head/sys/amd64/amd64/efirt.c ============================================================================== --- head/sys/amd64/amd64/efirt.c Tue Oct 11 21:59:22 2016 (r307069) +++ head/sys/amd64/amd64/efirt.c Tue Oct 11 22:24:30 2016 (r307070) @@ -61,6 +61,7 @@ __FBSDID("$FreeBSD$"); static struct efi_systbl *efi_systbl; static struct efi_cfgtbl *efi_cfgtbl; static struct efi_rt *efi_runtime; +static struct cdev *efi_cdev; static int efi_status2err[25] = { 0, /* EFI_SUCCESS */ @@ -402,13 +403,15 @@ efi_init(void) return (ENXIO); } - return (0); + return (efidev_init(&efi_cdev)); } static void efi_uninit(void) { + efidev_uninit(efi_cdev); + efi_destroy_1t1_map(); efi_systbl = NULL; Modified: head/sys/conf/files ============================================================================== --- head/sys/conf/files Tue Oct 11 21:59:22 2016 (r307069) +++ head/sys/conf/files Tue Oct 11 22:24:30 2016 (r307070) @@ -1431,6 +1431,7 @@ dev/ed/if_ed_novell.c optional ed dev/ed/if_ed_rtl80x9.c optional ed dev/ed/if_ed_pccard.c optional ed pccard dev/ed/if_ed_pci.c optional ed pci +dev/efidev/efidev.c optional efirt dev/eisa/eisa_if.m standard dev/eisa/eisaconf.c optional eisa dev/e1000/if_em.c optional em \ Added: head/sys/dev/efidev/efidev.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/dev/efidev/efidev.c Tue Oct 11 22:24:30 2016 (r307070) @@ -0,0 +1,199 @@ +/*- + * Copyright (c) 2016 Netflix, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer + * in this position and unchanged. + * 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 ``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 BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +static d_ioctl_t efidev_ioctl; + +static struct cdevsw efi_cdevsw = { + .d_name = "efi", + .d_version = D_VERSION, + .d_ioctl = efidev_ioctl, +}; + +/* ARGSUSED */ +static int +efidev_ioctl(struct cdev *dev __unused, u_long cmd, caddr_t addr, + int flags __unused, struct thread *td __unused) +{ + int error; + + switch (cmd) { + case EFIIOC_GET_TABLE: + { + struct efi_get_table_ioc *egtioc = + (struct efi_get_table_ioc *)addr; + + error = efi_get_table(&egtioc->uuid, &egtioc->ptr); + break; + } + case EFIIOC_GET_TIME: + { + struct efi_tm *tm = (struct efi_tm *)addr; + + error = efi_get_time(tm); + break; + } + case EFIIOC_SET_TIME: + { + struct efi_tm *tm = (struct efi_tm *)addr; + + error = efi_set_time(tm); + break; + } + case EFIIOC_VAR_GET: + { + struct efi_var_ioc *ev = (struct efi_var_ioc *)addr; + void *data; + efi_char *name; + + data = malloc(ev->datasize, M_TEMP, M_WAITOK); + name = malloc(ev->namesize, M_TEMP, M_WAITOK); + error = copyin(ev->name, name, ev->namesize); + if (error) + goto vg_out; + if (name[ev->namesize / sizeof(efi_char) - 1] != 0) { + error = EINVAL; + goto vg_out; + } + + error = efi_var_get(name, &ev->vendor, &ev->attrib, + &ev->datasize, data); + + if (error == 0) { + error = copyout(data, ev->data, ev->datasize); + } else if (error == EOVERFLOW) { + /* + * Pass back the size we really need, but + * convert the error to 0 so the copyout + * happens. datasize was updated in the + * efi_var_get call. + */ + ev->data = NULL; + error = 0; + } +vg_out: + free(data, M_TEMP); + free(name, M_TEMP); + break; + } + case EFIIOC_VAR_NEXT: + { + struct efi_var_ioc *ev = (struct efi_var_ioc *)addr; + efi_char *name; + + name = malloc(ev->namesize, M_TEMP, M_WAITOK); + if (name == NULL) { + error = ENOMEM; + goto vn_out; + } + error = copyin(ev->name, name, ev->namesize); + if (error) + goto vn_out; + /* Note: namesize is the buffer size, not the string lenght */ + + error = efi_var_nextname(&ev->namesize, name, &ev->vendor); + if (error == 0) { + error = copyout(name, ev->name, ev->namesize); + } else if (error == EOVERFLOW) { + ev->name = NULL; + error = 0; + } + vn_out: + if (name != NULL) + free(name, M_TEMP); + break; + } + case EFIIOC_VAR_SET: + { + struct efi_var_ioc *ev = (struct efi_var_ioc *)addr; + void *data = NULL; + efi_char *name; + + /* datasize == 0 -> delete (more or less) */ + if (ev->datasize > 0) + data = malloc(ev->datasize, M_TEMP, M_WAITOK); + name = malloc(ev->namesize, M_TEMP, M_WAITOK); + if (ev->datasize) { + error = copyin(ev->data, data, ev->datasize); + if (error) + goto vs_out; + } + error = copyin(ev->name, name, ev->namesize); + if (error) + goto vs_out; + if (name[ev->namesize / sizeof(efi_char) - 1] != 0) { + error = EINVAL; + goto vs_out; + } + + error = efi_var_set(name, &ev->vendor, ev->attrib, ev->datasize, + data); +vs_out: + if (data != NULL) + free(data, M_TEMP); + free(name, M_TEMP); + break; + } + default: + error = ENOTTY; + break; + } + + return (error); +} + +int +efidev_init(struct cdev **cdev) +{ + + *cdev = make_dev(&efi_cdevsw, 0, UID_ROOT, GID_WHEEL, 0700, + "efidev"); + + return (0); +} + +int +efidev_uninit(struct cdev *cdev) +{ + + destroy_dev(cdev); + + return (0); +} Added: head/sys/i386/include/efi.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/i386/include/efi.h Tue Oct 11 22:24:30 2016 (r307070) @@ -0,0 +1,39 @@ +/*- + * Copyright (c) 2016 The FreeBSD Foundation + * All rights reserved. + * + * This software was developed by Konstantin Belousov + * under sponsorship from the FreeBSD Foundation. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#ifndef __I386_INCLUDE_EFI_H_ +#define __I386_INCLUDE_EFI_H_ + +#define EFIABI_ATTR /* __attribute__((ms_abi)) */ /* clang fails with this */ + +/* Note: we don't actually support this on i386 yet */ + +#endif /* __I386_INCLUDE_EFI_H_ */ Modified: head/sys/modules/efirt/Makefile ============================================================================== --- head/sys/modules/efirt/Makefile Tue Oct 11 21:59:22 2016 (r307069) +++ head/sys/modules/efirt/Makefile Tue Oct 11 22:24:30 2016 (r307070) @@ -1,9 +1,10 @@ # $FreeBSD$ .PATH: ${.CURDIR}/../../${MACHINE}/${MACHINE} +.PATH: ${.CURDIR}/../../dev/efidev KMOD= efirt -SRCS= efirt.c +SRCS= efirt.c efidev.c SRCS+= device_if.h bus_if.h .include Modified: head/sys/sys/efi.h ============================================================================== --- head/sys/sys/efi.h Tue Oct 11 21:59:22 2016 (r307069) +++ head/sys/sys/efi.h Tue Oct 11 22:24:30 2016 (r307070) @@ -165,6 +165,9 @@ struct efi_systbl { #ifdef _KERNEL extern vm_paddr_t efi_systbl_phys; +struct cdev; +int efidev_init(struct cdev **); +int efidev_uninit(struct cdev *); #endif /* _KERNEL */ #endif /* _SYS_EFI_H_ */ Added: head/sys/sys/efiio.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/sys/efiio.h Tue Oct 11 22:24:30 2016 (r307070) @@ -0,0 +1,59 @@ +/*- + * Copyright (c) 2016 Netflix, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer + * in this position and unchanged. + * 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 ``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 BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#ifndef _SYS_EFIIO_H_ +#define _SYS_EFIIO_H_ + +#include +#include +#include + +struct efi_get_table_ioc +{ + struct uuid uuid; /* UUID to look up */ + void *ptr; /* Pointer to table in KVA space */ +}; + +struct efi_var_ioc +{ + efi_char *name; /* User pointer to name, in wide chars */ + size_t namesize; /* Number of wide characters in name */ + struct uuid vendor; /* Vendor's UUID for variable */ + uint32_t attrib; /* Attributes */ + void *data; /* User pointer to the data */ + size_t datasize; /* Number of *bytes* in the data */ +}; + +#define EFIIOC_GET_TABLE _IOWR('E', 1, struct efi_get_table_ioc) +#define EFIIOC_GET_TIME _IOR('E', 2, struct efi_tm) +#define EFIIOC_SET_TIME _IOW('E', 3, struct efi_tm) +#define EFIIOC_VAR_GET _IOWR('E', 4, struct efi_var_ioc) +#define EFIIOC_VAR_NEXT _IOWR('E', 5, struct efi_var_ioc) +#define EFIIOC_VAR_SET _IOWR('E', 6, struct efi_var_ioc) + +#endif /* _SYS_EFIIO_H_ */ From owner-svn-src-all@freebsd.org Tue Oct 11 22:30:43 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 6C7EFC0BC50; Tue, 11 Oct 2016 22:30:43 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 17EB16C5; Tue, 11 Oct 2016 22:30:43 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9BMUgh4053514; Tue, 11 Oct 2016 22:30:42 GMT (envelope-from imp@FreeBSD.org) Received: (from imp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9BMUfw2053504; Tue, 11 Oct 2016 22:30:41 GMT (envelope-from imp@FreeBSD.org) Message-Id: <201610112230.u9BMUfw2053504@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: imp set sender to imp@FreeBSD.org using -f From: Warner Losh Date: Tue, 11 Oct 2016 22:30:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307071 - in head: lib lib/libefi lib/libefivar share/mk X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Oct 2016 22:30:43 -0000 Author: imp Date: Tue Oct 11 22:30:41 2016 New Revision: 307071 URL: https://svnweb.freebsd.org/changeset/base/307071 Log: Create libefivar library. This library aims to provide the same API as the GPL'd version of this library. It implements the common Linux API for programatically manipulating UEFI environment varibales using the UEFI Runtime Services the kernel provides. It replaces the old efi library since it is programmed to a different interface, but retails the CHAR16 to UTF-8 and vice versa conversion routines. The new name is to match Linux program's expectations. Differential Revision: https://reviews.freebsd.org/D8128 Reviewed by: kib@, wblock@, Ganael Laplanche Added: head/lib/libefivar/ head/lib/libefivar/Makefile (contents, props changed) head/lib/libefivar/efivar.3 (contents, props changed) head/lib/libefivar/efivar.c (contents, props changed) head/lib/libefivar/efivar.h (contents, props changed) head/lib/libefivar/libefivar.c - copied, changed from r307070, head/lib/libefi/libefi.c head/lib/libefivar/libefivar_int.h - copied, changed from r307070, head/lib/libefi/libefi_int.h Deleted: head/lib/libefi/ Modified: head/lib/Makefile head/share/mk/bsd.libnames.mk head/share/mk/src.libnames.mk head/share/mk/src.opts.mk Modified: head/lib/Makefile ============================================================================== --- head/lib/Makefile Tue Oct 11 22:24:30 2016 (r307070) +++ head/lib/Makefile Tue Oct 11 22:30:41 2016 (r307071) @@ -49,6 +49,7 @@ SUBDIR= ${SUBDIR_BOOTSTRAP} \ libdevstat \ libdwarf \ libedit \ + ${_libefivar} \ ${_libelftc} \ libevent \ libexecinfo \ @@ -240,6 +241,10 @@ _libcxxrt= libcxxrt _libcplusplus= libc++ .endif +.if ${MACHINE_ARCH} == "amd64" +_libefivar= libefivar +.endif + .if ${MK_LIBTHR} != "no" _libthr= libthr .endif Added: head/lib/libefivar/Makefile ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/lib/libefivar/Makefile Tue Oct 11 22:30:41 2016 (r307071) @@ -0,0 +1,53 @@ +# Copyright 1998 Juniper Networks, Inc. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# 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$ + +.include + +PACKAGE=lib${LIB} +LIB= efivar +SRCS= efivar.c libefivar.c +INCS= efivar.h +SHLIB_MAJOR= 1 +MAN= efivar.3 + +MLINKS+=efivar.3 efi_set_variables_supported.3 \ + efivar.3 efi_del_variable.3 \ + efivar.3 efi_get_variable.3 \ + efivar.3 efi_get_variable_attributes.3 \ + efivar.3 efi_get_variable_size.3 \ + efivar.3 efi_append_variable.3 \ + efivar.3 efi_set_variable.3 \ + efivar.3 efi_get_next_variable_name.3 \ + efivar.3 efi_str_to_guid.3 \ + efivar.3 efi_guid_to_str.3 \ + efivar.3 efi_name_to_guid.3 \ + efivar.3 efi_guid_to_name.3 \ + efivar.3 efi_guid_to_symbol.3 \ + efivar.3 libefivar.3 + +WARNS?= 9 + +.include Added: head/lib/libefivar/efivar.3 ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/lib/libefivar/efivar.3 Tue Oct 11 22:30:41 2016 (r307071) @@ -0,0 +1,98 @@ +.\" Copyright 2016 Netflix, Inc. +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" $FreeBSD$ +.\" +.Dd September 14, 2016 +.Dt LIBEFIVAR 3 +.Os +.Sh NAME +.Nm libefivar +.Nd EFI Non Volatile Variable Suppoert +.Sh SYNOPSIS +.In efivar.h +.Ft int +.Fn efi_append_variable "efi_guid_t guid" "const char *name" "void *data" "size_t data_size" "uint32_t attributes" +.Ft int +.Fn efi_del_variable "efi_guid_t guid" "const char *name" +.Ft int +.Fn efi_get_variable "efi_guid_t guid" "const char *name" "void **data" "ssize_t *data_size" "uint32_t *attributes" +.Ft int +.Fn efi_get_variable_attributes "efi_guid_t guid" "const char *name" "uint32_t *attributes" +.Ft int +.Fn efi_get_variable_size "efi_guid_t guid" "const char *name" "size_t *size" +.Ft int +.Fn efi_get_next_variable_name "efi_guid_t **guid" "char **name" +.Ft int +.Fn efi_guid_to_name "efi_guid_t *guid" "char **name" +.Ft int +.Fn efi_guid_to_symbol "efi_guid_t *guid" "char **symbol" +.Ft int +.Fn efi_guid_to_str "const efi_guid_t *guid" "char **sp" +.Ft int +.Fn efi_name_to_guid "const char *name" "efi_guid_t *guid" +.Ft int +.Fn efi_set_variable "efi_guid_t guid" "const char *name" "void *data" "size_t data_size" "uint32_t attributes" +.Ft int +.Fn efi_str_to_guid "const char *s" "efi_guid_t *guid"; +.Ft int +.Fn efi_variables_supported "void"; +.Sh DESCRIPTION +The +.Nm +library implements access to EFI Variables via the EFI Runtime +Serivces. +All char * strings are converted to 16-bit UTF strings before passing +them to EFI. +.Pp +.Fn efi_variables_supported +returns non-zero if the current machine supports setting of EFI firmware +variables and the kernel support for doing so is present. +Otherwise zero is returned. +.Pp +.Fn efi_del_variable +deletes the EFI variable selected by +.Dv guid +and +.Dv name . +.Pp +.Fn efi_get_variable +.Fn efi_get_variable_attributes +.Fn efi_get_variable_size +.Fn efi_append_variable +.Fn efi_set_variable +.Fn efi_get_next_variable_name +.Fn efi_str_to_guid +.Fn efi_guid_to_str +.Fn efi_name_to_guid +.Fn efi_guid_to_name +.Fn efi_guid_to_symbol +This function is not actually implemented. +.Sh BUGS +No facilities exist to process the strings as native UTF. +This is a limitation in the Linux libefivar library interface. +.Sh AUTHORS +.An -nosplit +This software was originally written by +.An Warner Losh . Added: head/lib/libefivar/efivar.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/lib/libefivar/efivar.c Tue Oct 11 22:30:41 2016 (r307071) @@ -0,0 +1,380 @@ +/*- + * Copyright (c) 2016 Netflix, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer + * in this position and unchanged. + * 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 ``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 BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "libefivar_int.h" + +static int efi_fd = -2; + +#define Z { 0, 0, 0, 0, 0, { 0 } } + +const efi_guid_t efi_guid_empty = Z; + +static struct uuid_table +{ + const char *uuid_str; + const char *name; + efi_guid_t guid; +} guid_tbl [] = +{ + { "00000000-0000-0000-0000-000000000000", "zero", Z }, + { "093e0fae-a6c4-4f50-9f1b-d41e2b89c19a", "sha512", Z }, + { "0abba7dc-e516-4167-bbf5-4d9d1c739416", "redhat", Z }, + { "0b6e5233-a65c-44c9-9407-d9ab83bfc8bd", "sha224", Z }, + { "126a762d-5758-4fca-8531-201a7f57f850", "lenovo_boot_menu", Z }, + { "3bd2a492-96c0-4079-b420-fcf98ef103ed", "x509_sha256", Z }, + { "3c5766e8-269c-4e34-aa14-ed776e85b3b6", "rsa2048", Z }, + { "3CC24E96-22C7-41D8-8863-8E39DCDCC2CF", "lenovo", Z }, + { "3f7e615b-0d45-4f80-88dc-26b234958560", "lenovo_diag", Z }, + { "446dbf63-2502-4cda-bcfa-2465d2b0fe9d", "x509_sha512", Z }, + { "4aafd29d-68df-49ee-8aa9-347d375665a7", "pkcs7_cert", Z }, + { "605dab50-e046-4300-abb6-3dd810dd8b23", "shim", Z }, + { "665d3f60-ad3e-4cad-8e26-db46eee9f1b5", "lenovo_rescue", Z }, + { "67f8444f-8743-48f1-a328-1eaab8736080", "rsa2048_sha1", Z }, + { "7076876e-80c2-4ee6-aad2-28b349a6865b", "x509_sha384", Z }, + { "721c8b66-426c-4e86-8e99-3457c46ab0b9", "lenovo_setup", Z }, + { "77fa9abd-0359-4d32-bd60-28f4e78f784b", "microsoft", Z }, + { "7FACC7B6-127F-4E9C-9C5D-080F98994345", "lenovo_2", Z }, + { "826ca512-cf10-4ac9-b187-be01496631bd", "sha1", Z }, + { "82988420-7467-4490-9059-feb448dd1963", "lenovo_me_config", Z }, + { "8be4df61-93ca-11d2-aa0d-00e098032b8c", "global", Z }, + { "a5c059a1-94e4-4aa7-87b5-ab155c2bf072", "x509_cert", Z }, + { "a7717414-c616-4977-9420-844712a735bf", "rsa2048_sha256_cert", Z }, + { "a7d8d9a6-6ab0-4aeb-ad9d-163e59a7a380", "lenovo_diag_splash", Z }, + { "ade9e48f-9cb8-98e6-31af-b4e6009e2fe3", "redhat_2", Z }, + { "bc7838d2-0f82-4d60-8316-c068ee79d25b", "lenovo_msg", Z }, + { "c1c41626-504c-4092-aca9-41f936934328", "sha256", Z }, + { "c57ad6b7-0515-40a8-9d21-551652854e37", "shell", Z }, + { "d719b2cb-3d3a-4596-a3bc-dad00e67656f", "security", Z }, + { "e2b36190-879b-4a3d-ad8d-f2e7bba32784", "rsa2048_sha256", Z }, + { "ff3e5307-9fd0-48c9-85f1-8ad56c701e01", "sha384", Z }, + { "f46ee6f4-4785-43a3-923d-7f786c3c8479", "lenovo_startup_interrupt", Z }, + { "ffffffff-ffff-ffff-ffff-ffffffffffff", "zzignore-this-guid", Z }, +}; +#undef Z + +static void +efi_guid_tbl_compile(void) +{ + size_t i; + uint32_t status; + + for (i = 0; i < nitems(guid_tbl); i++) { + uuid_from_string(guid_tbl[i].uuid_str, &guid_tbl[i].guid, + &status); + /* all f's is a bad version, so ignore that error */ + if (status != uuid_s_ok && status != uuid_s_bad_version) + fprintf(stderr, "Can't convert %s to a uuid for %s: %d\n", + guid_tbl[i].uuid_str, guid_tbl[i].name, (int)status); + } +} + +static int +efi_open_dev(void) +{ + + if (efi_fd == -2) + efi_fd = open("/dev/efidev", O_RDWR); + if (efi_fd < 0) + efi_fd = -1; + else + efi_guid_tbl_compile(); + return (efi_fd); +} + +static void +efi_var_reset(struct efi_var_ioc *var) +{ + var->name = NULL; + var->namesize = 0; + memset(&var->vendor, 0, sizeof(var->vendor)); + var->attrib = 0; + var->data = NULL; + var->datasize = 0; +} + +static int +rv_to_linux_rv(int rv) +{ + if (rv == 0) + rv = 1; + else if (errno == ENOENT) { + rv = 0; + errno = 0; + } else + rv = -errno; + return (rv); +} + +int +efi_append_variable(efi_guid_t guid, const char *name, + uint8_t *data, size_t data_size, uint32_t attributes) +{ + + return efi_set_variable(guid, name, data, data_size, + attributes | EFI_VARIABLE_APPEND_WRITE, 0); +} + +int +efi_del_variable(efi_guid_t guid, const char *name) +{ + + /* data_size of 0 deletes the variable */ + return efi_set_variable(guid, name, NULL, 0, 0, 0); +} + +int +efi_get_variable(efi_guid_t guid, const char *name, + uint8_t **data, size_t *data_size, uint32_t *attributes) +{ + struct efi_var_ioc var; + int rv; + static uint8_t buf[1024*32]; + + if (efi_open_dev() == -1) + return -1; + + efi_var_reset(&var); + rv = libefi_utf8_to_ucs2(name, &var.name, &var.namesize); + if (rv != 0) + goto errout; + var.vendor = guid; + var.data = buf; + var.datasize = sizeof(buf); + rv = ioctl(efi_fd, EFIIOC_VAR_GET, &var); + if (data_size != NULL) + *data_size = var.datasize; + if (data != NULL) + *data = buf; + if (attributes != NULL) + *attributes = var.attrib; +errout: + free(var.name); + + return rv_to_linux_rv(rv); +} + +int +efi_get_variable_attributes(efi_guid_t guid, const char *name, + uint32_t *attributes) +{ + /* Make sure this construct works -- I think it will fail */ + + return efi_get_variable(guid, name, NULL, NULL, attributes); +} + +int +efi_get_variable_size(efi_guid_t guid, const char *name, + size_t *size) +{ + + /* XXX check to make sure this matches the linux value */ + + *size = 0; + return efi_get_variable(guid, name, NULL, size, NULL); +} + +int +efi_get_next_variable_name(efi_guid_t **guid, char **name) +{ + struct efi_var_ioc var; + int rv; + static efi_char *buf; + static size_t buflen = 256 * sizeof(efi_char); + static efi_guid_t retguid; + size_t size; + + if (efi_open_dev() == -1) + return -1; + + if (buf == NULL) + buf = malloc(buflen); + +again: + efi_var_reset(&var); + var.name = buf; + var.namesize = buflen; + if (*name == NULL) { + *buf = 0; + /* GUID zeroed in var_reset */ + } else { + rv = libefi_utf8_to_ucs2(*name, &var.name, &size); + if (rv != 0) + goto errout; + var.vendor = **guid; + } + rv = ioctl(efi_fd, EFIIOC_VAR_NEXT, &var); + if (rv == 0 && var.name == NULL) { + /* + * oops, too little space. Try again. + */ + void *new = realloc(buf, buflen); + buflen = var.namesize; + if (new == NULL) { + rv = -1; + errno = ENOMEM; + goto done; + } + buf = new; + goto again; + } + + if (rv == 0) { + *name = NULL; /* XXX */ + var.name[var.namesize / sizeof(efi_char)] = 0; /* EFI doesn't NUL terminate */ + rv = libefi_ucs2_to_utf8(var.name, name); + if (rv != 0) + goto errout; + retguid = var.vendor; + *guid = &retguid; + } +errout: + + /* XXX The linux interface expects name to be a static buffer -- fix or leak memory? */ +done: + return (rv_to_linux_rv(rv)); +} + +int +efi_guid_cmp(const efi_guid_t *guid1, const efi_guid_t *guid2) +{ + uint32_t status; + + return uuid_compare(guid1, guid2, &status); +} + +int +efi_guid_is_zero(const efi_guid_t *guid) +{ + uint32_t status; + + return uuid_is_nil(guid, &status); +} + +int +efi_guid_to_name(efi_guid_t *guid, char **name) +{ + size_t i; + uint32_t status; + + for (i = 0; i < nitems(guid_tbl); i++) { + if (uuid_equal(guid, &guid_tbl[i].guid, &status)) { + *name = strdup(guid_tbl[i].name); + return (0); + } + } + return (efi_guid_to_str(guid, name)); +} + +int +efi_guid_to_symbol(efi_guid_t *guid __unused, char **symbol __unused) +{ + + /* + * Unsure what this is used for, efibootmgr doesn't use it. + * Leave unimplemented for now. + */ + return -1; +} + +int +efi_guid_to_str(const efi_guid_t *guid, char **sp) +{ + uint32_t status; + + /* knows efi_guid_t is a typedef of uuid_t */ + uuid_to_string(guid, sp, &status); + + return (status == uuid_s_ok ? 0 : -1); +} + +int +efi_name_to_guid(const char *name, efi_guid_t *guid) +{ + size_t i; + + for (i = 0; i < nitems(guid_tbl); i++) { + if (strcmp(name, guid_tbl[i].name) == 0) { + *guid = guid_tbl[i].guid; + return (0); + } + } + return (efi_str_to_guid(name, guid)); +} + +int +efi_set_variable(efi_guid_t guid, const char *name, + uint8_t *data, size_t data_size, uint32_t attributes, mode_t mode __unused) +{ + struct efi_var_ioc var; + int rv; + + if (efi_open_dev() == -1) + return -1; + + efi_var_reset(&var); + rv = libefi_utf8_to_ucs2(name, &var.name, &var.namesize); + if (rv != 0) + goto errout; + var.vendor = guid; + var.data = data; + var.datasize = data_size; + var.attrib = attributes; + rv = ioctl(efi_fd, EFIIOC_VAR_SET, &var); +errout: + free(var.name); + + return rv; +} + +int +efi_str_to_guid(const char *s, efi_guid_t *guid) +{ + uint32_t status; + + /* knows efi_guid_t is a typedef of uuid_t */ + uuid_from_string(s, guid, &status); + + return (status == uuid_s_ok ? 0 : -1); +} + +int +efi_variables_supported(void) +{ + + return efi_open_dev() != -1; +} Added: head/lib/libefivar/efivar.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/lib/libefivar/efivar.h Tue Oct 11 22:30:41 2016 (r307071) @@ -0,0 +1,121 @@ +/*- + * Copyright (c) 2016 Netflix, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer + * in this position and unchanged. + * 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 ``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 BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#ifndef _EFIVAR_H_ +#define _EFIVAR_H_ + +#include +#include +#include +#include + +/* Shoud these be elsewhere ? */ +#define EFI_VARIABLE_NON_VOLATILE 0x00000001 +#define EFI_VARIABLE_BOOTSERVICE_ACCESS 0x00000002 +#define EFI_VARIABLE_RUNTIME_ACCESS 0x00000004 +#define EFI_VARIABLE_HARDWARE_ERROR_RECORD 0x00000008 +#define EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS 0x00000010 +#define EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS \ + 0x00000020 +#define EFI_VARIABLE_APPEND_WRITE 0x00000040 +#if 0 /* todo */ +#define EFI_VARIABLE_HAS_AUTH_HEADER +#define EFI_VARIABLE_HAS_SIGNATURE +#endif + + +typedef uuid_t efi_guid_t; +#if BYTE_ORDER == LITTLE_ENDIAN +#define EFI_GUID(a, b, c, d, e0, e1, e2, e3, e4, e5) \ + ((efi_guid_t) {(a), (b), (c), (d) >> 8, (d) & 0xff, \ + { (e0), (e1), (e2), (e3), (e4), (e5) }}) +#else +#define EFI_GUID(a, b, c, d, e0, e1, e2, e3, e4, e5) \ + ((efi_guid_t) {(a), (b), (c), (d) & 0xff, (d) >> 8, \ + { (e0), (e1), (e2), (e3), (e4), (e5) }}) +#endif + +#define EFI_GLOBAL_GUID EFI_GUID(0x8be4df61, 0x93ca, 0x11d2, 0xaa0d, \ + 0x00, 0xe0, 0x98, 0x03, 0x2b, 0x8c) + +int efi_append_variable(efi_guid_t guid, const char *name, + uint8_t *data, size_t data_size, uint32_t attributes); +int efi_del_variable(efi_guid_t guid, const char *name); +int efi_get_variable(efi_guid_t guid, const char *name, + uint8_t **data, size_t *data_size, uint32_t *attributes); +int efi_get_variable_attributes(efi_guid_t guid, const char *name, + uint32_t *attributes); +int efi_get_variable_size(efi_guid_t guid, const char *name, size_t *size); +int efi_get_next_variable_name(efi_guid_t **guid, char **name); +int efi_guid_cmp(const efi_guid_t *guid1, const efi_guid_t *guid2); +int efi_guid_is_zero(const efi_guid_t *guid1); +int efi_guid_to_name(efi_guid_t *guid, char **name); +int efi_guid_to_symbol(efi_guid_t *guid, char **symbol); +int efi_guid_to_str(const efi_guid_t *guid, char **sp); +int efi_name_to_guid(const char *name, efi_guid_t *guid); +int efi_set_variable(efi_guid_t guid, const char *name, + uint8_t *data, size_t data_size, uint32_t attributes, mode_t mode); +int efi_str_to_guid(const char *s, efi_guid_t *guid); +int efi_variables_supported(void); + +extern const efi_guid_t efi_guid_empty; + +/* Stubs that are expected, but aren't really used */ +static inline int +efi_error_get(unsigned int n __unused, char ** const fn __unused, + char ** const func __unused, int *line __unused, + char ** const msg __unused, int *err __unused) +{ + return 0; +} + +static inline int +efi_error_set(const char *fn __unused, const char *func __unused, + int line __unused, int err __unused, const char *fmt __unused, ...) +{ + return 0; +} + +static inline void +efi_error_clear(void) +{ +} + +static inline int +efi_error(const char *fmt __unused, ...) +{ + return 0; +} + +static inline int +efi_error_val(int val __unused, const char *fmt __unused, ...) +{ + return 0; +} + +#endif /* _EFIVAR_H_ */ Copied and modified: head/lib/libefivar/libefivar.c (from r307070, head/lib/libefi/libefi.c) ============================================================================== --- head/lib/libefi/libefi.c Tue Oct 11 22:24:30 2016 (r307070, copy source) +++ head/lib/libefivar/libefivar.c Tue Oct 11 22:30:41 2016 (r307071) @@ -27,86 +27,105 @@ #include __FBSDID("$FreeBSD$"); -#include #include -#include +#include #include #include #include #include +#include +#include -#include "libefi_int.h" +#include "libefivar_int.h" -static int __iofd = -1; +#include -static void -iodev_fd_close(void) +/* + * If nm were converted to utf8, what what would strlen + * return on the resulting string? + */ +static size_t +utf8_len_of_ucs2(const efi_char *nm) { + size_t len; + efi_char c; - close(__iofd); -} - -static int -iodev_fd(int *fd) -{ - - *fd = __iofd; - if (__iofd != -1) - return (0); - - __iofd = open("/dev/io", O_RDWR); - if (__iofd == -1) - return (errno); + len = 0; + while (*nm) { + c = *nm++; + if (c > 0x7ff) + len += 3; + else if (c > 0x7f) + len += 2; + else + len++; + } - atexit(iodev_fd_close); - *fd = __iofd; - return (0); + return (len); } int -libefi_ucs2_to_utf8(u_short *nm, size_t *szp, char *name) +libefi_ucs2_to_utf8(const efi_char *nm, char **name) { size_t len, sz; - u_short c; + efi_char c; + char *cp; + int freeit = *name == NULL; + sz = utf8_len_of_ucs2(nm) + 1; len = 0; - sz = *szp; + if (*name != NULL) + cp = *name; + else + cp = *name = malloc(sz); + if (*name == NULL) + return (ENOMEM); + while (*nm) { c = *nm++; if (c > 0x7ff) { if (len++ < sz) - *name++ = 0xE0 | (c >> 12); + *cp++ = (char)(0xE0 | (c >> 12)); if (len++ < sz) - *name++ = 0x80 | ((c >> 6) & 0x3f); + *cp++ = (char)(0x80 | ((c >> 6) & 0x3f)); if (len++ < sz) - *name++ = 0x80 | (c & 0x3f); + *cp++ = (char)(0x80 | (c & 0x3f)); } else if (c > 0x7f) { if (len++ < sz) - *name++ = 0xC0 | ((c >> 6) & 0x1f); + *cp++ = (char)(0xC0 | ((c >> 6) & 0x1f)); if (len++ < sz) - *name++ = 0x80 | (c & 0x3f); + *cp++ = (char)(0x80 | (c & 0x3f)); } else { if (len++ < sz) - *name++ = (c & 0x7f); + *cp++ = (char)(c & 0x7f); } } - if (len++ < sz) - *name++ = 0; - *szp = len; - return ((len <= sz) ? 0 : EOVERFLOW); + if (len >= sz) { + /* Absent bugs, we'll never return EOVERFLOW */ + if (freeit) + free(*name); + return (EOVERFLOW); + } + *cp++ = '\0'; + + return (0); } int -libefi_utf8_to_ucs2(char *name, size_t *szp, u_short **nmp) +libefi_utf8_to_ucs2(const char *name, efi_char **nmp, size_t *len) { - u_short *nm; + efi_char *nm; size_t sz; uint32_t ucs4; int c, bytes; + int freeit = *nmp == NULL; - *szp = sz = (*szp == 0) ? strlen(name) * 2 + 2 : *szp; - *nmp = nm = malloc(sz); + sz = strlen(name) * 2 + 2; + if (*nmp == NULL) + *nmp = malloc(sz); + nm = *nmp; + *len = sz; ucs4 = 0; bytes = 0; @@ -119,7 +138,8 @@ libefi_utf8_to_ucs2(char *name, size_t * if ((c & 0xc0) != 0x80) { /* Initial characters. */ if (bytes != 0) { - free(nm); + if (freeit) + free(nm); return (EILSEQ); } if ((c & 0xf8) == 0xf0) { @@ -141,36 +161,28 @@ libefi_utf8_to_ucs2(char *name, size_t * ucs4 = (ucs4 << 6) + (c & 0x3f); bytes--; } else if (bytes == 0) { - free(nm); + if (freeit) + free(nm); return (EILSEQ); } } if (bytes == 0) { if (ucs4 > 0xffff) { - free(nm); + if (freeit) + free(nm); return (EILSEQ); } - *nm++ = (u_short)ucs4; + *nm++ = (efi_char)ucs4; sz -= 2; } } if (sz < 2) { - free(nm); + if (freeit) + free(nm); return (EDOOFUS); } + sz -= 2; *nm = 0; + *len -= sz; return (0); } - -int -libefi_efivar(struct iodev_efivar_req *req) -{ - int error, fd; - - error = iodev_fd(&fd); - if (!error) - error = (ioctl(fd, IODEV_EFIVAR, req) == -1) ? errno : 0; - if (!error) - error = req->result; - return (error); -} Copied and modified: head/lib/libefivar/libefivar_int.h (from r307070, head/lib/libefi/libefi_int.h) ============================================================================== --- head/lib/libefi/libefi_int.h Tue Oct 11 22:24:30 2016 (r307070, copy source) +++ head/lib/libefivar/libefivar_int.h Tue Oct 11 22:30:41 2016 (r307071) @@ -29,12 +29,7 @@ #ifndef _LIBEFI_INT_H_ #define _LIBEFI_INT_H_ -#include -#include - -int libefi_ucs2_to_utf8(u_short *, size_t *, char *); -int libefi_utf8_to_ucs2(char *, size_t *, u_short **); - -int libefi_efivar(struct iodev_efivar_req *); +int libefi_ucs2_to_utf8(const efi_char *, char **); +int libefi_utf8_to_ucs2(const char *, efi_char **, size_t *); #endif /* _LIBEFI_INT_H_ */ Modified: head/share/mk/bsd.libnames.mk ============================================================================== --- head/share/mk/bsd.libnames.mk Tue Oct 11 22:24:30 2016 (r307070) +++ head/share/mk/bsd.libnames.mk Tue Oct 11 22:30:41 2016 (r307071) @@ -59,6 +59,7 @@ LIBDPV?= ${DESTDIR}${LIBDIR}/libdpv.a LIBDTRACE?= ${DESTDIR}${LIBDIR}/libdtrace.a LIBDWARF?= ${DESTDIR}${LIBDIR}/libdwarf.a LIBEDIT?= ${DESTDIR}${LIBDIR}/libedit.a +LIBEFIVAR?= ${DESTDIR}${LIBDIR}/libefivar.a LIBELF?= ${DESTDIR}${LIBDIR}/libelf.a LIBEXECINFO?= ${DESTDIR}${LIBDIR}/libexecinfo.a LIBFETCH?= ${DESTDIR}${LIBDIR}/libfetch.a Modified: head/share/mk/src.libnames.mk ============================================================================== --- head/share/mk/src.libnames.mk Tue Oct 11 22:24:30 2016 (r307070) +++ head/share/mk/src.libnames.mk Tue Oct 11 22:30:41 2016 (r307071) @@ -91,6 +91,7 @@ _LIBRARIES= \ dtrace \ dwarf \ edit \ + efivar \ elf \ execinfo \ fetch \ Modified: head/share/mk/src.opts.mk ============================================================================== --- head/share/mk/src.opts.mk Tue Oct 11 22:24:30 2016 (r307070) +++ head/share/mk/src.opts.mk Tue Oct 11 22:30:41 2016 (r307071) @@ -82,6 +82,7 @@ __DEFAULT_YES_OPTIONS = \ DYNAMICROOT \ ED_CRYPTO \ EE \ + EFI \ ELFTOOLCHAIN_BOOTSTRAP \ EXAMPLES \ FDT \ @@ -263,6 +264,9 @@ BROKEN_OPTIONS+=LIBSOFT .if ${__T:Mmips*} BROKEN_OPTIONS+=SSP .endif +.if ${__T:Mmips*} || ${__T:Mpowerpc*} || ${__T:Msparc64} || ${__T:Mriscv*} +BROKEN_OPTIONS+=EFI +.endif .include From owner-svn-src-all@freebsd.org Tue Oct 11 22:31:47 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 6A55BC0BCB2; Tue, 11 Oct 2016 22:31:47 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 3B915959; Tue, 11 Oct 2016 22:31:47 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9BMVkmt056212; Tue, 11 Oct 2016 22:31:46 GMT (envelope-from imp@FreeBSD.org) Received: (from imp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9BMVk8K056208; Tue, 11 Oct 2016 22:31:46 GMT (envelope-from imp@FreeBSD.org) Message-Id: <201610112231.u9BMVk8K056208@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: imp set sender to imp@FreeBSD.org using -f From: Warner Losh Date: Tue, 11 Oct 2016 22:31:46 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307072 - in head/usr.sbin: . efivar X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Oct 2016 22:31:47 -0000 Author: imp Date: Tue Oct 11 22:31:45 2016 New Revision: 307072 URL: https://svnweb.freebsd.org/changeset/base/307072 Log: Add efivar(1) to manipulate EFI variables. It uses a similar command line interface to the Linux program, as well as adding a number of useful features to make using it in shell scripts easier (since we don't have a filesystem to fall back on interacting with). Differential Revision: https://reviews.freebsd.org/D8128 Reviewed by: kib@, wblock@, Ganael Laplanche Added: head/usr.sbin/efivar/ head/usr.sbin/efivar/Makefile (contents, props changed) head/usr.sbin/efivar/efivar.8 (contents, props changed) head/usr.sbin/efivar/efivar.c (contents, props changed) Modified: head/usr.sbin/Makefile Modified: head/usr.sbin/Makefile ============================================================================== --- head/usr.sbin/Makefile Tue Oct 11 22:30:41 2016 (r307071) +++ head/usr.sbin/Makefile Tue Oct 11 22:31:45 2016 (r307072) @@ -123,6 +123,7 @@ SUBDIR.${MK_BSNMP}+= bsnmpd SUBDIR.${MK_CTM}+= ctm SUBDIR.${MK_DIALOG}+= tzsetup SUBDIR.${MK_DIALOG}+= bsdconfig +SUBDIR.${MK_EFI}+= efivar SUBDIR.${MK_FLOPPY}+= fdcontrol SUBDIR.${MK_FLOPPY}+= fdformat SUBDIR.${MK_FLOPPY}+= fdread Added: head/usr.sbin/efivar/Makefile ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/usr.sbin/efivar/Makefile Tue Oct 11 22:31:45 2016 (r307072) @@ -0,0 +1,8 @@ +# $FreeBSD$ + +PROG= efivar +MAN= efivar.8 + +LIBADD= efivar + +.include Added: head/usr.sbin/efivar/efivar.8 ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/usr.sbin/efivar/efivar.8 Tue Oct 11 22:31:45 2016 (r307072) @@ -0,0 +1,164 @@ +.\" Copyright (c) 2003 Netflix, Inc +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" $FreeBSD$ +.\" +.Dd September 29, 2016 +.Dt EFIVAR 8 +.Os +.Sh NAME +.Nm efivar +.Nd UEFI environemnt variable interaction +.Sh SYNOPSIS +.Nm +.Op Fl abdDHlLNpRtw +.Op Fl n Ar name +.Op Fl f Ar file +.Op Fl -append +.Op Fl -ascii +.Op Fl -attributes +.Op Fl -binary +.Op Fl -delete +.Op Fl -fromfile Ar file +.Op Fl -hex +.Op Fl -list-guids +.Op Fl -list +.Op Fl -name Ar name +.Op Fl -no-name +.Op Fl -print +.Op Fl -print-decimal +.Op Fl -raw-guid +.Op Fl -write +.Ar name Ns Op = Ns Ar value +.Sh DESCRIPTION +This program manages +.Dq Unified Extensible Firmware Interface +.Pq UEFI +environment variables. +UEFI variables have three part: A namespace, a name and a value. +The namespace is a GUID that's self assigned by the group defining the +variables. +The name is a Unicode name for the variable. +The value is binary data. +All Unicode data is presented to the user as UTF-8. +.Pp +The following options are available: +.Bl -tag -width 20m +.It Fl n Ar name Fl -name Ar name +Specify the name of the variable to operate on. +The +.Ar name +argument is the GUID of variable, followed by a dash, followed by the +UEFI variable name. +The GUID may be in numeric format, or may be one of the well known +symbolic name (see +.Fl -list-guids +for a complete list). +.It Fl f Ar file Fl -fromfile Ar file +When writing or appending to a variable, take the data for the +variable's value from +.Ar file +instead of from the command line. +This flag implies +.Fl -write +unless the +.Fl -append +flag is given. +This is not well understood and currently unimplemented. +.It Fl a Fl -append +Append the specified value to the UEFI variable rather than replacing +it.p +.It Fl t Ar attr Fl -attributes Ar attr +Specify, in user hostile hexidecimal, the attributes for this +variable. +See section 7.2 (GetVariable subsection, Related Definitions) of the +UEFI Specification for hex values to use. +.It Fl A Fl -ascii +Display the variable data as modified ascii: All printable characters +are printed, while unprintable characters are rendered as a two-digit +hexadecimal number preceeded by a % character. +.It Fl A Fl -binary +Display the variable data as binary data. +Usually will be used with the +.Fl N +or +.Fl -no-name +flag. +Useful in scripts. +.It Fl D Fl -delete +Delete the specified variable. +May not be used with either the +.Fl -write +or the +.Fl -append +flags. +No +.Ar value +may be specified. +.It Fl H Fl -hex +List variable data as a hex dump. +.It Fl L Fl -list-guids +Lists the well known GUIDs. +The names listed here may be used in place of the numeric GUID values. +These names will replace the numeric GUID values unless +.Fl -raw-guid +flag is specified. +.It Fl l Fl -list +List all the variables. +If the +.Fl -print +flag is also listed, their values will be displayed. +.It Fl N Fl -no-name +Do not display the variable name. +.It Fl p Fl -print +Print the value of the variable. +.It Fl d Fl -print-decimal +Treat the value of the variable as a number and print it as a +decimal. +This is currently unimplemented. +.It Fl R Fl -raw-guid +Do not substitute well known names for GUID numeric values in output. +.It Fl w Fl -write +Write (replace) the variable specified with the value specified. +.It Ar name +Display the +.Ar name +environment variable. +.It Ar name Ns = Ns Ar value +Set the specified +.Ar name +to +.Ar value . +This is not yet implemented. +.Sh COMPATIBILITY +The +.Nm +program is intended to be compatible (strict superset) with a progam +of the same name included in the Red Hat libefivar package. +.Sh SEE ALSO +Appendix A of the UEFI specification has the format for GUIDs. +All GUIDs +.Dq Globally Unique Identifiers +have the format described in RFC 4122. +.El Added: head/usr.sbin/efivar/efivar.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/usr.sbin/efivar/efivar.c Tue Oct 11 22:31:45 2016 (r307072) @@ -0,0 +1,349 @@ +/*- + * Copyright (c) 2016 Netflix, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY NETAPP, INC ``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 NETAPP, INC OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* options descriptor */ +static struct option longopts[] = { + { "append", no_argument, NULL, 'a' }, + { "ascii", no_argument, NULL, 'A' }, + { "attributes", required_argument, NULL, 't' }, + { "binary", no_argument, NULL, 'b' }, + { "delete", no_argument, NULL, 'D' }, + { "fromfile", required_argument, NULL, 'f' }, + { "hex", no_argument, NULL, 'H' }, + { "list-guids", no_argument, NULL, 'L' }, + { "list", no_argument, NULL, 'l' }, + { "name", required_argument, NULL, 'n' }, + { "no-name", no_argument, NULL, 'N' }, + { "print", no_argument, NULL, 'p' }, + { "print-decimal", no_argument, NULL, 'd' }, + { "raw-guid", no_argument, NULL, 'R' }, + { "write", no_argument, NULL, 'w' }, + { NULL, 0, NULL, 0 } +}; + + +static int aflag, Aflag, bflag, dflag, Dflag, Hflag, Nflag, + lflag, Lflag, Rflag, wflag, pflag; +static char *varname; +static u_long attrib = 0x7; + +static void +usage(void) +{ + + errx(1, "efivar [-abdDHlLNpRtw] [-n name] [-f file] [--append] [--ascii]\n" + "\t[--attributes] [--binary] [--delete] [--fromfile file] [--hex]\n" + "\t[--list-guids] [--list] [--name name] [--no-name] [--print]\n" + "\t[--print-decimal] [--raw-guid] [--write] name[=value]"); +} + +static void +breakdown_name(char *name, efi_guid_t *guid, char **vname) +{ + char *cp; + + cp = strrchr(name, '-'); + if (cp == NULL) + errx(1, "Invalid name: %s", name); + *vname = cp + 1; + *cp = '\0'; + if (efi_str_to_guid(name, guid) < 0) + errx(1, "Invalid guid %s", name); +} + +static uint8_t * +get_value(char *val, size_t *datalen) +{ + static char buffer[16*1024]; + + if (val != NULL) { + *datalen = strlen(val); + return ((uint8_t *)val); + } + /* Read from stdin */ + *datalen = sizeof(buffer); + *datalen = read(0, buffer, *datalen); + return ((uint8_t *)buffer); +} + +static void +append_variable(char *name, char *val) +{ + char *vname; + efi_guid_t guid; + size_t datalen; + uint8_t *data; + + breakdown_name(name, &guid, &vname); + data = get_value(val, &datalen); + if (efi_append_variable(guid, vname, data, datalen, attrib) < 0) + err(1, "efi_append_variable"); +} + +static void +delete_variable(char *name) +{ + char *vname; + efi_guid_t guid; + + breakdown_name(name, &guid, &vname); + if (efi_del_variable(guid, vname) < 0) + err(1, "efi_del_variable"); +} + +static void +write_variable(char *name, char *val) +{ + char *vname; + efi_guid_t guid; + size_t datalen; + uint8_t *data; + + breakdown_name(name, &guid, &vname); + data = get_value(val, &datalen); + if (efi_set_variable(guid, vname, data, datalen, attrib, 0) < 0) + err(1, "efi_set_variable"); +} + +static void +asciidump(uint8_t *data, size_t datalen) +{ + size_t i; + int len; + + len = 0; + if (!Nflag) + printf("\n"); + for (i = 0; i < datalen; i++) { + if (isprint(data[i])) { + len++; + if (len > 80) { + len = 0; + printf("\n"); + } + printf("%c", data[i]); + } else { + len +=3; + if (len > 80) { + len = 0; + printf("\n"); + } + printf("%%%02x", data[i]); + } + } + printf("\n"); +} + +static void +hexdump(uint8_t *data, size_t datalen) +{ + size_t i; + + if (!Nflag) + printf("\n"); + for (i = 0; i < datalen; i++) { + if (i % 16 == 0) { + if (i != 0) + printf("\n"); + printf("%04x: ", (int)i); + } + printf("%02x ", data[i]); + } + printf("\n"); +} + +static void +bindump(uint8_t *data, size_t datalen) +{ + write(1, data, datalen); +} + +static void +print_var(efi_guid_t *guid, char *name) +{ + uint32_t att; + uint8_t *data; + size_t datalen; + char *gname; + int rv; + + efi_guid_to_str(guid, &gname); + if (!Nflag) + printf("%s-%s", gname, name); + if (pflag) { + rv = efi_get_variable(*guid, name, &data, &datalen, &att); + + if (rv < 0) + printf("\n --- Error getting value --- %d", errno); + else { + if (Aflag) + asciidump(data, datalen); + else if (bflag) + bindump(data, datalen); + else + hexdump(data, datalen); + } + } + free(gname); + if (!Nflag) + printf("\n"); +} + +static void +print_variable(char *name) +{ + char *vname; + efi_guid_t guid; + + breakdown_name(name, &guid, &vname); + print_var(&guid, vname); +} + +static void +print_variables(void) +{ + int rv; + char *name = NULL; + efi_guid_t *guid = NULL; + + while ((rv = efi_get_next_variable_name(&guid, &name)) > 0) + print_var(guid, name); + + if (rv < 0) + err(1, "Error listing names"); +} + +static void +parse_args(int argc, char **argv) +{ + int ch, i; + + while ((ch = getopt_long(argc, argv, "aAbdDf:HlLNn:pRt:w", + longopts, NULL)) != -1) { + switch (ch) { + case 'a': + aflag++; + break; + case 'A': + Aflag++; + break; + case 'b': + bflag++; + break; + case 'd': + dflag++; + break; + case 'D': + Dflag++; + break; + case 'H': + Hflag++; + break; + case 'l': + lflag++; + break; + case 'L': + Lflag++; + break; + case 'n': + varname = optarg; + break; + case 'N': + Nflag++; + break; + case 'p': + pflag++; + break; + case 'R': + Rflag++; + break; + case 'w': + wflag++; + break; + case 'f': + case 't': + case 0: + errx(1, "unknown or unimplemented option\n"); + break; + default: + usage(); + } + } + argc -= optind; + argv += optind; + + if (argc == 1) + varname = argv[0]; + + if (aflag + Dflag + wflag > 1) { + warnx("Can only use one of -a (--append), " + "-D (--delete) and -w (--write)"); + usage(); + } + + if (aflag + Dflag + wflag > 0 && varname == NULL) { + warnx("Must specify a variable for -a (--append), " + "-D (--delete) or -w (--write)"); + usage(); + } + + if (aflag) + append_variable(varname, NULL); + else if (Dflag) + delete_variable(varname); + else if (wflag) + write_variable(varname, NULL); + else if (varname) { + pflag++; + print_variable(varname); + } else if (argc > 0) { + pflag++; + for (i = 0; i < argc; i++) + print_variable(argv[i]); + } else + print_variables(); +} + +int +main(int argc, char **argv) +{ + + parse_args(argc, argv); +} From owner-svn-src-all@freebsd.org Tue Oct 11 22:32:13 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A2367C0BDF2; Tue, 11 Oct 2016 22:32:13 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 70FD0BF0; Tue, 11 Oct 2016 22:32:13 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9BMWCHM056272; Tue, 11 Oct 2016 22:32:12 GMT (envelope-from imp@FreeBSD.org) Received: (from imp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9BMWCmG056271; Tue, 11 Oct 2016 22:32:12 GMT (envelope-from imp@FreeBSD.org) Message-Id: <201610112232.u9BMWCmG056271@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: imp set sender to imp@FreeBSD.org using -f From: Warner Losh Date: Tue, 11 Oct 2016 22:32:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307073 - head/sys/modules/bwn X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Oct 2016 22:32:13 -0000 Author: imp Date: Tue Oct 11 22:32:12 2016 New Revision: 307073 URL: https://svnweb.freebsd.org/changeset/base/307073 Log: Properly include the 802.11n PHY support files when the BWM_GPL_PHY option is included. Remove the comment suggesting that people uncomment things because it is OBE. Modified: head/sys/modules/bwn/Makefile Modified: head/sys/modules/bwn/Makefile ============================================================================== --- head/sys/modules/bwn/Makefile Tue Oct 11 22:31:45 2016 (r307072) +++ head/sys/modules/bwn/Makefile Tue Oct 11 22:32:12 2016 (r307073) @@ -14,17 +14,15 @@ SRCS+= if_bwn_phy_n.c # Other SRCS+= device_if.h bus_if.h pci_if.h opt_bwn.h opt_wlan.h -# Uncomment this for the GPL PHY code; this requires the -# module be built with BWN_GPL_PHY set in the kernel -# configuration. - -#.PATH: ${.CURDIR}/../../gnu/dev/bwn/phy_n -#SRCS+= if_bwn_radio_2055.c -#SRCS+= if_bwn_radio_2056.c -#SRCS+= if_bwn_radio_2057.c -#SRCS+= if_bwn_phy_n_tables.c -#SRCS+= if_bwn_phy_n_ppr.c -#SRCS+= if_bwn_phy_n_core.c +# The following need the BWN_GPL_PHY kenrel option to opt-in +# to the GPL'd 802.11n PHY support for this driver. +.PATH: ${.CURDIR}/../../gnu/dev/bwn/phy_n +SRCS.BWN_GPL_PHY+= if_bwn_radio_2055.c +SRCS.BWN_GPL_PHY+= if_bwn_radio_2056.c +SRCS.BWN_GPL_PHY+= if_bwn_radio_2057.c +SRCS.BWN_GPL_PHY+= if_bwn_phy_n_tables.c +SRCS.BWN_GPL_PHY+= if_bwn_phy_n_ppr.c +SRCS.BWN_GPL_PHY+= if_bwn_phy_n_core.c .include From owner-svn-src-all@freebsd.org Tue Oct 11 22:54:31 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 25060C0D274; Tue, 11 Oct 2016 22:54:31 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id F383C8FA; Tue, 11 Oct 2016 22:54:30 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9BMsUea064401; Tue, 11 Oct 2016 22:54:30 GMT (envelope-from imp@FreeBSD.org) Received: (from imp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9BMsTQW064396; Tue, 11 Oct 2016 22:54:29 GMT (envelope-from imp@FreeBSD.org) Message-Id: <201610112254.u9BMsTQW064396@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: imp set sender to imp@FreeBSD.org using -f From: Warner Losh Date: Tue, 11 Oct 2016 22:54:29 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307074 - in head/sys: mips/include pc98/include powerpc/include riscv/include sparc64/include X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Oct 2016 22:54:31 -0000 Author: imp Date: Tue Oct 11 22:54:29 2016 New Revision: 307074 URL: https://svnweb.freebsd.org/changeset/base/307074 Log: Include stubs even on the platforms we don't support so libsysdecode continues to build. Added: head/sys/mips/include/efi.h - copied, changed from r307073, head/sys/i386/include/efi.h head/sys/pc98/include/efi.h - copied, changed from r307073, head/sys/i386/include/efi.h head/sys/powerpc/include/efi.h - copied, changed from r307073, head/sys/i386/include/efi.h head/sys/riscv/include/efi.h - copied, changed from r307073, head/sys/i386/include/efi.h head/sys/sparc64/include/efi.h - copied, changed from r307073, head/sys/i386/include/efi.h Copied and modified: head/sys/mips/include/efi.h (from r307073, head/sys/i386/include/efi.h) ============================================================================== --- head/sys/i386/include/efi.h Tue Oct 11 22:32:12 2016 (r307073, copy source) +++ head/sys/mips/include/efi.h Tue Oct 11 22:54:29 2016 (r307074) @@ -29,11 +29,11 @@ * $FreeBSD$ */ -#ifndef __I386_INCLUDE_EFI_H_ -#define __I386_INCLUDE_EFI_H_ +#ifndef __MIPS_INCLUDE_EFI_H_ +#define __MIPS_INCLUDE_EFI_H_ -#define EFIABI_ATTR /* __attribute__((ms_abi)) */ /* clang fails with this */ +#define EFIABI_ATTR -/* Note: we don't actually support this on i386 yet */ +/* Note: we don't actually support this on mips */ -#endif /* __I386_INCLUDE_EFI_H_ */ +#endif /* __MIPS_INCLUDE_EFI_H_ */ Copied and modified: head/sys/pc98/include/efi.h (from r307073, head/sys/i386/include/efi.h) ============================================================================== --- head/sys/i386/include/efi.h Tue Oct 11 22:32:12 2016 (r307073, copy source) +++ head/sys/pc98/include/efi.h Tue Oct 11 22:54:29 2016 (r307074) @@ -29,11 +29,11 @@ * $FreeBSD$ */ -#ifndef __I386_INCLUDE_EFI_H_ -#define __I386_INCLUDE_EFI_H_ +#ifndef __PC98_INCLUDE_EFI_H_ +#define __PC98_INCLUDE_EFI_H_ -#define EFIABI_ATTR /* __attribute__((ms_abi)) */ /* clang fails with this */ +#define EFIABI_ATTR -/* Note: we don't actually support this on i386 yet */ +/* Note: we don't actually support this on pc98 */ -#endif /* __I386_INCLUDE_EFI_H_ */ +#endif /* __PC98_INCLUDE_EFI_H_ */ Copied and modified: head/sys/powerpc/include/efi.h (from r307073, head/sys/i386/include/efi.h) ============================================================================== --- head/sys/i386/include/efi.h Tue Oct 11 22:32:12 2016 (r307073, copy source) +++ head/sys/powerpc/include/efi.h Tue Oct 11 22:54:29 2016 (r307074) @@ -29,11 +29,11 @@ * $FreeBSD$ */ -#ifndef __I386_INCLUDE_EFI_H_ -#define __I386_INCLUDE_EFI_H_ +#ifndef __POWERPC_INCLUDE_EFI_H_ +#define __POWERPC_INCLUDE_EFI_H_ -#define EFIABI_ATTR /* __attribute__((ms_abi)) */ /* clang fails with this */ +#define EFIABI_ATTR -/* Note: we don't actually support this on i386 yet */ +/* Note: we don't actually support this on powerpc */ -#endif /* __I386_INCLUDE_EFI_H_ */ +#endif /* __POWERPC_INCLUDE_EFI_H_ */ Copied and modified: head/sys/riscv/include/efi.h (from r307073, head/sys/i386/include/efi.h) ============================================================================== --- head/sys/i386/include/efi.h Tue Oct 11 22:32:12 2016 (r307073, copy source) +++ head/sys/riscv/include/efi.h Tue Oct 11 22:54:29 2016 (r307074) @@ -29,11 +29,11 @@ * $FreeBSD$ */ -#ifndef __I386_INCLUDE_EFI_H_ -#define __I386_INCLUDE_EFI_H_ +#ifndef __RISCV_INCLUDE_EFI_H_ +#define __RISCV_INCLUDE_EFI_H_ -#define EFIABI_ATTR /* __attribute__((ms_abi)) */ /* clang fails with this */ +#define EFIABI_ATTR -/* Note: we don't actually support this on i386 yet */ +/* Note: we don't actually support this on riscv */ #endif /* __I386_INCLUDE_EFI_H_ */ Copied and modified: head/sys/sparc64/include/efi.h (from r307073, head/sys/i386/include/efi.h) ============================================================================== --- head/sys/i386/include/efi.h Tue Oct 11 22:32:12 2016 (r307073, copy source) +++ head/sys/sparc64/include/efi.h Tue Oct 11 22:54:29 2016 (r307074) @@ -29,11 +29,11 @@ * $FreeBSD$ */ -#ifndef __I386_INCLUDE_EFI_H_ -#define __I386_INCLUDE_EFI_H_ +#ifndef __SPARC64_INCLUDE_EFI_H_ +#define __SPARC64_INCLUDE_EFI_H_ -#define EFIABI_ATTR /* __attribute__((ms_abi)) */ /* clang fails with this */ +#define EFIABI_ATTR -/* Note: we don't actually support this on i386 yet */ +/* Note: we don't actually support this on sparc64 */ #endif /* __I386_INCLUDE_EFI_H_ */ From owner-svn-src-all@freebsd.org Tue Oct 11 23:11:58 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 67E49C0D6AD for ; Tue, 11 Oct 2016 23:11:58 +0000 (UTC) (envelope-from shawn.webb@hardenedbsd.org) Received: from mail-qk0-x22e.google.com (mail-qk0-x22e.google.com [IPv6:2607:f8b0:400d:c09::22e]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 17B8FF6C for ; Tue, 11 Oct 2016 23:11:58 +0000 (UTC) (envelope-from shawn.webb@hardenedbsd.org) Received: by mail-qk0-x22e.google.com with SMTP id n189so10671668qke.0 for ; Tue, 11 Oct 2016 16:11:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hardenedbsd-org.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=UHHk5raOvXN6h+TsPRvtcyVAUejtJu7mhJq5Kl2cK1U=; b=P0yjPlAMpbTzcV0BYvB10VILHXtKacKT+cj50NF7dxXldSapYy51R1Zrj28pTg8SIn D28Nevu6UgsyAmxtJ2DN4qbV54ldE3c9Ib4z49UTJCSsSEuretkq3WNe8IfCyBqKsYvu cYpzFT6TrJ9B68AG9+pl/CyRRDzYYlcaTYH2pV+kJlBEq4O3aIHI7OvnSY/xHVl+XGXw u9AepxkbDjLyzTyLqIZyyzHwrJ7fO2praO7GEGi3spx2FGAC34ALj1jY65G+M5KIx/SO pityAaKjVM3ZXGSVK6MEgPWKv5KnnJ5aMOLETN4MVf1UhlseSXK4bX3DpqQ9bHbj+Z3Y OR3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=UHHk5raOvXN6h+TsPRvtcyVAUejtJu7mhJq5Kl2cK1U=; b=WRqAerWLp2LsOX5XWFw4e9GjUVX7blXz2G26YpZk/qymTZQzTqMjcXqPsGZ6xlRNDG 656cKCPIY/3+4g+9nASrn7OCPvgi1I4EXUr4C+jQAxzUGNYoQ8WVigrCqUgLH8+dQwyI Rwf/u2r6eWAhDxEdrMfO96xOC4GNDxq+VvjlaFcKv5YHSoDONM3OXJ8pPqjS1it9TV15 raJUFfMinviiLAbeo65XFyXZmE9Zfrsl+eHbClThH+Ju6ZTaxO/8m9hfz8i7O3MenC96 iYBkCL5E87QWjiKyXQfm/v8C27Scm+0+MA/YRMVOEiWEsCvm3TQCZU+LBUA0NeLRYmMP RBMA== X-Gm-Message-State: AA6/9Rk78dJxuDtbLcIk0fQvspkKoIApSQ4LSPiWho6wtwXcWATd7f8R3sQd5pTSCztSIo8o X-Received: by 10.55.101.201 with SMTP id z192mr5241218qkb.35.1476227517244; Tue, 11 Oct 2016 16:11:57 -0700 (PDT) Received: from mutt-hardenedbsd (pool-100-16-218-231.bltmmd.fios.verizon.net. [100.16.218.231]) by smtp.gmail.com with ESMTPSA id 137sm1868767qkd.42.2016.10.11.16.11.55 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 11 Oct 2016 16:11:55 -0700 (PDT) Date: Tue, 11 Oct 2016 19:11:53 -0400 From: Shawn Webb To: Warner Losh Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r307072 - in head/usr.sbin: . efivar Message-ID: <20161011231153.GB55764@mutt-hardenedbsd> References: <201610112231.u9BMVk8K056208@repo.freebsd.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="zx4FCpZtqtKETZ7O" Content-Disposition: inline In-Reply-To: <201610112231.u9BMVk8K056208@repo.freebsd.org> X-Operating-System: FreeBSD mutt-hardenedbsd 12.0-CURRENT-HBSD FreeBSD 12.0-CURRENT-HBSD X-PGP-Key: http://pgp.mit.edu/pks/lookup?op=vindex&search=0x6A84658F52456EEE User-Agent: Mutt/1.6.1 (2016-04-27) X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Oct 2016 23:11:58 -0000 --zx4FCpZtqtKETZ7O Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Oct 11, 2016 at 10:31:46PM +0000, Warner Losh wrote: > Author: imp > Date: Tue Oct 11 22:31:45 2016 > New Revision: 307072 > URL: https://svnweb.freebsd.org/changeset/base/307072 >=20 > Log: > Add efivar(1) to manipulate EFI variables. It uses a similar command > line interface to the Linux program, as well as adding a number of > useful features to make using it in shell scripts easier (since we > don't have a filesystem to fall back on interacting with). > =20 > Differential Revision: https://reviews.freebsd.org/D8128 > Reviewed by: kib@, wblock@, Ganael Laplanche >=20 > Added: > head/usr.sbin/efivar/ > head/usr.sbin/efivar/Makefile (contents, props changed) > head/usr.sbin/efivar/efivar.8 (contents, props changed) > head/usr.sbin/efivar/efivar.c (contents, props changed) > Modified: > head/usr.sbin/Makefile The commit log says efivar(1), but the manpage is efivar(8). Maybe 1 is a typo? Thanks, --=20 Shawn Webb Cofounder and Security Engineer HardenedBSD GPG Key ID: 0x6A84658F52456EEE GPG Key Fingerprint: 2ABA B6BD EF6A F486 BE89 3D9E 6A84 658F 5245 6EEE --zx4FCpZtqtKETZ7O Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAEBCAAGBQJX/XG3AAoJEGqEZY9SRW7ubZoP+gLhkt6OwX7l6E9/5TFMhH6T 74MwJRLgvVZMkZE/nxXdUTPDvhIENztY8DoZaAMvjYF/nrxHL8JAIZkJFatNNmrc AxZWDdwykYWdjU56x9VUJmwkzWNuBFQEtKKDZ4ERC7jLiFP9S7SAx0UeHMRdHQ/s I3HbbadKUc+/HkCv8cbnpW4hvnxQWmZaZmLPG/HPTOppCqDkB381QStVBffP+NkD FzhIjcUQNI1mHYQ3+jATMsF10stmA+MK2xUbInB822l12EAvXxiQo80K2P3zXI1m FJ1SJfQZSqDSMC6eb71OJj2x3MiBNf7ZK8Qs7pD9PDUI3/iGOHg1JrIX0z7cxcS8 eI89UcfQiKwGmgj/AS+CY+zO4s6MqOkXqHR6aICiiqTaVVjdyUSbWRxB75Wfr5zJ lXTfgC35ImmRixmYUUMVruKDF3PmBZBVVatydYkklIf3klpSizT68Kxtl6QalW/g Z6kLCjsVMS8FW9jJ11U60sOFgLaq1KUFoe0nse8rjKTjvkyq5xLg8v/jt9dApVMx DTakoOt/kt/8/Dg8rmE3LF1PVr23rg6uwSsKv2C3uyoNSeErRtHVReLP+MYyyDhV kNXZsqcCcByL4SGjMPsHgq8fyAm9TpibE7yx8wYrPsF2tMVIbbMOIdPtPLQ1Ie81 qXYZOZApGUT/Gd1H2VAK =tsK6 -----END PGP SIGNATURE----- --zx4FCpZtqtKETZ7O-- From owner-svn-src-all@freebsd.org Tue Oct 11 23:13:26 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 61594C0D749 for ; Tue, 11 Oct 2016 23:13:26 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: from mail-it0-x235.google.com (mail-it0-x235.google.com [IPv6:2607:f8b0:4001:c0b::235]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 338871AF for ; Tue, 11 Oct 2016 23:13:26 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: by mail-it0-x235.google.com with SMTP id l13so124532802itl.1 for ; Tue, 11 Oct 2016 16:13:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20150623.gappssmtp.com; s=20150623; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=KWcj1hItiocGkURBnA7eLU7J5juDXH5oOXBKMMZ06v0=; b=uThz9KDs6lfUa0klkspJJhFtHdgvZkzY7DWmnE9p0n9ySaRex38p/59+umaco6cKEz dYWNGiUUWAXBkBQIyrIDFmdQUSf9UMCbXCdOVzj0ehX5fXrJRXyFTQ0FXh4+pm+ZuFaG L/+eDmAexZbiGk7j9QX3gY+CH6YEn8VhnQLRXZ39Ten02F56/AYZmGh/NBSlD6lqO8Mc 2Yu/1dU0u0H+zWtt8lftUTpGXigQJ/6c5vBd7gh9hQzMS1Nx80pnMw0v4UX9WTXrXegG CH8k1VPzjAZPZCd45sUvY57a+BNKjpyTuHiBapEAl3dsWcpujLKH3IOSCYFKViDelYsk BNzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=KWcj1hItiocGkURBnA7eLU7J5juDXH5oOXBKMMZ06v0=; b=BOrHWhq2t5Oz9oAVuusBHSD9RPjGhq8xKIb2d5gj/Pv1MtKFg4BnXK6JpKlwfALLm9 bopFScKIxgRq0Stu87TOP5Hw3hdBrBv2S2kl8owtQ5OOtRU0ZQ5ZsHi1z86A80AbV46/ mfbn40kwZWiFdXZAkJlvSSxwP4lOF+NbZ6O2ss/XfKNFlvs9NhlFJU0tBMtqixwbHazT Nt4pxbGJKYzZQJXkIJTbYsaRkfSDJJZKbkot8wEEnI0TKCvVNlMEywbnv2ynL/3cqu1I FkuOD2j1iz3XRvRGZJlHi3jaG6tyCJynXdHZftmRkc4+18HjOOPYkFmOK096GACEuR+a GF2A== X-Gm-Message-State: AA6/9Rn8pHkjtaB5qjYuXPH1iTYZtFzhFVUU19F4vikw1Tol0z81TaufcnGOBNvJNnCfuRs+8RGbfMqRbO/iWQ== X-Received: by 10.107.15.222 with SMTP id 91mr434186iop.19.1476227605533; Tue, 11 Oct 2016 16:13:25 -0700 (PDT) MIME-Version: 1.0 Sender: wlosh@bsdimp.com Received: by 10.79.77.85 with HTTP; Tue, 11 Oct 2016 16:13:24 -0700 (PDT) X-Originating-IP: [69.53.245.200] In-Reply-To: <20161011231153.GB55764@mutt-hardenedbsd> References: <201610112231.u9BMVk8K056208@repo.freebsd.org> <20161011231153.GB55764@mutt-hardenedbsd> From: Warner Losh Date: Tue, 11 Oct 2016 17:13:24 -0600 X-Google-Sender-Auth: dnCTyi7cQylSF7q6y40lzSZBDRo Message-ID: Subject: Re: svn commit: r307072 - in head/usr.sbin: . efivar To: Shawn Webb Cc: Warner Losh , src-committers , "svn-src-all@freebsd.org" , "svn-src-head@freebsd.org" Content-Type: text/plain; charset=UTF-8 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Oct 2016 23:13:26 -0000 On Tue, Oct 11, 2016 at 5:11 PM, Shawn Webb wrote: > On Tue, Oct 11, 2016 at 10:31:46PM +0000, Warner Losh wrote: >> Author: imp >> Date: Tue Oct 11 22:31:45 2016 >> New Revision: 307072 >> URL: https://svnweb.freebsd.org/changeset/base/307072 >> >> Log: >> Add efivar(1) to manipulate EFI variables. It uses a similar command >> line interface to the Linux program, as well as adding a number of >> useful features to make using it in shell scripts easier (since we >> don't have a filesystem to fall back on interacting with). >> >> Differential Revision: https://reviews.freebsd.org/D8128 >> Reviewed by: kib@, wblock@, Ganael Laplanche >> >> Added: >> head/usr.sbin/efivar/ >> head/usr.sbin/efivar/Makefile (contents, props changed) >> head/usr.sbin/efivar/efivar.8 (contents, props changed) >> head/usr.sbin/efivar/efivar.c (contents, props changed) >> Modified: >> head/usr.sbin/Makefile > > The commit log says efivar(1), but the manpage is efivar(8). Maybe 1 is > a typo? (1) is a typo :( Warner From owner-svn-src-all@freebsd.org Tue Oct 11 23:19:04 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 259D4C0D848 for ; Tue, 11 Oct 2016 23:19:04 +0000 (UTC) (envelope-from shawn.webb@hardenedbsd.org) Received: from mail-qk0-x22b.google.com (mail-qk0-x22b.google.com [IPv6:2607:f8b0:400d:c09::22b]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id CC4FC3C2 for ; Tue, 11 Oct 2016 23:19:03 +0000 (UTC) (envelope-from shawn.webb@hardenedbsd.org) Received: by mail-qk0-x22b.google.com with SMTP id o68so56187885qkf.3 for ; Tue, 11 Oct 2016 16:19:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hardenedbsd-org.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=mVUIfriiusj2LbYbUE4F06wFpWNZoAkajZC/pWYUxgA=; b=tRSEQzWjuartWKK/yqyOXvK1PgLXCMC/KQoD96b6o/0Dbc0kSRh0Z0s2sqjBF9Lg0m oIfUwtQevEJc+++Gii5ptkdF3O2OzG7vC7xE9Kz2+UM1vS2plJUkI9xs/k/yE0nRp+F+ FBYuGO8419583RToIrRXxyf4WgN8w0hulZVtYeZshHjpHjFT1h2nvSFuK3EPoHluEQbV hn6pLbkwv5woIDb1XLhKh56KMfgQLPpvrguSkQ8oqXlnJriAHG9orPsBL9n+XoioqiFZ 7SOUzcYENNgIF9TmedMZxBdagnppIMaXt12EaYRcSAz+ZXwzQToPiGqsnX3jdYGpoqd7 9sfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=mVUIfriiusj2LbYbUE4F06wFpWNZoAkajZC/pWYUxgA=; b=fAm4rquFc5gOOQxlDbSc5LPIj5S32FE8zMvMKRDLbJhao9ql2QkcV9ZHMr7CIMcpcY 6GkLJSLyMGe50gD3ctm6t7al97FOtJ0nIZdPELjX6fWL7Ckz+bkULaR1a4OBOveWZDOr 4736wQRYfsb7DoWvbUO+SxBPwdg3ZX9sajQusfkgnVrLFUkAeV9aVK70j37iPIHmtG7Y BMi0NXF+uKyLLpV+upB2d9z6aqNSVhieGumFxaMovQAV2HbWi54oeooWR9YOwj+GDf8p m5I/8JVC8HH8dWnoZCXsN3HcV35m2QHO1F8SINTc3BXjAIpeLYf5l9idzjng1ePdihkt l83g== X-Gm-Message-State: AA6/9RlceMaAS3R5WeT87kX5JeF1/KDXjJB1BERg76GaS73bYlsLB+SOGZLqzMhG+CdUxp4Z X-Received: by 10.55.154.135 with SMTP id c129mr5461468qke.304.1476227943000; Tue, 11 Oct 2016 16:19:03 -0700 (PDT) Received: from mutt-hardenedbsd (pool-100-16-218-231.bltmmd.fios.verizon.net. [100.16.218.231]) by smtp.gmail.com with ESMTPSA id v24sm1899475qtv.15.2016.10.11.16.19.01 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 11 Oct 2016 16:19:01 -0700 (PDT) Date: Tue, 11 Oct 2016 19:19:00 -0400 From: Shawn Webb To: Warner Losh Cc: Warner Losh , src-committers , "svn-src-all@freebsd.org" , "svn-src-head@freebsd.org" Subject: Re: svn commit: r307072 - in head/usr.sbin: . efivar Message-ID: <20161011231900.GC55764@mutt-hardenedbsd> References: <201610112231.u9BMVk8K056208@repo.freebsd.org> <20161011231153.GB55764@mutt-hardenedbsd> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="rQ2U398070+RC21q" Content-Disposition: inline In-Reply-To: X-Operating-System: FreeBSD mutt-hardenedbsd 12.0-CURRENT-HBSD FreeBSD 12.0-CURRENT-HBSD X-PGP-Key: http://pgp.mit.edu/pks/lookup?op=vindex&search=0x6A84658F52456EEE User-Agent: Mutt/1.6.1 (2016-04-27) X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Oct 2016 23:19:04 -0000 --rQ2U398070+RC21q Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Oct 11, 2016 at 05:13:24PM -0600, Warner Losh wrote: > On Tue, Oct 11, 2016 at 5:11 PM, Shawn Webb = wrote: > > On Tue, Oct 11, 2016 at 10:31:46PM +0000, Warner Losh wrote: > >> Author: imp > >> Date: Tue Oct 11 22:31:45 2016 > >> New Revision: 307072 > >> URL: https://svnweb.freebsd.org/changeset/base/307072 > >> > >> Log: > >> Add efivar(1) to manipulate EFI variables. It uses a similar command > >> line interface to the Linux program, as well as adding a number of > >> useful features to make using it in shell scripts easier (since we > >> don't have a filesystem to fall back on interacting with). > >> > >> Differential Revision: https://reviews.freebsd.org/D8128 > >> Reviewed by: kib@, wblock@, Ganael Laplanche > >> > >> Added: > >> head/usr.sbin/efivar/ > >> head/usr.sbin/efivar/Makefile (contents, props changed) > >> head/usr.sbin/efivar/efivar.8 (contents, props changed) > >> head/usr.sbin/efivar/efivar.c (contents, props changed) > >> Modified: > >> head/usr.sbin/Makefile > > > > The commit log says efivar(1), but the manpage is efivar(8). Maybe 1 is > > a typo? >=20 > (1) is a typo :( No worries. Thanks for the quick response. I just wanted to make sure that it was supposed to be 8 versus the 1 in the log. Good to see a program like this in base. Good work. --=20 Shawn Webb Cofounder and Security Engineer HardenedBSD GPG Key ID: 0x6A84658F52456EEE GPG Key Fingerprint: 2ABA B6BD EF6A F486 BE89 3D9E 6A84 658F 5245 6EEE --rQ2U398070+RC21q Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAEBCAAGBQJX/XNjAAoJEGqEZY9SRW7uqEEP/Auvue/9rpwkiziq0Kc2NpqB gJY/Dubfl16vk8nId8Wk0ixnEU/92mSmW+QWzpF2rqrmva/N/1lvqezwAeWsd5U5 IjgFr79Dzq8Mdby49hzGiqQQPMOfsPc+eHSvLt3ZR0W+utwpOX89IqdHOVD312tb npT865xNV/bxsGGMRHl7ZFwmJDQ/FZYcpTFSGv9HG463/jCBeNgHH9y0zmvtYOC4 dJvfLkCwHsoyqp+5X1fMpTJu6X9SLAvs6Nfg5bSreg3ueEdfuPne9D/F2kfHsdRI +GB10xH2N5XYQVLAxU696Xk5LM/v56lxPx2ERmk2VYwNzCosZMWXY0EwXzlTohBF xyuEruQhNdAuKAauBeMR03XmpwGX7SkWb2bS5VlU6SJvbBhf+nH7Z8nQSefHba02 ncO68h4BlxYD+IgKPQ3HeG0uQJkbjEfRHlIdLX+kt9WbrzO1QiVRa3l71IVkwhEi uBpBGe4+D5bnwBIgWjanUrPTDEl6+eCAGopcyv9uopAPxCA82HcdePgrYu9kceCF 6RODyjtBADqssRHk7Xnc71Qt932TLc1hyf9lCJJpkN/GcMFIKUy3mshYseNiQMPO 00oY712390e3yUAaNFUamLs7/h3ZLJuPzBLlfxF6r1er2iw+ZjEjvZizwpz6+Ej5 ciXZf8BThtperVBiHyif =ysVG -----END PGP SIGNATURE----- --rQ2U398070+RC21q-- From owner-svn-src-all@freebsd.org Wed Oct 12 00:42:48 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C28FBC0EBE7; Wed, 12 Oct 2016 00:42:48 +0000 (UTC) (envelope-from jonathan@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 80693E9B; Wed, 12 Oct 2016 00:42:48 +0000 (UTC) (envelope-from jonathan@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9C0gl19006634; Wed, 12 Oct 2016 00:42:47 GMT (envelope-from jonathan@FreeBSD.org) Received: (from jonathan@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9C0glMP006629; Wed, 12 Oct 2016 00:42:47 GMT (envelope-from jonathan@FreeBSD.org) Message-Id: <201610120042.u9C0glMP006629@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jonathan set sender to jonathan@FreeBSD.org using -f From: Jonathan Anderson Date: Wed, 12 Oct 2016 00:42:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307075 - head/share/mk X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Oct 2016 00:42:48 -0000 Author: jonathan Date: Wed Oct 12 00:42:46 2016 New Revision: 307075 URL: https://svnweb.freebsd.org/changeset/base/307075 Log: Extract suffix rules into bsd.suffixes[-posix].mk. Refactor make suffix rules into separate files (one for POSIX and one not), and rationalise the rules so that bsd.lib.mk can contain only those rules that are library-specific (.c.po and .c.pico). This can be accomplished by adding ${STATIC_CFLAGS} to the .c.o rule unconditionally. STATIC_CFLAGS are only defined for use by sys.mk rules in lib/libpam/Makefile.inc (see r227797), so it should be safe to include them unconditionally in sys.mk's .c.o rule (tested by make universe and a ports exp-run). Reviewed by: bdrewery, sjg Approved by: rwatson (mentor) Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D6805 Added: head/share/mk/bsd.suffixes-posix.mk (contents, props changed) head/share/mk/bsd.suffixes.mk (contents, props changed) Modified: head/share/mk/Makefile head/share/mk/bsd.lib.mk head/share/mk/sys.mk Modified: head/share/mk/Makefile ============================================================================== --- head/share/mk/Makefile Tue Oct 11 22:54:29 2016 (r307074) +++ head/share/mk/Makefile Wed Oct 12 00:42:46 2016 (r307075) @@ -49,6 +49,8 @@ FILES= \ bsd.progs.mk \ bsd.snmpmod.mk \ bsd.subdir.mk \ + bsd.suffixes-posix.mk \ + bsd.suffixes.mk \ bsd.symver.mk \ bsd.sys.mk \ bsd.test.mk \ Modified: head/share/mk/bsd.lib.mk ============================================================================== --- head/share/mk/bsd.lib.mk Tue Oct 11 22:54:29 2016 (r307074) +++ head/share/mk/bsd.lib.mk Wed Oct 12 00:42:46 2016 (r307075) @@ -78,7 +78,6 @@ CTFFLAGS+= -g # prefer .s to a .c, add .po, remove stuff not used in the BSD libraries # .pico used for PIC object files -.SUFFIXES: .SUFFIXES: .out .o .po .pico .S .asm .s .c .cc .cpp .cxx .C .f .y .l .ln .if !defined(PICFLAG) @@ -91,10 +90,6 @@ PICFLAG=-fpic PO_FLAG=-pg -.c.o: - ${CC} ${STATIC_CFLAGS} ${CFLAGS} -c ${.IMPSRC} -o ${.TARGET} - ${CTFCONVERT_CMD} - .c.po: ${CC} ${PO_FLAG} ${STATIC_CFLAGS} ${PO_CFLAGS} -c ${.IMPSRC} -o ${.TARGET} ${CTFCONVERT_CMD} @@ -103,9 +98,6 @@ PO_FLAG=-pg ${CC} ${PICFLAG} -DPIC ${SHARED_CFLAGS} ${CFLAGS} -c ${.IMPSRC} -o ${.TARGET} ${CTFCONVERT_CMD} -.cc.o .C.o .cpp.o .cxx.o: - ${CXX} ${STATIC_CXXFLAGS} ${CXXFLAGS} -c ${.IMPSRC} -o ${.TARGET} - .cc.po .C.po .cpp.po .cxx.po: ${CXX} ${PO_FLAG} ${STATIC_CXXFLAGS} ${PO_CXXFLAGS} -c ${.IMPSRC} -o ${.TARGET} Added: head/share/mk/bsd.suffixes-posix.mk ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/share/mk/bsd.suffixes-posix.mk Wed Oct 12 00:42:46 2016 (r307075) @@ -0,0 +1,56 @@ +# $FreeBSD$ + +# Posix 1003.2 mandated rules +# +# Quoted directly from the Posix 1003.2 draft, only the macros +# $@, $< and $* have been replaced by ${.TARGET}, ${.IMPSRC}, and +# ${.PREFIX}, resp. + +# SINGLE SUFFIX RULES +.c: + ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${.IMPSRC} + +.f: + ${FC} ${FFLAGS} ${LDFLAGS} -o ${.TARGET} ${.IMPSRC} + +.sh: + cp -f ${.IMPSRC} ${.TARGET} + chmod a+x ${.TARGET} + +# DOUBLE SUFFIX RULES + +.c.o: + ${CC} ${CFLAGS} -c ${.IMPSRC} + +.f.o: + ${FC} ${FFLAGS} -c ${.IMPSRC} + +.y.o: + ${YACC} ${YFLAGS} ${.IMPSRC} + ${CC} ${CFLAGS} -c y.tab.c + rm -f y.tab.c + mv y.tab.o ${.TARGET} + +.l.o: + ${LEX} ${LFLAGS} ${.IMPSRC} + ${CC} ${CFLAGS} -c lex.yy.c + rm -f lex.yy.c + mv lex.yy.o ${.TARGET} + +.y.c: + ${YACC} ${YFLAGS} ${.IMPSRC} + mv y.tab.c ${.TARGET} + +.l.c: + ${LEX} ${LFLAGS} ${.IMPSRC} + mv lex.yy.c ${.TARGET} + +.c.a: + ${CC} ${CFLAGS} -c ${.IMPSRC} + ${AR} ${ARFLAGS} ${.TARGET} ${.PREFIX}.o + rm -f ${.PREFIX}.o + +.f.a: + ${FC} ${FFLAGS} -c ${.IMPSRC} + ${AR} ${ARFLAGS} ${.TARGET} ${.PREFIX}.o + rm -f ${.PREFIX}.o Added: head/share/mk/bsd.suffixes.mk ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/share/mk/bsd.suffixes.mk Wed Oct 12 00:42:46 2016 (r307075) @@ -0,0 +1,99 @@ +# $FreeBSD$ + +.sh: + cp -f ${.IMPSRC} ${.TARGET} + chmod a+x ${.TARGET} + +.c.ln: + ${LINT} ${LINTOBJFLAGS} ${CFLAGS:M-[DIU]*} ${.IMPSRC} || \ + touch ${.TARGET} + +.cc.ln .C.ln .cpp.ln .cxx.ln: + ${LINT} ${LINTOBJFLAGS} ${CXXFLAGS:M-[DIU]*} ${.IMPSRC} || \ + touch ${.TARGET} + +.c: + ${CC} ${CFLAGS} ${LDFLAGS} ${.IMPSRC} ${LDLIBS} -o ${.TARGET} + ${CTFCONVERT_CMD} + +.c.o: + ${CC} ${STATIC_CFLAGS} ${CFLAGS} -c ${.IMPSRC} -o ${.TARGET} + ${CTFCONVERT_CMD} + +.cc .cpp .cxx .C: + ${CXX} ${CXXFLAGS} ${LDFLAGS} ${.IMPSRC} ${LDLIBS} -o ${.TARGET} + +.cc.o .cpp.o .cxx.o .C.o: + ${CXX} ${STATIC_CXXFLAGS} ${CXXFLAGS} -c ${.IMPSRC} -o ${.TARGET} + +.m.o: + ${OBJC} ${OBJCFLAGS} -c ${.IMPSRC} -o ${.TARGET} + ${CTFCONVERT_CMD} + +.p.o: + ${PC} ${PFLAGS} -c ${.IMPSRC} -o ${.TARGET} + ${CTFCONVERT_CMD} + +.e .r .F .f: + ${FC} ${RFLAGS} ${EFLAGS} ${FFLAGS} ${LDFLAGS} ${.IMPSRC} ${LDLIBS} \ + -o ${.TARGET} + +.e.o .r.o .F.o .f.o: + ${FC} ${RFLAGS} ${EFLAGS} ${FFLAGS} -c ${.IMPSRC} -o ${.TARGET} + +.S.o: + ${CC:N${CCACHE_BIN}} ${CFLAGS} ${ACFLAGS} -c ${.IMPSRC} -o ${.TARGET} + ${CTFCONVERT_CMD} + +.asm.o: + ${CC:N${CCACHE_BIN}} -x assembler-with-cpp ${CFLAGS} ${ACFLAGS} -c ${.IMPSRC} \ + -o ${.TARGET} + ${CTFCONVERT_CMD} + +.s.o: + ${AS} ${AFLAGS} -o ${.TARGET} ${.IMPSRC} + ${CTFCONVERT_CMD} + +# XXX not -j safe +.y.o: + ${YACC} ${YFLAGS} ${.IMPSRC} + ${CC} ${CFLAGS} -c y.tab.c -o ${.TARGET} + rm -f y.tab.c + ${CTFCONVERT_CMD} + +.l.o: + ${LEX} -t ${LFLAGS} ${.IMPSRC} > ${.PREFIX}.tmp.c + ${CC} ${CFLAGS} -c ${.PREFIX}.tmp.c -o ${.TARGET} + rm -f ${.PREFIX}.tmp.c + ${CTFCONVERT_CMD} + +# XXX not -j safe +.y.c: + ${YACC} ${YFLAGS} ${.IMPSRC} + mv y.tab.c ${.TARGET} + +.l.c: + ${LEX} -t ${LFLAGS} ${.IMPSRC} > ${.TARGET} + +.s.out .c.out .o.out: + ${CC} ${CFLAGS} ${LDFLAGS} ${.IMPSRC} ${LDLIBS} -o ${.TARGET} + ${CTFCONVERT_CMD} + +.f.out .F.out .r.out .e.out: + ${FC} ${EFLAGS} ${RFLAGS} ${FFLAGS} ${LDFLAGS} ${.IMPSRC} \ + ${LDLIBS} -o ${.TARGET} + rm -f ${.PREFIX}.o + ${CTFCONVERT_CMD} + +# XXX not -j safe +.y.out: + ${YACC} ${YFLAGS} ${.IMPSRC} + ${CC} ${CFLAGS} ${LDFLAGS} y.tab.c ${LDLIBS} -ly -o ${.TARGET} + rm -f y.tab.c + ${CTFCONVERT_CMD} + +.l.out: + ${LEX} -t ${LFLAGS} ${.IMPSRC} > ${.PREFIX}.tmp.c + ${CC} ${CFLAGS} ${LDFLAGS} ${.PREFIX}.tmp.c ${LDLIBS} -ll -o ${.TARGET} + rm -f ${.PREFIX}.tmp.c + ${CTFCONVERT_CMD} Modified: head/share/mk/sys.mk ============================================================================== --- head/share/mk/sys.mk Tue Oct 11 22:54:29 2016 (r307074) +++ head/share/mk/sys.mk Wed Oct 12 00:42:46 2016 (r307075) @@ -259,162 +259,12 @@ YFLAGS ?= -d .if defined(%POSIX) -# Posix 1003.2 mandated rules -# -# Quoted directly from the Posix 1003.2 draft, only the macros -# $@, $< and $* have been replaced by ${.TARGET}, ${.IMPSRC}, and -# ${.PREFIX}, resp. - -# SINGLE SUFFIX RULES -.c: - ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${.IMPSRC} - -.f: - ${FC} ${FFLAGS} ${LDFLAGS} -o ${.TARGET} ${.IMPSRC} - -.sh: - cp -f ${.IMPSRC} ${.TARGET} - chmod a+x ${.TARGET} - -# DOUBLE SUFFIX RULES - -.c.o: - ${CC} ${CFLAGS} -c ${.IMPSRC} - -.f.o: - ${FC} ${FFLAGS} -c ${.IMPSRC} - -.y.o: - ${YACC} ${YFLAGS} ${.IMPSRC} - ${CC} ${CFLAGS} -c y.tab.c - rm -f y.tab.c - mv y.tab.o ${.TARGET} - -.l.o: - ${LEX} ${LFLAGS} ${.IMPSRC} - ${CC} ${CFLAGS} -c lex.yy.c - rm -f lex.yy.c - mv lex.yy.o ${.TARGET} - -.y.c: - ${YACC} ${YFLAGS} ${.IMPSRC} - mv y.tab.c ${.TARGET} - -.l.c: - ${LEX} ${LFLAGS} ${.IMPSRC} - mv lex.yy.c ${.TARGET} - -.c.a: - ${CC} ${CFLAGS} -c ${.IMPSRC} - ${AR} ${ARFLAGS} ${.TARGET} ${.PREFIX}.o - rm -f ${.PREFIX}.o - -.f.a: - ${FC} ${FFLAGS} -c ${.IMPSRC} - ${AR} ${ARFLAGS} ${.TARGET} ${.PREFIX}.o - rm -f ${.PREFIX}.o +.include "bsd.suffixes-posix.mk" .else # non-Posix rule set - -.sh: - cp -f ${.IMPSRC} ${.TARGET} - chmod a+x ${.TARGET} - -.c.ln: - ${LINT} ${LINTOBJFLAGS} ${CFLAGS:M-[DIU]*} ${.IMPSRC} || \ - touch ${.TARGET} - -.cc.ln .C.ln .cpp.ln .cxx.ln: - ${LINT} ${LINTOBJFLAGS} ${CXXFLAGS:M-[DIU]*} ${.IMPSRC} || \ - touch ${.TARGET} - -.c: - ${CC} ${CFLAGS} ${LDFLAGS} ${.IMPSRC} ${LDLIBS} -o ${.TARGET} - ${CTFCONVERT_CMD} - -.c.o: - ${CC} ${CFLAGS} -c ${.IMPSRC} -o ${.TARGET} - ${CTFCONVERT_CMD} - -.cc .cpp .cxx .C: - ${CXX} ${CXXFLAGS} ${LDFLAGS} ${.IMPSRC} ${LDLIBS} -o ${.TARGET} - -.cc.o .cpp.o .cxx.o .C.o: - ${CXX} ${CXXFLAGS} -c ${.IMPSRC} -o ${.TARGET} - -.m.o: - ${OBJC} ${OBJCFLAGS} -c ${.IMPSRC} -o ${.TARGET} - ${CTFCONVERT_CMD} - -.p.o: - ${PC} ${PFLAGS} -c ${.IMPSRC} -o ${.TARGET} - ${CTFCONVERT_CMD} - -.e .r .F .f: - ${FC} ${RFLAGS} ${EFLAGS} ${FFLAGS} ${LDFLAGS} ${.IMPSRC} ${LDLIBS} \ - -o ${.TARGET} - -.e.o .r.o .F.o .f.o: - ${FC} ${RFLAGS} ${EFLAGS} ${FFLAGS} -c ${.IMPSRC} -o ${.TARGET} - -.S.o: - ${CC:N${CCACHE_BIN}} ${CFLAGS} ${ACFLAGS} -c ${.IMPSRC} -o ${.TARGET} - ${CTFCONVERT_CMD} - -.asm.o: - ${CC:N${CCACHE_BIN}} -x assembler-with-cpp ${CFLAGS} ${ACFLAGS} -c ${.IMPSRC} \ - -o ${.TARGET} - ${CTFCONVERT_CMD} - -.s.o: - ${AS} ${AFLAGS} -o ${.TARGET} ${.IMPSRC} - ${CTFCONVERT_CMD} - -# XXX not -j safe -.y.o: - ${YACC} ${YFLAGS} ${.IMPSRC} - ${CC} ${CFLAGS} -c y.tab.c -o ${.TARGET} - rm -f y.tab.c - ${CTFCONVERT_CMD} - -.l.o: - ${LEX} -t ${LFLAGS} ${.IMPSRC} > ${.PREFIX}.tmp.c - ${CC} ${CFLAGS} -c ${.PREFIX}.tmp.c -o ${.TARGET} - rm -f ${.PREFIX}.tmp.c - ${CTFCONVERT_CMD} - -# XXX not -j safe -.y.c: - ${YACC} ${YFLAGS} ${.IMPSRC} - mv y.tab.c ${.TARGET} - -.l.c: - ${LEX} -t ${LFLAGS} ${.IMPSRC} > ${.TARGET} - -.s.out .c.out .o.out: - ${CC} ${CFLAGS} ${LDFLAGS} ${.IMPSRC} ${LDLIBS} -o ${.TARGET} - ${CTFCONVERT_CMD} - -.f.out .F.out .r.out .e.out: - ${FC} ${EFLAGS} ${RFLAGS} ${FFLAGS} ${LDFLAGS} ${.IMPSRC} \ - ${LDLIBS} -o ${.TARGET} - rm -f ${.PREFIX}.o - ${CTFCONVERT_CMD} - -# XXX not -j safe -.y.out: - ${YACC} ${YFLAGS} ${.IMPSRC} - ${CC} ${CFLAGS} ${LDFLAGS} y.tab.c ${LDLIBS} -ly -o ${.TARGET} - rm -f y.tab.c - ${CTFCONVERT_CMD} - -.l.out: - ${LEX} -t ${LFLAGS} ${.IMPSRC} > ${.PREFIX}.tmp.c - ${CC} ${CFLAGS} ${LDFLAGS} ${.PREFIX}.tmp.c ${LDLIBS} -ll -o ${.TARGET} - rm -f ${.PREFIX}.tmp.c - ${CTFCONVERT_CMD} +.include "bsd.suffixes.mk" # Pull in global settings. __MAKE_CONF?=/etc/make.conf From owner-svn-src-all@freebsd.org Wed Oct 12 00:56:50 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id BF4BEC0EEAA; Wed, 12 Oct 2016 00:56:50 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 8525E908; Wed, 12 Oct 2016 00:56:50 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9C0unst010860; Wed, 12 Oct 2016 00:56:49 GMT (envelope-from emaste@FreeBSD.org) Received: (from emaste@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9C0unQT010859; Wed, 12 Oct 2016 00:56:49 GMT (envelope-from emaste@FreeBSD.org) Message-Id: <201610120056.u9C0unQT010859@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: emaste set sender to emaste@FreeBSD.org using -f From: Ed Maste Date: Wed, 12 Oct 2016 00:56:49 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307076 - head/sys/kern X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Oct 2016 00:56:50 -0000 Author: emaste Date: Wed Oct 12 00:56:49 2016 New Revision: 307076 URL: https://svnweb.freebsd.org/changeset/base/307076 Log: Use correct size type in do_setopt_accept_filter Submitted by: ecturt@gmail.com Modified: head/sys/kern/uipc_accf.c Modified: head/sys/kern/uipc_accf.c ============================================================================== --- head/sys/kern/uipc_accf.c Wed Oct 12 00:42:46 2016 (r307075) +++ head/sys/kern/uipc_accf.c Wed Oct 12 00:56:49 2016 (r307076) @@ -250,7 +250,7 @@ do_setopt_accept_filter(struct socket *s newaf = malloc(sizeof(*newaf), M_ACCF, M_WAITOK | M_ZERO); if (afp->accf_create != NULL && afap->af_name[0] != '\0') { - int len = strlen(afap->af_name) + 1; + size_t len = strlen(afap->af_name) + 1; newaf->so_accept_filter_str = malloc(len, M_ACCF, M_WAITOK); strcpy(newaf->so_accept_filter_str, afap->af_name); From owner-svn-src-all@freebsd.org Wed Oct 12 01:52:30 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 4964BC0CE11; Wed, 12 Oct 2016 01:52:30 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 0E1528F5; Wed, 12 Oct 2016 01:52:29 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9C1qTNH033898; Wed, 12 Oct 2016 01:52:29 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9C1qT1M033897; Wed, 12 Oct 2016 01:52:29 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610120152.u9C1qT1M033897@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Wed, 12 Oct 2016 01:52:29 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307078 - head/sys/net X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Oct 2016 01:52:30 -0000 Author: sephe Date: Wed Oct 12 01:52:29 2016 New Revision: 307078 URL: https://svnweb.freebsd.org/changeset/base/307078 Log: ifnet: Use if_link_state snapshot to invoke ifnet_link_event So that everyone in this task have consistent view of link state. Reviewed by: ae MFC after: 1 week Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8214 Modified: head/sys/net/if.c Modified: head/sys/net/if.c ============================================================================== --- head/sys/net/if.c Wed Oct 12 01:21:18 2016 (r307077) +++ head/sys/net/if.c Wed Oct 12 01:52:29 2016 (r307078) @@ -2206,7 +2206,7 @@ do_link_state_change(void *arg, int pend if (log_link_state_change) log(LOG_NOTICE, "%s: link state changed to %s\n", ifp->if_xname, (link_state == LINK_STATE_UP) ? "UP" : "DOWN" ); - EVENTHANDLER_INVOKE(ifnet_link_event, ifp, ifp->if_link_state); + EVENTHANDLER_INVOKE(ifnet_link_event, ifp, link_state); CURVNET_RESTORE(); } From owner-svn-src-all@freebsd.org Wed Oct 12 02:03:07 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 72B4FC0D15D; Wed, 12 Oct 2016 02:03:07 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 3C27CECB; Wed, 12 Oct 2016 02:03:07 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9C236so037774; Wed, 12 Oct 2016 02:03:06 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9C2356x037760; Wed, 12 Oct 2016 02:03:05 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610120203.u9C2356x037760@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Wed, 12 Oct 2016 02:03:05 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307079 - in stable/10/sys/dev/hyperv: include netvsc storvsc utilities vmbus X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Oct 2016 02:03:07 -0000 Author: sephe Date: Wed Oct 12 02:03:05 2016 New Revision: 307079 URL: https://svnweb.freebsd.org/changeset/base/307079 Log: MFC 302882-302884 302882 hyperv/vmbus: Function rename And reorder the error prone parameters list. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7191 302883 hyperv/vmbus: Field rename Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7193 302884 hyperv/vmbus: Factor out macros to do channel packet length conversion. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7194 Modified: stable/10/sys/dev/hyperv/include/hyperv.h stable/10/sys/dev/hyperv/include/vmbus.h stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.c stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.c stable/10/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c stable/10/sys/dev/hyperv/utilities/hv_heartbeat.c stable/10/sys/dev/hyperv/utilities/hv_kvp.c stable/10/sys/dev/hyperv/utilities/hv_shutdown.c stable/10/sys/dev/hyperv/utilities/hv_timesync.c stable/10/sys/dev/hyperv/vmbus/hv_channel.c stable/10/sys/dev/hyperv/vmbus/vmbus_reg.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/hyperv/include/hyperv.h ============================================================================== --- stable/10/sys/dev/hyperv/include/hyperv.h Wed Oct 12 01:52:29 2016 (r307078) +++ stable/10/sys/dev/hyperv/include/hyperv.h Wed Oct 12 02:03:05 2016 (r307079) @@ -323,14 +323,6 @@ int hv_vmbus_channel_open( void hv_vmbus_channel_close(hv_vmbus_channel *channel); -int hv_vmbus_channel_send_packet( - hv_vmbus_channel* channel, - void* buffer, - uint32_t buffer_len, - uint64_t request_id, - uint16_t type, - uint16_t flags); - int hv_vmbus_channel_establish_gpadl( hv_vmbus_channel* channel, /* must be phys and virt contiguous */ Modified: stable/10/sys/dev/hyperv/include/vmbus.h ============================================================================== --- stable/10/sys/dev/hyperv/include/vmbus.h Wed Oct 12 01:52:29 2016 (r307078) +++ stable/10/sys/dev/hyperv/include/vmbus.h Wed Oct 12 02:03:05 2016 (r307079) @@ -59,6 +59,8 @@ struct vmbus_gpa { struct hv_vmbus_channel; +int vmbus_chan_send(struct hv_vmbus_channel *chan, uint16_t type, + uint16_t flags, void *data, int dlen, uint64_t xactid); int vmbus_chan_send_sglist(struct hv_vmbus_channel *chan, struct vmbus_gpa sg[], int sglen, void *data, int dlen, uint64_t xactid); Modified: stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.c Wed Oct 12 01:52:29 2016 (r307078) +++ stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.c Wed Oct 12 02:03:05 2016 (r307079) @@ -182,9 +182,9 @@ hv_nv_init_rx_buffer_with_net_vsp(struct /* Send the gpadl notification request */ - ret = hv_vmbus_channel_send_packet(sc->hn_prichan, init_pkt, - sizeof(nvsp_msg), (uint64_t)(uintptr_t)init_pkt, - VMBUS_CHANPKT_TYPE_INBAND, VMBUS_CHANPKT_FLAG_RC); + ret = vmbus_chan_send(sc->hn_prichan, + VMBUS_CHANPKT_TYPE_INBAND, VMBUS_CHANPKT_FLAG_RC, + init_pkt, sizeof(nvsp_msg), (uint64_t)(uintptr_t)init_pkt); if (ret != 0) { goto cleanup; } @@ -275,9 +275,9 @@ hv_nv_init_send_buffer_with_net_vsp(stru /* Send the gpadl notification request */ - ret = hv_vmbus_channel_send_packet(sc->hn_prichan, init_pkt, - sizeof(nvsp_msg), (uint64_t)init_pkt, - VMBUS_CHANPKT_TYPE_INBAND, VMBUS_CHANPKT_FLAG_RC); + ret = vmbus_chan_send(sc->hn_prichan, + VMBUS_CHANPKT_TYPE_INBAND, VMBUS_CHANPKT_FLAG_RC, + init_pkt, sizeof(nvsp_msg), (uint64_t)init_pkt); if (ret != 0) { goto cleanup; } @@ -334,10 +334,9 @@ hv_nv_destroy_rx_buffer(netvsc_dev *net_ revoke_pkt->msgs.vers_1_msgs.revoke_rx_buf.id = NETVSC_RECEIVE_BUFFER_ID; - ret = hv_vmbus_channel_send_packet(net_dev->sc->hn_prichan, - revoke_pkt, sizeof(nvsp_msg), - (uint64_t)(uintptr_t)revoke_pkt, - VMBUS_CHANPKT_TYPE_INBAND, 0); + ret = vmbus_chan_send(net_dev->sc->hn_prichan, + VMBUS_CHANPKT_TYPE_INBAND, 0, revoke_pkt, sizeof(nvsp_msg), + (uint64_t)(uintptr_t)revoke_pkt); /* * If we failed here, we might as well return and have a leak @@ -402,10 +401,10 @@ hv_nv_destroy_send_buffer(netvsc_dev *ne revoke_pkt->msgs.vers_1_msgs.revoke_send_buf.id = NETVSC_SEND_BUFFER_ID; - ret = hv_vmbus_channel_send_packet(net_dev->sc->hn_prichan, + ret = vmbus_chan_send(net_dev->sc->hn_prichan, + VMBUS_CHANPKT_TYPE_INBAND, 0, revoke_pkt, sizeof(nvsp_msg), - (uint64_t)(uintptr_t)revoke_pkt, - VMBUS_CHANPKT_TYPE_INBAND, 0); + (uint64_t)(uintptr_t)revoke_pkt); /* * If we failed here, we might as well return and have a leak * rather than continue and a bugchk @@ -469,9 +468,9 @@ hv_nv_negotiate_nvsp_protocol(struct hn_ init_pkt->msgs.init_msgs.init.protocol_version_2 = nvsp_ver; /* Send the init request */ - ret = hv_vmbus_channel_send_packet(sc->hn_prichan, init_pkt, - sizeof(nvsp_msg), (uint64_t)(uintptr_t)init_pkt, - VMBUS_CHANPKT_TYPE_INBAND, VMBUS_CHANPKT_FLAG_RC); + ret = vmbus_chan_send(sc->hn_prichan, + VMBUS_CHANPKT_TYPE_INBAND, VMBUS_CHANPKT_FLAG_RC, + init_pkt, sizeof(nvsp_msg), (uint64_t)(uintptr_t)init_pkt); if (ret != 0) return (-1); @@ -512,9 +511,8 @@ hv_nv_send_ndis_config(struct hn_softc * = 1; /* Send the configuration packet */ - ret = hv_vmbus_channel_send_packet(sc->hn_prichan, init_pkt, - sizeof(nvsp_msg), (uint64_t)(uintptr_t)init_pkt, - VMBUS_CHANPKT_TYPE_INBAND, 0); + ret = vmbus_chan_send(sc->hn_prichan, VMBUS_CHANPKT_TYPE_INBAND, 0, + init_pkt, sizeof(nvsp_msg), (uint64_t)(uintptr_t)init_pkt); if (ret != 0) return (-EINVAL); @@ -591,9 +589,8 @@ hv_nv_connect_to_vsp(struct hn_softc *sc /* Send the init request */ - ret = hv_vmbus_channel_send_packet(sc->hn_prichan, init_pkt, - sizeof(nvsp_msg), (uint64_t)(uintptr_t)init_pkt, - VMBUS_CHANPKT_TYPE_INBAND, 0); + ret = vmbus_chan_send(sc->hn_prichan, VMBUS_CHANPKT_TYPE_INBAND, 0, + init_pkt, sizeof(nvsp_msg), (uint64_t)(uintptr_t)init_pkt); if (ret != 0) { goto cleanup; } @@ -815,9 +812,9 @@ hv_nv_on_send(struct hv_vmbus_channel *c ret = vmbus_chan_send_sglist(chan, pkt->gpa, pkt->gpa_cnt, &send_msg, sizeof(nvsp_msg), (uint64_t)(uintptr_t)pkt); } else { - ret = hv_vmbus_channel_send_packet(chan, - &send_msg, sizeof(nvsp_msg), (uint64_t)(uintptr_t)pkt, - VMBUS_CHANPKT_TYPE_INBAND, VMBUS_CHANPKT_FLAG_RC); + ret = vmbus_chan_send(chan, + VMBUS_CHANPKT_TYPE_INBAND, VMBUS_CHANPKT_FLAG_RC, + &send_msg, sizeof(nvsp_msg), (uint64_t)(uintptr_t)pkt); } return (ret); @@ -916,8 +913,8 @@ hv_nv_on_receive_completion(struct hv_vm retry_send_cmplt: /* Send the completion */ - ret = hv_vmbus_channel_send_packet(chan, &rx_comp_msg, - sizeof(nvsp_msg), tid, VMBUS_CHANPKT_TYPE_COMP, 0); + ret = vmbus_chan_send(chan, VMBUS_CHANPKT_TYPE_COMP, 0, + &rx_comp_msg, sizeof(nvsp_msg), tid); if (ret == 0) { /* success */ /* no-op */ Modified: stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.c Wed Oct 12 01:52:29 2016 (r307078) +++ stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.c Wed Oct 12 02:03:05 2016 (r307079) @@ -1167,9 +1167,9 @@ hv_rf_on_device_add(struct hn_softc *sc, init_pkt->msgs.vers_5_msgs.subchannel_request.num_subchannels = net_dev->num_channel - 1; - ret = hv_vmbus_channel_send_packet(sc->hn_prichan, init_pkt, - sizeof(nvsp_msg), (uint64_t)(uintptr_t)init_pkt, - VMBUS_CHANPKT_TYPE_INBAND, VMBUS_CHANPKT_FLAG_RC); + ret = vmbus_chan_send(sc->hn_prichan, + VMBUS_CHANPKT_TYPE_INBAND, VMBUS_CHANPKT_FLAG_RC, + init_pkt, sizeof(nvsp_msg), (uint64_t)(uintptr_t)init_pkt); if (ret != 0) { device_printf(dev, "Fail to allocate subchannel\n"); goto out; Modified: stable/10/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c ============================================================================== --- stable/10/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c Wed Oct 12 01:52:29 2016 (r307078) +++ stable/10/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c Wed Oct 12 02:03:05 2016 (r307079) @@ -356,13 +356,9 @@ storvsc_send_multichannel_request(struct vstor_packet->flags = REQUEST_COMPLETION_FLAG; vstor_packet->u.multi_channels_cnt = request_channels_cnt; - ret = hv_vmbus_channel_send_packet( - sc->hs_chan, - vstor_packet, - VSTOR_PKT_SIZE, - (uint64_t)(uintptr_t)request, - VMBUS_CHANPKT_TYPE_INBAND, - VMBUS_CHANPKT_FLAG_RC); + ret = vmbus_chan_send(sc->hs_chan, + VMBUS_CHANPKT_TYPE_INBAND, VMBUS_CHANPKT_FLAG_RC, + vstor_packet, VSTOR_PKT_SIZE, (uint64_t)(uintptr_t)request); /* wait for 5 seconds */ ret = sema_timedwait(&request->synch_sema, 5 * hz); @@ -427,13 +423,9 @@ hv_storvsc_channel_init(struct storvsc_s vstor_packet->flags = REQUEST_COMPLETION_FLAG; - ret = hv_vmbus_channel_send_packet( - sc->hs_chan, - vstor_packet, - VSTOR_PKT_SIZE, - (uint64_t)(uintptr_t)request, - VMBUS_CHANPKT_TYPE_INBAND, - VMBUS_CHANPKT_FLAG_RC); + ret = vmbus_chan_send(sc->hs_chan, + VMBUS_CHANPKT_TYPE_INBAND, VMBUS_CHANPKT_FLAG_RC, + vstor_packet, VSTOR_PKT_SIZE, (uint64_t)(uintptr_t)request); if (ret != 0) goto cleanup; @@ -461,13 +453,9 @@ hv_storvsc_channel_init(struct storvsc_s /* revision is only significant for Windows guests */ vstor_packet->u.version.revision = 0; - ret = hv_vmbus_channel_send_packet( - sc->hs_chan, - vstor_packet, - VSTOR_PKT_SIZE, - (uint64_t)(uintptr_t)request, - VMBUS_CHANPKT_TYPE_INBAND, - VMBUS_CHANPKT_FLAG_RC); + ret = vmbus_chan_send(sc->hs_chan, + VMBUS_CHANPKT_TYPE_INBAND, VMBUS_CHANPKT_FLAG_RC, + vstor_packet, VSTOR_PKT_SIZE, (uint64_t)(uintptr_t)request); if (ret != 0) goto cleanup; @@ -504,13 +492,9 @@ hv_storvsc_channel_init(struct storvsc_s vstor_packet->operation = VSTOR_OPERATION_QUERYPROPERTIES; vstor_packet->flags = REQUEST_COMPLETION_FLAG; - ret = hv_vmbus_channel_send_packet( - sc->hs_chan, - vstor_packet, - VSTOR_PKT_SIZE, - (uint64_t)(uintptr_t)request, - VMBUS_CHANPKT_TYPE_INBAND, - VMBUS_CHANPKT_FLAG_RC); + ret = vmbus_chan_send(sc->hs_chan, + VMBUS_CHANPKT_TYPE_INBAND, VMBUS_CHANPKT_FLAG_RC, + vstor_packet, VSTOR_PKT_SIZE, (uint64_t)(uintptr_t)request); if ( ret != 0) goto cleanup; @@ -540,13 +524,9 @@ hv_storvsc_channel_init(struct storvsc_s vstor_packet->operation = VSTOR_OPERATION_ENDINITIALIZATION; vstor_packet->flags = REQUEST_COMPLETION_FLAG; - ret = hv_vmbus_channel_send_packet( - sc->hs_chan, - vstor_packet, - VSTOR_PKT_SIZE, - (uint64_t)(uintptr_t)request, - VMBUS_CHANPKT_TYPE_INBAND, - VMBUS_CHANPKT_FLAG_RC); + ret = vmbus_chan_send(sc->hs_chan, + VMBUS_CHANPKT_TYPE_INBAND, VMBUS_CHANPKT_FLAG_RC, + vstor_packet, VSTOR_PKT_SIZE, (uint64_t)(uintptr_t)request); if (ret != 0) { goto cleanup; @@ -631,12 +611,10 @@ hv_storvsc_host_reset(struct storvsc_sof vstor_packet->operation = VSTOR_OPERATION_RESETBUS; vstor_packet->flags = REQUEST_COMPLETION_FLAG; - ret = hv_vmbus_channel_send_packet(dev->channel, - vstor_packet, - VSTOR_PKT_SIZE, - (uint64_t)(uintptr_t)&sc->hs_reset_req, - VMBUS_CHANPKT_TYPE_INBAND, - VMBUS_CHANPKT_FLAG_RC); + ret = vmbus_chan_send(dev->channel, + VMBUS_CHANPKT_TYPE_INBAND, VMBUS_CHANPKT_FLAG_RC, + vstor_packet, VSTOR_PKT_SIZE, + (uint64_t)(uintptr_t)&sc->hs_reset_req); if (ret != 0) { goto cleanup; @@ -695,13 +673,9 @@ hv_storvsc_io_request(struct storvsc_sof &request->prp_list.gpa_range, request->prp_cnt, vstor_packet, VSTOR_PKT_SIZE, (uint64_t)(uintptr_t)request); } else { - ret = hv_vmbus_channel_send_packet( - outgoing_channel, - vstor_packet, - VSTOR_PKT_SIZE, - (uint64_t)(uintptr_t)request, - VMBUS_CHANPKT_TYPE_INBAND, - VMBUS_CHANPKT_FLAG_RC); + ret = vmbus_chan_send(outgoing_channel, + VMBUS_CHANPKT_TYPE_INBAND, VMBUS_CHANPKT_FLAG_RC, + vstor_packet, VSTOR_PKT_SIZE, (uint64_t)(uintptr_t)request); } mtx_lock(&request->softc->hs_lock); Modified: stable/10/sys/dev/hyperv/utilities/hv_heartbeat.c ============================================================================== --- stable/10/sys/dev/hyperv/utilities/hv_heartbeat.c Wed Oct 12 01:52:29 2016 (r307078) +++ stable/10/sys/dev/hyperv/utilities/hv_heartbeat.c Wed Oct 12 02:03:05 2016 (r307079) @@ -87,8 +87,8 @@ hv_heartbeat_cb(void *context) icmsghdrp->icflags = HV_ICMSGHDRFLAG_TRANSACTION | HV_ICMSGHDRFLAG_RESPONSE; - hv_vmbus_channel_send_packet(channel, buf, recvlen, requestid, - VMBUS_CHANPKT_TYPE_INBAND, 0); + vmbus_chan_send(channel, VMBUS_CHANPKT_TYPE_INBAND, 0, + buf, recvlen, requestid); } } Modified: stable/10/sys/dev/hyperv/utilities/hv_kvp.c ============================================================================== --- stable/10/sys/dev/hyperv/utilities/hv_kvp.c Wed Oct 12 01:52:29 2016 (r307078) +++ stable/10/sys/dev/hyperv/utilities/hv_kvp.c Wed Oct 12 02:03:05 2016 (r307079) @@ -575,11 +575,9 @@ hv_kvp_respond_host(hv_kvp_sc *sc, int e hv_icmsg_hdrp->status = error; hv_icmsg_hdrp->icflags = HV_ICMSGHDRFLAG_TRANSACTION | HV_ICMSGHDRFLAG_RESPONSE; - error = hv_vmbus_channel_send_packet(sc->util_sc.channel, - sc->rcv_buf, - sc->host_msg_len, sc->host_msg_id, - VMBUS_CHANPKT_TYPE_INBAND, 0); - + error = vmbus_chan_send(sc->util_sc.channel, + VMBUS_CHANPKT_TYPE_INBAND, 0, sc->rcv_buf, sc->host_msg_len, + sc->host_msg_id); if (error) hv_kvp_log_info("%s: hv_kvp_respond_host: sendpacket error:%d\n", __func__, error); Modified: stable/10/sys/dev/hyperv/utilities/hv_shutdown.c ============================================================================== --- stable/10/sys/dev/hyperv/utilities/hv_shutdown.c Wed Oct 12 01:52:29 2016 (r307078) +++ stable/10/sys/dev/hyperv/utilities/hv_shutdown.c Wed Oct 12 02:03:05 2016 (r307079) @@ -105,9 +105,8 @@ hv_shutdown_cb(void *context) icmsghdrp->icflags = HV_ICMSGHDRFLAG_TRANSACTION | HV_ICMSGHDRFLAG_RESPONSE; - hv_vmbus_channel_send_packet(channel, buf, - recv_len, request_id, - VMBUS_CHANPKT_TYPE_INBAND, 0); + vmbus_chan_send(channel, VMBUS_CHANPKT_TYPE_INBAND, 0, + buf, recv_len, request_id); } if (execute_shutdown) Modified: stable/10/sys/dev/hyperv/utilities/hv_timesync.c ============================================================================== --- stable/10/sys/dev/hyperv/utilities/hv_timesync.c Wed Oct 12 01:52:29 2016 (r307078) +++ stable/10/sys/dev/hyperv/utilities/hv_timesync.c Wed Oct 12 02:03:05 2016 (r307079) @@ -163,9 +163,8 @@ hv_timesync_cb(void *context) icmsghdrp->icflags = HV_ICMSGHDRFLAG_TRANSACTION | HV_ICMSGHDRFLAG_RESPONSE; - hv_vmbus_channel_send_packet(channel, time_buf, - recvlen, requestId, - VMBUS_CHANPKT_TYPE_INBAND, 0); + vmbus_chan_send(channel, VMBUS_CHANPKT_TYPE_INBAND, 0, + time_buf, recvlen, requestId); } } Modified: stable/10/sys/dev/hyperv/vmbus/hv_channel.c ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/hv_channel.c Wed Oct 12 01:52:29 2016 (r307078) +++ stable/10/sys/dev/hyperv/vmbus/hv_channel.c Wed Oct 12 02:03:05 2016 (r307079) @@ -622,8 +622,8 @@ hv_vmbus_channel_close(struct hv_vmbus_c } int -hv_vmbus_channel_send_packet(struct hv_vmbus_channel *chan, - void *data, uint32_t dlen, uint64_t xactid, uint16_t type, uint16_t flags) +vmbus_chan_send(struct hv_vmbus_channel *chan, uint16_t type, uint16_t flags, + void *data, int dlen, uint64_t xactid) { struct vmbus_chanpkt pkt; int pktlen, pad_pktlen, hlen, error; @@ -633,12 +633,12 @@ hv_vmbus_channel_send_packet(struct hv_v hlen = sizeof(pkt); pktlen = hlen + dlen; - pad_pktlen = roundup2(pktlen, VMBUS_CHANPKT_SIZE_ALIGN); + pad_pktlen = VMBUS_CHANPKT_TOTLEN(pktlen); pkt.cp_hdr.cph_type = type; pkt.cp_hdr.cph_flags = flags; - pkt.cp_hdr.cph_data_ofs = hlen >> VMBUS_CHANPKT_SIZE_SHIFT; - pkt.cp_hdr.cph_len = pad_pktlen >> VMBUS_CHANPKT_SIZE_SHIFT; + VMBUS_CHANPKT_SETLEN(pkt.cp_hdr.cph_hlen, hlen); + VMBUS_CHANPKT_SETLEN(pkt.cp_hdr.cph_tlen, pad_pktlen); pkt.cp_hdr.cph_xactid = xactid; iov[0].iov_base = &pkt; @@ -669,12 +669,12 @@ vmbus_chan_send_sglist(struct hv_vmbus_c hlen = __offsetof(struct vmbus_chanpkt_sglist, cp_gpa[sglen]); pktlen = hlen + dlen; - pad_pktlen = roundup2(pktlen, VMBUS_CHANPKT_SIZE_ALIGN); + pad_pktlen = VMBUS_CHANPKT_TOTLEN(pktlen); pkt.cp_hdr.cph_type = VMBUS_CHANPKT_TYPE_GPA; pkt.cp_hdr.cph_flags = VMBUS_CHANPKT_FLAG_RC; - pkt.cp_hdr.cph_data_ofs = hlen >> VMBUS_CHANPKT_SIZE_SHIFT; - pkt.cp_hdr.cph_len = pad_pktlen >> VMBUS_CHANPKT_SIZE_SHIFT; + VMBUS_CHANPKT_SETLEN(pkt.cp_hdr.cph_hlen, hlen); + VMBUS_CHANPKT_SETLEN(pkt.cp_hdr.cph_tlen, pad_pktlen); pkt.cp_hdr.cph_xactid = xactid; pkt.cp_rsvd = 0; pkt.cp_gpa_cnt = sglen; @@ -711,12 +711,12 @@ vmbus_chan_send_prplist(struct hv_vmbus_ hlen = __offsetof(struct vmbus_chanpkt_prplist, cp_range[0].gpa_page[prp_cnt]); pktlen = hlen + dlen; - pad_pktlen = roundup2(pktlen, VMBUS_CHANPKT_SIZE_ALIGN); + pad_pktlen = VMBUS_CHANPKT_TOTLEN(pktlen); pkt.cp_hdr.cph_type = VMBUS_CHANPKT_TYPE_GPA; pkt.cp_hdr.cph_flags = VMBUS_CHANPKT_FLAG_RC; - pkt.cp_hdr.cph_data_ofs = hlen >> VMBUS_CHANPKT_SIZE_SHIFT; - pkt.cp_hdr.cph_len = pad_pktlen >> VMBUS_CHANPKT_SIZE_SHIFT; + VMBUS_CHANPKT_SETLEN(pkt.cp_hdr.cph_hlen, hlen); + VMBUS_CHANPKT_SETLEN(pkt.cp_hdr.cph_tlen, pad_pktlen); pkt.cp_hdr.cph_xactid = xactid; pkt.cp_rsvd = 0; pkt.cp_range_cnt = 1; Modified: stable/10/sys/dev/hyperv/vmbus/vmbus_reg.h ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/vmbus_reg.h Wed Oct 12 01:52:29 2016 (r307078) +++ stable/10/sys/dev/hyperv/vmbus/vmbus_reg.h Wed Oct 12 02:03:05 2016 (r307079) @@ -115,10 +115,18 @@ CTASSERT(sizeof(struct vmbus_mnf) == PAG #define VMBUS_CHANPKT_SIZE_SHIFT 3 #define VMBUS_CHANPKT_SIZE_ALIGN (1 << VMBUS_CHANPKT_SIZE_SHIFT) +#define VMBUS_CHANPKT_SETLEN(pktlen, len) \ +do { \ + (pktlen) = (len) >> VMBUS_CHANPKT_SIZE_SHIFT; \ +} while (0) + +#define VMBUS_CHANPKT_TOTLEN(tlen) \ + roundup2((tlen), VMBUS_CHANPKT_SIZE_ALIGN) + struct vmbus_chanpkt_hdr { uint16_t cph_type; - uint16_t cph_data_ofs; /* in 8 bytes */ - uint16_t cph_len; /* in 8 bytes */ + uint16_t cph_hlen; /* header len, in 8 bytes */ + uint16_t cph_tlen; /* total len, in 8 bytes */ uint16_t cph_flags; uint64_t cph_xactid; } __packed; From owner-svn-src-all@freebsd.org Wed Oct 12 02:09:55 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A3B5AC0D4C3; Wed, 12 Oct 2016 02:09:55 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 679321387; Wed, 12 Oct 2016 02:09:55 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9C29sWk038148; Wed, 12 Oct 2016 02:09:54 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9C29rgs038138; Wed, 12 Oct 2016 02:09:53 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610120209.u9C29rgs038138@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Wed, 12 Oct 2016 02:09:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307080 - in stable/10/sys/dev/hyperv: include netvsc storvsc utilities vmbus X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Oct 2016 02:09:55 -0000 Author: sephe Date: Wed Oct 12 02:09:53 2016 New Revision: 307080 URL: https://svnweb.freebsd.org/changeset/base/307080 Log: MFC 302885,302886 302885 hyperv/vmbus: Cleanup channel receiving. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7202 302886 hyperv/vmbus: Cleanup channel packet receiving. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7204 Modified: stable/10/sys/dev/hyperv/include/hyperv.h stable/10/sys/dev/hyperv/include/vmbus.h stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.c stable/10/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c stable/10/sys/dev/hyperv/utilities/hv_heartbeat.c stable/10/sys/dev/hyperv/utilities/hv_kvp.c stable/10/sys/dev/hyperv/utilities/hv_shutdown.c stable/10/sys/dev/hyperv/utilities/hv_timesync.c stable/10/sys/dev/hyperv/vmbus/hv_channel.c stable/10/sys/dev/hyperv/vmbus/vmbus_reg.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/hyperv/include/hyperv.h ============================================================================== --- stable/10/sys/dev/hyperv/include/hyperv.h Wed Oct 12 02:03:05 2016 (r307079) +++ stable/10/sys/dev/hyperv/include/hyperv.h Wed Oct 12 02:09:53 2016 (r307080) @@ -90,28 +90,6 @@ struct hyperv_guid { int hyperv_guid2str(const struct hyperv_guid *, char *, size_t); -typedef struct { - uint16_t type; - uint16_t data_offset8; - uint16_t length8; - uint16_t flags; - uint64_t transaction_id; -} __packed hv_vm_packet_descriptor; - -typedef struct { - uint32_t byte_count; - uint32_t byte_offset; -} __packed hv_vm_transfer_page; - -typedef struct { - hv_vm_packet_descriptor d; - uint16_t transfer_page_set_id; - hv_bool_uint8_t sender_owns_set; - uint8_t reserved; - uint32_t range_count; - hv_vm_transfer_page ranges[1]; -} __packed hv_vm_transfer_page_packet_header; - #define HW_MACADDR_LEN 6 /* @@ -298,20 +276,6 @@ hv_set_channel_read_state(hv_vmbus_chann channel->ch_flags |= VMBUS_CHAN_FLAG_BATCHREAD; } -int hv_vmbus_channel_recv_packet( - hv_vmbus_channel* channel, - void* buffer, - uint32_t buffer_len, - uint32_t* buffer_actual_len, - uint64_t* request_id); - -int hv_vmbus_channel_recv_packet_raw( - hv_vmbus_channel* channel, - void* buffer, - uint32_t buffer_len, - uint32_t* buffer_actual_len, - uint64_t* request_id); - int hv_vmbus_channel_open( hv_vmbus_channel* channel, uint32_t send_ring_buffer_size, Modified: stable/10/sys/dev/hyperv/include/vmbus.h ============================================================================== --- stable/10/sys/dev/hyperv/include/vmbus.h Wed Oct 12 02:03:05 2016 (r307079) +++ stable/10/sys/dev/hyperv/include/vmbus.h Wed Oct 12 02:09:53 2016 (r307080) @@ -47,6 +47,19 @@ struct vmbus_gpa { uint64_t gpa_page; } __packed; +#define VMBUS_CHANPKT_SIZE_SHIFT 3 + +#define VMBUS_CHANPKT_GETLEN(pktlen) \ + (((int)(pktlen)) << VMBUS_CHANPKT_SIZE_SHIFT) + +struct vmbus_chanpkt_hdr { + uint16_t cph_type; /* VMBUS_CHANPKT_TYPE_ */ + uint16_t cph_hlen; /* header len, in 8 bytes */ + uint16_t cph_tlen; /* total len, in 8 bytes */ + uint16_t cph_flags; /* VMBUS_CHANPKT_FLAG_ */ + uint64_t cph_xactid; +} __packed; + #define VMBUS_CHANPKT_TYPE_INBAND 0x0006 #define VMBUS_CHANPKT_TYPE_RXBUF 0x0007 #define VMBUS_CHANPKT_TYPE_GPA 0x0009 @@ -54,11 +67,33 @@ struct vmbus_gpa { #define VMBUS_CHANPKT_FLAG_RC 0x0001 /* report completion */ +#define VMBUS_CHANPKT_CONST_DATA(pkt) \ + (const void *)((const uint8_t *)(pkt) + \ + VMBUS_CHANPKT_GETLEN((pkt)->cph_hlen)) + +struct vmbus_rxbuf_desc { + uint32_t rb_len; + uint32_t rb_ofs; +} __packed; + +struct vmbus_chanpkt_rxbuf { + struct vmbus_chanpkt_hdr cp_hdr; + uint16_t cp_rxbuf_id; + uint16_t cp_rsvd; + uint32_t cp_rxbuf_cnt; + struct vmbus_rxbuf_desc cp_rxbuf[]; +} __packed; + #define VMBUS_CHAN_SGLIST_MAX 32 #define VMBUS_CHAN_PRPLIST_MAX 32 struct hv_vmbus_channel; +int vmbus_chan_recv(struct hv_vmbus_channel *chan, void *data, int *dlen, + uint64_t *xactid); +int vmbus_chan_recv_pkt(struct hv_vmbus_channel *chan, + struct vmbus_chanpkt_hdr *pkt, int *pktlen); + int vmbus_chan_send(struct hv_vmbus_channel *chan, uint16_t type, uint16_t flags, void *data, int dlen, uint64_t xactid); int vmbus_chan_send_sglist(struct hv_vmbus_channel *chan, Modified: stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.c Wed Oct 12 02:03:05 2016 (r307079) +++ stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.c Wed Oct 12 02:09:53 2016 (r307080) @@ -63,12 +63,12 @@ static int hv_nv_destroy_send_buffer(ne static int hv_nv_destroy_rx_buffer(netvsc_dev *net_dev); static int hv_nv_connect_to_vsp(struct hn_softc *sc); static void hv_nv_on_send_completion(netvsc_dev *net_dev, - struct hv_vmbus_channel *, hv_vm_packet_descriptor *pkt); + struct hv_vmbus_channel *, const struct vmbus_chanpkt_hdr *pkt); static void hv_nv_on_receive_completion(struct hv_vmbus_channel *chan, uint64_t tid, uint32_t status); static void hv_nv_on_receive(netvsc_dev *net_dev, struct hn_softc *sc, struct hv_vmbus_channel *chan, - hv_vm_packet_descriptor *pkt); + const struct vmbus_chanpkt_hdr *pkt); /* * @@ -725,13 +725,12 @@ hv_nv_on_device_remove(struct hn_softc * */ static void hv_nv_on_send_completion(netvsc_dev *net_dev, struct hv_vmbus_channel *chan, - hv_vm_packet_descriptor *pkt) + const struct vmbus_chanpkt_hdr *pkt) { - nvsp_msg *nvsp_msg_pkt; + const nvsp_msg *nvsp_msg_pkt; netvsc_packet *net_vsc_pkt; - nvsp_msg_pkt = - (nvsp_msg *)((unsigned long)pkt + (pkt->data_offset8 << 3)); + nvsp_msg_pkt = VMBUS_CHANPKT_CONST_DATA(pkt); if (nvsp_msg_pkt->hdr.msg_type == nvsp_msg_type_init_complete || nvsp_msg_pkt->hdr.msg_type @@ -748,7 +747,7 @@ hv_nv_on_send_completion(netvsc_dev *net nvsp_msg_1_type_send_rndis_pkt_complete) { /* Get the send context */ net_vsc_pkt = - (netvsc_packet *)(unsigned long)pkt->transaction_id; + (netvsc_packet *)(unsigned long)pkt->cph_xactid; if (NULL != net_vsc_pkt) { if (net_vsc_pkt->send_buf_section_idx != NVSP_1_CHIMNEY_SEND_INVALID_SECTION_INDEX) { @@ -828,10 +827,10 @@ hv_nv_on_send(struct hv_vmbus_channel *c */ static void hv_nv_on_receive(netvsc_dev *net_dev, struct hn_softc *sc, - struct hv_vmbus_channel *chan, hv_vm_packet_descriptor *pkt) + struct hv_vmbus_channel *chan, const struct vmbus_chanpkt_hdr *pkthdr) { - hv_vm_transfer_page_packet_header *vm_xfer_page_pkt; - nvsp_msg *nvsp_msg_pkt; + const struct vmbus_chanpkt_rxbuf *pkt; + const nvsp_msg *nvsp_msg_pkt; netvsc_packet vsc_pkt; netvsc_packet *net_vsc_pkt = &vsc_pkt; device_t dev = sc->hn_dev; @@ -839,43 +838,31 @@ hv_nv_on_receive(netvsc_dev *net_dev, st int i = 0; int status = nvsp_status_success; - /* - * All inbound packets other than send completion should be - * xfer page packet. - */ - if (pkt->type != VMBUS_CHANPKT_TYPE_RXBUF) { - device_printf(dev, "packet type %d is invalid!\n", pkt->type); - return; - } - - nvsp_msg_pkt = (nvsp_msg *)((unsigned long)pkt - + (pkt->data_offset8 << 3)); + nvsp_msg_pkt = VMBUS_CHANPKT_CONST_DATA(pkthdr); /* Make sure this is a valid nvsp packet */ if (nvsp_msg_pkt->hdr.msg_type != nvsp_msg_1_type_send_rndis_pkt) { - device_printf(dev, "packet hdr type %d is invalid!\n", - pkt->type); + device_printf(dev, "packet hdr type %u is invalid!\n", + nvsp_msg_pkt->hdr.msg_type); return; } - vm_xfer_page_pkt = (hv_vm_transfer_page_packet_header *)pkt; + pkt = (const struct vmbus_chanpkt_rxbuf *)pkthdr; - if (vm_xfer_page_pkt->transfer_page_set_id != - NETVSC_RECEIVE_BUFFER_ID) { - device_printf(dev, "transfer_page_set_id %d is invalid!\n", - vm_xfer_page_pkt->transfer_page_set_id); + if (pkt->cp_rxbuf_id != NETVSC_RECEIVE_BUFFER_ID) { + device_printf(dev, "rxbuf_id %d is invalid!\n", + pkt->cp_rxbuf_id); return; } - count = vm_xfer_page_pkt->range_count; + count = pkt->cp_rxbuf_cnt; /* Each range represents 1 RNDIS pkt that contains 1 Ethernet frame */ for (i = 0; i < count; i++) { net_vsc_pkt->status = nvsp_status_success; - net_vsc_pkt->data = (void *)((unsigned long)net_dev->rx_buf + - vm_xfer_page_pkt->ranges[i].byte_offset); - net_vsc_pkt->tot_data_buf_len = - vm_xfer_page_pkt->ranges[i].byte_count; + net_vsc_pkt->data = ((uint8_t *)net_dev->rx_buf + + pkt->cp_rxbuf[i].rb_ofs); + net_vsc_pkt->tot_data_buf_len = pkt->cp_rxbuf[i].rb_len; hv_rf_on_receive(net_dev, chan, net_vsc_pkt); if (net_vsc_pkt->status != nvsp_status_success) { @@ -888,8 +875,7 @@ hv_nv_on_receive(netvsc_dev *net_dev, st * messages (not just data messages) will trigger a response * message back to the host. */ - hv_nv_on_receive_completion(chan, vm_xfer_page_pkt->d.transaction_id, - status); + hv_nv_on_receive_completion(chan, pkt->cp_hdr.cph_xactid, status); } /* @@ -933,19 +919,19 @@ retry_send_cmplt: * Net VSC receiving vRSS send table from VSP */ static void -hv_nv_send_table(struct hn_softc *sc, hv_vm_packet_descriptor *pkt) +hv_nv_send_table(struct hn_softc *sc, const struct vmbus_chanpkt_hdr *pkt) { netvsc_dev *net_dev; - nvsp_msg *nvsp_msg_pkt; + const nvsp_msg *nvsp_msg_pkt; int i; - uint32_t count, *table; + uint32_t count; + const uint32_t *table; net_dev = hv_nv_get_inbound_net_device(sc); if (!net_dev) return; - nvsp_msg_pkt = - (nvsp_msg *)((unsigned long)pkt + (pkt->data_offset8 << 3)); + nvsp_msg_pkt = VMBUS_CHANPKT_CONST_DATA(pkt); if (nvsp_msg_pkt->hdr.msg_type != nvsp_msg5_type_send_indirection_table) { @@ -961,8 +947,8 @@ hv_nv_send_table(struct hn_softc *sc, hv return; } - table = (uint32_t *) - ((unsigned long)&nvsp_msg_pkt->msgs.vers_5_msgs.send_table + + table = (const uint32_t *) + ((const uint8_t *)&nvsp_msg_pkt->msgs.vers_5_msgs.send_table + nvsp_msg_pkt->msgs.vers_5_msgs.send_table.offset); for (i = 0; i < count; i++) @@ -979,44 +965,40 @@ hv_nv_on_channel_callback(void *xchan) device_t dev = chan->ch_dev; struct hn_softc *sc = device_get_softc(dev); netvsc_dev *net_dev; - uint32_t bytes_rxed; - uint64_t request_id; - hv_vm_packet_descriptor *desc; - uint8_t *buffer; + void *buffer; int bufferlen = NETVSC_PACKET_SIZE; - int ret = 0; net_dev = hv_nv_get_inbound_net_device(sc); if (net_dev == NULL) return; buffer = chan->hv_chan_rdbuf; - do { - ret = hv_vmbus_channel_recv_packet_raw(chan, - buffer, bufferlen, &bytes_rxed, &request_id); + struct vmbus_chanpkt_hdr *pkt = buffer; + uint32_t bytes_rxed; + int ret; + + bytes_rxed = bufferlen; + ret = vmbus_chan_recv_pkt(chan, pkt, &bytes_rxed); if (ret == 0) { if (bytes_rxed > 0) { - desc = (hv_vm_packet_descriptor *)buffer; - switch (desc->type) { + switch (pkt->cph_type) { case VMBUS_CHANPKT_TYPE_COMP: hv_nv_on_send_completion(net_dev, chan, - desc); + pkt); break; case VMBUS_CHANPKT_TYPE_RXBUF: - hv_nv_on_receive(net_dev, sc, chan, desc); + hv_nv_on_receive(net_dev, sc, chan, pkt); break; case VMBUS_CHANPKT_TYPE_INBAND: - hv_nv_send_table(sc, desc); + hv_nv_send_table(sc, pkt); break; default: device_printf(dev, - "hv_cb recv unknow type %d " - " packet\n", desc->type); + "unknown chan pkt %u\n", + pkt->cph_type); break; } - } else { - break; } } else if (ret == ENOBUFS) { /* Handle large packet */ @@ -1035,6 +1017,9 @@ hv_nv_on_channel_callback(void *xchan) break; } bufferlen = bytes_rxed; + } else { + /* No more packets */ + break; } } while (1); Modified: stable/10/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c ============================================================================== --- stable/10/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c Wed Oct 12 02:03:05 2016 (r307079) +++ stable/10/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c Wed Oct 12 02:09:53 2016 (r307080) @@ -780,12 +780,10 @@ hv_storvsc_on_channel_callback(void *xch struct hv_storvsc_request *request; struct vstor_packet *vstor_packet; - ret = hv_vmbus_channel_recv_packet( - channel, - packet, - roundup2(VSTOR_PKT_SIZE, 8), - &bytes_recvd, - &request_id); + bytes_recvd = roundup2(VSTOR_PKT_SIZE, 8); + ret = vmbus_chan_recv(channel, packet, &bytes_recvd, &request_id); + KASSERT(ret != ENOBUFS, ("storvsc recvbuf is not large enough")); + /* XXX check bytes_recvd to make sure that it contains enough data */ while ((ret == 0) && (bytes_recvd > 0)) { request = (struct hv_storvsc_request *)(uintptr_t)request_id; @@ -819,12 +817,16 @@ hv_storvsc_on_channel_callback(void *xch break; } } - ret = hv_vmbus_channel_recv_packet( - channel, - packet, - roundup2(VSTOR_PKT_SIZE, 8), - &bytes_recvd, - &request_id); + + bytes_recvd = roundup2(VSTOR_PKT_SIZE, 8), + ret = vmbus_chan_recv(channel, packet, &bytes_recvd, + &request_id); + KASSERT(ret != ENOBUFS, + ("storvsc recvbuf is not large enough")); + /* + * XXX check bytes_recvd to make sure that it contains + * enough data + */ } } Modified: stable/10/sys/dev/hyperv/utilities/hv_heartbeat.c ============================================================================== --- stable/10/sys/dev/hyperv/utilities/hv_heartbeat.c Wed Oct 12 02:03:05 2016 (r307079) +++ stable/10/sys/dev/hyperv/utilities/hv_heartbeat.c Wed Oct 12 02:09:53 2016 (r307080) @@ -52,7 +52,7 @@ hv_heartbeat_cb(void *context) { uint8_t* buf; hv_vmbus_channel* channel; - uint32_t recvlen; + int recvlen; uint64_t requestid; int ret; @@ -64,8 +64,10 @@ hv_heartbeat_cb(void *context) buf = softc->receive_buffer;; channel = softc->channel; - ret = hv_vmbus_channel_recv_packet(channel, buf, PAGE_SIZE, &recvlen, - &requestid); + recvlen = PAGE_SIZE; + ret = vmbus_chan_recv(channel, buf, &recvlen, &requestid); + KASSERT(ret != ENOBUFS, ("hvheartbeat recvbuf is not large enough")); + /* XXX check recvlen to make sure that it contains enough data */ if ((ret == 0) && recvlen > 0) { Modified: stable/10/sys/dev/hyperv/utilities/hv_kvp.c ============================================================================== --- stable/10/sys/dev/hyperv/utilities/hv_kvp.c Wed Oct 12 02:03:05 2016 (r307079) +++ stable/10/sys/dev/hyperv/utilities/hv_kvp.c Wed Oct 12 02:09:53 2016 (r307080) @@ -626,8 +626,10 @@ hv_kvp_process_request(void *context, in kvp_buf = sc->util_sc.receive_buffer;; channel = sc->util_sc.channel; - ret = hv_vmbus_channel_recv_packet(channel, kvp_buf, 2 * PAGE_SIZE, - &recvlen, &requestid); + recvlen = 2 * PAGE_SIZE; + ret = vmbus_chan_recv(channel, kvp_buf, &recvlen, &requestid); + KASSERT(ret != ENOBUFS, ("hvkvp recvbuf is not large enough")); + /* XXX check recvlen to make sure that it contains enough data */ while ((ret == 0) && (recvlen > 0)) { @@ -691,9 +693,11 @@ hv_kvp_process_request(void *context, in /* * Try reading next buffer */ - recvlen = 0; - ret = hv_vmbus_channel_recv_packet(channel, kvp_buf, 2 * PAGE_SIZE, - &recvlen, &requestid); + recvlen = 2 * PAGE_SIZE; + ret = vmbus_chan_recv(channel, kvp_buf, &recvlen, &requestid); + KASSERT(ret != ENOBUFS, ("hvkvp recvbuf is not large enough")); + /* XXX check recvlen to make sure that it contains enough data */ + hv_kvp_log_info("%s: read: context %p, ret =%d, recvlen=%d\n", __func__, context, ret, recvlen); } Modified: stable/10/sys/dev/hyperv/utilities/hv_shutdown.c ============================================================================== --- stable/10/sys/dev/hyperv/utilities/hv_shutdown.c Wed Oct 12 02:03:05 2016 (r307079) +++ stable/10/sys/dev/hyperv/utilities/hv_shutdown.c Wed Oct 12 02:09:53 2016 (r307080) @@ -67,8 +67,11 @@ hv_shutdown_cb(void *context) softc = (hv_util_sc*)context; buf = softc->receive_buffer;; channel = softc->channel; - ret = hv_vmbus_channel_recv_packet(channel, buf, PAGE_SIZE, - &recv_len, &request_id); + + recv_len = PAGE_SIZE; + ret = vmbus_chan_recv(channel, buf, &recv_len, &request_id); + KASSERT(ret != ENOBUFS, ("hvshutdown recvbuf is not large enough")); + /* XXX check recv_len to make sure that it contains enough data */ if ((ret == 0) && recv_len > 0) { Modified: stable/10/sys/dev/hyperv/utilities/hv_timesync.c ============================================================================== --- stable/10/sys/dev/hyperv/utilities/hv_timesync.c Wed Oct 12 02:03:05 2016 (r307079) +++ stable/10/sys/dev/hyperv/utilities/hv_timesync.c Wed Oct 12 02:09:53 2016 (r307080) @@ -144,8 +144,10 @@ hv_timesync_cb(void *context) channel = softc->util_sc.channel; time_buf = softc->util_sc.receive_buffer; - ret = hv_vmbus_channel_recv_packet(channel, time_buf, - PAGE_SIZE, &recvlen, &requestId); + recvlen = PAGE_SIZE; + ret = vmbus_chan_recv(channel, time_buf, &recvlen, &requestId); + KASSERT(ret != ENOBUFS, ("hvtimesync recvbuf is not large enough")); + /* XXX check recvlen to make sure that it contains enough data */ if ((ret == 0) && recvlen > 0) { icmsghdrp = (struct hv_vmbus_icmsg_hdr *) &time_buf[ Modified: stable/10/sys/dev/hyperv/vmbus/hv_channel.c ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/hv_channel.c Wed Oct 12 02:03:05 2016 (r307079) +++ stable/10/sys/dev/hyperv/vmbus/hv_channel.c Wed Oct 12 02:09:53 2016 (r307080) @@ -736,84 +736,60 @@ vmbus_chan_send_prplist(struct hv_vmbus_ return error; } -/** - * @brief Retrieve the user packet on the specified channel - */ int -hv_vmbus_channel_recv_packet( - hv_vmbus_channel* channel, - void* Buffer, - uint32_t buffer_len, - uint32_t* buffer_actual_len, - uint64_t* request_id) +vmbus_chan_recv(struct hv_vmbus_channel *chan, void *data, int *dlen0, + uint64_t *xactid) { - int ret; - uint32_t user_len; - uint32_t packet_len; - hv_vm_packet_descriptor desc; - - *buffer_actual_len = 0; - *request_id = 0; - - ret = hv_ring_buffer_peek(&channel->inbound, &desc, - sizeof(hv_vm_packet_descriptor)); - if (ret != 0) - return (0); + struct vmbus_chanpkt_hdr pkt; + int error, dlen, hlen; - packet_len = desc.length8 << 3; - user_len = packet_len - (desc.data_offset8 << 3); + error = hv_ring_buffer_peek(&chan->inbound, &pkt, sizeof(pkt)); + if (error) + return error; - *buffer_actual_len = user_len; + hlen = VMBUS_CHANPKT_GETLEN(pkt.cph_hlen); + dlen = VMBUS_CHANPKT_GETLEN(pkt.cph_tlen) - hlen; - if (user_len > buffer_len) - return (EINVAL); + if (*dlen0 < dlen) { + /* Return the size of this packet's data. */ + *dlen0 = dlen; + return ENOBUFS; + } - *request_id = desc.transaction_id; + *xactid = pkt.cph_xactid; + *dlen0 = dlen; - /* Copy over the packet to the user buffer */ - ret = hv_ring_buffer_read(&channel->inbound, Buffer, user_len, - (desc.data_offset8 << 3)); + /* Skip packet header */ + error = hv_ring_buffer_read(&chan->inbound, data, dlen, hlen); + KASSERT(!error, ("hv_ring_buffer_read failed")); - return (0); + return 0; } -/** - * @brief Retrieve the raw packet on the specified channel - */ int -hv_vmbus_channel_recv_packet_raw( - hv_vmbus_channel* channel, - void* buffer, - uint32_t buffer_len, - uint32_t* buffer_actual_len, - uint64_t* request_id) +vmbus_chan_recv_pkt(struct hv_vmbus_channel *chan, + struct vmbus_chanpkt_hdr *pkt0, int *pktlen0) { - int ret; - uint32_t packetLen; - hv_vm_packet_descriptor desc; + struct vmbus_chanpkt_hdr pkt; + int error, pktlen; - *buffer_actual_len = 0; - *request_id = 0; + error = hv_ring_buffer_peek(&chan->inbound, &pkt, sizeof(pkt)); + if (error) + return error; + + pktlen = VMBUS_CHANPKT_GETLEN(pkt.cph_tlen); + if (*pktlen0 < pktlen) { + /* Return the size of this packet. */ + *pktlen0 = pktlen; + return ENOBUFS; + } + *pktlen0 = pktlen; + + /* Include packet header */ + error = hv_ring_buffer_read(&chan->inbound, pkt0, pktlen, 0); + KASSERT(!error, ("hv_ring_buffer_read failed")); - ret = hv_ring_buffer_peek( - &channel->inbound, &desc, - sizeof(hv_vm_packet_descriptor)); - - if (ret != 0) - return (0); - - packetLen = desc.length8 << 3; - *buffer_actual_len = packetLen; - - if (packetLen > buffer_len) - return (ENOBUFS); - - *request_id = desc.transaction_id; - - /* Copy over the entire packet to the user buffer */ - ret = hv_ring_buffer_read(&channel->inbound, buffer, packetLen, 0); - - return (0); + return 0; } static void Modified: stable/10/sys/dev/hyperv/vmbus/vmbus_reg.h ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/vmbus_reg.h Wed Oct 12 02:03:05 2016 (r307079) +++ stable/10/sys/dev/hyperv/vmbus/vmbus_reg.h Wed Oct 12 02:09:53 2016 (r307080) @@ -112,7 +112,6 @@ CTASSERT(sizeof(struct vmbus_mnf) == PAG * Channel packets */ -#define VMBUS_CHANPKT_SIZE_SHIFT 3 #define VMBUS_CHANPKT_SIZE_ALIGN (1 << VMBUS_CHANPKT_SIZE_SHIFT) #define VMBUS_CHANPKT_SETLEN(pktlen, len) \ @@ -123,14 +122,6 @@ do { \ #define VMBUS_CHANPKT_TOTLEN(tlen) \ roundup2((tlen), VMBUS_CHANPKT_SIZE_ALIGN) -struct vmbus_chanpkt_hdr { - uint16_t cph_type; - uint16_t cph_hlen; /* header len, in 8 bytes */ - uint16_t cph_tlen; /* total len, in 8 bytes */ - uint16_t cph_flags; - uint64_t cph_xactid; -} __packed; - struct vmbus_chanpkt { struct vmbus_chanpkt_hdr cp_hdr; } __packed; From owner-svn-src-all@freebsd.org Wed Oct 12 02:15:08 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 756FEC0D749; Wed, 12 Oct 2016 02:15:08 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4FBFA181A; Wed, 12 Oct 2016 02:15:08 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9C2F7Of041702; Wed, 12 Oct 2016 02:15:07 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9C2F7uI041698; Wed, 12 Oct 2016 02:15:07 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610120215.u9C2F7uI041698@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Wed, 12 Oct 2016 02:15:07 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307081 - in stable/10/sys/dev/hyperv: include netvsc vmbus X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Oct 2016 02:15:08 -0000 Author: sephe Date: Wed Oct 12 02:15:06 2016 New Revision: 307081 URL: https://svnweb.freebsd.org/changeset/base/307081 Log: MFC 302887 hyperv/hn: Busdma-fy rxbuf and chimney sending buffer Nuke unused channel GPADL API. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7211 Modified: stable/10/sys/dev/hyperv/include/hyperv.h stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.c stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h stable/10/sys/dev/hyperv/vmbus/hv_channel.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/hyperv/include/hyperv.h ============================================================================== --- stable/10/sys/dev/hyperv/include/hyperv.h Wed Oct 12 02:09:53 2016 (r307080) +++ stable/10/sys/dev/hyperv/include/hyperv.h Wed Oct 12 02:15:06 2016 (r307081) @@ -287,14 +287,6 @@ int hv_vmbus_channel_open( void hv_vmbus_channel_close(hv_vmbus_channel *channel); -int hv_vmbus_channel_establish_gpadl( - hv_vmbus_channel* channel, - /* must be phys and virt contiguous */ - void* contig_buffer, - /* page-size multiple */ - uint32_t size, - uint32_t* gpadl_handle); - int hv_vmbus_channel_teardown_gpdal( hv_vmbus_channel* channel, uint32_t gpadl_handle); Modified: stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.c Wed Oct 12 02:09:53 2016 (r307080) +++ stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.c Wed Oct 12 02:15:06 2016 (r307081) @@ -151,19 +151,27 @@ hv_nv_init_rx_buffer_with_net_vsp(struct return (ENODEV); } - net_dev->rx_buf = contigmalloc(net_dev->rx_buf_size, M_NETVSC, - M_ZERO, 0UL, BUS_SPACE_MAXADDR, PAGE_SIZE, 0); + net_dev->rx_buf = hyperv_dmamem_alloc(bus_get_dma_tag(sc->hn_dev), + PAGE_SIZE, 0, net_dev->rx_buf_size, &net_dev->rxbuf_dma, + BUS_DMA_WAITOK | BUS_DMA_ZERO); + if (net_dev->rx_buf == NULL) { + device_printf(sc->hn_dev, "allocate rxbuf failed\n"); + return ENOMEM; + } /* - * Establish the GPADL handle for this buffer on this channel. - * Note: This call uses the vmbus connection rather than the - * channel to establish the gpadl handle. - * GPADL: Guest physical address descriptor list. - */ - ret = hv_vmbus_channel_establish_gpadl( - sc->hn_prichan, net_dev->rx_buf, - net_dev->rx_buf_size, &net_dev->rx_buf_gpadl_handle); + * Connect the RXBUF GPADL to the primary channel. + * + * NOTE: + * Only primary channel has RXBUF connected to it. Sub-channels + * just share this RXBUF. + */ + ret = vmbus_chan_gpadl_connect(sc->hn_prichan, + net_dev->rxbuf_dma.hv_paddr, net_dev->rx_buf_size, + &net_dev->rx_buf_gpadl_handle); if (ret != 0) { + device_printf(sc->hn_dev, "rxbuf gpadl connect failed: %d\n", + ret); goto cleanup; } @@ -242,22 +250,27 @@ hv_nv_init_send_buffer_with_net_vsp(stru return (ENODEV); } - net_dev->send_buf = contigmalloc(net_dev->send_buf_size, M_NETVSC, - M_ZERO, 0UL, BUS_SPACE_MAXADDR, PAGE_SIZE, 0); + net_dev->send_buf = hyperv_dmamem_alloc(bus_get_dma_tag(sc->hn_dev), + PAGE_SIZE, 0, net_dev->send_buf_size, &net_dev->txbuf_dma, + BUS_DMA_WAITOK | BUS_DMA_ZERO); if (net_dev->send_buf == NULL) { - ret = ENOMEM; - goto cleanup; + device_printf(sc->hn_dev, "allocate chimney txbuf failed\n"); + return ENOMEM; } /* - * Establish the gpadl handle for this buffer on this channel. - * Note: This call uses the vmbus connection rather than the - * channel to establish the gpadl handle. + * Connect chimney sending buffer GPADL to the primary channel. + * + * NOTE: + * Only primary channel has chimney sending buffer connected to it. + * Sub-channels just share this chimney sending buffer. */ - ret = hv_vmbus_channel_establish_gpadl(sc->hn_prichan, - net_dev->send_buf, net_dev->send_buf_size, + ret = vmbus_chan_gpadl_connect(sc->hn_prichan, + net_dev->txbuf_dma.hv_paddr, net_dev->send_buf_size, &net_dev->send_buf_gpadl_handle); if (ret != 0) { + device_printf(sc->hn_dev, "chimney sending buffer gpadl " + "connect failed: %d\n", ret); goto cleanup; } @@ -363,7 +376,7 @@ hv_nv_destroy_rx_buffer(netvsc_dev *net_ if (net_dev->rx_buf) { /* Free up the receive buffer */ - contigfree(net_dev->rx_buf, net_dev->rx_buf_size, M_NETVSC); + hyperv_dmamem_free(&net_dev->rxbuf_dma, net_dev->rx_buf); net_dev->rx_buf = NULL; } @@ -431,7 +444,7 @@ hv_nv_destroy_send_buffer(netvsc_dev *ne if (net_dev->send_buf) { /* Free up the receive buffer */ - contigfree(net_dev->send_buf, net_dev->send_buf_size, M_NETVSC); + hyperv_dmamem_free(&net_dev->txbuf_dma, net_dev->send_buf); net_dev->send_buf = NULL; } Modified: stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h Wed Oct 12 02:09:53 2016 (r307080) +++ stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h Wed Oct 12 02:15:06 2016 (r307081) @@ -57,6 +57,7 @@ #include #include +#include #include #define HN_USE_TXDESC_BUFRING @@ -1075,6 +1076,8 @@ typedef struct netvsc_dev_ { uint32_t num_channel; + struct hyperv_dma rxbuf_dma; + struct hyperv_dma txbuf_dma; uint32_t vrss_send_table[VRSS_SEND_TABLE_SIZE]; } netvsc_dev; Modified: stable/10/sys/dev/hyperv/vmbus/hv_channel.c ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/hv_channel.c Wed Oct 12 02:09:53 2016 (r307080) +++ stable/10/sys/dev/hyperv/vmbus/hv_channel.c Wed Oct 12 02:15:06 2016 (r307081) @@ -337,17 +337,6 @@ failed: return ret; } -/** - * @brief Establish a GPADL for the specified buffer - */ -int -hv_vmbus_channel_establish_gpadl(struct hv_vmbus_channel *channel, - void *contig_buffer, uint32_t size, uint32_t *gpadl) -{ - return vmbus_chan_gpadl_connect(channel, - hv_get_phys_addr(contig_buffer), size, gpadl); -} - int vmbus_chan_gpadl_connect(struct hv_vmbus_channel *chan, bus_addr_t paddr, int size, uint32_t *gpadl0) From owner-svn-src-all@freebsd.org Wed Oct 12 02:16:51 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 8CE20C0D80C; Wed, 12 Oct 2016 02:16:51 +0000 (UTC) (envelope-from jtl@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 36E2F19B9; Wed, 12 Oct 2016 02:16:51 +0000 (UTC) (envelope-from jtl@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9C2GoGg041898; Wed, 12 Oct 2016 02:16:50 GMT (envelope-from jtl@FreeBSD.org) Received: (from jtl@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9C2Gga8041814; Wed, 12 Oct 2016 02:16:42 GMT (envelope-from jtl@FreeBSD.org) Message-Id: <201610120216.u9C2Gga8041814@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jtl set sender to jtl@FreeBSD.org using -f From: "Jonathan T. Looney" Date: Wed, 12 Oct 2016 02:16:42 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307082 - in head: . sys/amd64/conf sys/arm/conf sys/arm64/conf sys/conf sys/i386/conf sys/mips/conf sys/modules/cc sys/modules/khelp sys/netinet sys/netinet/tcp_stacks sys/pc98/conf sy... X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Oct 2016 02:16:51 -0000 Author: jtl Date: Wed Oct 12 02:16:42 2016 New Revision: 307082 URL: https://svnweb.freebsd.org/changeset/base/307082 Log: In the TCP stack, the hhook(9) framework provides hooks for kernel modules to add actions that run when a TCP frame is sent or received on a TCP session in the ESTABLISHED state. In the base tree, this functionality is only used for the h_ertt module, which is used by the cc_cdg, cc_chd, cc_hd, and cc_vegas congestion control modules. Presently, we incur overhead to check for hooks each time a TCP frame is sent or received on an ESTABLISHED TCP session. This change adds a new compile-time option (TCP_HHOOK) to determine whether to include the hhook(9) framework for TCP. To retain backwards compatibility, I added the TCP_HHOOK option to every configuration file that already defined "options INET". (Therefore, this patch introduces no functional change. In order to see a functional difference, you need to compile a custom kernel without the TCP_HHOOK option.) This change will allow users to easily exclude this functionality from their kernel, should they wish to do so. Note that any users who use a custom kernel configuration and use one of the congestion control modules listed above will need to add the TCP_HHOOK option to their kernel configuration. Reviewed by: rrs, lstewart, hiren (previous version), sjg (makefiles only) Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D8185 Modified: head/UPDATING head/sys/amd64/conf/GENERIC head/sys/arm/conf/ATMEL head/sys/arm/conf/AVILA head/sys/arm/conf/BWCT head/sys/arm/conf/CAMBRIA head/sys/arm/conf/CNS11XXNAS head/sys/arm/conf/CRB head/sys/arm/conf/DB-78XXX head/sys/arm/conf/DB-88F5XXX head/sys/arm/conf/DB-88F6XXX head/sys/arm/conf/DOCKSTAR head/sys/arm/conf/DREAMPLUG-1001 head/sys/arm/conf/EA3250 head/sys/arm/conf/EB9200 head/sys/arm/conf/ETHERNUT5 head/sys/arm/conf/EXYNOS5.common head/sys/arm/conf/GUMSTIX head/sys/arm/conf/HL200 head/sys/arm/conf/HL201 head/sys/arm/conf/KB920X head/sys/arm/conf/NSLU head/sys/arm/conf/QILA9G20 head/sys/arm/conf/SAM9260EK head/sys/arm/conf/SAM9G20EK head/sys/arm/conf/SAM9X25EK head/sys/arm/conf/SHEEVAPLUG head/sys/arm/conf/SN9G45 head/sys/arm/conf/TS7800 head/sys/arm/conf/std.armv6 head/sys/arm64/conf/GENERIC head/sys/conf/NOTES head/sys/conf/options head/sys/i386/conf/GENERIC head/sys/mips/conf/ADM5120 head/sys/mips/conf/ALCHEMY head/sys/mips/conf/AR71XX_BASE head/sys/mips/conf/AR724X_BASE head/sys/mips/conf/BCM head/sys/mips/conf/BERI_TEMPLATE head/sys/mips/conf/ERL head/sys/mips/conf/GXEMUL head/sys/mips/conf/GXEMUL32 head/sys/mips/conf/IDT head/sys/mips/conf/MT7620 head/sys/mips/conf/OCTEON1 head/sys/mips/conf/PB92 head/sys/mips/conf/QCA953X_BASE head/sys/mips/conf/QEMU head/sys/mips/conf/RT305X head/sys/mips/conf/RT5350 head/sys/mips/conf/SENTRY5 head/sys/mips/conf/XLR head/sys/mips/conf/XLR64 head/sys/mips/conf/XLRN32 head/sys/mips/conf/std.AR5312 head/sys/mips/conf/std.AR5315 head/sys/mips/conf/std.AR91XX head/sys/mips/conf/std.AR933X head/sys/mips/conf/std.AR934X head/sys/mips/conf/std.MALTA head/sys/mips/conf/std.QCA955X head/sys/mips/conf/std.SWARM head/sys/mips/conf/std.XLP head/sys/modules/cc/Makefile head/sys/modules/khelp/Makefile head/sys/netinet/tcp_input.c head/sys/netinet/tcp_output.c head/sys/netinet/tcp_stacks/fastpath.c head/sys/netinet/tcp_subr.c head/sys/netinet/tcp_var.h head/sys/pc98/conf/GENERIC head/sys/powerpc/conf/GENERIC head/sys/powerpc/conf/GENERIC64 head/sys/powerpc/conf/MPC85XX head/sys/riscv/conf/GENERIC head/sys/sparc64/conf/GENERIC Modified: head/UPDATING ============================================================================== --- head/UPDATING Wed Oct 12 02:15:06 2016 (r307081) +++ head/UPDATING Wed Oct 12 02:16:42 2016 (r307082) @@ -31,6 +31,11 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 12 disable the most expensive debugging functionality run "ln -s 'abort:false,junk:false' /etc/malloc.conf".) +20161008: + Use of the cc_cdg, cc_chd, cc_hd, or cc_vegas congestion control + modules now requires that the kernel configuration contain the + TCP_HHOOK option. (This option is included in the GENERIC kernel.) + 20161003: The WITHOUT_ELFCOPY_AS_OBJCOPY src.conf(5) knob has been retired. ELF Tool Chain's elfcopy is always installed as /usr/bin/objcopy. Modified: head/sys/amd64/conf/GENERIC ============================================================================== --- head/sys/amd64/conf/GENERIC Wed Oct 12 02:15:06 2016 (r307081) +++ head/sys/amd64/conf/GENERIC Wed Oct 12 02:16:42 2016 (r307082) @@ -30,6 +30,7 @@ options INET # InterNETworking options INET6 # IPv6 communications protocols options IPSEC # IP (v4/v6) security options TCP_OFFLOAD # TCP offload +options TCP_HHOOK # hhook(9) framework for TCP options SCTP # Stream Control Transmission Protocol options FFS # Berkeley Fast Filesystem options SOFTUPDATES # Enable FFS soft updates support Modified: head/sys/arm/conf/ATMEL ============================================================================== --- head/sys/arm/conf/ATMEL Wed Oct 12 02:15:06 2016 (r307081) +++ head/sys/arm/conf/ATMEL Wed Oct 12 02:16:42 2016 (r307082) @@ -35,6 +35,7 @@ options SCHED_4BSD # 4BSD scheduler #options PREEMPTION # Enable kernel thread preemption options INET # InterNETworking options INET6 # IPv6 communications protocols +options TCP_HHOOK # hhook(9) framework for TCP options SCTP # Stream Control Transmission Protocol options FFS # Berkeley Fast Filesystem options SOFTUPDATES # Enable FFS soft updates support Modified: head/sys/arm/conf/AVILA ============================================================================== --- head/sys/arm/conf/AVILA Wed Oct 12 02:15:06 2016 (r307081) +++ head/sys/arm/conf/AVILA Wed Oct 12 02:16:42 2016 (r307082) @@ -36,6 +36,7 @@ options DEVICE_POLLING options SCHED_4BSD # 4BSD scheduler options INET # InterNETworking +options TCP_HHOOK # hhook(9) framework for TCP options GEOM_PART_BSD # BSD partition scheme options GEOM_PART_MBR # MBR partition scheme options TMPFS # Efficient memory filesystem Modified: head/sys/arm/conf/BWCT ============================================================================== --- head/sys/arm/conf/BWCT Wed Oct 12 02:15:06 2016 (r307081) +++ head/sys/arm/conf/BWCT Wed Oct 12 02:16:42 2016 (r307082) @@ -33,6 +33,7 @@ makeoptions MODULES_OVERRIDE="" options SCHED_4BSD # 4BSD scheduler options INET # InterNETworking #options INET6 # IPv6 communications protocols +options TCP_HHOOK # hhook(9) framework for TCP options FFS # Berkeley Fast Filesystem options SOFTUPDATES # Enable FFS soft updates support #options UFS_ACL # Support for access control lists Modified: head/sys/arm/conf/CAMBRIA ============================================================================== --- head/sys/arm/conf/CAMBRIA Wed Oct 12 02:15:06 2016 (r307081) +++ head/sys/arm/conf/CAMBRIA Wed Oct 12 02:16:42 2016 (r307082) @@ -37,6 +37,7 @@ options DEVICE_POLLING options SCHED_4BSD # 4BSD scheduler #options PREEMPTION options INET # InterNETworking +options TCP_HHOOK # hhook(9) framework for TCP options GEOM_PART_BSD # BSD partition scheme options GEOM_PART_MBR # MBR partition scheme options TMPFS # Efficient memory filesystem Modified: head/sys/arm/conf/CNS11XXNAS ============================================================================== --- head/sys/arm/conf/CNS11XXNAS Wed Oct 12 02:15:06 2016 (r307081) +++ head/sys/arm/conf/CNS11XXNAS Wed Oct 12 02:16:42 2016 (r307082) @@ -46,6 +46,7 @@ options GEOM_LABEL # Provides labeliza options INET # InterNETworking options INET6 # IPv6 communications protocols +options TCP_HHOOK # hhook(9) framework for TCP options FFS # Berkeley Fast Filesystem options SOFTUPDATES # Enable FFS soft updates support options UFS_ACL # Support for access control lists Modified: head/sys/arm/conf/CRB ============================================================================== --- head/sys/arm/conf/CRB Wed Oct 12 02:15:06 2016 (r307081) +++ head/sys/arm/conf/CRB Wed Oct 12 02:16:42 2016 (r307082) @@ -34,6 +34,7 @@ options HZ=100 options SCHED_4BSD # 4BSD scheduler options INET # InterNETworking options INET6 # IPv6 communications protocols +options TCP_HHOOK # hhook(9) framework for TCP options FFS # Berkeley Fast Filesystem options SOFTUPDATES # Enable FFS soft updates support options UFS_ACL # Support for access control lists Modified: head/sys/arm/conf/DB-78XXX ============================================================================== --- head/sys/arm/conf/DB-78XXX Wed Oct 12 02:15:06 2016 (r307081) +++ head/sys/arm/conf/DB-78XXX Wed Oct 12 02:16:42 2016 (r307082) @@ -15,6 +15,7 @@ makeoptions WERROR="-Werror" options SCHED_4BSD # 4BSD scheduler options INET # InterNETworking options INET6 # IPv6 communications protocols +options TCP_HHOOK # hhook(9) framework for TCP options GEOM_PART_BSD # BSD partition scheme options GEOM_PART_MBR # MBR partition scheme options TMPFS # Efficient memory filesystem Modified: head/sys/arm/conf/DB-88F5XXX ============================================================================== --- head/sys/arm/conf/DB-88F5XXX Wed Oct 12 02:15:06 2016 (r307081) +++ head/sys/arm/conf/DB-88F5XXX Wed Oct 12 02:16:42 2016 (r307082) @@ -15,6 +15,7 @@ makeoptions WERROR="-Werror" options SCHED_4BSD # 4BSD scheduler options INET # InterNETworking options INET6 # IPv6 communications protocols +options TCP_HHOOK # hhook(9) framework for TCP options GEOM_PART_BSD # BSD partition scheme options GEOM_PART_MBR # MBR partition scheme options TMPFS # Efficient memory filesystem Modified: head/sys/arm/conf/DB-88F6XXX ============================================================================== --- head/sys/arm/conf/DB-88F6XXX Wed Oct 12 02:15:06 2016 (r307081) +++ head/sys/arm/conf/DB-88F6XXX Wed Oct 12 02:16:42 2016 (r307082) @@ -15,6 +15,7 @@ makeoptions WERROR="-Werror" options SCHED_4BSD # 4BSD scheduler options INET # InterNETworking options INET6 # IPv6 communications protocols +options TCP_HHOOK # hhook(9) framework for TCP options FFS # Berkeley Fast Filesystem options NANDFS # NAND Filesystem options NFSCL # Network Filesystem Client Modified: head/sys/arm/conf/DOCKSTAR ============================================================================== --- head/sys/arm/conf/DOCKSTAR Wed Oct 12 02:15:06 2016 (r307081) +++ head/sys/arm/conf/DOCKSTAR Wed Oct 12 02:16:42 2016 (r307082) @@ -29,6 +29,7 @@ options SOC_MV_KIRKWOOD options SCHED_4BSD # 4BSD scheduler options INET # InterNETworking options INET6 # IPv6 communications protocols +options TCP_HHOOK # hhook(9) framework for TCP options FFS # Berkeley Fast Filesystem options SOFTUPDATES # Enable FFS soft updates support options NFSCL # Network Filesystem Client Modified: head/sys/arm/conf/DREAMPLUG-1001 ============================================================================== --- head/sys/arm/conf/DREAMPLUG-1001 Wed Oct 12 02:15:06 2016 (r307081) +++ head/sys/arm/conf/DREAMPLUG-1001 Wed Oct 12 02:16:42 2016 (r307082) @@ -32,6 +32,7 @@ options SOC_MV_KIRKWOOD options SCHED_4BSD # 4BSD scheduler options INET # InterNETworking options INET6 # IPv6 communications protocols +options TCP_HHOOK # hhook(9) framework for TCP options FFS # Berkeley Fast Filesystem options SOFTUPDATES # Enable FFS soft updates support options NFSCL # Network Filesystem Client Modified: head/sys/arm/conf/EA3250 ============================================================================== --- head/sys/arm/conf/EA3250 Wed Oct 12 02:15:06 2016 (r307081) +++ head/sys/arm/conf/EA3250 Wed Oct 12 02:16:42 2016 (r307082) @@ -16,6 +16,7 @@ makeoptions WERROR="-Werror" options SCHED_4BSD # 4BSD scheduler options INET # InterNETworking options INET6 # IPv6 communications protocols +options TCP_HHOOK # hhook(9) framework for TCP options FFS # Berkeley Fast Filesystem options NFSCL # Network Filesystem Client options NFSLOCKD # Network Lock Manager Modified: head/sys/arm/conf/EB9200 ============================================================================== --- head/sys/arm/conf/EB9200 Wed Oct 12 02:15:06 2016 (r307081) +++ head/sys/arm/conf/EB9200 Wed Oct 12 02:16:42 2016 (r307082) @@ -26,6 +26,7 @@ makeoptions MODULES_OVERRIDE="" options SCHED_4BSD # 4BSD scheduler options INET # InterNETworking #options INET6 # IPv6 communications protocols +options TCP_HHOOK # hhook(9) framework for TCP options FFS # Berkeley Fast Filesystem #options SOFTUPDATES # Enable FFS soft updates support #options UFS_ACL # Support for access control lists Modified: head/sys/arm/conf/ETHERNUT5 ============================================================================== --- head/sys/arm/conf/ETHERNUT5 Wed Oct 12 02:15:06 2016 (r307081) +++ head/sys/arm/conf/ETHERNUT5 Wed Oct 12 02:16:42 2016 (r307082) @@ -31,6 +31,7 @@ options SCHED_4BSD # 4BSD scheduler #options PREEMPTION # Enable kernel thread preemption options INET # InterNETworking #options INET6 # IPv6 communications protocols +options TCP_HHOOK # hhook(9) framework for TCP #options SCTP # Stream Control Transmission Protocol options FFS # Berkeley Fast Filesystem options SOFTUPDATES # Enable FFS soft updates support Modified: head/sys/arm/conf/EXYNOS5.common ============================================================================== --- head/sys/arm/conf/EXYNOS5.common Wed Oct 12 02:15:06 2016 (r307081) +++ head/sys/arm/conf/EXYNOS5.common Wed Oct 12 02:16:42 2016 (r307082) @@ -25,6 +25,7 @@ options SCHED_ULE # ULE scheduler options PREEMPTION # Enable kernel thread preemption options INET # InterNETworking options INET6 # IPv6 communications protocols +options TCP_HHOOK # hhook(9) framework for TCP options SCTP # Stream Control Transmission Protocol options FFS # Berkeley Fast Filesystem options SOFTUPDATES # Enable FFS soft updates support Modified: head/sys/arm/conf/GUMSTIX ============================================================================== --- head/sys/arm/conf/GUMSTIX Wed Oct 12 02:15:06 2016 (r307081) +++ head/sys/arm/conf/GUMSTIX Wed Oct 12 02:16:42 2016 (r307082) @@ -39,6 +39,7 @@ options HZ=100 options SCHED_4BSD # 4BSD scheduler options INET # InterNETworking #options INET6 # IPv6 communications protocols +options TCP_HHOOK # hhook(9) framework for TCP options FFS # Berkeley Fast Filesystem options SOFTUPDATES # Enable FFS soft updates support options UFS_ACL # Support for access control lists Modified: head/sys/arm/conf/HL200 ============================================================================== --- head/sys/arm/conf/HL200 Wed Oct 12 02:15:06 2016 (r307081) +++ head/sys/arm/conf/HL200 Wed Oct 12 02:16:42 2016 (r307082) @@ -31,6 +31,7 @@ makeoptions MODULES_OVERRIDE="" options SCHED_4BSD # 4BSD scheduler options INET # InterNETworking #options INET6 # IPv6 communications protocols +options TCP_HHOOK # hhook(9) framework for TCP options FFS # Berkeley Fast Filesystem #options SOFTUPDATES # Enable FFS soft updates support #options UFS_ACL # Support for access control lists Modified: head/sys/arm/conf/HL201 ============================================================================== --- head/sys/arm/conf/HL201 Wed Oct 12 02:15:06 2016 (r307081) +++ head/sys/arm/conf/HL201 Wed Oct 12 02:16:42 2016 (r307082) @@ -29,6 +29,7 @@ makeoptions MODULES_OVERRIDE="" options SCHED_4BSD # 4BSD scheduler options INET # InterNETworking #options INET6 # IPv6 communications protocols +options TCP_HHOOK # hhook(9) framework for TCP options FFS # Berkeley Fast Filesystem #options SOFTUPDATES # Enable FFS soft updates support #options UFS_ACL # Support for access control lists Modified: head/sys/arm/conf/KB920X ============================================================================== --- head/sys/arm/conf/KB920X Wed Oct 12 02:15:06 2016 (r307081) +++ head/sys/arm/conf/KB920X Wed Oct 12 02:16:42 2016 (r307082) @@ -32,6 +32,7 @@ makeoptions MODULES_OVERRIDE="" options SCHED_4BSD # 4BSD scheduler options INET # InterNETworking #options INET6 # IPv6 communications protocols +options TCP_HHOOK # hhook(9) framework for TCP options FFS # Berkeley Fast Filesystem #options SOFTUPDATES # Enable FFS soft updates support #options UFS_ACL # Support for access control lists Modified: head/sys/arm/conf/NSLU ============================================================================== --- head/sys/arm/conf/NSLU Wed Oct 12 02:15:06 2016 (r307081) +++ head/sys/arm/conf/NSLU Wed Oct 12 02:16:42 2016 (r307082) @@ -43,6 +43,7 @@ options DEVICE_POLLING options SCHED_ULE # ULE scheduler options INET # InterNETworking options INET6 # IPv6 communications protocols +options TCP_HHOOK # hhook(9) framework for TCP options FFS # Berkeley Fast Filesystem options SOFTUPDATES # Enable FFS soft updates support options UFS_ACL # Support for access control lists Modified: head/sys/arm/conf/QILA9G20 ============================================================================== --- head/sys/arm/conf/QILA9G20 Wed Oct 12 02:15:06 2016 (r307081) +++ head/sys/arm/conf/QILA9G20 Wed Oct 12 02:16:42 2016 (r307082) @@ -32,6 +32,7 @@ makeoptions MODULES_OVERRIDE="" options SCHED_4BSD # 4BSD scheduler options INET # InterNETworking #options INET6 # IPv6 communications protocols +options TCP_HHOOK # hhook(9) framework for TCP options FFS # Berkeley Fast Filesystem #options SOFTUPDATES # Enable FFS soft updates support #options UFS_ACL # Support for access control lists Modified: head/sys/arm/conf/SAM9260EK ============================================================================== --- head/sys/arm/conf/SAM9260EK Wed Oct 12 02:15:06 2016 (r307081) +++ head/sys/arm/conf/SAM9260EK Wed Oct 12 02:16:42 2016 (r307082) @@ -42,6 +42,7 @@ options SCHED_4BSD # 4BSD scheduler #options PREEMPTION # Enable kernel thread preemption options INET # InterNETworking #options INET6 # IPv6 communications protocols +options TCP_HHOOK # hhook(9) framework for TCP #options SCTP # Stream Control Transmission Protocol options FFS # Berkeley Fast Filesystem options SOFTUPDATES # Enable FFS soft updates support Modified: head/sys/arm/conf/SAM9G20EK ============================================================================== --- head/sys/arm/conf/SAM9G20EK Wed Oct 12 02:15:06 2016 (r307081) +++ head/sys/arm/conf/SAM9G20EK Wed Oct 12 02:16:42 2016 (r307082) @@ -38,6 +38,7 @@ makeoptions MODULES_OVERRIDE="" options SCHED_4BSD # 4BSD scheduler options INET # InterNETworking #options INET6 # IPv6 communications protocols +options TCP_HHOOK # hhook(9) framework for TCP options TMPFS # Efficient memory filesystem options FFS # Berkeley Fast Filesystem #options SOFTUPDATES # Enable FFS soft updates support Modified: head/sys/arm/conf/SAM9X25EK ============================================================================== --- head/sys/arm/conf/SAM9X25EK Wed Oct 12 02:15:06 2016 (r307081) +++ head/sys/arm/conf/SAM9X25EK Wed Oct 12 02:16:42 2016 (r307082) @@ -31,6 +31,7 @@ makeoptions MODULES_OVERRIDE="" options SCHED_4BSD # 4BSD scheduler options INET # InterNETworking #options INET6 # IPv6 communications protocols +options TCP_HHOOK # hhook(9) framework for TCP options FFS # Berkeley Fast Filesystem #options SOFTUPDATES # Enable FFS soft updates support #options UFS_ACL # Support for access control lists Modified: head/sys/arm/conf/SHEEVAPLUG ============================================================================== --- head/sys/arm/conf/SHEEVAPLUG Wed Oct 12 02:15:06 2016 (r307081) +++ head/sys/arm/conf/SHEEVAPLUG Wed Oct 12 02:16:42 2016 (r307082) @@ -17,6 +17,7 @@ options HZ=1000 options SCHED_4BSD # 4BSD scheduler options INET # InterNETworking options INET6 # IPv6 communications protocols +options TCP_HHOOK # hhook(9) framework for TCP options FFS # Berkeley Fast Filesystem options NANDFS # NAND Filesystem options NFSCL # Network Filesystem Client Modified: head/sys/arm/conf/SN9G45 ============================================================================== --- head/sys/arm/conf/SN9G45 Wed Oct 12 02:15:06 2016 (r307081) +++ head/sys/arm/conf/SN9G45 Wed Oct 12 02:16:42 2016 (r307082) @@ -31,6 +31,7 @@ makeoptions MODULES_OVERRIDE="" options SCHED_4BSD # 4BSD scheduler options INET # InterNETworking #options INET6 # IPv6 communications protocols +options TCP_HHOOK # hhook(9) framework for TCP options FFS # Berkeley Fast Filesystem #options SOFTUPDATES # Enable FFS soft updates support #options UFS_ACL # Support for access control lists Modified: head/sys/arm/conf/TS7800 ============================================================================== --- head/sys/arm/conf/TS7800 Wed Oct 12 02:15:06 2016 (r307081) +++ head/sys/arm/conf/TS7800 Wed Oct 12 02:16:42 2016 (r307082) @@ -15,6 +15,7 @@ makeoptions WERROR="-Werror" options SCHED_4BSD # 4BSD scheduler options INET # InterNETworking options INET6 # IPv6 communications protocols +options TCP_HHOOK # hhook(9) framework for TCP options FFS # Berkeley Fast Filesystem options SOFTUPDATES # Enable FFS soft updates support options NFSCL # Network Filesystem Client Modified: head/sys/arm/conf/std.armv6 ============================================================================== --- head/sys/arm/conf/std.armv6 Wed Oct 12 02:15:06 2016 (r307081) +++ head/sys/arm/conf/std.armv6 Wed Oct 12 02:16:42 2016 (r307082) @@ -7,6 +7,7 @@ options ARM_L2_PIPT # Only L2 PIPT is options PREEMPTION # Enable kernel thread preemption options INET # InterNETworking options INET6 # IPv6 communications protocols +options TCP_HHOOK # hhook(9) framework for TCP options IPSEC # IP (v4/v6) security options SCTP # Stream Control Transmission Protocol options FFS # Berkeley Fast Filesystem Modified: head/sys/arm64/conf/GENERIC ============================================================================== --- head/sys/arm64/conf/GENERIC Wed Oct 12 02:15:06 2016 (r307081) +++ head/sys/arm64/conf/GENERIC Wed Oct 12 02:16:42 2016 (r307082) @@ -29,6 +29,7 @@ options PREEMPTION # Enable kernel thr options INET # InterNETworking options INET6 # IPv6 communications protocols options IPSEC # IP (v4/v6) security +options TCP_HHOOK # hhook(9) framework for TCP options TCP_OFFLOAD # TCP offload options SCTP # Stream Control Transmission Protocol options FFS # Berkeley Fast Filesystem Modified: head/sys/conf/NOTES ============================================================================== --- head/sys/conf/NOTES Wed Oct 12 02:15:06 2016 (r307081) +++ head/sys/conf/NOTES Wed Oct 12 02:16:42 2016 (r307082) @@ -982,6 +982,8 @@ device lagg # TCPPCAP enables code which keeps the last n packets sent and received # on a TCP socket. # +# TCP_HHOOK enables the hhook(9) framework hooks for the TCP stack. +# # RADIX_MPATH provides support for equal-cost multi-path routing. # options MROUTING # Multicast routing @@ -1001,6 +1003,7 @@ options IPSTEALTH #support for stealth options PF_DEFAULT_TO_DROP #drop everything by default options TCPDEBUG options TCPPCAP +options TCP_HHOOK options RADIX_MPATH # The MBUF_STRESS_TEST option enables options which create Modified: head/sys/conf/options ============================================================================== --- head/sys/conf/options Wed Oct 12 02:15:06 2016 (r307081) +++ head/sys/conf/options Wed Oct 12 02:16:42 2016 (r307082) @@ -443,6 +443,7 @@ SLIP_IFF_OPTS opt_slip.h TCPDEBUG TCPPCAP opt_global.h SIFTR +TCP_HHOOK opt_inet.h TCP_OFFLOAD opt_inet.h # Enable code to dispatch TCP offloading TCP_RFC7413 opt_inet.h TCP_RFC7413_MAX_KEYS opt_inet.h Modified: head/sys/i386/conf/GENERIC ============================================================================== --- head/sys/i386/conf/GENERIC Wed Oct 12 02:15:06 2016 (r307081) +++ head/sys/i386/conf/GENERIC Wed Oct 12 02:16:42 2016 (r307082) @@ -31,6 +31,7 @@ options PREEMPTION # Enable kernel thr options INET # InterNETworking options INET6 # IPv6 communications protocols options IPSEC # IP (v4/v6) security +options TCP_HHOOK # hhook(9) framework for TCP options TCP_OFFLOAD # TCP offload options SCTP # Stream Control Transmission Protocol options FFS # Berkeley Fast Filesystem Modified: head/sys/mips/conf/ADM5120 ============================================================================== --- head/sys/mips/conf/ADM5120 Wed Oct 12 02:15:06 2016 (r307081) +++ head/sys/mips/conf/ADM5120 Wed Oct 12 02:16:42 2016 (r307082) @@ -33,6 +33,7 @@ options KDB options SCHED_4BSD #4BSD scheduler options INET #InterNETworking +options TCP_HHOOK # hhook(9) framework for TCP options NFSCL #Network Filesystem Client options NFS_ROOT #NFS usable as /, requires NFSCL options PSEUDOFS #Pseudo-filesystem framework Modified: head/sys/mips/conf/ALCHEMY ============================================================================== --- head/sys/mips/conf/ALCHEMY Wed Oct 12 02:15:06 2016 (r307081) +++ head/sys/mips/conf/ALCHEMY Wed Oct 12 02:16:42 2016 (r307082) @@ -33,6 +33,7 @@ options KDB options SCHED_4BSD #4BSD scheduler options INET #InterNETworking +options TCP_HHOOK # hhook(9) framework for TCP options NFSCL #Network Filesystem Client options NFS_ROOT #NFS usable as /, requires NFSCL options PSEUDOFS #Pseudo-filesystem framework Modified: head/sys/mips/conf/AR71XX_BASE ============================================================================== --- head/sys/mips/conf/AR71XX_BASE Wed Oct 12 02:15:06 2016 (r307081) +++ head/sys/mips/conf/AR71XX_BASE Wed Oct 12 02:16:42 2016 (r307082) @@ -35,6 +35,7 @@ options KDB options SCHED_4BSD #4BSD scheduler options INET #InterNETworking options INET6 # IPv6 +options TCP_HHOOK # hhook(9) framework for TCP # options NFSCL #Network Filesystem Client Modified: head/sys/mips/conf/AR724X_BASE ============================================================================== --- head/sys/mips/conf/AR724X_BASE Wed Oct 12 02:15:06 2016 (r307081) +++ head/sys/mips/conf/AR724X_BASE Wed Oct 12 02:16:42 2016 (r307082) @@ -36,6 +36,7 @@ options KDB options SCHED_4BSD #4BSD scheduler options INET #InterNETworking #options INET6 # IPv6 +options TCP_HHOOK # hhook(9) framework for TCP #options NFSCL #Network Filesystem Client options PSEUDOFS #Pseudo-filesystem framework options _KPOSIX_PRIORITY_SCHEDULING #Posix P1003_1B real-time extensions Modified: head/sys/mips/conf/BCM ============================================================================== --- head/sys/mips/conf/BCM Wed Oct 12 02:15:06 2016 (r307081) +++ head/sys/mips/conf/BCM Wed Oct 12 02:16:42 2016 (r307082) @@ -28,6 +28,7 @@ options KDB options SCHED_4BSD #4BSD scheduler options INET #InterNETworking +options TCP_HHOOK # hhook(9) framework for TCP options NFSCL #Network Filesystem Client #options NFS_ROOT #NFS usable as /, requires NFSCL options PSEUDOFS #Pseudo-filesystem framework Modified: head/sys/mips/conf/BERI_TEMPLATE ============================================================================== --- head/sys/mips/conf/BERI_TEMPLATE Wed Oct 12 02:15:06 2016 (r307081) +++ head/sys/mips/conf/BERI_TEMPLATE Wed Oct 12 02:16:42 2016 (r307082) @@ -39,6 +39,7 @@ options FFS #Berkeley Fast Filesystem options INET options INET6 +options TCP_HHOOK # hhook(9) framework for TCP options KGSSAPI options NFSCL options NFSLOCKD Modified: head/sys/mips/conf/ERL ============================================================================== --- head/sys/mips/conf/ERL Wed Oct 12 02:15:06 2016 (r307081) +++ head/sys/mips/conf/ERL Wed Oct 12 02:16:42 2016 (r307082) @@ -55,6 +55,7 @@ options SCHED_ULE # ULE scheduler options PREEMPTION # Enable kernel thread preemption options INET # InterNETworking options INET6 # IPv6 communications protocols +options TCP_HHOOK # hhook(9) framework for TCP options SCTP # Stream Control Transmission Protocol options FFS # Berkeley Fast Filesystem options SOFTUPDATES # Enable FFS soft updates support Modified: head/sys/mips/conf/GXEMUL ============================================================================== --- head/sys/mips/conf/GXEMUL Wed Oct 12 02:15:06 2016 (r307081) +++ head/sys/mips/conf/GXEMUL Wed Oct 12 02:16:42 2016 (r307082) @@ -32,6 +32,7 @@ options SMP # Symmetric MultiProcesso options SCHED_ULE options INET # InterNETworking options INET6 # IPv6 communications protocols +options TCP_HHOOK # hhook(9) framework for TCP options FFS #Berkeley Fast Filesystem Modified: head/sys/mips/conf/GXEMUL32 ============================================================================== --- head/sys/mips/conf/GXEMUL32 Wed Oct 12 02:15:06 2016 (r307081) +++ head/sys/mips/conf/GXEMUL32 Wed Oct 12 02:16:42 2016 (r307082) @@ -30,6 +30,7 @@ options SMP # Symmetric MultiProcesso options SCHED_ULE options INET # InterNETworking options INET6 # IPv6 communications protocols +options TCP_HHOOK # hhook(9) framework for TCP options FFS #Berkeley Fast Filesystem Modified: head/sys/mips/conf/IDT ============================================================================== --- head/sys/mips/conf/IDT Wed Oct 12 02:15:06 2016 (r307081) +++ head/sys/mips/conf/IDT Wed Oct 12 02:16:42 2016 (r307082) @@ -16,6 +16,7 @@ options KDB options SCHED_4BSD #4BSD scheduler options INET #InterNETworking +options TCP_HHOOK # hhook(9) framework for TCP options NFSCL #Network Filesystem Client options NFS_ROOT #NFS usable as /, requires NFSCL options PSEUDOFS #Pseudo-filesystem framework Modified: head/sys/mips/conf/MT7620 ============================================================================== --- head/sys/mips/conf/MT7620 Wed Oct 12 02:15:06 2016 (r307081) +++ head/sys/mips/conf/MT7620 Wed Oct 12 02:16:42 2016 (r307082) @@ -54,6 +54,7 @@ options SCHED_ULE #options SCHED_4BSD #4BSD scheduler #options COMPAT_43 options INET #InterNETworking +options TCP_HHOOK # hhook(9) framework for TCP options NFSCL #Network Filesystem Client options NFS_ROOT #NFS usable as /, requires NFSCL options PSEUDOFS #Pseudo-filesystem framework Modified: head/sys/mips/conf/OCTEON1 ============================================================================== --- head/sys/mips/conf/OCTEON1 Wed Oct 12 02:15:06 2016 (r307081) +++ head/sys/mips/conf/OCTEON1 Wed Oct 12 02:16:42 2016 (r307082) @@ -54,6 +54,7 @@ options SCHED_ULE # ULE scheduler options PREEMPTION # Enable kernel thread preemption options INET # InterNETworking options INET6 # IPv6 communications protocols +options TCP_HHOOK # hhook(9) framework for TCP options SCTP # Stream Control Transmission Protocol options FFS # Berkeley Fast Filesystem options SOFTUPDATES # Enable FFS soft updates support Modified: head/sys/mips/conf/PB92 ============================================================================== --- head/sys/mips/conf/PB92 Wed Oct 12 02:15:06 2016 (r307081) +++ head/sys/mips/conf/PB92 Wed Oct 12 02:16:42 2016 (r307082) @@ -37,6 +37,7 @@ options SCHED_4BSD #4BSD scheduler options INET #InterNETworking # Can't do IPv6 - it just doesn't fit. # options INET6 +options TCP_HHOOK # hhook(9) framework for TCP # options NFSCL #Network Filesystem Client options PSEUDOFS #Pseudo-filesystem framework options _KPOSIX_PRIORITY_SCHEDULING #Posix P1003_1B real-time extensions Modified: head/sys/mips/conf/QCA953X_BASE ============================================================================== --- head/sys/mips/conf/QCA953X_BASE Wed Oct 12 02:15:06 2016 (r307081) +++ head/sys/mips/conf/QCA953X_BASE Wed Oct 12 02:16:42 2016 (r307082) @@ -31,6 +31,7 @@ options ALT_BREAK_TO_DEBUGGER options SCHED_4BSD #4BSD scheduler options INET #InterNETworking #options INET6 #InterNETworking +options TCP_HHOOK # hhook(9) framework for TCP #options NFSCL #Network Filesystem Client options PSEUDOFS #Pseudo-filesystem framework options _KPOSIX_PRIORITY_SCHEDULING #Posix P1003_1B real-time extensions Modified: head/sys/mips/conf/QEMU ============================================================================== --- head/sys/mips/conf/QEMU Wed Oct 12 02:15:06 2016 (r307081) +++ head/sys/mips/conf/QEMU Wed Oct 12 02:16:42 2016 (r307082) @@ -32,6 +32,7 @@ options KDB options SCHED_4BSD #4BSD scheduler options INET #InterNETworking +options TCP_HHOOK # hhook(9) framework for TCP options NFSCL #Network Filesystem Client options NFS_ROOT #NFS usable as /, requires NFSCL options PSEUDOFS #Pseudo-filesystem framework Modified: head/sys/mips/conf/RT305X ============================================================================== --- head/sys/mips/conf/RT305X Wed Oct 12 02:15:06 2016 (r307081) +++ head/sys/mips/conf/RT305X Wed Oct 12 02:16:42 2016 (r307082) @@ -53,6 +53,7 @@ options SCHED_ULE #options SCHED_4BSD #4BSD scheduler #options COMPAT_43 options INET #InterNETworking +options TCP_HHOOK # hhook(9) framework for TCP options NFSCL #Network Filesystem Client options NFS_ROOT #NFS usable as /, requires NFSCL options PSEUDOFS #Pseudo-filesystem framework Modified: head/sys/mips/conf/RT5350 ============================================================================== --- head/sys/mips/conf/RT5350 Wed Oct 12 02:15:06 2016 (r307081) +++ head/sys/mips/conf/RT5350 Wed Oct 12 02:16:42 2016 (r307082) @@ -51,6 +51,7 @@ options KDB options SCHED_ULE options INET #InterNETworking +options TCP_HHOOK # hhook(9) framework for TCP #options NFSCL #Network Filesystem Client #options NFS_ROOT #NFS usable as /, requires NFSCL options PSEUDOFS #Pseudo-filesystem framework Modified: head/sys/mips/conf/SENTRY5 ============================================================================== --- head/sys/mips/conf/SENTRY5 Wed Oct 12 02:15:06 2016 (r307081) +++ head/sys/mips/conf/SENTRY5 Wed Oct 12 02:16:42 2016 (r307082) @@ -44,6 +44,7 @@ options KDB options SCHED_4BSD #4BSD scheduler options INET #InterNETworking +options TCP_HHOOK # hhook(9) framework for TCP options NFSCL #Network Filesystem Client options NFS_ROOT #NFS usable as /, requires NFSCL options PSEUDOFS #Pseudo-filesystem framework Modified: head/sys/mips/conf/XLR ============================================================================== --- head/sys/mips/conf/XLR Wed Oct 12 02:15:06 2016 (r307081) +++ head/sys/mips/conf/XLR Wed Oct 12 02:16:42 2016 (r307082) @@ -62,6 +62,7 @@ options PREEMPTION # Enable kernel thr #options FULL_PREEMPTION # Enable kernel thread preemption options INET # InterNETworking options INET6 # IPv6 communications protocols +options TCP_HHOOK # hhook(9) framework for TCP options FFS # Berkeley Fast Filesystem #options SOFTUPDATES # Enable FFS soft updates support options UFS_ACL # Support for access control lists Modified: head/sys/mips/conf/XLR64 ============================================================================== --- head/sys/mips/conf/XLR64 Wed Oct 12 02:15:06 2016 (r307081) +++ head/sys/mips/conf/XLR64 Wed Oct 12 02:16:42 2016 (r307082) @@ -36,6 +36,7 @@ options SMP #options FULL_PREEMPTION # Enable kernel thread preemption options INET # InterNETworking options INET6 # IPv6 communications protocols +options TCP_HHOOK # hhook(9) framework for TCP options FFS # Berkeley Fast Filesystem #options SOFTUPDATES # Enable FFS soft updates support options UFS_ACL # Support for access control lists Modified: head/sys/mips/conf/XLRN32 ============================================================================== --- head/sys/mips/conf/XLRN32 Wed Oct 12 02:15:06 2016 (r307081) +++ head/sys/mips/conf/XLRN32 Wed Oct 12 02:16:42 2016 (r307082) @@ -36,6 +36,7 @@ options PREEMPTION # Enable kernel thr #options FULL_PREEMPTION # Enable kernel thread preemption options INET # InterNETworking options INET6 # IPv6 communications protocols +options TCP_HHOOK # hhook(9) framework for TCP options FFS # Berkeley Fast Filesystem #options SOFTUPDATES # Enable FFS soft updates support options UFS_ACL # Support for access control lists Modified: head/sys/mips/conf/std.AR5312 ============================================================================== --- head/sys/mips/conf/std.AR5312 Wed Oct 12 02:15:06 2016 (r307081) +++ head/sys/mips/conf/std.AR5312 Wed Oct 12 02:16:42 2016 (r307082) @@ -34,6 +34,7 @@ options KDB options SCHED_4BSD #4BSD scheduler options INET #InterNETworking options INET6 # IPv6 +options TCP_HHOOK # hhook(9) framework for TCP # options NFSCL #Network Filesystem Client Modified: head/sys/mips/conf/std.AR5315 ============================================================================== --- head/sys/mips/conf/std.AR5315 Wed Oct 12 02:15:06 2016 (r307081) +++ head/sys/mips/conf/std.AR5315 Wed Oct 12 02:16:42 2016 (r307082) @@ -33,6 +33,7 @@ options KDB options SCHED_4BSD #4BSD scheduler options INET #InterNETworking options INET6 # IPv6 +options TCP_HHOOK # hhook(9) framework for TCP # options NFSCL #Network Filesystem Client Modified: head/sys/mips/conf/std.AR91XX ============================================================================== --- head/sys/mips/conf/std.AR91XX Wed Oct 12 02:15:06 2016 (r307081) +++ head/sys/mips/conf/std.AR91XX Wed Oct 12 02:16:42 2016 (r307082) @@ -32,6 +32,7 @@ options VM_KMEM_SIZE_SCALE=1 options SCHED_4BSD #4BSD scheduler options INET #InterNETworking options INET6 #InterNETworking +options TCP_HHOOK # hhook(9) framework for TCP #options NFSCL #Network Filesystem Client options PSEUDOFS #Pseudo-filesystem framework options _KPOSIX_PRIORITY_SCHEDULING #Posix P1003_1B real-time extensions Modified: head/sys/mips/conf/std.AR933X ============================================================================== --- head/sys/mips/conf/std.AR933X Wed Oct 12 02:15:06 2016 (r307081) +++ head/sys/mips/conf/std.AR933X Wed Oct 12 02:16:42 2016 (r307082) @@ -30,6 +30,7 @@ options ALT_BREAK_TO_DEBUGGER options SCHED_4BSD #4BSD scheduler options INET #InterNETworking #options INET6 #InterNETworking +options TCP_HHOOK # hhook(9) framework for TCP #options NFSCL #Network Filesystem Client options PSEUDOFS #Pseudo-filesystem framework options _KPOSIX_PRIORITY_SCHEDULING #Posix P1003_1B real-time extensions Modified: head/sys/mips/conf/std.AR934X ============================================================================== --- head/sys/mips/conf/std.AR934X Wed Oct 12 02:15:06 2016 (r307081) +++ head/sys/mips/conf/std.AR934X Wed Oct 12 02:16:42 2016 (r307082) @@ -31,6 +31,7 @@ options ALQ options SCHED_4BSD #4BSD scheduler options INET #InterNETworking #options INET6 #InterNETworking +options TCP_HHOOK # hhook(9) framework for TCP #options NFSCL #Network Filesystem Client options PSEUDOFS #Pseudo-filesystem framework options _KPOSIX_PRIORITY_SCHEDULING #Posix P1003_1B real-time extensions Modified: head/sys/mips/conf/std.MALTA ============================================================================== --- head/sys/mips/conf/std.MALTA Wed Oct 12 02:15:06 2016 (r307081) +++ head/sys/mips/conf/std.MALTA Wed Oct 12 02:16:42 2016 (r307082) @@ -21,6 +21,7 @@ options KDB options SCHED_4BSD #4BSD scheduler options INET #InterNETworking +options TCP_HHOOK # hhook(9) framework for TCP options NFSCL #Network Filesystem Client options NFS_ROOT #NFS usable as /, requires NFSCL options PSEUDOFS #Pseudo-filesystem framework Modified: head/sys/mips/conf/std.QCA955X ============================================================================== --- head/sys/mips/conf/std.QCA955X Wed Oct 12 02:15:06 2016 (r307081) +++ head/sys/mips/conf/std.QCA955X Wed Oct 12 02:16:42 2016 (r307082) @@ -35,6 +35,7 @@ options ALQ options SCHED_4BSD #4BSD scheduler options INET #InterNETworking #options INET6 #InterNETworking +options TCP_HHOOK # hhook(9) framework for TCP #options NFSCL #Network Filesystem Client options PSEUDOFS #Pseudo-filesystem framework options _KPOSIX_PRIORITY_SCHEDULING #Posix P1003_1B real-time extensions Modified: head/sys/mips/conf/std.SWARM ============================================================================== --- head/sys/mips/conf/std.SWARM Wed Oct 12 02:15:06 2016 (r307081) +++ head/sys/mips/conf/std.SWARM Wed Oct 12 02:16:42 2016 (r307082) @@ -20,6 +20,7 @@ options KDB options SCHED_4BSD #4BSD scheduler options INET #InterNETworking +options TCP_HHOOK # hhook(9) framework for TCP options NFSCL #Network Filesystem Client options NFS_ROOT #NFS usable as /, requires NFSCL options PSEUDOFS #Pseudo-filesystem framework Modified: head/sys/mips/conf/std.XLP ============================================================================== --- head/sys/mips/conf/std.XLP Wed Oct 12 02:15:06 2016 (r307081) +++ head/sys/mips/conf/std.XLP Wed Oct 12 02:16:42 2016 (r307082) @@ -15,6 +15,7 @@ options PREEMPTION # Enable kernel thr #options FULL_PREEMPTION # Enable kernel thread preemption options INET # InterNETworking options INET6 # IPv6 communications protocols +options TCP_HHOOK # hhook(9) framework for TCP options FFS # Berkeley Fast Filesystem #options SOFTUPDATES # Enable FFS soft updates support options UFS_ACL # Support for access control lists Modified: head/sys/modules/cc/Makefile ============================================================================== --- head/sys/modules/cc/Makefile Wed Oct 12 02:15:06 2016 (r307081) +++ head/sys/modules/cc/Makefile Wed Oct 12 02:16:42 2016 (r307082) @@ -1,11 +1,20 @@ # $FreeBSD$ -SUBDIR= cc_cdg \ - cc_chd \ - cc_cubic \ +SUBDIR= cc_cubic \ cc_dctcp \ + cc_htcp + + +# Do we have the TCP_HHOOK symbol defined? If not, there is no point in +# building these modules by default. +# We will default to building these modules unless $OPT_INET is defined +# and does not contain the TCP_HHOOK option. +.if defined(ALL_MODULES) || ${OPT_INET:UTCP_HHOOK:MTCP_HHOOK} != "" +SUBDIR+= \ + cc_cdg \ + cc_chd \ cc_hd \ - cc_htcp \ cc_vegas +.endif .include Modified: head/sys/modules/khelp/Makefile ============================================================================== --- head/sys/modules/khelp/Makefile Wed Oct 12 02:15:06 2016 (r307081) +++ head/sys/modules/khelp/Makefile Wed Oct 12 02:16:42 2016 (r307082) @@ -1,5 +1,13 @@ # $FreeBSD$ -SUBDIR= h_ertt +SUBDIR= + +# Do we have the TCP_HHOOK symbol defined? If not, there is no point in +# building this modules by default. +# We will default to building this module unless $OPT_INET is defined +# and does not contain the TCP_HHOOK option. +.if defined(ALL_MODULES) || ${OPT_INET:UTCP_HHOOK:MTCP_HHOOK} != "" +SUBDIR+= h_ertt +.endif .include Modified: head/sys/netinet/tcp_input.c ============================================================================== --- head/sys/netinet/tcp_input.c Wed Oct 12 02:15:06 2016 (r307081) +++ head/sys/netinet/tcp_input.c Wed Oct 12 02:16:42 2016 (r307082) @@ -57,7 +57,9 @@ __FBSDID("$FreeBSD$"); #include #include +#ifdef TCP_HHOOK #include +#endif #include #include #include /* for proc0 declaration */ @@ -278,6 +280,7 @@ kmod_tcpstat_inc(int statnum) counter_u64_add(VNET(tcpstat)[statnum], 1); } +#ifdef TCP_HHOOK /* * Wrapper for the TCP established input helper hook. */ @@ -295,6 +298,7 @@ hhook_run_tcp_est_in(struct tcpcb *tp, s tp->osd); } } +#endif /* * CC wrapper hook functions @@ -1753,8 +1757,10 @@ tcp_do_segment(struct mbuf *m, struct tc } acked = BYTES_THIS_ACK(tp, th); +#ifdef TCP_HHOOK /* Run HHOOK_TCP_ESTABLISHED_IN helper hooks. */ hhook_run_tcp_est_in(tp, th, &to); +#endif TCPSTAT_ADD(tcps_rcvackpack, nsegs); TCPSTAT_ADD(tcps_rcvackbyte, acked); @@ -2499,8 +2505,10 @@ tcp_do_segment(struct mbuf *m, struct tc */ tp->sackhint.sacked_bytes = 0; +#ifdef TCP_HHOOK /* Run HHOOK_TCP_ESTABLISHED_IN helper hooks. */ hhook_run_tcp_est_in(tp, th, &to); +#endif if (SEQ_LEQ(th->th_ack, tp->snd_una)) { u_int maxseg; Modified: head/sys/netinet/tcp_output.c ============================================================================== --- head/sys/netinet/tcp_output.c Wed Oct 12 02:15:06 2016 (r307081) +++ head/sys/netinet/tcp_output.c Wed Oct 12 02:16:42 2016 (r307082) @@ -40,7 +40,9 @@ __FBSDID("$FreeBSD$"); #include #include #include +#ifdef TCP_HHOOK #include +#endif #include #include #include @@ -140,11 +142,14 @@ SYSCTL_INT(_net_inet_tcp, OID_AUTO, send tcp_timer_active((tp), TT_PERSIST), \ ("neither rexmt nor persist timer is set")) +#ifdef TCP_HHOOK static void inline hhook_run_tcp_est_out(struct tcpcb *tp, struct tcphdr *th, struct tcpopt *to, uint32_t len, int tso); +#endif static void inline cc_after_idle(struct tcpcb *tp); +#ifdef TCP_HHOOK /* * Wrapper for the TCP established output helper hook. */ @@ -165,6 +170,7 @@ hhook_run_tcp_est_out(struct tcpcb *tp, tp->osd); } } +#endif /* * CC wrapper hook functions @@ -1306,8 +1312,10 @@ send: __func__, len, hdrlen, ipoptlen, m_length(m, NULL))); #endif +#ifdef TCP_HHOOK /* Run HHOOK_TCP_ESTABLISHED_OUT helper hooks. */ hhook_run_tcp_est_out(tp, th, &to, len, tso); +#endif #ifdef TCPDEBUG /* Modified: head/sys/netinet/tcp_stacks/fastpath.c ============================================================================== --- head/sys/netinet/tcp_stacks/fastpath.c Wed Oct 12 02:15:06 2016 (r307081) +++ head/sys/netinet/tcp_stacks/fastpath.c Wed Oct 12 02:16:42 2016 (r307082) @@ -62,7 +62,9 @@ __FBSDID("$FreeBSD$"); #include #include #include +#ifdef TCP_HHOOK #include +#endif #include #include #include /* for proc0 declaration */ @@ -266,8 +268,10 @@ tcp_do_fastack(struct mbuf *m, struct tc if (winup_only == 0) { acked = BYTES_THIS_ACK(tp, th); +#ifdef TCP_HHOOK /* Run HHOOK_TCP_ESTABLISHED_IN helper hooks. */ hhook_run_tcp_est_in(tp, th, to); +#endif TCPSTAT_ADD(tcps_rcvackbyte, acked); sbdrop(&so->so_snd, acked); @@ -1040,8 +1044,10 @@ tcp_do_slowpath(struct mbuf *m, struct t */ tp->sackhint.sacked_bytes = 0; +#ifdef TCP_HHOOK /* Run HHOOK_TCP_ESTABLISHED_IN helper hooks. */ hhook_run_tcp_est_in(tp, th, to); +#endif if (SEQ_LEQ(th->th_ack, tp->snd_una)) { if (tlen == 0 && tiwin == tp->snd_wnd) { @@ -2127,8 +2133,10 @@ tcp_fastack(struct mbuf *m, struct tcphd if (winup_only == 0) { acked = BYTES_THIS_ACK(tp, th); +#ifdef TCP_HHOOK /* Run HHOOK_TCP_ESTABLISHED_IN helper hooks. */ hhook_run_tcp_est_in(tp, th, to); +#endif TCPSTAT_ADD(tcps_rcvackbyte, acked); sbdrop(&so->so_snd, acked); Modified: head/sys/netinet/tcp_subr.c ============================================================================== --- head/sys/netinet/tcp_subr.c Wed Oct 12 02:15:06 2016 (r307081) +++ head/sys/netinet/tcp_subr.c Wed Oct 12 02:16:42 2016 (r307082) @@ -42,9 +42,13 @@ __FBSDID("$FreeBSD$"); #include #include #include +#ifdef TCP_HHOOK #include +#endif #include +#ifdef TCP_HHOOK #include +#endif #include #include #include @@ -238,7 +242,9 @@ SYSCTL_INT(_net_inet_tcp, OID_AUTO, sign VNET_DEFINE(uma_zone_t, sack_hole_zone); #define V_sack_hole_zone VNET(sack_hole_zone) +#ifdef TCP_HHOOK VNET_DEFINE(struct hhook_head *, tcp_hhh[HHOOK_TCP_LAST+1]); +#endif static struct inpcb *tcp_notify(struct inpcb *, int); static struct inpcb *tcp_mtudisc_notify(struct inpcb *, int); @@ -449,7 +455,9 @@ struct tcpcb_mem { struct tcpcb tcb; struct tcp_timer tt; struct cc_var ccv; +#ifdef TCP_HHOOK struct osd osd; +#endif }; static VNET_DEFINE(uma_zone_t, tcpcb_zone); @@ -605,12 +613,14 @@ tcp_init(void) tcbhash_tuneable = "net.inet.tcp.tcbhashsize"; +#ifdef TCP_HHOOK if (hhook_head_register(HHOOK_TYPE_TCP, HHOOK_TCP_EST_IN, &V_tcp_hhh[HHOOK_TCP_EST_IN], HHOOK_NOWAIT|HHOOK_HEADISINVNET) != 0) printf("%s: WARNING: unable to register helper hook\n", __func__); if (hhook_head_register(HHOOK_TYPE_TCP, HHOOK_TCP_EST_OUT, &V_tcp_hhh[HHOOK_TCP_EST_OUT], HHOOK_NOWAIT|HHOOK_HEADISINVNET) != 0) printf("%s: WARNING: unable to register helper hook\n", __func__); +#endif hashsize = TCBHASHSIZE; TUNABLE_INT_FETCH(tcbhash_tuneable, &hashsize); if (hashsize == 0) { @@ -763,6 +773,7 @@ tcp_destroy(void *unused __unused) tcp_fastopen_destroy(); #endif +#ifdef TCP_HHOOK error = hhook_head_deregister(V_tcp_hhh[HHOOK_TCP_EST_IN]); if (error != 0) { printf("%s: WARNING: unable to deregister helper hook " @@ -775,6 +786,7 @@ tcp_destroy(void *unused __unused) "type=%d, id=%d: error %d returned\n", __func__, HHOOK_TYPE_TCP, HHOOK_TCP_EST_OUT, error); } +#endif } VNET_SYSUNINIT(tcp, SI_SUB_PROTO_DOMAIN, SI_ORDER_FOURTH, tcp_destroy, NULL); #endif @@ -1204,6 +1216,7 @@ tcp_newtcpcb(struct inpcb *inp) return (NULL); } +#ifdef TCP_HHOOK tp->osd = &tm->osd; if (khelp_init_osd(HELPER_CLASS_TCP, tp->osd)) { if (tp->t_fb->tfb_tcp_fb_fini) @@ -1212,6 +1225,7 @@ tcp_newtcpcb(struct inpcb *inp) uma_zfree(V_tcpcb_zone, tm); return (NULL); } +#endif #ifdef VIMAGE tp->t_vnet = inp->inp_vnet; @@ -1477,7 +1491,9 @@ tcp_discardcb(struct tcpcb *tp) if (CC_ALGO(tp)->cb_destroy != NULL) CC_ALGO(tp)->cb_destroy(tp->ccv); +#ifdef TCP_HHOOK khelp_destroy_osd(tp->osd); +#endif CC_ALGO(tp) = NULL; inp->inp_ppcb = NULL; Modified: head/sys/netinet/tcp_var.h ============================================================================== --- head/sys/netinet/tcp_var.h Wed Oct 12 02:15:06 2016 (r307081) +++ head/sys/netinet/tcp_var.h Wed Oct 12 02:16:42 2016 (r307082) @@ -749,8 +749,10 @@ VNET_DECLARE(int, tcp_ecn_maxretries); #define V_tcp_do_ecn VNET(tcp_do_ecn) #define V_tcp_ecn_maxretries VNET(tcp_ecn_maxretries) +#ifdef TCP_HHOOK VNET_DECLARE(struct hhook_head *, tcp_hhh[HHOOK_TCP_LAST + 1]); #define V_tcp_hhh VNET(tcp_hhh) +#endif VNET_DECLARE(int, tcp_do_rfc6675_pipe); #define V_tcp_do_rfc6675_pipe VNET(tcp_do_rfc6675_pipe) @@ -788,8 +790,10 @@ void cc_ack_received(struct tcpcb *tp, s void cc_conn_init(struct tcpcb *tp); void cc_post_recovery(struct tcpcb *tp, struct tcphdr *th); void cc_cong_signal(struct tcpcb *tp, struct tcphdr *th, uint32_t type); +#ifdef TCP_HHOOK void hhook_run_tcp_est_in(struct tcpcb *tp, struct tcphdr *th, struct tcpopt *to); +#endif int tcp_input(struct mbuf **, int *, int); void tcp_do_segment(struct mbuf *, struct tcphdr *, Modified: head/sys/pc98/conf/GENERIC ============================================================================== --- head/sys/pc98/conf/GENERIC Wed Oct 12 02:15:06 2016 (r307081) +++ head/sys/pc98/conf/GENERIC Wed Oct 12 02:16:42 2016 (r307082) @@ -30,6 +30,7 @@ options SCHED_4BSD # 4BSD scheduler options INET # InterNETworking options INET6 # IPv6 communications protocols options IPSEC # IP (v4/v6) security +options TCP_HHOOK # hhook(9) framework for TCP options SCTP # Stream Control Transmission Protocol options FFS # Berkeley Fast Filesystem options SOFTUPDATES # Enable FFS soft updates support Modified: head/sys/powerpc/conf/GENERIC ============================================================================== --- head/sys/powerpc/conf/GENERIC Wed Oct 12 02:15:06 2016 (r307081) +++ head/sys/powerpc/conf/GENERIC Wed Oct 12 02:16:42 2016 (r307082) @@ -38,6 +38,7 @@ options PREEMPTION #Enable kernel thre options INET #InterNETworking options INET6 #IPv6 communications protocols options IPSEC # IP (v4/v6) security +options TCP_HHOOK # hhook(9) framework for TCP options SCTP #Stream Control Transmission Protocol options FFS #Berkeley Fast Filesystem options SOFTUPDATES #Enable FFS soft updates support Modified: head/sys/powerpc/conf/GENERIC64 ============================================================================== --- head/sys/powerpc/conf/GENERIC64 Wed Oct 12 02:15:06 2016 (r307081) +++ head/sys/powerpc/conf/GENERIC64 Wed Oct 12 02:16:42 2016 (r307082) @@ -37,6 +37,7 @@ options SCHED_ULE #ULE scheduler options PREEMPTION #Enable kernel thread preemption options INET #InterNETworking options INET6 #IPv6 communications protocols +options TCP_HHOOK # hhook(9) framework for TCP options SCTP #Stream Control Transmission Protocol options FFS #Berkeley Fast Filesystem options SOFTUPDATES #Enable FFS soft updates support Modified: head/sys/powerpc/conf/MPC85XX ============================================================================== --- head/sys/powerpc/conf/MPC85XX Wed Oct 12 02:15:06 2016 (r307081) +++ head/sys/powerpc/conf/MPC85XX Wed Oct 12 02:16:42 2016 (r307082) @@ -36,6 +36,7 @@ options GDB options GEOM_PART_GPT options INET options INET6 +options TCP_HHOOK # hhook(9) framework for TCP options INVARIANTS options INVARIANT_SUPPORT options KDB Modified: head/sys/riscv/conf/GENERIC ============================================================================== --- head/sys/riscv/conf/GENERIC Wed Oct 12 02:15:06 2016 (r307081) +++ head/sys/riscv/conf/GENERIC Wed Oct 12 02:16:42 2016 (r307082) @@ -32,6 +32,7 @@ options SCHED_ULE # ULE scheduler options PREEMPTION # Enable kernel thread preemption options INET # InterNETworking *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-all@freebsd.org Wed Oct 12 02:30:35 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 398DBC0DAA1; Wed, 12 Oct 2016 02:30:35 +0000 (UTC) (envelope-from jtl@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 09BEC1F2F; Wed, 12 Oct 2016 02:30:34 +0000 (UTC) (envelope-from jtl@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9C2UYYI046691; Wed, 12 Oct 2016 02:30:34 GMT (envelope-from jtl@FreeBSD.org) Received: (from jtl@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9C2UYHf046690; Wed, 12 Oct 2016 02:30:34 GMT (envelope-from jtl@FreeBSD.org) Message-Id: <201610120230.u9C2UYHf046690@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jtl set sender to jtl@FreeBSD.org using -f From: "Jonathan T. Looney" Date: Wed, 12 Oct 2016 02:30:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307083 - head/sys/netinet X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Oct 2016 02:30:35 -0000 Author: jtl Date: Wed Oct 12 02:30:33 2016 New Revision: 307083 URL: https://svnweb.freebsd.org/changeset/base/307083 Log: Currently, when tcp_input() receives a packet on a session that matches a TCPCB, it checks (so->so_options & SO_ACCEPTCONN) to determine whether or not the socket is a listening socket. However, this causes the code to access a different cacheline. If we first check if the socket is in the LISTEN state, we can avoid accessing so->so_options when processing packets received for ESTABLISHED sessions. If INVARIANTS is defined, the code still needs to access both variables to check that so->so_options is consistent with the state. Reviewed by: gallatin MFC after: 1 week Sponsored by: Netflix Modified: head/sys/netinet/tcp_input.c Modified: head/sys/netinet/tcp_input.c ============================================================================== --- head/sys/netinet/tcp_input.c Wed Oct 12 02:16:42 2016 (r307082) +++ head/sys/netinet/tcp_input.c Wed Oct 12 02:30:33 2016 (r307083) @@ -1071,11 +1071,11 @@ relocked: * state) we look into the SYN cache if this is a new connection * attempt or the completion of a previous one. */ - if (so->so_options & SO_ACCEPTCONN) { + KASSERT(tp->t_state == TCPS_LISTEN || !(so->so_options & SO_ACCEPTCONN), + ("%s: so accepting but tp %p not listening", __func__, tp)); + if (tp->t_state == TCPS_LISTEN && (so->so_options & SO_ACCEPTCONN)) { struct in_conninfo inc; - KASSERT(tp->t_state == TCPS_LISTEN, ("%s: so accepting but " - "tp not listening", __func__)); bzero(&inc, sizeof(inc)); #ifdef INET6 if (isipv6) { From owner-svn-src-all@freebsd.org Wed Oct 12 02:32:25 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E2828C0DB1D; Wed, 12 Oct 2016 02:32:25 +0000 (UTC) (envelope-from jonlooney@gmail.com) Received: from mail-qk0-x22a.google.com (mail-qk0-x22a.google.com [IPv6:2607:f8b0:400d:c09::22a]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id A1A0535A; Wed, 12 Oct 2016 02:32:25 +0000 (UTC) (envelope-from jonlooney@gmail.com) Received: by mail-qk0-x22a.google.com with SMTP id f128so13548514qkb.1; Tue, 11 Oct 2016 19:32:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=wLoVJiAgIyXW+alBLBhB/jYl69f2IENiyY2YSbNIf/g=; b=uuas3bbN2g3DKdRLyusP4L9PG5X7WNX9KZeU0p4CxxXIlWgMNsDGFMUUddGo2vJ6oG 2Mjc1A6/PDljCsKU+Z4876YiplXz1GahUMiGqQ3pVt8BdTJfD+1WiQcu6nkD10sePQpU f3o01fNDd3eN6US9UiyMqTOEvddoSlxHxtN1IhC52ByG+DBBJscIQX/0Kw334DYcEgw/ P0VbKa3WTHtyZysXmfiF76v6TIyD1fi9+971CJD/Akwda01fLPERsodjAEnseFkAvVu3 KBTtVOtTkLiKBPJToMtuOs5JJS/T+Z4W2h4l+LrZtmPt354LDeybI/36oA911UKk8+ph 9WxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=wLoVJiAgIyXW+alBLBhB/jYl69f2IENiyY2YSbNIf/g=; b=MeMbibH4+7nQpSu9F6aQgnL1SvKGDmnkjSMTX9sByFTED1JIYodbtGg0jOeupgAoxY 3Rh69h1nZsZsDUM7u6x8JQ6O2ch2Po4DK4Hct7Svmf8+g3e9WfUXPWjmgn4RbunVYaIs x+9svf80gbnHYXzWMQ5QlawLO0uYaV9ykCyxZaQtCxzviqSoJQFSDATYrefGIZHYsu3d qfRJNROS/IIOFRkk5RyQD49a12scH37hAOQ3BDbLkgCGr7YxfopccTRE+MFg9eUmacAa jC8V6Pfvpdbd9tbu0Dodx1DaxbM0Zky9MlVPKB8R0bLI5UExhre9y34sRkZgj5Sq8DQg 9Mlw== X-Gm-Message-State: AA6/9Rn7h6emRmiAtY72zJDtYsctVUxymLrD9HtVtVQCxelzGquyjcLv9ROJ+DM7a+XJqz7G+EIJGL0f6ymPSQ== X-Received: by 10.55.149.67 with SMTP id x64mr7136784qkd.135.1476239544652; Tue, 11 Oct 2016 19:32:24 -0700 (PDT) MIME-Version: 1.0 Received: by 10.200.53.208 with HTTP; Tue, 11 Oct 2016 19:32:24 -0700 (PDT) In-Reply-To: <201610120230.u9C2UYHf046690@repo.freebsd.org> References: <201610120230.u9C2UYHf046690@repo.freebsd.org> From: Jonathan Looney Date: Tue, 11 Oct 2016 22:32:24 -0400 Message-ID: Subject: Re: svn commit: r307083 - head/sys/netinet To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Content-Type: text/plain; charset=UTF-8 X-Content-Filtered-By: Mailman/MimeDel 2.1.23 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Oct 2016 02:32:26 -0000 On Tue, Oct 11, 2016 at 10:30 PM, Jonathan T. Looney wrote: > Author: jtl > Date: Wed Oct 12 02:30:33 2016 > New Revision: 307083 > URL: https://svnweb.freebsd.org/changeset/base/307083 > > Log: > Currently, when tcp_input() receives a packet on a session that matches a > TCPCB, it checks (so->so_options & SO_ACCEPTCONN) to determine whether or > not the socket is a listening socket. However, this causes the code to > access a different cacheline. If we first check if the socket is in the > LISTEN state, we can avoid accessing so->so_options when processing > packets > received for ESTABLISHED sessions. > > If INVARIANTS is defined, the code still needs to access both variables > to > check that so->so_options is consistent with the state. > > Reviewed by: gallatin > MFC after: 1 week > Sponsored by: Netflix > This should have also noted: Differential Revision: https://reviews.freebsd.org/D8221 Sorry for the omission! Jonathan From owner-svn-src-all@freebsd.org Wed Oct 12 02:45:32 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 19903C0DE71; Wed, 12 Oct 2016 02:45:32 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id D6D6EB75; Wed, 12 Oct 2016 02:45:31 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9C2jVtT053319; Wed, 12 Oct 2016 02:45:31 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9C2jUKT053311; Wed, 12 Oct 2016 02:45:30 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610120245.u9C2jUKT053311@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Wed, 12 Oct 2016 02:45:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307084 - in stable/10/sys/dev/hyperv: include netvsc storvsc utilities vmbus X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Oct 2016 02:45:32 -0000 Author: sephe Date: Wed Oct 12 02:45:30 2016 New Revision: 307084 URL: https://svnweb.freebsd.org/changeset/base/307084 Log: MFC 302888-302892,302986,303020-303022 302888 hyperv/hn: Busdma-fy rxbuf and chimney sending buffer Nuke unused channel GPADL API. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7211 302889 hyperv/vmbus: Back out r302888 temporarily Committed by accident w/ duplicated commit log Sponsored by: Microsoft OSTC 302890 hyperv/vmbus: Function rename Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7212 302891 hyperv/vmbus: Cosmetic vmbus channel close cleanup Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7213 302892 hyperv/vmbus: Cleanup channel sysctl tree creation Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7214 302986 hyperv/vmbus: Cosmetic vmbus channel open cleanup Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7217 303020 hyperv/vmbus: Cleanup cpu based channel selection. And create cpu to channel map at device attach time for storvsc(4). Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7229 303021 hyperv/vmbus: Function rename Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7230 303022 hyperv/vmbus: Temp/internal variable/function rename Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7231 Modified: stable/10/sys/dev/hyperv/include/hyperv.h stable/10/sys/dev/hyperv/include/vmbus.h stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.c stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c stable/10/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c stable/10/sys/dev/hyperv/utilities/hv_util.c stable/10/sys/dev/hyperv/vmbus/hv_channel.c stable/10/sys/dev/hyperv/vmbus/vmbus_reg.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/hyperv/include/hyperv.h ============================================================================== --- stable/10/sys/dev/hyperv/include/hyperv.h Wed Oct 12 02:30:33 2016 (r307083) +++ stable/10/sys/dev/hyperv/include/hyperv.h Wed Oct 12 02:45:30 2016 (r307084) @@ -267,42 +267,6 @@ typedef struct hv_vmbus_channel { #define VMBUS_CHAN_ST_OPENED_SHIFT 0 #define VMBUS_CHAN_ST_OPENED (1 << VMBUS_CHAN_ST_OPENED_SHIFT) -static inline void -hv_set_channel_read_state(hv_vmbus_channel* channel, boolean_t on) -{ - if (!on) - channel->ch_flags &= ~VMBUS_CHAN_FLAG_BATCHREAD; - else - channel->ch_flags |= VMBUS_CHAN_FLAG_BATCHREAD; -} - -int hv_vmbus_channel_open( - hv_vmbus_channel* channel, - uint32_t send_ring_buffer_size, - uint32_t recv_ring_buffer_size, - void* user_data, - uint32_t user_data_len, - vmbus_chan_callback_t cb, - void *cbarg); - -void hv_vmbus_channel_close(hv_vmbus_channel *channel); - -int hv_vmbus_channel_teardown_gpdal( - hv_vmbus_channel* channel, - uint32_t gpadl_handle); - -int vmbus_chan_gpadl_connect(struct hv_vmbus_channel *chan, - bus_addr_t paddr, int size, uint32_t *gpadl); - -struct hv_vmbus_channel* vmbus_select_outgoing_channel(struct hv_vmbus_channel *promary); - -void vmbus_channel_cpu_set(struct hv_vmbus_channel *chan, int cpu); -void vmbus_channel_cpu_rr(struct hv_vmbus_channel *chan); -struct hv_vmbus_channel ** - vmbus_get_subchan(struct hv_vmbus_channel *pri_chan, int subchan_cnt); -void vmbus_rel_subchan(struct hv_vmbus_channel **subchan, int subchan_cnt); -void vmbus_drain_subchan(struct hv_vmbus_channel *pri_chan); - /** * @brief Get physical address from virtual */ Modified: stable/10/sys/dev/hyperv/include/vmbus.h ============================================================================== --- stable/10/sys/dev/hyperv/include/vmbus.h Wed Oct 12 02:30:33 2016 (r307083) +++ stable/10/sys/dev/hyperv/include/vmbus.h Wed Oct 12 02:45:30 2016 (r307084) @@ -89,6 +89,27 @@ struct vmbus_chanpkt_rxbuf { struct hv_vmbus_channel; +int vmbus_chan_open(struct hv_vmbus_channel *chan, + int txbr_size, int rxbr_size, const void *udata, int udlen, + vmbus_chan_callback_t cb, void *cbarg); +void vmbus_chan_close(struct hv_vmbus_channel *chan); + +int vmbus_chan_gpadl_connect(struct hv_vmbus_channel *chan, + bus_addr_t paddr, int size, uint32_t *gpadl); +int vmbus_chan_gpadl_disconnect(struct hv_vmbus_channel *chan, + uint32_t gpadl); + +void vmbus_chan_cpu_set(struct hv_vmbus_channel *chan, int cpu); +void vmbus_chan_cpu_rr(struct hv_vmbus_channel *chan); +struct hv_vmbus_channel * + vmbus_chan_cpu2chan(struct hv_vmbus_channel *chan, int cpu); +void vmbus_chan_set_readbatch(struct hv_vmbus_channel *chan, bool on); + +struct hv_vmbus_channel ** + vmbus_subchan_get(struct hv_vmbus_channel *pri_chan, int subchan_cnt); +void vmbus_subchan_rel(struct hv_vmbus_channel **subchan, int subchan_cnt); +void vmbus_subchan_drain(struct hv_vmbus_channel *pri_chan); + int vmbus_chan_recv(struct hv_vmbus_channel *chan, void *data, int *dlen, uint64_t *xactid); int vmbus_chan_recv_pkt(struct hv_vmbus_channel *chan, Modified: stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.c Wed Oct 12 02:30:33 2016 (r307083) +++ stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.c Wed Oct 12 02:45:30 2016 (r307084) @@ -362,7 +362,7 @@ hv_nv_destroy_rx_buffer(netvsc_dev *net_ /* Tear down the gpadl on the vsp end */ if (net_dev->rx_buf_gpadl_handle) { - ret = hv_vmbus_channel_teardown_gpdal(net_dev->sc->hn_prichan, + ret = vmbus_chan_gpadl_disconnect(net_dev->sc->hn_prichan, net_dev->rx_buf_gpadl_handle); /* * If we failed here, we might as well return and have a leak @@ -429,7 +429,7 @@ hv_nv_destroy_send_buffer(netvsc_dev *ne /* Tear down the gpadl on the vsp end */ if (net_dev->send_buf_gpadl_handle) { - ret = hv_vmbus_channel_teardown_gpdal(net_dev->sc->hn_prichan, + ret = vmbus_chan_gpadl_disconnect(net_dev->sc->hn_prichan, net_dev->send_buf_gpadl_handle); /* @@ -644,7 +644,7 @@ hv_nv_subchan_attach(struct hv_vmbus_cha { chan->hv_chan_rdbuf = malloc(NETVSC_PACKET_SIZE, M_NETVSC, M_WAITOK); - hv_vmbus_channel_open(chan, NETVSC_DEVICE_RING_BUFFER_SIZE, + vmbus_chan_open(chan, NETVSC_DEVICE_RING_BUFFER_SIZE, NETVSC_DEVICE_RING_BUFFER_SIZE, NULL, 0, hv_nv_on_channel_callback, chan); } @@ -674,7 +674,7 @@ hv_nv_on_device_add(struct hn_softc *sc, /* * Open the channel */ - ret = hv_vmbus_channel_open(chan, + ret = vmbus_chan_open(chan, NETVSC_DEVICE_RING_BUFFER_SIZE, NETVSC_DEVICE_RING_BUFFER_SIZE, NULL, 0, hv_nv_on_channel_callback, chan); if (ret != 0) { @@ -694,7 +694,7 @@ hv_nv_on_device_add(struct hn_softc *sc, close: /* Now, we can close the channel safely */ free(chan->hv_chan_rdbuf, M_NETVSC); - hv_vmbus_channel_close(chan); + vmbus_chan_close(chan); cleanup: /* @@ -725,7 +725,7 @@ hv_nv_on_device_remove(struct hn_softc * /* Now, we can close the channel safely */ free(sc->hn_prichan->hv_chan_rdbuf, M_NETVSC); - hv_vmbus_channel_close(sc->hn_prichan); + vmbus_chan_close(sc->hn_prichan); sema_destroy(&net_dev->channel_init_sema); free(net_dev, M_NETVSC); Modified: stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Wed Oct 12 02:30:33 2016 (r307083) +++ stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Wed Oct 12 02:45:30 2016 (r307084) @@ -1603,7 +1603,7 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, } /* Wait for subchannels to be destroyed */ - vmbus_drain_subchan(sc->hn_prichan); + vmbus_subchan_drain(sc->hn_prichan); error = hv_rf_on_device_add(sc, &device_info, sc->hn_rx_ring_inuse); @@ -3006,7 +3006,7 @@ hn_channel_attach(struct hn_softc *sc, s } /* Bind channel to a proper CPU */ - vmbus_channel_cpu_set(chan, (sc->hn_cpu + idx) % mp_ncpus); + vmbus_chan_cpu_set(chan, (sc->hn_cpu + idx) % mp_ncpus); } static void @@ -3029,7 +3029,7 @@ hn_subchan_setup(struct hn_softc *sc) int i; /* Wait for sub-channels setup to complete. */ - subchan = vmbus_get_subchan(sc->hn_prichan, subchan_cnt); + subchan = vmbus_subchan_get(sc->hn_prichan, subchan_cnt); /* Attach the sub-channels. */ for (i = 0; i < subchan_cnt; ++i) { @@ -3039,7 +3039,7 @@ hn_subchan_setup(struct hn_softc *sc) } /* Release the sub-channels */ - vmbus_rel_subchan(subchan, subchan_cnt); + vmbus_subchan_rel(subchan, subchan_cnt); if_printf(sc->hn_ifp, "%d sub-channels setup done\n", subchan_cnt); } Modified: stable/10/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c ============================================================================== --- stable/10/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c Wed Oct 12 02:30:33 2016 (r307083) +++ stable/10/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c Wed Oct 12 02:45:30 2016 (r307084) @@ -147,6 +147,8 @@ struct storvsc_softc { struct hv_storvsc_request hs_init_req; struct hv_storvsc_request hs_reset_req; device_t hs_dev; + + struct hv_vmbus_channel *hs_cpu2chan[MAXCPU]; }; @@ -315,8 +317,8 @@ storvsc_subchan_attach(struct storvsc_so memset(&props, 0, sizeof(props)); new_channel->hv_chan_priv1 = sc; - vmbus_channel_cpu_rr(new_channel); - ret = hv_vmbus_channel_open(new_channel, + vmbus_chan_cpu_rr(new_channel); + ret = vmbus_chan_open(new_channel, sc->hs_drv_props->drv_ringbuffer_size, sc->hs_drv_props->drv_ringbuffer_size, (void *)&props, @@ -377,14 +379,14 @@ storvsc_send_multichannel_request(struct } /* Wait for sub-channels setup to complete. */ - subchan = vmbus_get_subchan(sc->hs_chan, request_channels_cnt); + subchan = vmbus_subchan_get(sc->hs_chan, request_channels_cnt); /* Attach the sub-channels. */ for (i = 0; i < request_channels_cnt; ++i) storvsc_subchan_attach(sc, subchan[i]); /* Release the sub-channels. */ - vmbus_rel_subchan(subchan, request_channels_cnt); + vmbus_subchan_rel(subchan, request_channels_cnt); if (bootverbose) printf("Storvsc create multi-channel success!\n"); @@ -574,8 +576,8 @@ hv_storvsc_connect_vsp(struct storvsc_so * Open the channel */ KASSERT(sc->hs_chan->hv_chan_priv1 == sc, ("invalid chan priv1")); - vmbus_channel_cpu_rr(sc->hs_chan); - ret = hv_vmbus_channel_open( + vmbus_chan_cpu_rr(sc->hs_chan); + ret = vmbus_chan_open( sc->hs_chan, sc->hs_drv_props->drv_ringbuffer_size, sc->hs_drv_props->drv_ringbuffer_size, @@ -665,7 +667,7 @@ hv_storvsc_io_request(struct storvsc_sof vstor_packet->operation = VSTOR_OPERATION_EXECUTESRB; - outgoing_channel = vmbus_select_outgoing_channel(sc->hs_chan); + outgoing_channel = sc->hs_cpu2chan[curcpu]; mtx_unlock(&request->softc->hs_lock); if (request->prp_list.gpa_range.gpa_len) { @@ -872,6 +874,20 @@ storvsc_probe(device_t dev) return (ret); } +static void +storvsc_create_cpu2chan(struct storvsc_softc *sc) +{ + int cpu; + + CPU_FOREACH(cpu) { + sc->hs_cpu2chan[cpu] = vmbus_chan_cpu2chan(sc->hs_chan, cpu); + if (bootverbose) { + device_printf(sc->hs_dev, "cpu%d -> chan%u\n", + cpu, sc->hs_cpu2chan[cpu]->ch_id); + } + } +} + /** * @brief StorVSC attach function * @@ -969,6 +985,9 @@ storvsc_attach(device_t dev) goto cleanup; } + /* Construct cpu to channel mapping */ + storvsc_create_cpu2chan(sc); + /* * Create the device queue. * Hyper-V maps each target to one SCSI HBA @@ -1083,7 +1102,7 @@ storvsc_detach(device_t dev) * under the protection of the incoming channel lock. */ - hv_vmbus_channel_close(sc->hs_chan); + vmbus_chan_close(sc->hs_chan); mtx_lock(&sc->hs_lock); while (!LIST_EMPTY(&sc->hs_free_list)) { Modified: stable/10/sys/dev/hyperv/utilities/hv_util.c ============================================================================== --- stable/10/sys/dev/hyperv/utilities/hv_util.c Wed Oct 12 02:30:33 2016 (r307083) +++ stable/10/sys/dev/hyperv/utilities/hv_util.c Wed Oct 12 02:45:30 2016 (r307084) @@ -40,6 +40,7 @@ #include #include +#include #include "hv_util.h" void @@ -89,9 +90,9 @@ hv_util_attach(device_t dev) * Turn off batched reading for all util drivers before we open the * channel. */ - hv_set_channel_read_state(softc->channel, FALSE); + vmbus_chan_set_readbatch(softc->channel, false); - ret = hv_vmbus_channel_open(softc->channel, 4 * PAGE_SIZE, + ret = vmbus_chan_open(softc->channel, 4 * PAGE_SIZE, 4 * PAGE_SIZE, NULL, 0, softc->callback, softc); @@ -110,7 +111,7 @@ hv_util_detach(device_t dev) { struct hv_util_sc *sc = device_get_softc(dev); - hv_vmbus_channel_close(sc->channel); + vmbus_chan_close(sc->channel); free(sc->receive_buffer, M_DEVBUF); return (0); Modified: stable/10/sys/dev/hyperv/vmbus/hv_channel.c ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/hv_channel.c Wed Oct 12 02:30:33 2016 (r307083) +++ stable/10/sys/dev/hyperv/vmbus/hv_channel.c Wed Oct 12 02:45:30 2016 (r307084) @@ -51,7 +51,7 @@ __FBSDID("$FreeBSD$"); #include #include -static void vmbus_chan_send_event(hv_vmbus_channel* channel); +static void vmbus_chan_signal_tx(struct hv_vmbus_channel *chan); static void vmbus_chan_update_evtflagcnt(struct vmbus_softc *, const struct hv_vmbus_channel *); @@ -81,195 +81,194 @@ vmbus_chan_msgprocs[VMBUS_CHANMSG_TYPE_M * @brief Trigger an event notification on the specified channel */ static void -vmbus_chan_send_event(hv_vmbus_channel *channel) +vmbus_chan_signal_tx(struct hv_vmbus_channel *chan) { - struct vmbus_softc *sc = channel->vmbus_sc; - uint32_t chanid = channel->ch_id; + struct vmbus_softc *sc = chan->vmbus_sc; + uint32_t chanid = chan->ch_id; atomic_set_long(&sc->vmbus_tx_evtflags[chanid >> VMBUS_EVTFLAG_SHIFT], 1UL << (chanid & VMBUS_EVTFLAG_MASK)); - if (channel->ch_flags & VMBUS_CHAN_FLAG_HASMNF) { + if (chan->ch_flags & VMBUS_CHAN_FLAG_HASMNF) { atomic_set_int( - &sc->vmbus_mnf2->mnf_trigs[channel->ch_montrig_idx].mt_pending, - channel->ch_montrig_mask); + &sc->vmbus_mnf2->mnf_trigs[chan->ch_montrig_idx].mt_pending, + chan->ch_montrig_mask); } else { - hypercall_signal_event(channel->ch_monprm_dma.hv_paddr); + hypercall_signal_event(chan->ch_monprm_dma.hv_paddr); } } static int -vmbus_channel_sysctl_monalloc(SYSCTL_HANDLER_ARGS) +vmbus_chan_sysctl_mnf(SYSCTL_HANDLER_ARGS) { struct hv_vmbus_channel *chan = arg1; - int alloc = 0; + int mnf = 0; if (chan->ch_flags & VMBUS_CHAN_FLAG_HASMNF) - alloc = 1; - return sysctl_handle_int(oidp, &alloc, 0, req); + mnf = 1; + return sysctl_handle_int(oidp, &mnf, 0, req); } static void -vmbus_channel_sysctl_create(hv_vmbus_channel* channel) +vmbus_chan_sysctl_create(struct hv_vmbus_channel *chan) { - device_t dev; - struct sysctl_oid *devch_sysctl; - struct sysctl_oid *devch_id_sysctl, *devch_sub_sysctl; - struct sysctl_oid *devch_id_in_sysctl, *devch_id_out_sysctl; + struct sysctl_oid *ch_tree, *chid_tree, *br_tree; struct sysctl_ctx_list *ctx; uint32_t ch_id; - uint16_t sub_ch_id; char name[16]; - - hv_vmbus_channel* primary_ch = channel->ch_prichan; - if (primary_ch == NULL) { - dev = channel->ch_dev; - ch_id = channel->ch_id; - } else { - dev = primary_ch->ch_dev; - ch_id = primary_ch->ch_id; - sub_ch_id = channel->ch_subidx; - } - ctx = &channel->ch_sysctl_ctx; + /* + * Add sysctl nodes related to this channel to this + * channel's sysctl ctx, so that they can be destroyed + * independently upon close of this channel, which can + * happen even if the device is not detached. + */ + ctx = &chan->ch_sysctl_ctx; sysctl_ctx_init(ctx); - /* This creates dev.DEVNAME.DEVUNIT.channel tree */ - devch_sysctl = SYSCTL_ADD_NODE(ctx, - SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), - OID_AUTO, "channel", CTLFLAG_RD | CTLFLAG_MPSAFE, 0, ""); - /* This creates dev.DEVNAME.DEVUNIT.channel.CHANID tree */ + + /* + * Create dev.NAME.UNIT.channel tree. + */ + ch_tree = SYSCTL_ADD_NODE(ctx, + SYSCTL_CHILDREN(device_get_sysctl_tree(chan->ch_dev)), + OID_AUTO, "channel", CTLFLAG_RD | CTLFLAG_MPSAFE, 0, ""); + if (ch_tree == NULL) + return; + + /* + * Create dev.NAME.UNIT.channel.CHANID tree. + */ + if (VMBUS_CHAN_ISPRIMARY(chan)) + ch_id = chan->ch_id; + else + ch_id = chan->ch_prichan->ch_id; snprintf(name, sizeof(name), "%d", ch_id); - devch_id_sysctl = SYSCTL_ADD_NODE(ctx, - SYSCTL_CHILDREN(devch_sysctl), - OID_AUTO, name, CTLFLAG_RD | CTLFLAG_MPSAFE, 0, ""); - - if (primary_ch != NULL) { - devch_sub_sysctl = SYSCTL_ADD_NODE(ctx, - SYSCTL_CHILDREN(devch_id_sysctl), - OID_AUTO, "sub", CTLFLAG_RD | CTLFLAG_MPSAFE, 0, ""); - snprintf(name, sizeof(name), "%d", sub_ch_id); - devch_id_sysctl = SYSCTL_ADD_NODE(ctx, - SYSCTL_CHILDREN(devch_sub_sysctl), - OID_AUTO, name, CTLFLAG_RD | CTLFLAG_MPSAFE, 0, ""); - - SYSCTL_ADD_UINT(ctx, SYSCTL_CHILDREN(devch_id_sysctl), - OID_AUTO, "chanid", CTLFLAG_RD, - &channel->ch_id, 0, "channel id"); - } - SYSCTL_ADD_UINT(ctx, SYSCTL_CHILDREN(devch_id_sysctl), OID_AUTO, - "cpu", CTLFLAG_RD, &channel->ch_cpuid, 0, "owner CPU id"); - SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(devch_id_sysctl), OID_AUTO, - "monitor_allocated", CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_MPSAFE, - channel, 0, vmbus_channel_sysctl_monalloc, "I", - "is monitor allocated to this channel"); - - devch_id_in_sysctl = SYSCTL_ADD_NODE(ctx, - SYSCTL_CHILDREN(devch_id_sysctl), - OID_AUTO, - "in", - CTLFLAG_RD | CTLFLAG_MPSAFE, 0, ""); - devch_id_out_sysctl = SYSCTL_ADD_NODE(ctx, - SYSCTL_CHILDREN(devch_id_sysctl), - OID_AUTO, - "out", - CTLFLAG_RD | CTLFLAG_MPSAFE, 0, ""); - hv_ring_buffer_stat(ctx, - SYSCTL_CHILDREN(devch_id_in_sysctl), - &(channel->inbound), - "inbound ring buffer stats"); - hv_ring_buffer_stat(ctx, - SYSCTL_CHILDREN(devch_id_out_sysctl), - &(channel->outbound), - "outbound ring buffer stats"); + chid_tree = SYSCTL_ADD_NODE(ctx, SYSCTL_CHILDREN(ch_tree), + OID_AUTO, name, CTLFLAG_RD | CTLFLAG_MPSAFE, 0, ""); + if (chid_tree == NULL) + return; + + if (!VMBUS_CHAN_ISPRIMARY(chan)) { + /* + * Create dev.NAME.UNIT.channel.CHANID.sub tree. + */ + ch_tree = SYSCTL_ADD_NODE(ctx, SYSCTL_CHILDREN(chid_tree), + OID_AUTO, "sub", CTLFLAG_RD | CTLFLAG_MPSAFE, 0, ""); + if (ch_tree == NULL) + return; + + /* + * Create dev.NAME.UNIT.channel.CHANID.sub.SUBIDX tree. + * + * NOTE: + * chid_tree is changed to this new sysctl tree. + */ + snprintf(name, sizeof(name), "%d", chan->ch_subidx); + chid_tree = SYSCTL_ADD_NODE(ctx, SYSCTL_CHILDREN(ch_tree), + OID_AUTO, name, CTLFLAG_RD | CTLFLAG_MPSAFE, 0, ""); + if (chid_tree == NULL) + return; + + SYSCTL_ADD_UINT(ctx, SYSCTL_CHILDREN(chid_tree), OID_AUTO, + "chanid", CTLFLAG_RD, &chan->ch_id, 0, "channel id"); + } + + SYSCTL_ADD_UINT(ctx, SYSCTL_CHILDREN(chid_tree), OID_AUTO, + "cpu", CTLFLAG_RD, &chan->ch_cpuid, 0, "owner CPU id"); + SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(chid_tree), OID_AUTO, + "mnf", CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_MPSAFE, + chan, 0, vmbus_chan_sysctl_mnf, "I", + "has monitor notification facilities"); + + /* + * Create sysctl tree for RX bufring. + */ + br_tree = SYSCTL_ADD_NODE(ctx, SYSCTL_CHILDREN(chid_tree), OID_AUTO, + "in", CTLFLAG_RD | CTLFLAG_MPSAFE, 0, ""); + if (br_tree != NULL) { + hv_ring_buffer_stat(ctx, SYSCTL_CHILDREN(br_tree), + &chan->inbound, "inbound ring buffer stats"); + } + + /* + * Create sysctl tree for TX bufring. + */ + br_tree = SYSCTL_ADD_NODE(ctx, SYSCTL_CHILDREN(chid_tree), OID_AUTO, + "out", CTLFLAG_RD | CTLFLAG_MPSAFE, 0, ""); + if (br_tree != NULL) { + hv_ring_buffer_stat(ctx, SYSCTL_CHILDREN(br_tree), + &chan->outbound, "outbound ring buffer stats"); + } } -/** - * @brief Open the specified channel - */ int -hv_vmbus_channel_open( - hv_vmbus_channel* new_channel, - uint32_t send_ring_buffer_size, - uint32_t recv_ring_buffer_size, - void* user_data, - uint32_t user_data_len, - vmbus_chan_callback_t cb, - void *cbarg) +vmbus_chan_open(struct hv_vmbus_channel *chan, int txbr_size, int rxbr_size, + const void *udata, int udlen, vmbus_chan_callback_t cb, void *cbarg) { - struct vmbus_softc *sc = new_channel->vmbus_sc; + struct vmbus_softc *sc = chan->vmbus_sc; const struct vmbus_chanmsg_chopen_resp *resp; const struct vmbus_message *msg; struct vmbus_chanmsg_chopen *req; struct vmbus_msghc *mh; uint32_t status; - int ret = 0; + int error; uint8_t *br; - if (user_data_len > VMBUS_CHANMSG_CHOPEN_UDATA_SIZE) { + if (udlen > VMBUS_CHANMSG_CHOPEN_UDATA_SIZE) { device_printf(sc->vmbus_dev, - "invalid udata len %u for chan%u\n", - user_data_len, new_channel->ch_id); + "invalid udata len %d for chan%u\n", udlen, chan->ch_id); return EINVAL; } - KASSERT((send_ring_buffer_size & PAGE_MASK) == 0, + KASSERT((txbr_size & PAGE_MASK) == 0, ("send bufring size is not multiple page")); - KASSERT((recv_ring_buffer_size & PAGE_MASK) == 0, + KASSERT((rxbr_size & PAGE_MASK) == 0, ("recv bufring size is not multiple page")); - if (atomic_testandset_int(&new_channel->ch_stflags, + if (atomic_testandset_int(&chan->ch_stflags, VMBUS_CHAN_ST_OPENED_SHIFT)) - panic("double-open chan%u", new_channel->ch_id); + panic("double-open chan%u", chan->ch_id); - new_channel->ch_cb = cb; - new_channel->ch_cbarg = cbarg; + chan->ch_cb = cb; + chan->ch_cbarg = cbarg; - vmbus_chan_update_evtflagcnt(sc, new_channel); + vmbus_chan_update_evtflagcnt(sc, chan); - new_channel->ch_tq = VMBUS_PCPU_GET(new_channel->vmbus_sc, event_tq, - new_channel->ch_cpuid); - if (new_channel->ch_flags & VMBUS_CHAN_FLAG_BATCHREAD) { - TASK_INIT(&new_channel->ch_task, 0, vmbus_chan_task, - new_channel); - } else { - TASK_INIT(&new_channel->ch_task, 0, vmbus_chan_task_nobatch, - new_channel); - } + chan->ch_tq = VMBUS_PCPU_GET(chan->vmbus_sc, event_tq, chan->ch_cpuid); + if (chan->ch_flags & VMBUS_CHAN_FLAG_BATCHREAD) + TASK_INIT(&chan->ch_task, 0, vmbus_chan_task, chan); + else + TASK_INIT(&chan->ch_task, 0, vmbus_chan_task_nobatch, chan); /* * Allocate the TX+RX bufrings. * XXX should use ch_dev dtag */ br = hyperv_dmamem_alloc(bus_get_dma_tag(sc->vmbus_dev), - PAGE_SIZE, 0, send_ring_buffer_size + recv_ring_buffer_size, - &new_channel->ch_bufring_dma, BUS_DMA_WAITOK | BUS_DMA_ZERO); + PAGE_SIZE, 0, txbr_size + rxbr_size, &chan->ch_bufring_dma, + BUS_DMA_WAITOK | BUS_DMA_ZERO); if (br == NULL) { device_printf(sc->vmbus_dev, "bufring allocation failed\n"); - ret = ENOMEM; + error = ENOMEM; goto failed; } - new_channel->ch_bufring = br; + chan->ch_bufring = br; /* TX bufring comes first */ - hv_vmbus_ring_buffer_init(&new_channel->outbound, - br, send_ring_buffer_size); + hv_vmbus_ring_buffer_init(&chan->outbound, br, txbr_size); /* RX bufring immediately follows TX bufring */ - hv_vmbus_ring_buffer_init(&new_channel->inbound, - br + send_ring_buffer_size, recv_ring_buffer_size); + hv_vmbus_ring_buffer_init(&chan->inbound, br + txbr_size, rxbr_size); /* Create sysctl tree for this channel */ - vmbus_channel_sysctl_create(new_channel); + vmbus_chan_sysctl_create(chan); /* * Connect the bufrings, both RX and TX, to this channel. */ - ret = vmbus_chan_gpadl_connect(new_channel, - new_channel->ch_bufring_dma.hv_paddr, - send_ring_buffer_size + recv_ring_buffer_size, - &new_channel->ch_bufring_gpadl); - if (ret != 0) { + error = vmbus_chan_gpadl_connect(chan, chan->ch_bufring_dma.hv_paddr, + txbr_size + rxbr_size, &chan->ch_bufring_gpadl); + if (error) { device_printf(sc->vmbus_dev, - "failed to connect bufring GPADL to chan%u\n", - new_channel->ch_id); + "failed to connect bufring GPADL to chan%u\n", chan->ch_id); goto failed; } @@ -280,26 +279,26 @@ hv_vmbus_channel_open( if (mh == NULL) { device_printf(sc->vmbus_dev, "can not get msg hypercall for chopen(chan%u)\n", - new_channel->ch_id); - ret = ENXIO; + chan->ch_id); + error = ENXIO; goto failed; } req = vmbus_msghc_dataptr(mh); req->chm_hdr.chm_type = VMBUS_CHANMSG_TYPE_CHOPEN; - req->chm_chanid = new_channel->ch_id; - req->chm_openid = new_channel->ch_id; - req->chm_gpadl = new_channel->ch_bufring_gpadl; - req->chm_vcpuid = new_channel->ch_vcpuid; - req->chm_rxbr_pgofs = send_ring_buffer_size >> PAGE_SHIFT; - if (user_data_len) - memcpy(req->chm_udata, user_data, user_data_len); + req->chm_chanid = chan->ch_id; + req->chm_openid = chan->ch_id; + req->chm_gpadl = chan->ch_bufring_gpadl; + req->chm_vcpuid = chan->ch_vcpuid; + req->chm_txbr_pgcnt = txbr_size >> PAGE_SHIFT; + if (udlen > 0) + memcpy(req->chm_udata, udata, udlen); - ret = vmbus_msghc_exec(sc, mh); - if (ret != 0) { + error = vmbus_msghc_exec(sc, mh); + if (error) { device_printf(sc->vmbus_dev, "chopen(chan%u) msg hypercall exec failed: %d\n", - new_channel->ch_id, ret); + chan->ch_id, error); vmbus_msghc_put(sc, mh); goto failed; } @@ -313,28 +312,25 @@ hv_vmbus_channel_open( if (status == 0) { if (bootverbose) { device_printf(sc->vmbus_dev, "chan%u opened\n", - new_channel->ch_id); + chan->ch_id); } return 0; } - device_printf(sc->vmbus_dev, "failed to open chan%u\n", - new_channel->ch_id); - ret = ENXIO; + device_printf(sc->vmbus_dev, "failed to open chan%u\n", chan->ch_id); + error = ENXIO; failed: - if (new_channel->ch_bufring_gpadl) { - hv_vmbus_channel_teardown_gpdal(new_channel, - new_channel->ch_bufring_gpadl); - new_channel->ch_bufring_gpadl = 0; - } - if (new_channel->ch_bufring != NULL) { - hyperv_dmamem_free(&new_channel->ch_bufring_dma, - new_channel->ch_bufring); - new_channel->ch_bufring = NULL; + if (chan->ch_bufring_gpadl) { + vmbus_chan_gpadl_disconnect(chan, chan->ch_bufring_gpadl); + chan->ch_bufring_gpadl = 0; + } + if (chan->ch_bufring != NULL) { + hyperv_dmamem_free(&chan->ch_bufring_dma, chan->ch_bufring); + chan->ch_bufring = NULL; } - atomic_clear_int(&new_channel->ch_stflags, VMBUS_CHAN_ST_OPENED); - return ret; + atomic_clear_int(&chan->ch_stflags, VMBUS_CHAN_ST_OPENED); + return error; } int @@ -468,7 +464,7 @@ vmbus_chan_gpadl_connect(struct hv_vmbus * Disconnect the GPA from the target channel */ int -hv_vmbus_channel_teardown_gpdal(struct hv_vmbus_channel *chan, uint32_t gpadl) +vmbus_chan_gpadl_disconnect(struct hv_vmbus_channel *chan, uint32_t gpadl) { struct vmbus_softc *sc = chan->vmbus_sc; struct vmbus_msghc *mh; @@ -505,41 +501,45 @@ hv_vmbus_channel_teardown_gpdal(struct h } static void -hv_vmbus_channel_close_internal(hv_vmbus_channel *channel) +vmbus_chan_close_internal(struct hv_vmbus_channel *chan) { - struct vmbus_softc *sc = channel->vmbus_sc; + struct vmbus_softc *sc = chan->vmbus_sc; struct vmbus_msghc *mh; struct vmbus_chanmsg_chclose *req; - struct taskqueue *tq = channel->ch_tq; + struct taskqueue *tq = chan->ch_tq; int error; /* TODO: stringent check */ - atomic_clear_int(&channel->ch_stflags, VMBUS_CHAN_ST_OPENED); - - sysctl_ctx_free(&channel->ch_sysctl_ctx); + atomic_clear_int(&chan->ch_stflags, VMBUS_CHAN_ST_OPENED); /* - * Set ch_tq to NULL to avoid more requests be scheduled + * Free this channel's sysctl tree attached to its device's + * sysctl tree. */ - channel->ch_tq = NULL; - taskqueue_drain(tq, &channel->ch_task); - channel->ch_cb = NULL; + sysctl_ctx_free(&chan->ch_sysctl_ctx); - /** - * Send a closing message + /* + * Set ch_tq to NULL to avoid more requests be scheduled. + * XXX pretty broken; need rework. */ + chan->ch_tq = NULL; + taskqueue_drain(tq, &chan->ch_task); + chan->ch_cb = NULL; + /* + * Close this channel. + */ mh = vmbus_msghc_get(sc, sizeof(*req)); if (mh == NULL) { device_printf(sc->vmbus_dev, "can not get msg hypercall for chclose(chan%u)\n", - channel->ch_id); + chan->ch_id); return; } req = vmbus_msghc_dataptr(mh); req->chm_hdr.chm_type = VMBUS_CHANMSG_TYPE_CHCLOSE; - req->chm_chanid = channel->ch_id; + req->chm_chanid = chan->ch_id; error = vmbus_msghc_exec_noresult(mh); vmbus_msghc_put(sc, mh); @@ -547,30 +547,28 @@ hv_vmbus_channel_close_internal(hv_vmbus if (error) { device_printf(sc->vmbus_dev, "chclose(chan%u) msg hypercall exec failed: %d\n", - channel->ch_id, error); + chan->ch_id, error); return; } else if (bootverbose) { - device_printf(sc->vmbus_dev, "close chan%u\n", - channel->ch_id); + device_printf(sc->vmbus_dev, "close chan%u\n", chan->ch_id); } - /* Tear down the gpadl for the channel's ring buffer */ - if (channel->ch_bufring_gpadl) { - hv_vmbus_channel_teardown_gpdal(channel, - channel->ch_bufring_gpadl); - channel->ch_bufring_gpadl = 0; + /* + * Disconnect the TX+RX bufrings from this channel. + */ + if (chan->ch_bufring_gpadl) { + vmbus_chan_gpadl_disconnect(chan, chan->ch_bufring_gpadl); + chan->ch_bufring_gpadl = 0; } - /* TODO: Send a msg to release the childRelId */ - - /* cleanup the ring buffers for this channel */ - hv_ring_buffer_cleanup(&channel->outbound); - hv_ring_buffer_cleanup(&channel->inbound); - - if (channel->ch_bufring != NULL) { - hyperv_dmamem_free(&channel->ch_bufring_dma, - channel->ch_bufring); - channel->ch_bufring = NULL; + /* + * Destroy the TX+RX bufrings. + */ + hv_ring_buffer_cleanup(&chan->outbound); + hv_ring_buffer_cleanup(&chan->inbound); + if (chan->ch_bufring != NULL) { + hyperv_dmamem_free(&chan->ch_bufring_dma, chan->ch_bufring); + chan->ch_bufring = NULL; } } @@ -580,7 +578,7 @@ hv_vmbus_channel_close_internal(hv_vmbus * are not being opened. */ void -hv_vmbus_channel_close(struct hv_vmbus_channel *chan) +vmbus_chan_close(struct hv_vmbus_channel *chan) { int subchan_cnt; @@ -600,14 +598,14 @@ hv_vmbus_channel_close(struct hv_vmbus_c struct hv_vmbus_channel **subchan; int i; - subchan = vmbus_get_subchan(chan, subchan_cnt); + subchan = vmbus_subchan_get(chan, subchan_cnt); for (i = 0; i < subchan_cnt; ++i) - hv_vmbus_channel_close_internal(subchan[i]); - vmbus_rel_subchan(subchan, subchan_cnt); + vmbus_chan_close_internal(subchan[i]); + vmbus_subchan_rel(subchan, subchan_cnt); } /* Then close the primary channel. */ - hv_vmbus_channel_close_internal(chan); + vmbus_chan_close_internal(chan); } int @@ -639,7 +637,7 @@ vmbus_chan_send(struct hv_vmbus_channel error = hv_ring_buffer_write(&chan->outbound, iov, 3, &send_evt); if (!error && send_evt) - vmbus_chan_send_event(chan); + vmbus_chan_signal_tx(chan); return error; } @@ -679,7 +677,7 @@ vmbus_chan_send_sglist(struct hv_vmbus_c error = hv_ring_buffer_write(&chan->outbound, iov, 4, &send_evt); if (!error && send_evt) - vmbus_chan_send_event(chan); + vmbus_chan_signal_tx(chan); return error; } @@ -721,7 +719,7 @@ vmbus_chan_send_prplist(struct hv_vmbus_ error = hv_ring_buffer_write(&chan->outbound, iov, 4, &send_evt); if (!error && send_evt) - vmbus_chan_send_event(chan); + vmbus_chan_signal_tx(chan); return error; } @@ -840,20 +838,20 @@ vmbus_event_flags_proc(struct vmbus_soft chid_base = f << VMBUS_EVTFLAG_SHIFT; while ((chid_ofs = ffsl(flags)) != 0) { - struct hv_vmbus_channel *channel; + struct hv_vmbus_channel *chan; --chid_ofs; /* NOTE: ffsl is 1-based */ flags &= ~(1UL << chid_ofs); - channel = sc->vmbus_chmap[chid_base + chid_ofs]; + chan = sc->vmbus_chmap[chid_base + chid_ofs]; /* if channel is closed or closing */ - if (channel == NULL || channel->ch_tq == NULL) + if (chan == NULL || chan->ch_tq == NULL) continue; - if (channel->ch_flags & VMBUS_CHAN_FLAG_BATCHREAD) - hv_ring_buffer_read_begin(&channel->inbound); - taskqueue_enqueue(channel->ch_tq, &channel->ch_task); + if (chan->ch_flags & VMBUS_CHAN_FLAG_BATCHREAD) + hv_ring_buffer_read_begin(&chan->inbound); + taskqueue_enqueue(chan->ch_tq, &chan->ch_task); } } } @@ -1038,7 +1036,7 @@ vmbus_chan_add(struct hv_vmbus_channel * } void -vmbus_channel_cpu_set(struct hv_vmbus_channel *chan, int cpu) +vmbus_chan_cpu_set(struct hv_vmbus_channel *chan, int cpu) { KASSERT(cpu >= 0 && cpu < mp_ncpus, ("invalid cpu %d", cpu)); @@ -1058,13 +1056,13 @@ vmbus_channel_cpu_set(struct hv_vmbus_ch } void -vmbus_channel_cpu_rr(struct hv_vmbus_channel *chan) +vmbus_chan_cpu_rr(struct hv_vmbus_channel *chan) { static uint32_t vmbus_chan_nextcpu; int cpu; cpu = atomic_fetchadd_int(&vmbus_chan_nextcpu, 1) % mp_ncpus; - vmbus_channel_cpu_set(chan, cpu); + vmbus_chan_cpu_set(chan, cpu); } static void @@ -1073,9 +1071,9 @@ vmbus_chan_cpu_default(struct hv_vmbus_c /* * By default, pin the channel to cpu0. Devices having * special channel-cpu mapping requirement should call - * vmbus_channel_cpu_{set,rr}(). + * vmbus_chan_cpu_{set,rr}(). */ - vmbus_channel_cpu_set(chan, 0); + vmbus_chan_cpu_set(chan, 0); } static void @@ -1251,65 +1249,67 @@ vmbus_chan_destroy_all(struct vmbus_soft mtx_unlock(&sc->vmbus_prichan_lock); } -/** - * @brief Select the best outgoing channel - * +/* * The channel whose vcpu binding is closest to the currect vcpu will * be selected. - * If no multi-channel, always select primary channel - * - * @param primary - primary channel + * If no multi-channel, always select primary channel. */ struct hv_vmbus_channel * -vmbus_select_outgoing_channel(struct hv_vmbus_channel *primary) +vmbus_chan_cpu2chan(struct hv_vmbus_channel *prichan, int cpu) { - hv_vmbus_channel *new_channel = NULL; - hv_vmbus_channel *outgoing_channel = primary; - int old_cpu_distance = 0; - int new_cpu_distance = 0; - int cur_vcpu = 0; - int smp_pro_id = PCPU_GET(cpuid); + struct hv_vmbus_channel *sel, *chan; + uint32_t vcpu, sel_dist; - if (TAILQ_EMPTY(&primary->ch_subchans)) { - return outgoing_channel; - } + KASSERT(cpu >= 0 && cpu < mp_ncpus, ("invalid cpuid %d", cpu)); + if (TAILQ_EMPTY(&prichan->ch_subchans)) + return prichan; - if (smp_pro_id >= MAXCPU) { - return outgoing_channel; - } + vcpu = VMBUS_PCPU_GET(prichan->vmbus_sc, vcpuid, cpu); - cur_vcpu = VMBUS_PCPU_GET(primary->vmbus_sc, vcpuid, smp_pro_id); - - /* XXX need lock */ - TAILQ_FOREACH(new_channel, &primary->ch_subchans, ch_sublink) { - if ((new_channel->ch_stflags & VMBUS_CHAN_ST_OPENED) == 0) { - continue; - } +#define CHAN_VCPU_DIST(ch, vcpu) \ + (((ch)->ch_vcpuid > (vcpu)) ? \ + ((ch)->ch_vcpuid - (vcpu)) : ((vcpu) - (ch)->ch_vcpuid)) - if (new_channel->ch_vcpuid == cur_vcpu){ - return new_channel; - } +#define CHAN_SELECT(ch) \ +do { \ + sel = ch; \ *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-all@freebsd.org Wed Oct 12 02:52:57 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 805D8C0E008 for ; Wed, 12 Oct 2016 02:52:57 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: from mail-it0-x235.google.com (mail-it0-x235.google.com [IPv6:2607:f8b0:4001:c0b::235]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4820BB2 for ; Wed, 12 Oct 2016 02:52:57 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: by mail-it0-x235.google.com with SMTP id l13so130547865itl.1 for ; Tue, 11 Oct 2016 19:52:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20150623.gappssmtp.com; s=20150623; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=viMUXSvsdHDxpjJvDTEXoMwuWSsE2uQ1IyIaFbGwMiU=; b=Omr5nZPugXfmLauIQvx0z5pyxq055MaZEM3Xg3UILk5Ygp4XuXdcgaht7TD1zoh0u0 cnBVznnfusE9mJ+LWbcagQmnqv3L1gr5huPn+hAR7VBce8mMM7NzPRyORceCx4yFnEQE K2ZFYbyl1gDRVT+MGN20eGf5XHZOm9HooRyH7MzymgyTtze0Ke6lCiOmtwDwmSevkfLG nvQfkYBBKOUfdh+tNeE76rZ7OaqBjZvulR2X2VHqEGwNya2oHUUdVX41gYxcpnjuB8b+ gJw4e3ZetLCWuGrOstTKHb19gqOszHlHsXEN38knpThGFr7wRKqWAmGXAQS3WD1yXFu4 b5jw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=viMUXSvsdHDxpjJvDTEXoMwuWSsE2uQ1IyIaFbGwMiU=; b=cwfoFICk5wBUckEYpuLB/mJytPSbVDm5bdRc11HpOUbGFCQUWSYxHpA+SmkK6yr1l8 n/kANwGp7rV+CJ5XhwDhBV024T+JsH77KZcolRsrxEnWXC4pUOTqBm9QKg4gMG6oxSDw r97i4yOMk0iLMDzhdCip9ry2DHCTLYlx9npn/6jIftUrS9LO/yoFiS/A9U9Zoa5ICXoJ 6hJdQctk9zagKcsL1yNlkBJu8oGWqsQT+UNOrCONu6wlrJnqLiq3FiNxW2DGg4+HGi+c 9sA+tGM4VJLET0BclhAXSJqJnHCdSc0A5nzWQsk51GU2zvoOAr6vLGVrNI8tAw7kS/Sf OxBg== X-Gm-Message-State: AA6/9RkGsg7UBhX60MdEPZfutQapUmLbi7dahAjPmkX12yklsFv71xfWUu6rtibqv6G6YtOkm8ayzwdWqk1iAw== X-Received: by 10.107.139.79 with SMTP id n76mr1147794iod.166.1476240776803; Tue, 11 Oct 2016 19:52:56 -0700 (PDT) MIME-Version: 1.0 Sender: wlosh@bsdimp.com Received: by 10.79.77.85 with HTTP; Tue, 11 Oct 2016 19:52:56 -0700 (PDT) X-Originating-IP: [69.53.245.200] In-Reply-To: <20161011231900.GC55764@mutt-hardenedbsd> References: <201610112231.u9BMVk8K056208@repo.freebsd.org> <20161011231153.GB55764@mutt-hardenedbsd> <20161011231900.GC55764@mutt-hardenedbsd> From: Warner Losh Date: Tue, 11 Oct 2016 20:52:56 -0600 X-Google-Sender-Auth: fot4HuhzSDrHtDa6PcmOzHl3s60 Message-ID: Subject: Re: svn commit: r307072 - in head/usr.sbin: . efivar To: Shawn Webb Cc: Warner Losh , src-committers , "svn-src-all@freebsd.org" , "svn-src-head@freebsd.org" Content-Type: text/plain; charset=UTF-8 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Oct 2016 02:52:57 -0000 On Tue, Oct 11, 2016 at 5:19 PM, Shawn Webb wrote: > On Tue, Oct 11, 2016 at 05:13:24PM -0600, Warner Losh wrote: >> On Tue, Oct 11, 2016 at 5:11 PM, Shawn Webb wrote: >> > On Tue, Oct 11, 2016 at 10:31:46PM +0000, Warner Losh wrote: >> >> Author: imp >> >> Date: Tue Oct 11 22:31:45 2016 >> >> New Revision: 307072 >> >> URL: https://svnweb.freebsd.org/changeset/base/307072 >> >> >> >> Log: >> >> Add efivar(1) to manipulate EFI variables. It uses a similar command >> >> line interface to the Linux program, as well as adding a number of >> >> useful features to make using it in shell scripts easier (since we >> >> don't have a filesystem to fall back on interacting with). >> >> >> >> Differential Revision: https://reviews.freebsd.org/D8128 >> >> Reviewed by: kib@, wblock@, Ganael Laplanche >> >> >> >> Added: >> >> head/usr.sbin/efivar/ >> >> head/usr.sbin/efivar/Makefile (contents, props changed) >> >> head/usr.sbin/efivar/efivar.8 (contents, props changed) >> >> head/usr.sbin/efivar/efivar.c (contents, props changed) >> >> Modified: >> >> head/usr.sbin/Makefile >> > >> > The commit log says efivar(1), but the manpage is efivar(8). Maybe 1 is >> > a typo? >> >> (1) is a typo :( > > No worries. Thanks for the quick response. I just wanted to make sure > that it was supposed to be 8 versus the 1 in the log. > > Good to see a program like this in base. Good work. Next up: corrected EFI variable support in the boot loader, and efibootmgr from Linux in ports... Warner From owner-svn-src-all@freebsd.org Wed Oct 12 02:55:25 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id AE140C0E0F1; Wed, 12 Oct 2016 02:55:25 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 75CA627B; Wed, 12 Oct 2016 02:55:25 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9C2tOic057045; Wed, 12 Oct 2016 02:55:24 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9C2tOwe057041; Wed, 12 Oct 2016 02:55:24 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610120255.u9C2tOwe057041@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Wed, 12 Oct 2016 02:55:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307086 - in stable/10/sys: conf dev/hyperv/vmbus modules/hyperv/vmbus X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Oct 2016 02:55:25 -0000 Author: sephe Date: Wed Oct 12 02:55:24 2016 New Revision: 307086 URL: https://svnweb.freebsd.org/changeset/base/307086 Log: MFC 303023 hyperv/vmbus: Rename laundered vmbus channel code Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7232 Added: stable/10/sys/dev/hyperv/vmbus/vmbus_chan.c - copied unchanged from r303023, head/sys/dev/hyperv/vmbus/vmbus_chan.c Deleted: stable/10/sys/dev/hyperv/vmbus/hv_channel.c Modified: stable/10/sys/conf/files.amd64 stable/10/sys/conf/files.i386 stable/10/sys/modules/hyperv/vmbus/Makefile Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/conf/files.amd64 ============================================================================== --- stable/10/sys/conf/files.amd64 Wed Oct 12 02:47:31 2016 (r307085) +++ stable/10/sys/conf/files.amd64 Wed Oct 12 02:55:24 2016 (r307086) @@ -271,11 +271,11 @@ dev/hyperv/utilities/hv_kvp.c optiona dev/hyperv/utilities/hv_shutdown.c optional hyperv dev/hyperv/utilities/hv_timesync.c optional hyperv dev/hyperv/utilities/hv_util.c optional hyperv -dev/hyperv/vmbus/hv_channel.c optional hyperv dev/hyperv/vmbus/hv_ring_buffer.c optional hyperv dev/hyperv/vmbus/hyperv.c optional hyperv dev/hyperv/vmbus/hyperv_busdma.c optional hyperv dev/hyperv/vmbus/vmbus.c optional hyperv +dev/hyperv/vmbus/vmbus_chan.c optional hyperv dev/hyperv/vmbus/vmbus_et.c optional hyperv dev/hyperv/vmbus/vmbus_if.m optional hyperv dev/hyperv/vmbus/amd64/hyperv_machdep.c optional hyperv Modified: stable/10/sys/conf/files.i386 ============================================================================== --- stable/10/sys/conf/files.i386 Wed Oct 12 02:47:31 2016 (r307085) +++ stable/10/sys/conf/files.i386 Wed Oct 12 02:55:24 2016 (r307086) @@ -248,11 +248,11 @@ dev/hyperv/utilities/hv_kvp.c optiona dev/hyperv/utilities/hv_shutdown.c optional hyperv dev/hyperv/utilities/hv_timesync.c optional hyperv dev/hyperv/utilities/hv_util.c optional hyperv -dev/hyperv/vmbus/hv_channel.c optional hyperv dev/hyperv/vmbus/hv_ring_buffer.c optional hyperv dev/hyperv/vmbus/hyperv.c optional hyperv dev/hyperv/vmbus/hyperv_busdma.c optional hyperv dev/hyperv/vmbus/vmbus.c optional hyperv +dev/hyperv/vmbus/vmbus_chan.c optional hyperv dev/hyperv/vmbus/vmbus_et.c optional hyperv dev/hyperv/vmbus/vmbus_if.m optional hyperv dev/hyperv/vmbus/i386/hyperv_machdep.c optional hyperv Copied: stable/10/sys/dev/hyperv/vmbus/vmbus_chan.c (from r303023, head/sys/dev/hyperv/vmbus/vmbus_chan.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/10/sys/dev/hyperv/vmbus/vmbus_chan.c Wed Oct 12 02:55:24 2016 (r307086, copy of r303023, head/sys/dev/hyperv/vmbus/vmbus_chan.c) @@ -0,0 +1,1380 @@ +/*- + * Copyright (c) 2009-2012,2016 Microsoft Corp. + * Copyright (c) 2012 NetApp Inc. + * Copyright (c) 2012 Citrix Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice unmodified, 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 ``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 BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include + +#include +#include +#include +#include +#include + +static void vmbus_chan_signal_tx(struct hv_vmbus_channel *chan); +static void vmbus_chan_update_evtflagcnt(struct vmbus_softc *, + const struct hv_vmbus_channel *); + +static void vmbus_chan_task(void *, int); +static void vmbus_chan_task_nobatch(void *, int); +static void vmbus_chan_detach_task(void *, int); + +static void vmbus_chan_msgproc_choffer(struct vmbus_softc *, + const struct vmbus_message *); +static void vmbus_chan_msgproc_chrescind(struct vmbus_softc *, + const struct vmbus_message *); + +/* + * Vmbus channel message processing. + */ +static const vmbus_chanmsg_proc_t +vmbus_chan_msgprocs[VMBUS_CHANMSG_TYPE_MAX] = { + VMBUS_CHANMSG_PROC(CHOFFER, vmbus_chan_msgproc_choffer), + VMBUS_CHANMSG_PROC(CHRESCIND, vmbus_chan_msgproc_chrescind), + + VMBUS_CHANMSG_PROC_WAKEUP(CHOPEN_RESP), + VMBUS_CHANMSG_PROC_WAKEUP(GPADL_CONNRESP), + VMBUS_CHANMSG_PROC_WAKEUP(GPADL_DISCONNRESP) +}; + +/** + * @brief Trigger an event notification on the specified channel + */ +static void +vmbus_chan_signal_tx(struct hv_vmbus_channel *chan) +{ + struct vmbus_softc *sc = chan->vmbus_sc; + uint32_t chanid = chan->ch_id; + + atomic_set_long(&sc->vmbus_tx_evtflags[chanid >> VMBUS_EVTFLAG_SHIFT], + 1UL << (chanid & VMBUS_EVTFLAG_MASK)); + + if (chan->ch_flags & VMBUS_CHAN_FLAG_HASMNF) { + atomic_set_int( + &sc->vmbus_mnf2->mnf_trigs[chan->ch_montrig_idx].mt_pending, + chan->ch_montrig_mask); + } else { + hypercall_signal_event(chan->ch_monprm_dma.hv_paddr); + } +} + +static int +vmbus_chan_sysctl_mnf(SYSCTL_HANDLER_ARGS) +{ + struct hv_vmbus_channel *chan = arg1; + int mnf = 0; + + if (chan->ch_flags & VMBUS_CHAN_FLAG_HASMNF) + mnf = 1; + return sysctl_handle_int(oidp, &mnf, 0, req); +} + +static void +vmbus_chan_sysctl_create(struct hv_vmbus_channel *chan) +{ + struct sysctl_oid *ch_tree, *chid_tree, *br_tree; + struct sysctl_ctx_list *ctx; + uint32_t ch_id; + char name[16]; + + /* + * Add sysctl nodes related to this channel to this + * channel's sysctl ctx, so that they can be destroyed + * independently upon close of this channel, which can + * happen even if the device is not detached. + */ + ctx = &chan->ch_sysctl_ctx; + sysctl_ctx_init(ctx); + + /* + * Create dev.NAME.UNIT.channel tree. + */ + ch_tree = SYSCTL_ADD_NODE(ctx, + SYSCTL_CHILDREN(device_get_sysctl_tree(chan->ch_dev)), + OID_AUTO, "channel", CTLFLAG_RD | CTLFLAG_MPSAFE, 0, ""); + if (ch_tree == NULL) + return; + + /* + * Create dev.NAME.UNIT.channel.CHANID tree. + */ + if (VMBUS_CHAN_ISPRIMARY(chan)) + ch_id = chan->ch_id; + else + ch_id = chan->ch_prichan->ch_id; + snprintf(name, sizeof(name), "%d", ch_id); + chid_tree = SYSCTL_ADD_NODE(ctx, SYSCTL_CHILDREN(ch_tree), + OID_AUTO, name, CTLFLAG_RD | CTLFLAG_MPSAFE, 0, ""); + if (chid_tree == NULL) + return; + + if (!VMBUS_CHAN_ISPRIMARY(chan)) { + /* + * Create dev.NAME.UNIT.channel.CHANID.sub tree. + */ + ch_tree = SYSCTL_ADD_NODE(ctx, SYSCTL_CHILDREN(chid_tree), + OID_AUTO, "sub", CTLFLAG_RD | CTLFLAG_MPSAFE, 0, ""); + if (ch_tree == NULL) + return; + + /* + * Create dev.NAME.UNIT.channel.CHANID.sub.SUBIDX tree. + * + * NOTE: + * chid_tree is changed to this new sysctl tree. + */ + snprintf(name, sizeof(name), "%d", chan->ch_subidx); + chid_tree = SYSCTL_ADD_NODE(ctx, SYSCTL_CHILDREN(ch_tree), + OID_AUTO, name, CTLFLAG_RD | CTLFLAG_MPSAFE, 0, ""); + if (chid_tree == NULL) + return; + + SYSCTL_ADD_UINT(ctx, SYSCTL_CHILDREN(chid_tree), OID_AUTO, + "chanid", CTLFLAG_RD, &chan->ch_id, 0, "channel id"); + } + + SYSCTL_ADD_UINT(ctx, SYSCTL_CHILDREN(chid_tree), OID_AUTO, + "cpu", CTLFLAG_RD, &chan->ch_cpuid, 0, "owner CPU id"); + SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(chid_tree), OID_AUTO, + "mnf", CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_MPSAFE, + chan, 0, vmbus_chan_sysctl_mnf, "I", + "has monitor notification facilities"); + + /* + * Create sysctl tree for RX bufring. + */ + br_tree = SYSCTL_ADD_NODE(ctx, SYSCTL_CHILDREN(chid_tree), OID_AUTO, + "in", CTLFLAG_RD | CTLFLAG_MPSAFE, 0, ""); + if (br_tree != NULL) { + hv_ring_buffer_stat(ctx, SYSCTL_CHILDREN(br_tree), + &chan->inbound, "inbound ring buffer stats"); + } + + /* + * Create sysctl tree for TX bufring. + */ + br_tree = SYSCTL_ADD_NODE(ctx, SYSCTL_CHILDREN(chid_tree), OID_AUTO, + "out", CTLFLAG_RD | CTLFLAG_MPSAFE, 0, ""); + if (br_tree != NULL) { + hv_ring_buffer_stat(ctx, SYSCTL_CHILDREN(br_tree), + &chan->outbound, "outbound ring buffer stats"); + } +} + +int +vmbus_chan_open(struct hv_vmbus_channel *chan, int txbr_size, int rxbr_size, + const void *udata, int udlen, vmbus_chan_callback_t cb, void *cbarg) +{ + struct vmbus_softc *sc = chan->vmbus_sc; + const struct vmbus_chanmsg_chopen_resp *resp; + const struct vmbus_message *msg; + struct vmbus_chanmsg_chopen *req; + struct vmbus_msghc *mh; + uint32_t status; + int error; + uint8_t *br; + + if (udlen > VMBUS_CHANMSG_CHOPEN_UDATA_SIZE) { + device_printf(sc->vmbus_dev, + "invalid udata len %d for chan%u\n", udlen, chan->ch_id); + return EINVAL; + } + KASSERT((txbr_size & PAGE_MASK) == 0, + ("send bufring size is not multiple page")); + KASSERT((rxbr_size & PAGE_MASK) == 0, + ("recv bufring size is not multiple page")); + + if (atomic_testandset_int(&chan->ch_stflags, + VMBUS_CHAN_ST_OPENED_SHIFT)) + panic("double-open chan%u", chan->ch_id); + + chan->ch_cb = cb; + chan->ch_cbarg = cbarg; + + vmbus_chan_update_evtflagcnt(sc, chan); + + chan->ch_tq = VMBUS_PCPU_GET(chan->vmbus_sc, event_tq, chan->ch_cpuid); + if (chan->ch_flags & VMBUS_CHAN_FLAG_BATCHREAD) + TASK_INIT(&chan->ch_task, 0, vmbus_chan_task, chan); + else + TASK_INIT(&chan->ch_task, 0, vmbus_chan_task_nobatch, chan); + + /* + * Allocate the TX+RX bufrings. + * XXX should use ch_dev dtag + */ + br = hyperv_dmamem_alloc(bus_get_dma_tag(sc->vmbus_dev), + PAGE_SIZE, 0, txbr_size + rxbr_size, &chan->ch_bufring_dma, + BUS_DMA_WAITOK | BUS_DMA_ZERO); + if (br == NULL) { + device_printf(sc->vmbus_dev, "bufring allocation failed\n"); + error = ENOMEM; + goto failed; + } + chan->ch_bufring = br; + + /* TX bufring comes first */ + hv_vmbus_ring_buffer_init(&chan->outbound, br, txbr_size); + /* RX bufring immediately follows TX bufring */ + hv_vmbus_ring_buffer_init(&chan->inbound, br + txbr_size, rxbr_size); + + /* Create sysctl tree for this channel */ + vmbus_chan_sysctl_create(chan); + + /* + * Connect the bufrings, both RX and TX, to this channel. + */ + error = vmbus_chan_gpadl_connect(chan, chan->ch_bufring_dma.hv_paddr, + txbr_size + rxbr_size, &chan->ch_bufring_gpadl); + if (error) { + device_printf(sc->vmbus_dev, + "failed to connect bufring GPADL to chan%u\n", chan->ch_id); + goto failed; + } + + /* + * Open channel w/ the bufring GPADL on the target CPU. + */ + mh = vmbus_msghc_get(sc, sizeof(*req)); + if (mh == NULL) { + device_printf(sc->vmbus_dev, + "can not get msg hypercall for chopen(chan%u)\n", + chan->ch_id); + error = ENXIO; + goto failed; + } + + req = vmbus_msghc_dataptr(mh); + req->chm_hdr.chm_type = VMBUS_CHANMSG_TYPE_CHOPEN; + req->chm_chanid = chan->ch_id; + req->chm_openid = chan->ch_id; + req->chm_gpadl = chan->ch_bufring_gpadl; + req->chm_vcpuid = chan->ch_vcpuid; + req->chm_txbr_pgcnt = txbr_size >> PAGE_SHIFT; + if (udlen > 0) + memcpy(req->chm_udata, udata, udlen); + + error = vmbus_msghc_exec(sc, mh); + if (error) { + device_printf(sc->vmbus_dev, + "chopen(chan%u) msg hypercall exec failed: %d\n", + chan->ch_id, error); + vmbus_msghc_put(sc, mh); + goto failed; + } + + msg = vmbus_msghc_wait_result(sc, mh); + resp = (const struct vmbus_chanmsg_chopen_resp *)msg->msg_data; + status = resp->chm_status; + + vmbus_msghc_put(sc, mh); + + if (status == 0) { + if (bootverbose) { + device_printf(sc->vmbus_dev, "chan%u opened\n", + chan->ch_id); + } + return 0; + } + + device_printf(sc->vmbus_dev, "failed to open chan%u\n", chan->ch_id); + error = ENXIO; + +failed: + if (chan->ch_bufring_gpadl) { + vmbus_chan_gpadl_disconnect(chan, chan->ch_bufring_gpadl); + chan->ch_bufring_gpadl = 0; + } + if (chan->ch_bufring != NULL) { + hyperv_dmamem_free(&chan->ch_bufring_dma, chan->ch_bufring); + chan->ch_bufring = NULL; + } + atomic_clear_int(&chan->ch_stflags, VMBUS_CHAN_ST_OPENED); + return error; +} + +int +vmbus_chan_gpadl_connect(struct hv_vmbus_channel *chan, bus_addr_t paddr, + int size, uint32_t *gpadl0) +{ + struct vmbus_softc *sc = chan->vmbus_sc; + struct vmbus_msghc *mh; + struct vmbus_chanmsg_gpadl_conn *req; + const struct vmbus_message *msg; + size_t reqsz; + uint32_t gpadl, status; + int page_count, range_len, i, cnt, error; + uint64_t page_id; + + /* + * Preliminary checks. + */ + + KASSERT((size & PAGE_MASK) == 0, + ("invalid GPA size %d, not multiple page size", size)); + page_count = size >> PAGE_SHIFT; + + KASSERT((paddr & PAGE_MASK) == 0, + ("GPA is not page aligned %jx", (uintmax_t)paddr)); + page_id = paddr >> PAGE_SHIFT; + + range_len = __offsetof(struct vmbus_gpa_range, gpa_page[page_count]); + /* + * We don't support multiple GPA ranges. + */ + if (range_len > UINT16_MAX) { + device_printf(sc->vmbus_dev, "GPA too large, %d pages\n", + page_count); + return EOPNOTSUPP; + } + + /* + * Allocate GPADL id. + */ + gpadl = vmbus_gpadl_alloc(sc); + *gpadl0 = gpadl; + + /* + * Connect this GPADL to the target channel. + * + * NOTE: + * Since each message can only hold small set of page + * addresses, several messages may be required to + * complete the connection. + */ + if (page_count > VMBUS_CHANMSG_GPADL_CONN_PGMAX) + cnt = VMBUS_CHANMSG_GPADL_CONN_PGMAX; + else + cnt = page_count; + page_count -= cnt; + + reqsz = __offsetof(struct vmbus_chanmsg_gpadl_conn, + chm_range.gpa_page[cnt]); + mh = vmbus_msghc_get(sc, reqsz); + if (mh == NULL) { + device_printf(sc->vmbus_dev, + "can not get msg hypercall for gpadl->chan%u\n", + chan->ch_id); + return EIO; + } + + req = vmbus_msghc_dataptr(mh); + req->chm_hdr.chm_type = VMBUS_CHANMSG_TYPE_GPADL_CONN; + req->chm_chanid = chan->ch_id; + req->chm_gpadl = gpadl; + req->chm_range_len = range_len; + req->chm_range_cnt = 1; + req->chm_range.gpa_len = size; + req->chm_range.gpa_ofs = 0; + for (i = 0; i < cnt; ++i) + req->chm_range.gpa_page[i] = page_id++; + + error = vmbus_msghc_exec(sc, mh); + if (error) { + device_printf(sc->vmbus_dev, + "gpadl->chan%u msg hypercall exec failed: %d\n", + chan->ch_id, error); + vmbus_msghc_put(sc, mh); + return error; + } + + while (page_count > 0) { + struct vmbus_chanmsg_gpadl_subconn *subreq; + + if (page_count > VMBUS_CHANMSG_GPADL_SUBCONN_PGMAX) + cnt = VMBUS_CHANMSG_GPADL_SUBCONN_PGMAX; + else + cnt = page_count; + page_count -= cnt; + + reqsz = __offsetof(struct vmbus_chanmsg_gpadl_subconn, + chm_gpa_page[cnt]); + vmbus_msghc_reset(mh, reqsz); + + subreq = vmbus_msghc_dataptr(mh); + subreq->chm_hdr.chm_type = VMBUS_CHANMSG_TYPE_GPADL_SUBCONN; + subreq->chm_gpadl = gpadl; + for (i = 0; i < cnt; ++i) + subreq->chm_gpa_page[i] = page_id++; + + vmbus_msghc_exec_noresult(mh); + } + KASSERT(page_count == 0, ("invalid page count %d", page_count)); + + msg = vmbus_msghc_wait_result(sc, mh); + status = ((const struct vmbus_chanmsg_gpadl_connresp *) + msg->msg_data)->chm_status; + + vmbus_msghc_put(sc, mh); + + if (status != 0) { + device_printf(sc->vmbus_dev, "gpadl->chan%u failed: " + "status %u\n", chan->ch_id, status); + return EIO; + } else { + if (bootverbose) { + device_printf(sc->vmbus_dev, "gpadl->chan%u " + "succeeded\n", chan->ch_id); + } + } + return 0; +} + +/* + * Disconnect the GPA from the target channel + */ +int +vmbus_chan_gpadl_disconnect(struct hv_vmbus_channel *chan, uint32_t gpadl) +{ + struct vmbus_softc *sc = chan->vmbus_sc; + struct vmbus_msghc *mh; + struct vmbus_chanmsg_gpadl_disconn *req; + int error; + + mh = vmbus_msghc_get(sc, sizeof(*req)); + if (mh == NULL) { + device_printf(sc->vmbus_dev, + "can not get msg hypercall for gpa x->chan%u\n", + chan->ch_id); + return EBUSY; + } + + req = vmbus_msghc_dataptr(mh); + req->chm_hdr.chm_type = VMBUS_CHANMSG_TYPE_GPADL_DISCONN; + req->chm_chanid = chan->ch_id; + req->chm_gpadl = gpadl; + + error = vmbus_msghc_exec(sc, mh); + if (error) { + device_printf(sc->vmbus_dev, + "gpa x->chan%u msg hypercall exec failed: %d\n", + chan->ch_id, error); + vmbus_msghc_put(sc, mh); + return error; + } + + vmbus_msghc_wait_result(sc, mh); + /* Discard result; no useful information */ + vmbus_msghc_put(sc, mh); + + return 0; +} + +static void +vmbus_chan_close_internal(struct hv_vmbus_channel *chan) +{ + struct vmbus_softc *sc = chan->vmbus_sc; + struct vmbus_msghc *mh; + struct vmbus_chanmsg_chclose *req; + struct taskqueue *tq = chan->ch_tq; + int error; + + /* TODO: stringent check */ + atomic_clear_int(&chan->ch_stflags, VMBUS_CHAN_ST_OPENED); + + /* + * Free this channel's sysctl tree attached to its device's + * sysctl tree. + */ + sysctl_ctx_free(&chan->ch_sysctl_ctx); + + /* + * Set ch_tq to NULL to avoid more requests be scheduled. + * XXX pretty broken; need rework. + */ + chan->ch_tq = NULL; + taskqueue_drain(tq, &chan->ch_task); + chan->ch_cb = NULL; + + /* + * Close this channel. + */ + mh = vmbus_msghc_get(sc, sizeof(*req)); + if (mh == NULL) { + device_printf(sc->vmbus_dev, + "can not get msg hypercall for chclose(chan%u)\n", + chan->ch_id); + return; + } + + req = vmbus_msghc_dataptr(mh); + req->chm_hdr.chm_type = VMBUS_CHANMSG_TYPE_CHCLOSE; + req->chm_chanid = chan->ch_id; + + error = vmbus_msghc_exec_noresult(mh); + vmbus_msghc_put(sc, mh); + + if (error) { + device_printf(sc->vmbus_dev, + "chclose(chan%u) msg hypercall exec failed: %d\n", + chan->ch_id, error); + return; + } else if (bootverbose) { + device_printf(sc->vmbus_dev, "close chan%u\n", chan->ch_id); + } + + /* + * Disconnect the TX+RX bufrings from this channel. + */ + if (chan->ch_bufring_gpadl) { + vmbus_chan_gpadl_disconnect(chan, chan->ch_bufring_gpadl); + chan->ch_bufring_gpadl = 0; + } + + /* + * Destroy the TX+RX bufrings. + */ + hv_ring_buffer_cleanup(&chan->outbound); + hv_ring_buffer_cleanup(&chan->inbound); + if (chan->ch_bufring != NULL) { + hyperv_dmamem_free(&chan->ch_bufring_dma, chan->ch_bufring); + chan->ch_bufring = NULL; + } +} + +/* + * Caller should make sure that all sub-channels have + * been added to 'chan' and all to-be-closed channels + * are not being opened. + */ +void +vmbus_chan_close(struct hv_vmbus_channel *chan) +{ + int subchan_cnt; + + if (!VMBUS_CHAN_ISPRIMARY(chan)) { + /* + * Sub-channel is closed when its primary channel + * is closed; done. + */ + return; + } + + /* + * Close all sub-channels, if any. + */ + subchan_cnt = chan->ch_subchan_cnt; + if (subchan_cnt > 0) { + struct hv_vmbus_channel **subchan; + int i; + + subchan = vmbus_subchan_get(chan, subchan_cnt); + for (i = 0; i < subchan_cnt; ++i) + vmbus_chan_close_internal(subchan[i]); + vmbus_subchan_rel(subchan, subchan_cnt); + } + + /* Then close the primary channel. */ + vmbus_chan_close_internal(chan); +} + +int +vmbus_chan_send(struct hv_vmbus_channel *chan, uint16_t type, uint16_t flags, + void *data, int dlen, uint64_t xactid) +{ + struct vmbus_chanpkt pkt; + int pktlen, pad_pktlen, hlen, error; + uint64_t pad = 0; + struct iovec iov[3]; + boolean_t send_evt; + + hlen = sizeof(pkt); + pktlen = hlen + dlen; + pad_pktlen = VMBUS_CHANPKT_TOTLEN(pktlen); + + pkt.cp_hdr.cph_type = type; + pkt.cp_hdr.cph_flags = flags; + VMBUS_CHANPKT_SETLEN(pkt.cp_hdr.cph_hlen, hlen); + VMBUS_CHANPKT_SETLEN(pkt.cp_hdr.cph_tlen, pad_pktlen); + pkt.cp_hdr.cph_xactid = xactid; + + iov[0].iov_base = &pkt; + iov[0].iov_len = hlen; + iov[1].iov_base = data; + iov[1].iov_len = dlen; + iov[2].iov_base = &pad; + iov[2].iov_len = pad_pktlen - pktlen; + + error = hv_ring_buffer_write(&chan->outbound, iov, 3, &send_evt); + if (!error && send_evt) + vmbus_chan_signal_tx(chan); + return error; +} + +int +vmbus_chan_send_sglist(struct hv_vmbus_channel *chan, + struct vmbus_gpa sg[], int sglen, void *data, int dlen, uint64_t xactid) +{ + struct vmbus_chanpkt_sglist pkt; + int pktlen, pad_pktlen, hlen, error; + struct iovec iov[4]; + boolean_t send_evt; + uint64_t pad = 0; + + KASSERT(sglen < VMBUS_CHAN_SGLIST_MAX, + ("invalid sglist len %d", sglen)); + + hlen = __offsetof(struct vmbus_chanpkt_sglist, cp_gpa[sglen]); + pktlen = hlen + dlen; + pad_pktlen = VMBUS_CHANPKT_TOTLEN(pktlen); + + pkt.cp_hdr.cph_type = VMBUS_CHANPKT_TYPE_GPA; + pkt.cp_hdr.cph_flags = VMBUS_CHANPKT_FLAG_RC; + VMBUS_CHANPKT_SETLEN(pkt.cp_hdr.cph_hlen, hlen); + VMBUS_CHANPKT_SETLEN(pkt.cp_hdr.cph_tlen, pad_pktlen); + pkt.cp_hdr.cph_xactid = xactid; + pkt.cp_rsvd = 0; + pkt.cp_gpa_cnt = sglen; + + iov[0].iov_base = &pkt; + iov[0].iov_len = sizeof(pkt); + iov[1].iov_base = sg; + iov[1].iov_len = sizeof(struct vmbus_gpa) * sglen; + iov[2].iov_base = data; + iov[2].iov_len = dlen; + iov[3].iov_base = &pad; + iov[3].iov_len = pad_pktlen - pktlen; + + error = hv_ring_buffer_write(&chan->outbound, iov, 4, &send_evt); + if (!error && send_evt) + vmbus_chan_signal_tx(chan); + return error; +} + +int +vmbus_chan_send_prplist(struct hv_vmbus_channel *chan, + struct vmbus_gpa_range *prp, int prp_cnt, void *data, int dlen, + uint64_t xactid) +{ + struct vmbus_chanpkt_prplist pkt; + int pktlen, pad_pktlen, hlen, error; + struct iovec iov[4]; + boolean_t send_evt; + uint64_t pad = 0; + + KASSERT(prp_cnt < VMBUS_CHAN_PRPLIST_MAX, + ("invalid prplist entry count %d", prp_cnt)); + + hlen = __offsetof(struct vmbus_chanpkt_prplist, + cp_range[0].gpa_page[prp_cnt]); + pktlen = hlen + dlen; + pad_pktlen = VMBUS_CHANPKT_TOTLEN(pktlen); + + pkt.cp_hdr.cph_type = VMBUS_CHANPKT_TYPE_GPA; + pkt.cp_hdr.cph_flags = VMBUS_CHANPKT_FLAG_RC; + VMBUS_CHANPKT_SETLEN(pkt.cp_hdr.cph_hlen, hlen); + VMBUS_CHANPKT_SETLEN(pkt.cp_hdr.cph_tlen, pad_pktlen); + pkt.cp_hdr.cph_xactid = xactid; + pkt.cp_rsvd = 0; + pkt.cp_range_cnt = 1; + + iov[0].iov_base = &pkt; + iov[0].iov_len = sizeof(pkt); + iov[1].iov_base = prp; + iov[1].iov_len = __offsetof(struct vmbus_gpa_range, gpa_page[prp_cnt]); + iov[2].iov_base = data; + iov[2].iov_len = dlen; + iov[3].iov_base = &pad; + iov[3].iov_len = pad_pktlen - pktlen; + + error = hv_ring_buffer_write(&chan->outbound, iov, 4, &send_evt); + if (!error && send_evt) + vmbus_chan_signal_tx(chan); + return error; +} + +int +vmbus_chan_recv(struct hv_vmbus_channel *chan, void *data, int *dlen0, + uint64_t *xactid) +{ + struct vmbus_chanpkt_hdr pkt; + int error, dlen, hlen; + + error = hv_ring_buffer_peek(&chan->inbound, &pkt, sizeof(pkt)); + if (error) + return error; + + hlen = VMBUS_CHANPKT_GETLEN(pkt.cph_hlen); + dlen = VMBUS_CHANPKT_GETLEN(pkt.cph_tlen) - hlen; + + if (*dlen0 < dlen) { + /* Return the size of this packet's data. */ + *dlen0 = dlen; + return ENOBUFS; + } + + *xactid = pkt.cph_xactid; + *dlen0 = dlen; + + /* Skip packet header */ + error = hv_ring_buffer_read(&chan->inbound, data, dlen, hlen); + KASSERT(!error, ("hv_ring_buffer_read failed")); + + return 0; +} + +int +vmbus_chan_recv_pkt(struct hv_vmbus_channel *chan, + struct vmbus_chanpkt_hdr *pkt0, int *pktlen0) +{ + struct vmbus_chanpkt_hdr pkt; + int error, pktlen; + + error = hv_ring_buffer_peek(&chan->inbound, &pkt, sizeof(pkt)); + if (error) + return error; + + pktlen = VMBUS_CHANPKT_GETLEN(pkt.cph_tlen); + if (*pktlen0 < pktlen) { + /* Return the size of this packet. */ + *pktlen0 = pktlen; + return ENOBUFS; + } + *pktlen0 = pktlen; + + /* Include packet header */ + error = hv_ring_buffer_read(&chan->inbound, pkt0, pktlen, 0); + KASSERT(!error, ("hv_ring_buffer_read failed")); + + return 0; +} + +static void +vmbus_chan_task(void *xchan, int pending __unused) +{ + struct hv_vmbus_channel *chan = xchan; + vmbus_chan_callback_t cb = chan->ch_cb; + void *cbarg = chan->ch_cbarg; + + /* + * Optimize host to guest signaling by ensuring: + * 1. While reading the channel, we disable interrupts from + * host. + * 2. Ensure that we process all posted messages from the host + * before returning from this callback. + * 3. Once we return, enable signaling from the host. Once this + * state is set we check to see if additional packets are + * available to read. In this case we repeat the process. + * + * NOTE: Interrupt has been disabled in the ISR. + */ + for (;;) { + uint32_t left; + + cb(cbarg); + + left = hv_ring_buffer_read_end(&chan->inbound); + if (left == 0) { + /* No more data in RX bufring; done */ + break; + } + hv_ring_buffer_read_begin(&chan->inbound); + } +} + +static void +vmbus_chan_task_nobatch(void *xchan, int pending __unused) +{ + struct hv_vmbus_channel *chan = xchan; + + chan->ch_cb(chan->ch_cbarg); +} + +static __inline void +vmbus_event_flags_proc(struct vmbus_softc *sc, volatile u_long *event_flags, + int flag_cnt) +{ + int f; + + for (f = 0; f < flag_cnt; ++f) { + uint32_t chid_base; + u_long flags; + int chid_ofs; + + if (event_flags[f] == 0) + continue; + + flags = atomic_swap_long(&event_flags[f], 0); + chid_base = f << VMBUS_EVTFLAG_SHIFT; + + while ((chid_ofs = ffsl(flags)) != 0) { + struct hv_vmbus_channel *chan; + + --chid_ofs; /* NOTE: ffsl is 1-based */ + flags &= ~(1UL << chid_ofs); + + chan = sc->vmbus_chmap[chid_base + chid_ofs]; + + /* if channel is closed or closing */ + if (chan == NULL || chan->ch_tq == NULL) + continue; + + if (chan->ch_flags & VMBUS_CHAN_FLAG_BATCHREAD) + hv_ring_buffer_read_begin(&chan->inbound); + taskqueue_enqueue(chan->ch_tq, &chan->ch_task); + } + } +} + +void +vmbus_event_proc(struct vmbus_softc *sc, int cpu) +{ + struct vmbus_evtflags *eventf; + + /* + * On Host with Win8 or above, the event page can be checked directly + * to get the id of the channel that has the pending interrupt. + */ + eventf = VMBUS_PCPU_GET(sc, event_flags, cpu) + VMBUS_SINT_MESSAGE; + vmbus_event_flags_proc(sc, eventf->evt_flags, + VMBUS_PCPU_GET(sc, event_flags_cnt, cpu)); +} + +void +vmbus_event_proc_compat(struct vmbus_softc *sc, int cpu) +{ + struct vmbus_evtflags *eventf; + + eventf = VMBUS_PCPU_GET(sc, event_flags, cpu) + VMBUS_SINT_MESSAGE; + if (atomic_testandclear_long(&eventf->evt_flags[0], 0)) { + vmbus_event_flags_proc(sc, sc->vmbus_rx_evtflags, + VMBUS_CHAN_MAX_COMPAT >> VMBUS_EVTFLAG_SHIFT); + } +} + +static void +vmbus_chan_update_evtflagcnt(struct vmbus_softc *sc, + const struct hv_vmbus_channel *chan) +{ + volatile int *flag_cnt_ptr; + int flag_cnt; + + flag_cnt = (chan->ch_id / VMBUS_EVTFLAG_LEN) + 1; + flag_cnt_ptr = VMBUS_PCPU_PTR(sc, event_flags_cnt, chan->ch_cpuid); + + for (;;) { + int old_flag_cnt; + + old_flag_cnt = *flag_cnt_ptr; + if (old_flag_cnt >= flag_cnt) + break; + if (atomic_cmpset_int(flag_cnt_ptr, old_flag_cnt, flag_cnt)) { + if (bootverbose) { + device_printf(sc->vmbus_dev, + "channel%u update cpu%d flag_cnt to %d\n", + chan->ch_id, chan->ch_cpuid, flag_cnt); + } + break; + } + } +} + +static struct hv_vmbus_channel * +vmbus_chan_alloc(struct vmbus_softc *sc) +{ + struct hv_vmbus_channel *chan; + + chan = malloc(sizeof(*chan), M_DEVBUF, M_WAITOK | M_ZERO); + + chan->ch_monprm = hyperv_dmamem_alloc(bus_get_dma_tag(sc->vmbus_dev), + HYPERCALL_PARAM_ALIGN, 0, sizeof(struct hyperv_mon_param), + &chan->ch_monprm_dma, BUS_DMA_WAITOK | BUS_DMA_ZERO); + if (chan->ch_monprm == NULL) { + device_printf(sc->vmbus_dev, "monprm alloc failed\n"); + free(chan, M_DEVBUF); + return NULL; + } + + chan->vmbus_sc = sc; + mtx_init(&chan->ch_subchan_lock, "vmbus subchan", NULL, MTX_DEF); + TAILQ_INIT(&chan->ch_subchans); + TASK_INIT(&chan->ch_detach_task, 0, vmbus_chan_detach_task, chan); + + return chan; +} + +static void +vmbus_chan_free(struct hv_vmbus_channel *chan) +{ + /* TODO: assert sub-channel list is empty */ + /* TODO: asset no longer on the primary channel's sub-channel list */ + /* TODO: asset no longer on the vmbus channel list */ + hyperv_dmamem_free(&chan->ch_monprm_dma, chan->ch_monprm); + mtx_destroy(&chan->ch_subchan_lock); + free(chan, M_DEVBUF); +} + +static int +vmbus_chan_add(struct hv_vmbus_channel *newchan) +{ + struct vmbus_softc *sc = newchan->vmbus_sc; + struct hv_vmbus_channel *prichan; + + if (newchan->ch_id == 0) { + /* + * XXX + * Chan0 will neither be processed nor should be offered; + * skip it. + */ + device_printf(sc->vmbus_dev, "got chan0 offer, discard\n"); + return EINVAL; + } else if (newchan->ch_id >= VMBUS_CHAN_MAX) { + device_printf(sc->vmbus_dev, "invalid chan%u offer\n", + newchan->ch_id); + return EINVAL; + } + sc->vmbus_chmap[newchan->ch_id] = newchan; + *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-all@freebsd.org Wed Oct 12 02:58:28 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 5A5EEC0E31A; Wed, 12 Oct 2016 02:58:28 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 299897A9; Wed, 12 Oct 2016 02:58:28 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9C2wRaq057214; Wed, 12 Oct 2016 02:58:27 GMT (envelope-from gonzo@FreeBSD.org) Received: (from gonzo@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9C2wRXC057213; Wed, 12 Oct 2016 02:58:27 GMT (envelope-from gonzo@FreeBSD.org) Message-Id: <201610120258.u9C2wRXC057213@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: gonzo set sender to gonzo@FreeBSD.org using -f From: Oleksandr Tymoshenko Date: Wed, 12 Oct 2016 02:58:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307087 - head/sys/arm/broadcom/bcm2835 X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Oct 2016 02:58:28 -0000 Author: gonzo Date: Wed Oct 12 02:58:27 2016 New Revision: 307087 URL: https://svnweb.freebsd.org/changeset/base/307087 Log: Make sure intc is attached before interrupt consumers If pass order is not specified devices are attached in the order they are defined in dts. Some interrupt consumers may be defined before intc. Also make sure intc interrupt-parent local_intc is attached before intc itself. Modified: head/sys/arm/broadcom/bcm2835/bcm2835_intr.c Modified: head/sys/arm/broadcom/bcm2835/bcm2835_intr.c ============================================================================== --- head/sys/arm/broadcom/bcm2835/bcm2835_intr.c Wed Oct 12 02:55:24 2016 (r307086) +++ head/sys/arm/broadcom/bcm2835/bcm2835_intr.c Wed Oct 12 02:58:27 2016 (r307087) @@ -468,7 +468,8 @@ static driver_t bcm_intc_driver = { static devclass_t bcm_intc_devclass; -DRIVER_MODULE(intc, simplebus, bcm_intc_driver, bcm_intc_devclass, 0, 0); +EARLY_DRIVER_MODULE(intc, simplebus, bcm_intc_driver, bcm_intc_devclass, + 0, 0, BUS_PASS_INTERRUPT + BUS_PASS_ORDER_LATE); #ifndef INTRNG int From owner-svn-src-all@freebsd.org Wed Oct 12 03:00:44 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 99530C0E44F; Wed, 12 Oct 2016 03:00:44 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 70B36A58; Wed, 12 Oct 2016 03:00:44 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9C30hbF057974; Wed, 12 Oct 2016 03:00:43 GMT (envelope-from gonzo@FreeBSD.org) Received: (from gonzo@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9C30hLG057970; Wed, 12 Oct 2016 03:00:43 GMT (envelope-from gonzo@FreeBSD.org) Message-Id: <201610120300.u9C30hLG057970@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: gonzo set sender to gonzo@FreeBSD.org using -f From: Oleksandr Tymoshenko Date: Wed, 12 Oct 2016 03:00:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307088 - head/sys/arm/broadcom/bcm2835 X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Oct 2016 03:00:44 -0000 Author: gonzo Date: Wed Oct 12 03:00:42 2016 New Revision: 307088 URL: https://svnweb.freebsd.org/changeset/base/307088 Log: Add compatible strings used in upstream dts files Modified: head/sys/arm/broadcom/bcm2835/bcm2835_bsc.c head/sys/arm/broadcom/bcm2835/bcm2835_dma.c head/sys/arm/broadcom/bcm2835/bcm2835_sdhci.c head/sys/arm/broadcom/bcm2835/bcm2835_spi.c Modified: head/sys/arm/broadcom/bcm2835/bcm2835_bsc.c ============================================================================== --- head/sys/arm/broadcom/bcm2835/bcm2835_bsc.c Wed Oct 12 02:58:27 2016 (r307087) +++ head/sys/arm/broadcom/bcm2835/bcm2835_bsc.c Wed Oct 12 03:00:42 2016 (r307088) @@ -52,6 +52,12 @@ __FBSDID("$FreeBSD$"); #include "iicbus_if.h" +static struct ofw_compat_data compat_data[] = { + {"broadcom,bcm2835-bsc", 1}, + {"brcm,bcm2708-i2c", 1}, + {NULL, 0} +}; + static void bcm_bsc_intr(void *); static int bcm_bsc_detach(device_t); @@ -214,7 +220,7 @@ bcm_bsc_probe(device_t dev) if (!ofw_bus_status_okay(dev)) return (ENXIO); - if (!ofw_bus_is_compatible(dev, "broadcom,bcm2835-bsc")) + if (ofw_bus_search_compatible(dev, compat_data)->ocd_data == 0) return (ENXIO); device_set_desc(dev, "BCM2708/2835 BSC controller"); Modified: head/sys/arm/broadcom/bcm2835/bcm2835_dma.c ============================================================================== --- head/sys/arm/broadcom/bcm2835/bcm2835_dma.c Wed Oct 12 02:58:27 2016 (r307087) +++ head/sys/arm/broadcom/bcm2835/bcm2835_dma.c Wed Oct 12 03:00:42 2016 (r307088) @@ -152,6 +152,12 @@ struct bcm_dma_softc { static struct bcm_dma_softc *bcm_dma_sc = NULL; static uint32_t bcm_dma_channel_mask; +static struct ofw_compat_data compat_data[] = { + {"broadcom,bcm2835-dma", 1}, + {"brcm,bcm2835-dma", 1}, + {NULL, 0} +}; + static void bcm_dmamap_cb(void *arg, bus_dma_segment_t *segs, int nseg, int err) @@ -656,7 +662,7 @@ bcm_dma_probe(device_t dev) if (!ofw_bus_status_okay(dev)) return (ENXIO); - if (!ofw_bus_is_compatible(dev, "broadcom,bcm2835-dma")) + if (ofw_bus_search_compatible(dev, compat_data)->ocd_data == 0) return (ENXIO); device_set_desc(dev, "BCM2835 DMA Controller"); Modified: head/sys/arm/broadcom/bcm2835/bcm2835_sdhci.c ============================================================================== --- head/sys/arm/broadcom/bcm2835/bcm2835_sdhci.c Wed Oct 12 02:58:27 2016 (r307087) +++ head/sys/arm/broadcom/bcm2835/bcm2835_sdhci.c Wed Oct 12 03:00:42 2016 (r307088) @@ -71,6 +71,12 @@ __FBSDID("$FreeBSD$"); static int bcm2835_sdhci_hs = 1; static int bcm2835_sdhci_pio_mode = 0; +static struct ofw_compat_data compat_data[] = { + {"broadcom,bcm2835-sdhci", 1}, + {"brcm,bcm2835-mmc", 1}, + {NULL, 0} +}; + TUNABLE_INT("hw.bcm2835.sdhci.hs", &bcm2835_sdhci_hs); TUNABLE_INT("hw.bcm2835.sdhci.pio_mode", &bcm2835_sdhci_pio_mode); @@ -126,10 +132,11 @@ bcm_sdhci_probe(device_t dev) if (!ofw_bus_status_okay(dev)) return (ENXIO); - if (!ofw_bus_is_compatible(dev, "broadcom,bcm2835-sdhci")) + if (ofw_bus_search_compatible(dev, compat_data)->ocd_data == 0) return (ENXIO); device_set_desc(dev, "Broadcom 2708 SDHCI controller"); + return (BUS_PROBE_DEFAULT); } Modified: head/sys/arm/broadcom/bcm2835/bcm2835_spi.c ============================================================================== --- head/sys/arm/broadcom/bcm2835/bcm2835_spi.c Wed Oct 12 02:58:27 2016 (r307087) +++ head/sys/arm/broadcom/bcm2835/bcm2835_spi.c Wed Oct 12 03:00:42 2016 (r307088) @@ -56,6 +56,12 @@ __FBSDID("$FreeBSD$"); #include "spibus_if.h" +static struct ofw_compat_data compat_data[] = { + {"broadcom,bcm2835-spi", 1}, + {"brcm,bcm2835-spi", 1}, + {NULL, 0} +}; + static void bcm_spi_intr(void *); #ifdef BCM_SPI_DEBUG @@ -231,7 +237,7 @@ bcm_spi_probe(device_t dev) if (!ofw_bus_status_okay(dev)) return (ENXIO); - if (!ofw_bus_is_compatible(dev, "broadcom,bcm2835-spi")) + if (ofw_bus_search_compatible(dev, compat_data)->ocd_data == 0) return (ENXIO); device_set_desc(dev, "BCM2708/2835 SPI controller"); From owner-svn-src-all@freebsd.org Wed Oct 12 03:03:07 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 02835C0E63E; Wed, 12 Oct 2016 03:03:07 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id AFCAC1262; Wed, 12 Oct 2016 03:03:06 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9C3358E061559; Wed, 12 Oct 2016 03:03:05 GMT (envelope-from gonzo@FreeBSD.org) Received: (from gonzo@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9C335Pm061557; Wed, 12 Oct 2016 03:03:05 GMT (envelope-from gonzo@FreeBSD.org) Message-Id: <201610120303.u9C335Pm061557@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: gonzo set sender to gonzo@FreeBSD.org using -f From: Oleksandr Tymoshenko Date: Wed, 12 Oct 2016 03:03:05 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307089 - head/sys/arm/broadcom/bcm2835 X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Oct 2016 03:03:07 -0000 Author: gonzo Date: Wed Oct 12 03:03:05 2016 New Revision: 307089 URL: https://svnweb.freebsd.org/changeset/base/307089 Log: Make framebuffer driver compatible with upstream DT - Add compatibility string - Add simplebus as possible parent bus Modified: head/sys/arm/broadcom/bcm2835/bcm2835_fb.c head/sys/arm/broadcom/bcm2835/bcm2835_fbd.c Modified: head/sys/arm/broadcom/bcm2835/bcm2835_fb.c ============================================================================== --- head/sys/arm/broadcom/bcm2835/bcm2835_fb.c Wed Oct 12 03:00:42 2016 (r307088) +++ head/sys/arm/broadcom/bcm2835/bcm2835_fb.c Wed Oct 12 03:03:05 2016 (r307089) @@ -111,6 +111,12 @@ struct bcmsc_softc { static struct bcmsc_softc bcmsc; +static struct ofw_compat_data compat_data[] = { + {"broadcom,bcm2835-fb", 1}, + {"brcm,bcm2708-fb", 1}, + {NULL, 0} +}; + static int bcm_fb_probe(device_t); static int bcm_fb_attach(device_t); static void bcmfb_update_margins(video_adapter_t *adp); @@ -121,8 +127,9 @@ bcm_fb_probe(device_t dev) { int error; - if (!ofw_bus_is_compatible(dev, "broadcom,bcm2835-fb")) + if (ofw_bus_search_compatible(dev, compat_data)->ocd_data == 0) return (ENXIO); + device_set_desc(dev, "BCM2835 framebuffer device"); error = sc_probe_unit(device_get_unit(dev), device_get_flags(dev) | SC_AUTODETECT_KBD); @@ -196,6 +203,7 @@ static driver_t bcm_fb_driver = { }; DRIVER_MODULE(bcm2835fb, ofwbus, bcm_fb_driver, bcm_fb_devclass, 0, 0); +DRIVER_MODULE(bcm2835fb, simplebus, bcm_fb_driver, bcm_fb_devclass, 0, 0); /* * Video driver routines and glue. Modified: head/sys/arm/broadcom/bcm2835/bcm2835_fbd.c ============================================================================== --- head/sys/arm/broadcom/bcm2835/bcm2835_fbd.c Wed Oct 12 03:00:42 2016 (r307088) +++ head/sys/arm/broadcom/bcm2835/bcm2835_fbd.c Wed Oct 12 03:03:05 2016 (r307089) @@ -65,6 +65,12 @@ struct bcmsc_softc { device_t dev; }; +static struct ofw_compat_data compat_data[] = { + {"broadcom,bcm2835-fb", 1}, + {"brcm,bcm2708-fb", 1}, + {NULL, 0} +}; + static int bcm_fb_probe(device_t); static int bcm_fb_attach(device_t); @@ -191,7 +197,8 @@ bcm_fb_sysctl_init(struct bcmsc_softc *s static int bcm_fb_probe(device_t dev) { - if (!ofw_bus_is_compatible(dev, "broadcom,bcm2835-fb")) + + if (ofw_bus_search_compatible(dev, compat_data)->ocd_data == 0) return (ENXIO); device_set_desc(dev, "BCM2835 VT framebuffer driver"); @@ -265,3 +272,4 @@ static driver_t bcm_fb_driver = { }; DRIVER_MODULE(bcm2835fb, ofwbus, bcm_fb_driver, bcm_fb_devclass, 0, 0); +DRIVER_MODULE(bcm2835fb, simplebus, bcm_fb_driver, bcm_fb_devclass, 0, 0); From owner-svn-src-all@freebsd.org Wed Oct 12 03:03:58 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 65D4EC0E6B0; Wed, 12 Oct 2016 03:03:58 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 6F5701589; Wed, 12 Oct 2016 03:03:57 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9C33uD4061676; Wed, 12 Oct 2016 03:03:56 GMT (envelope-from gonzo@FreeBSD.org) Received: (from gonzo@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9C33ue7061675; Wed, 12 Oct 2016 03:03:56 GMT (envelope-from gonzo@FreeBSD.org) Message-Id: <201610120303.u9C33ue7061675@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: gonzo set sender to gonzo@FreeBSD.org using -f From: Oleksandr Tymoshenko Date: Wed, 12 Oct 2016 03:03:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307091 - head/sys/arm/broadcom/bcm2835 X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Oct 2016 03:03:58 -0000 Author: gonzo Date: Wed Oct 12 03:03:55 2016 New Revision: 307091 URL: https://svnweb.freebsd.org/changeset/base/307091 Log: Add compatibility string from upstream DT Modified: head/sys/arm/broadcom/bcm2835/bcm2835_mbox.c Modified: head/sys/arm/broadcom/bcm2835/bcm2835_mbox.c ============================================================================== --- head/sys/arm/broadcom/bcm2835/bcm2835_mbox.c Wed Oct 12 03:03:43 2016 (r307090) +++ head/sys/arm/broadcom/bcm2835/bcm2835_mbox.c Wed Oct 12 03:03:55 2016 (r307091) @@ -92,6 +92,12 @@ struct bcm_mbox_softc { #define mbox_write_4(sc, reg, val) \ bus_space_write_4((sc)->bst, (sc)->bsh, reg, val) +static struct ofw_compat_data compat_data[] = { + {"broadcom,bcm2835-mbox", 1}, + {"brcm,bcm2835-mbox", 1}, + {NULL, 0} +}; + static int bcm_mbox_read_msg(struct bcm_mbox_softc *sc, int *ochan) { @@ -138,12 +144,12 @@ bcm_mbox_probe(device_t dev) if (!ofw_bus_status_okay(dev)) return (ENXIO); - if (ofw_bus_is_compatible(dev, "broadcom,bcm2835-mbox")) { - device_set_desc(dev, "BCM2835 VideoCore Mailbox"); - return(BUS_PROBE_DEFAULT); - } + if (ofw_bus_search_compatible(dev, compat_data)->ocd_data == 0) + return (ENXIO); + + device_set_desc(dev, "BCM2835 VideoCore Mailbox"); - return (ENXIO); + return (BUS_PROBE_DEFAULT); } static int From owner-svn-src-all@freebsd.org Wed Oct 12 03:06:07 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 43845C0E742; Wed, 12 Oct 2016 03:06:07 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id EDF6E173C; Wed, 12 Oct 2016 03:06:06 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9C3664D061817; Wed, 12 Oct 2016 03:06:06 GMT (envelope-from gonzo@FreeBSD.org) Received: (from gonzo@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9C366HP061816; Wed, 12 Oct 2016 03:06:06 GMT (envelope-from gonzo@FreeBSD.org) Message-Id: <201610120306.u9C366HP061816@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: gonzo set sender to gonzo@FreeBSD.org using -f From: Oleksandr Tymoshenko Date: Wed, 12 Oct 2016 03:06:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307092 - head/sys/arm/broadcom/bcm2835 X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Oct 2016 03:06:07 -0000 Author: gonzo Date: Wed Oct 12 03:06:05 2016 New Revision: 307092 URL: https://svnweb.freebsd.org/changeset/base/307092 Log: Make BCM2835 GPIO driver compatible with upstream DT - Add compatibility string - Make reserverd and read-only properties optional Modified: head/sys/arm/broadcom/bcm2835/bcm2835_gpio.c Modified: head/sys/arm/broadcom/bcm2835/bcm2835_gpio.c ============================================================================== --- head/sys/arm/broadcom/bcm2835/bcm2835_gpio.c Wed Oct 12 03:03:55 2016 (r307091) +++ head/sys/arm/broadcom/bcm2835/bcm2835_gpio.c Wed Oct 12 03:06:05 2016 (r307092) @@ -82,8 +82,6 @@ static struct resource_spec bcm_gpio_res { SYS_RES_MEMORY, 0, RF_ACTIVE }, { SYS_RES_IRQ, 0, RF_ACTIVE }, /* bank 0 interrupt */ { SYS_RES_IRQ, 1, RF_ACTIVE }, /* bank 1 interrupt */ - { SYS_RES_IRQ, 2, RF_ACTIVE }, /* bank 1 interrupt (mirrored) */ - { SYS_RES_IRQ, 3, RF_ACTIVE }, /* bank 0-1 interrupt (united) */ { -1, 0, 0 } }; @@ -159,6 +157,12 @@ enum bcm_gpio_pud { #define BCM_GPIO_GPPUD(_bank) (0x94) /* Pin Pull up/down */ #define BCM_GPIO_GPPUDCLK(_bank) (0x98 + _bank * 4) /* Pin Pull up clock */ +static struct ofw_compat_data compat_data[] = { + {"broadcom,bcm2835-gpio", 1}, + {"brcm,bcm2835-gpio", 1}, + {NULL, 0} +}; + static struct bcm_gpio_softc *bcm_gpio_sc = NULL; #ifdef INTRNG @@ -672,11 +676,11 @@ bcm_gpio_get_reserved_pins(struct bcm_gp phandle_t gpio, node, reserved; ssize_t len; - /* Get read-only pins. */ + /* Get read-only pins if they're porvided */ gpio = ofw_bus_get_node(sc->sc_dev); if (bcm_gpio_get_ro_pins(sc, gpio, "broadcom,read-only", "read-only") != 0) - return (-1); + return (0); /* Traverse the GPIO subnodes to find the reserved pins node. */ reserved = 0; node = OF_child(gpio); @@ -742,7 +746,7 @@ bcm_gpio_probe(device_t dev) if (!ofw_bus_status_okay(dev)) return (ENXIO); - if (!ofw_bus_is_compatible(dev, "broadcom,bcm2835-gpio")) + if (ofw_bus_search_compatible(dev, compat_data)->ocd_data == 0) return (ENXIO); device_set_desc(dev, "BCM2708/2835 GPIO controller"); From owner-svn-src-all@freebsd.org Wed Oct 12 03:07:50 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 5E427C0E7B3; Wed, 12 Oct 2016 03:07:50 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 3037218E4; Wed, 12 Oct 2016 03:07:50 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9C37nlN061951; Wed, 12 Oct 2016 03:07:49 GMT (envelope-from gonzo@FreeBSD.org) Received: (from gonzo@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9C37nVU061950; Wed, 12 Oct 2016 03:07:49 GMT (envelope-from gonzo@FreeBSD.org) Message-Id: <201610120307.u9C37nVU061950@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: gonzo set sender to gonzo@FreeBSD.org using -f From: Oleksandr Tymoshenko Date: Wed, 12 Oct 2016 03:07:49 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307093 - head/sys/arm/broadcom/bcm2835 X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Oct 2016 03:07:50 -0000 Author: gonzo Date: Wed Oct 12 03:07:49 2016 New Revision: 307093 URL: https://svnweb.freebsd.org/changeset/base/307093 Log: Make BCM283x USB driver compatible with upstream DT - Make resource allocation logic depend on compatibility string to check what format of DTS node should be used - FreeBSD's or upstream Modified: head/sys/arm/broadcom/bcm2835/bcm283x_dwc_fdt.c Modified: head/sys/arm/broadcom/bcm2835/bcm283x_dwc_fdt.c ============================================================================== --- head/sys/arm/broadcom/bcm2835/bcm283x_dwc_fdt.c Wed Oct 12 03:06:05 2016 (r307092) +++ head/sys/arm/broadcom/bcm2835/bcm283x_dwc_fdt.c Wed Oct 12 03:07:49 2016 (r307093) @@ -51,6 +51,12 @@ __FBSDID("$FreeBSD$"); #include +static struct ofw_compat_data compat_data[] = { + {"broadcom,bcm2835-usb", 1}, + {"brcm,bcm2708-usb", 1}, + {NULL, 0} +}; + static device_probe_t bcm283x_dwc_otg_probe; static device_attach_t bcm283x_dwc_otg_attach; @@ -61,7 +67,7 @@ bcm283x_dwc_otg_probe(device_t dev) if (!ofw_bus_status_okay(dev)) return (ENXIO); - if (!ofw_bus_is_compatible(dev, "broadcom,bcm2835-usb")) + if (ofw_bus_search_compatible(dev, compat_data)->ocd_data == 0) return (ENXIO); device_set_desc(dev, "DWC OTG 2.0 integrated USB controller (bcm283x)"); From owner-svn-src-all@freebsd.org Wed Oct 12 03:09:00 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 35039C0E8C2; Wed, 12 Oct 2016 03:09:00 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id E136E1C3D; Wed, 12 Oct 2016 03:08:59 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9C38x0k062114; Wed, 12 Oct 2016 03:08:59 GMT (envelope-from gonzo@FreeBSD.org) Received: (from gonzo@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9C38xVf062113; Wed, 12 Oct 2016 03:08:59 GMT (envelope-from gonzo@FreeBSD.org) Message-Id: <201610120308.u9C38xVf062113@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: gonzo set sender to gonzo@FreeBSD.org using -f From: Oleksandr Tymoshenko Date: Wed, 12 Oct 2016 03:08:59 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307095 - head/sys/contrib/vchiq/interface/vchiq_arm X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Oct 2016 03:09:00 -0000 Author: gonzo Date: Wed Oct 12 03:08:58 2016 New Revision: 307095 URL: https://svnweb.freebsd.org/changeset/base/307095 Log: Make VCHI driver compatible with upstream DT - Add compatibility string - Compensate difference in base address between our custom DTB and upstream one Modified: head/sys/contrib/vchiq/interface/vchiq_arm/vchiq_kmod.c Modified: head/sys/contrib/vchiq/interface/vchiq_arm/vchiq_kmod.c ============================================================================== --- head/sys/contrib/vchiq/interface/vchiq_arm/vchiq_kmod.c Wed Oct 12 03:08:11 2016 (r307094) +++ head/sys/contrib/vchiq/interface/vchiq_arm/vchiq_kmod.c Wed Oct 12 03:08:58 2016 (r307095) @@ -73,14 +73,25 @@ struct bcm_vchiq_softc { void* intr_hl; bus_space_tag_t bst; bus_space_handle_t bsh; + int regs_offset; }; static struct bcm_vchiq_softc *bcm_vchiq_sc = NULL; +#define BSD_DTB 1 +#define UPSTREAM_DTB 2 +static struct ofw_compat_data compat_data[] = { + {"broadcom,bcm2835-vchiq", BSD_DTB}, + {"brcm,bcm2835-vchiq", UPSTREAM_DTB}, + {NULL, 0} +}; + #define vchiq_read_4(reg) \ - bus_space_read_4(bcm_vchiq_sc->bst, bcm_vchiq_sc->bsh, reg) + bus_space_read_4(bcm_vchiq_sc->bst, bcm_vchiq_sc->bsh, (reg) + \ + bcm_vchiq_sc->regs_offset) #define vchiq_write_4(reg, val) \ - bus_space_write_4(bcm_vchiq_sc->bst, bcm_vchiq_sc->bsh, reg, val) + bus_space_write_4(bcm_vchiq_sc->bst, bcm_vchiq_sc->bsh, (reg) + \ + bcm_vchiq_sc->regs_offset, val) /* * Extern functions */ @@ -122,12 +133,11 @@ static int bcm_vchiq_probe(device_t dev) { - if (ofw_bus_is_compatible(dev, "broadcom,bcm2835-vchiq")) { - device_set_desc(dev, "BCM2835 VCHIQ"); - return(BUS_PROBE_DEFAULT); - } + if (ofw_bus_search_compatible(dev, compat_data)->ocd_data == 0) + return (ENXIO); - return (ENXIO); + device_set_desc(dev, "BCM2835 VCHIQ"); + return (BUS_PROBE_DEFAULT); } static int @@ -157,6 +167,9 @@ bcm_vchiq_attach(device_t dev) return (ENXIO); } + if (ofw_bus_search_compatible(dev, compat_data)->ocd_data == UPSTREAM_DTB) + sc->regs_offset = -0x40; + node = ofw_bus_get_node(dev); if ((OF_getencprop(node, "cache-line-size", &cell, sizeof(cell))) > 0) g_cache_line_size = cell; From owner-svn-src-all@freebsd.org Wed Oct 12 03:18:19 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C1888C0EA63; Wed, 12 Oct 2016 03:18:19 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4E0867D; Wed, 12 Oct 2016 03:18:19 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9C3IIWX065882; Wed, 12 Oct 2016 03:18:18 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9C3IHMQ065873; Wed, 12 Oct 2016 03:18:17 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610120318.u9C3IHMQ065873@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Wed, 12 Oct 2016 03:18:17 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307096 - in stable/10/sys/dev/hyperv: include netvsc storvsc utilities vmbus X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Oct 2016 03:18:19 -0000 Author: sephe Date: Wed Oct 12 03:18:17 2016 New Revision: 307096 URL: https://svnweb.freebsd.org/changeset/base/307096 Log: MFC 303066-303072,303127-303129,303131 303066 hyperv/vmbus: Get rid of unnecessary definition. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7240 303067 hyperv/vmbus: Move IC register definition to Hyper-V utilities Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7241 303068 hyperv/vmbus: Channel struct field rename Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7242 303069 hyperv/vmbus: Pass channel as the first argument for channel callback The prepares to kill device private fields in channel struct, which are not flexible and extensible. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7243 303070 hyperv/vmbus: Deprecate the device private data in channel struct They are neither flexible nor extensible. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7244 303071 hyperv/vmbus: Hide channel struct definition. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7245 303072 hyperv/vmbus: Save MNF trigger location instead of MNF trigger index. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7246 303127 hyperv/vmbus: Save event flag location and evet flag mask. This avoids unnecessary access to the vmbus_softc struct on sending path. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7257 303128 hyperv/vmbus: Reorder channel fields. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7258 303129 hyperv/vmbus: Shuffle function declaration and macro definition. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7259 303131 hyperv: hv_vmbus_channel -> vmbus_channel Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7260 Added: stable/10/sys/dev/hyperv/utilities/hv_utilreg.h - copied unchanged from r303067, head/sys/dev/hyperv/utilities/hv_utilreg.h stable/10/sys/dev/hyperv/vmbus/vmbus_chanvar.h - copied, changed from r303071, head/sys/dev/hyperv/vmbus/vmbus_chanvar.h Modified: stable/10/sys/dev/hyperv/include/hyperv.h stable/10/sys/dev/hyperv/include/vmbus.h stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.c stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c stable/10/sys/dev/hyperv/netvsc/hv_rndis.h stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.c stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.h stable/10/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c stable/10/sys/dev/hyperv/utilities/hv_heartbeat.c stable/10/sys/dev/hyperv/utilities/hv_kvp.c stable/10/sys/dev/hyperv/utilities/hv_shutdown.c stable/10/sys/dev/hyperv/utilities/hv_timesync.c stable/10/sys/dev/hyperv/utilities/hv_util.c stable/10/sys/dev/hyperv/utilities/hv_util.h stable/10/sys/dev/hyperv/vmbus/hv_vmbus_priv.h stable/10/sys/dev/hyperv/vmbus/vmbus.c stable/10/sys/dev/hyperv/vmbus/vmbus_chan.c stable/10/sys/dev/hyperv/vmbus/vmbus_var.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/hyperv/include/hyperv.h ============================================================================== --- stable/10/sys/dev/hyperv/include/hyperv.h Wed Oct 12 03:08:58 2016 (r307095) +++ stable/10/sys/dev/hyperv/include/hyperv.h Wed Oct 12 03:18:17 2016 (r307096) @@ -58,30 +58,6 @@ #include #include -typedef uint8_t hv_bool_uint8_t; - -#define HV_S_OK 0x00000000 -#define HV_E_FAIL 0x80004005 -#define HV_ERROR_NOT_SUPPORTED 0x80070032 -#define HV_ERROR_MACHINE_LOCKED 0x800704F7 - -/* - * VMBUS version is 32 bit, upper 16 bit for major_number and lower - * 16 bit for minor_number. - * - * 0.13 -- Windows Server 2008 - * 1.1 -- Windows 7 - * 2.4 -- Windows 8 - * 3.0 -- Windows 8.1 - */ -#define VMBUS_VERSION_WS2008 ((0 << 16) | (13)) -#define VMBUS_VERSION_WIN7 ((1 << 16) | (1)) -#define VMBUS_VERSION_WIN8 ((2 << 16) | (4)) -#define VMBUS_VERSION_WIN8_1 ((3 << 16) | (0)) - -#define VMBUS_VERSION_MAJOR(ver) (((uint32_t)(ver)) >> 16) -#define VMBUS_VERSION_MINOR(ver) (((uint32_t)(ver)) & 0xffff) - struct hyperv_guid { uint8_t hv_guid[16]; } __packed; @@ -90,183 +66,6 @@ struct hyperv_guid { int hyperv_guid2str(const struct hyperv_guid *, char *, size_t); -#define HW_MACADDR_LEN 6 - -/* - * Common defines for Hyper-V ICs - */ -#define HV_ICMSGTYPE_NEGOTIATE 0 -#define HV_ICMSGTYPE_HEARTBEAT 1 -#define HV_ICMSGTYPE_KVPEXCHANGE 2 -#define HV_ICMSGTYPE_SHUTDOWN 3 -#define HV_ICMSGTYPE_TIMESYNC 4 -#define HV_ICMSGTYPE_VSS 5 - -#define HV_ICMSGHDRFLAG_TRANSACTION 1 -#define HV_ICMSGHDRFLAG_REQUEST 2 -#define HV_ICMSGHDRFLAG_RESPONSE 4 - -typedef struct hv_vmbus_pipe_hdr { - uint32_t flags; - uint32_t msgsize; -} __packed hv_vmbus_pipe_hdr; - -typedef struct hv_vmbus_ic_version { - uint16_t major; - uint16_t minor; -} __packed hv_vmbus_ic_version; - -typedef struct hv_vmbus_icmsg_hdr { - hv_vmbus_ic_version icverframe; - uint16_t icmsgtype; - hv_vmbus_ic_version icvermsg; - uint16_t icmsgsize; - uint32_t status; - uint8_t ictransaction_id; - uint8_t icflags; - uint8_t reserved[2]; -} __packed hv_vmbus_icmsg_hdr; - -typedef struct hv_vmbus_icmsg_negotiate { - uint16_t icframe_vercnt; - uint16_t icmsg_vercnt; - uint32_t reserved; - hv_vmbus_ic_version icversion_data[1]; /* any size array */ -} __packed hv_vmbus_icmsg_negotiate; - -typedef struct hv_vmbus_shutdown_msg_data { - uint32_t reason_code; - uint32_t timeout_seconds; - uint32_t flags; - uint8_t display_message[2048]; -} __packed hv_vmbus_shutdown_msg_data; - -typedef struct hv_vmbus_heartbeat_msg_data { - uint64_t seq_num; - uint32_t reserved[8]; -} __packed hv_vmbus_heartbeat_msg_data; - -typedef struct { - /* - * offset in bytes from the start of ring data below - */ - volatile uint32_t write_index; - /* - * offset in bytes from the start of ring data below - */ - volatile uint32_t read_index; - /* - * NOTE: The interrupt_mask field is used only for channels, but - * vmbus connection also uses this data structure - */ - volatile uint32_t interrupt_mask; - /* pad it to PAGE_SIZE so that data starts on a page */ - uint8_t reserved[4084]; - - /* - * WARNING: Ring data starts here - * !!! DO NOT place any fields below this !!! - */ - uint8_t buffer[0]; /* doubles as interrupt mask */ -} __packed hv_vmbus_ring_buffer; - -typedef struct { - hv_vmbus_ring_buffer* ring_buffer; - struct mtx ring_lock; - uint32_t ring_data_size; /* ring_size */ -} hv_vmbus_ring_buffer_info; - -typedef void (*vmbus_chan_callback_t)(void *); - -typedef struct hv_vmbus_channel { - device_t ch_dev; - struct vmbus_softc *vmbus_sc; - uint32_t ch_flags; /* VMBUS_CHAN_FLAG_ */ - uint32_t ch_id; /* channel id */ - - /* - * These are based on the offer_msg.monitor_id. - * Save it here for easy access. - */ - int ch_montrig_idx; /* MNF trig index */ - uint32_t ch_montrig_mask;/* MNF trig mask */ - - /* - * send to parent - */ - hv_vmbus_ring_buffer_info outbound; - /* - * receive from parent - */ - hv_vmbus_ring_buffer_info inbound; - - struct taskqueue *ch_tq; - struct task ch_task; - vmbus_chan_callback_t ch_cb; - void *ch_cbarg; - - struct hyperv_mon_param *ch_monprm; - struct hyperv_dma ch_monprm_dma; - - int ch_cpuid; /* owner cpu */ - /* - * Virtual cpuid for ch_cpuid; it is used to communicate cpuid - * related information w/ Hyper-V. If MSR_HV_VP_INDEX does not - * exist, ch_vcpuid will always be 0 for compatibility. - */ - uint32_t ch_vcpuid; - - /* - * If this is a primary channel, ch_subchan* fields - * contain sub-channels belonging to this primary - * channel. - */ - struct mtx ch_subchan_lock; - TAILQ_HEAD(, hv_vmbus_channel) ch_subchans; - int ch_subchan_cnt; - - /* If this is a sub-channel */ - TAILQ_ENTRY(hv_vmbus_channel) ch_sublink; /* sub-channel link */ - struct hv_vmbus_channel *ch_prichan; /* owner primary chan */ - - /* - * Driver private data - */ - void *hv_chan_priv1; - void *hv_chan_priv2; - void *hv_chan_priv3; - - void *ch_bufring; /* TX+RX bufrings */ - struct hyperv_dma ch_bufring_dma; - uint32_t ch_bufring_gpadl; - - struct task ch_detach_task; - TAILQ_ENTRY(hv_vmbus_channel) ch_prilink; /* primary chan link */ - uint32_t ch_subidx; /* subchan index */ - volatile uint32_t ch_stflags; /* atomic-op */ - /* VMBUS_CHAN_ST_ */ - struct hyperv_guid ch_guid_type; - struct hyperv_guid ch_guid_inst; - - struct sysctl_ctx_list ch_sysctl_ctx; -} hv_vmbus_channel; - -#define VMBUS_CHAN_ISPRIMARY(chan) ((chan)->ch_subidx == 0) - -#define VMBUS_CHAN_FLAG_HASMNF 0x0001 -/* - * If this flag is set, this channel's interrupt will be masked in ISR, - * and the RX bufring will be drained before this channel's interrupt is - * unmasked. - * - * This flag is turned on by default. Drivers can turn it off according - * to their own requirement. - */ -#define VMBUS_CHAN_FLAG_BATCHREAD 0x0002 - -#define VMBUS_CHAN_ST_OPENED_SHIFT 0 -#define VMBUS_CHAN_ST_OPENED (1 << VMBUS_CHAN_ST_OPENED_SHIFT) - /** * @brief Get physical address from virtual */ @@ -278,10 +77,4 @@ hv_get_phys_addr(void *virt) return (ret); } -static __inline struct hv_vmbus_channel * -vmbus_get_channel(device_t dev) -{ - return device_get_ivars(dev); -} - #endif /* __HYPERV_H__ */ Modified: stable/10/sys/dev/hyperv/include/vmbus.h ============================================================================== --- stable/10/sys/dev/hyperv/include/vmbus.h Wed Oct 12 03:08:58 2016 (r307095) +++ stable/10/sys/dev/hyperv/include/vmbus.h Wed Oct 12 03:18:17 2016 (r307096) @@ -32,6 +32,23 @@ #include /* + * VMBUS version is 32 bit, upper 16 bit for major_number and lower + * 16 bit for minor_number. + * + * 0.13 -- Windows Server 2008 + * 1.1 -- Windows 7 + * 2.4 -- Windows 8 + * 3.0 -- Windows 8.1 + */ +#define VMBUS_VERSION_WS2008 ((0 << 16) | (13)) +#define VMBUS_VERSION_WIN7 ((1 << 16) | (1)) +#define VMBUS_VERSION_WIN8 ((2 << 16) | (4)) +#define VMBUS_VERSION_WIN8_1 ((3 << 16) | (0)) + +#define VMBUS_VERSION_MAJOR(ver) (((uint32_t)(ver)) >> 16) +#define VMBUS_VERSION_MINOR(ver) (((uint32_t)(ver)) & 0xffff) + +/* * GPA stuffs. */ struct vmbus_gpa_range { @@ -87,41 +104,56 @@ struct vmbus_chanpkt_rxbuf { #define VMBUS_CHAN_SGLIST_MAX 32 #define VMBUS_CHAN_PRPLIST_MAX 32 -struct hv_vmbus_channel; +struct vmbus_channel; +struct hyperv_guid; -int vmbus_chan_open(struct hv_vmbus_channel *chan, +typedef void (*vmbus_chan_callback_t)(struct vmbus_channel *, void *); + +static __inline struct vmbus_channel * +vmbus_get_channel(device_t dev) +{ + return device_get_ivars(dev); +} + +int vmbus_chan_open(struct vmbus_channel *chan, int txbr_size, int rxbr_size, const void *udata, int udlen, vmbus_chan_callback_t cb, void *cbarg); -void vmbus_chan_close(struct hv_vmbus_channel *chan); +void vmbus_chan_close(struct vmbus_channel *chan); -int vmbus_chan_gpadl_connect(struct hv_vmbus_channel *chan, +int vmbus_chan_gpadl_connect(struct vmbus_channel *chan, bus_addr_t paddr, int size, uint32_t *gpadl); -int vmbus_chan_gpadl_disconnect(struct hv_vmbus_channel *chan, +int vmbus_chan_gpadl_disconnect(struct vmbus_channel *chan, uint32_t gpadl); -void vmbus_chan_cpu_set(struct hv_vmbus_channel *chan, int cpu); -void vmbus_chan_cpu_rr(struct hv_vmbus_channel *chan); -struct hv_vmbus_channel * - vmbus_chan_cpu2chan(struct hv_vmbus_channel *chan, int cpu); -void vmbus_chan_set_readbatch(struct hv_vmbus_channel *chan, bool on); - -struct hv_vmbus_channel ** - vmbus_subchan_get(struct hv_vmbus_channel *pri_chan, int subchan_cnt); -void vmbus_subchan_rel(struct hv_vmbus_channel **subchan, int subchan_cnt); -void vmbus_subchan_drain(struct hv_vmbus_channel *pri_chan); +void vmbus_chan_cpu_set(struct vmbus_channel *chan, int cpu); +void vmbus_chan_cpu_rr(struct vmbus_channel *chan); +struct vmbus_channel * + vmbus_chan_cpu2chan(struct vmbus_channel *chan, int cpu); +void vmbus_chan_set_readbatch(struct vmbus_channel *chan, bool on); + +struct vmbus_channel ** + vmbus_subchan_get(struct vmbus_channel *pri_chan, int subchan_cnt); +void vmbus_subchan_rel(struct vmbus_channel **subchan, int subchan_cnt); +void vmbus_subchan_drain(struct vmbus_channel *pri_chan); -int vmbus_chan_recv(struct hv_vmbus_channel *chan, void *data, int *dlen, +int vmbus_chan_recv(struct vmbus_channel *chan, void *data, int *dlen, uint64_t *xactid); -int vmbus_chan_recv_pkt(struct hv_vmbus_channel *chan, +int vmbus_chan_recv_pkt(struct vmbus_channel *chan, struct vmbus_chanpkt_hdr *pkt, int *pktlen); -int vmbus_chan_send(struct hv_vmbus_channel *chan, uint16_t type, +int vmbus_chan_send(struct vmbus_channel *chan, uint16_t type, uint16_t flags, void *data, int dlen, uint64_t xactid); -int vmbus_chan_send_sglist(struct hv_vmbus_channel *chan, +int vmbus_chan_send_sglist(struct vmbus_channel *chan, struct vmbus_gpa sg[], int sglen, void *data, int dlen, uint64_t xactid); -int vmbus_chan_send_prplist(struct hv_vmbus_channel *chan, +int vmbus_chan_send_prplist(struct vmbus_channel *chan, struct vmbus_gpa_range *prp, int prp_cnt, void *data, int dlen, uint64_t xactid); +uint32_t vmbus_chan_id(const struct vmbus_channel *chan); +uint32_t vmbus_chan_subidx(const struct vmbus_channel *chan); +bool vmbus_chan_is_primary(const struct vmbus_channel *chan); +const struct hyperv_guid * + vmbus_chan_guid_inst(const struct vmbus_channel *chan); + #endif /* !_VMBUS_H_ */ Modified: stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.c Wed Oct 12 03:08:58 2016 (r307095) +++ stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.c Wed Oct 12 03:18:17 2016 (r307096) @@ -48,26 +48,24 @@ #include "hv_rndis.h" #include "hv_rndis_filter.h" -/* priv1 and priv2 are consumed by the main driver */ -#define hv_chan_rdbuf hv_chan_priv3 - MALLOC_DEFINE(M_NETVSC, "netvsc", "Hyper-V netvsc driver"); /* * Forward declarations */ -static void hv_nv_on_channel_callback(void *xchan); +static void hv_nv_on_channel_callback(struct vmbus_channel *chan, + void *xrxr); static int hv_nv_init_send_buffer_with_net_vsp(struct hn_softc *sc); static int hv_nv_init_rx_buffer_with_net_vsp(struct hn_softc *); static int hv_nv_destroy_send_buffer(netvsc_dev *net_dev); static int hv_nv_destroy_rx_buffer(netvsc_dev *net_dev); static int hv_nv_connect_to_vsp(struct hn_softc *sc); static void hv_nv_on_send_completion(netvsc_dev *net_dev, - struct hv_vmbus_channel *, const struct vmbus_chanpkt_hdr *pkt); -static void hv_nv_on_receive_completion(struct hv_vmbus_channel *chan, + struct vmbus_channel *, const struct vmbus_chanpkt_hdr *pkt); +static void hv_nv_on_receive_completion(struct vmbus_channel *chan, uint64_t tid, uint32_t status); static void hv_nv_on_receive(netvsc_dev *net_dev, - struct hn_softc *sc, struct hv_vmbus_channel *chan, + struct hn_rx_ring *rxr, struct vmbus_channel *chan, const struct vmbus_chanpkt_hdr *pkt); /* @@ -640,13 +638,14 @@ hv_nv_disconnect_from_vsp(netvsc_dev *ne } void -hv_nv_subchan_attach(struct hv_vmbus_channel *chan) +hv_nv_subchan_attach(struct vmbus_channel *chan, struct hn_rx_ring *rxr) { - - chan->hv_chan_rdbuf = malloc(NETVSC_PACKET_SIZE, M_NETVSC, M_WAITOK); + KASSERT(rxr->hn_rx_idx == vmbus_chan_subidx(chan), + ("chan%u subidx %u, rxr%d mismatch", + vmbus_chan_id(chan), vmbus_chan_subidx(chan), rxr->hn_rx_idx)); vmbus_chan_open(chan, NETVSC_DEVICE_RING_BUFFER_SIZE, NETVSC_DEVICE_RING_BUFFER_SIZE, NULL, 0, - hv_nv_on_channel_callback, chan); + hv_nv_on_channel_callback, rxr); } /* @@ -655,9 +654,10 @@ hv_nv_subchan_attach(struct hv_vmbus_cha * Callback when the device belonging to this driver is added */ netvsc_dev * -hv_nv_on_device_add(struct hn_softc *sc, void *additional_info) +hv_nv_on_device_add(struct hn_softc *sc, void *additional_info, + struct hn_rx_ring *rxr) { - struct hv_vmbus_channel *chan = sc->hn_prichan; + struct vmbus_channel *chan = sc->hn_prichan; netvsc_dev *net_dev; int ret = 0; @@ -669,18 +669,17 @@ hv_nv_on_device_add(struct hn_softc *sc, sema_init(&net_dev->channel_init_sema, 0, "netdev_sema"); - chan->hv_chan_rdbuf = malloc(NETVSC_PACKET_SIZE, M_NETVSC, M_WAITOK); - /* * Open the channel */ + KASSERT(rxr->hn_rx_idx == vmbus_chan_subidx(chan), + ("chan%u subidx %u, rxr%d mismatch", + vmbus_chan_id(chan), vmbus_chan_subidx(chan), rxr->hn_rx_idx)); ret = vmbus_chan_open(chan, NETVSC_DEVICE_RING_BUFFER_SIZE, NETVSC_DEVICE_RING_BUFFER_SIZE, - NULL, 0, hv_nv_on_channel_callback, chan); - if (ret != 0) { - free(chan->hv_chan_rdbuf, M_NETVSC); + NULL, 0, hv_nv_on_channel_callback, rxr); + if (ret != 0) goto cleanup; - } /* * Connect with the NetVsp @@ -693,7 +692,6 @@ hv_nv_on_device_add(struct hn_softc *sc, close: /* Now, we can close the channel safely */ - free(chan->hv_chan_rdbuf, M_NETVSC); vmbus_chan_close(chan); cleanup: @@ -724,7 +722,6 @@ hv_nv_on_device_remove(struct hn_softc * /* Now, we can close the channel safely */ - free(sc->hn_prichan->hv_chan_rdbuf, M_NETVSC); vmbus_chan_close(sc->hn_prichan); sema_destroy(&net_dev->channel_init_sema); @@ -737,7 +734,7 @@ hv_nv_on_device_remove(struct hn_softc * * Net VSC on send completion */ static void -hv_nv_on_send_completion(netvsc_dev *net_dev, struct hv_vmbus_channel *chan, +hv_nv_on_send_completion(netvsc_dev *net_dev, struct vmbus_channel *chan, const struct vmbus_chanpkt_hdr *pkt) { const nvsp_msg *nvsp_msg_pkt; @@ -801,7 +798,7 @@ hv_nv_on_send_completion(netvsc_dev *net * Returns 0 on success, non-zero on failure. */ int -hv_nv_on_send(struct hv_vmbus_channel *chan, netvsc_packet *pkt) +hv_nv_on_send(struct vmbus_channel *chan, netvsc_packet *pkt) { nvsp_msg send_msg; int ret; @@ -839,14 +836,13 @@ hv_nv_on_send(struct hv_vmbus_channel *c * with virtual addresses. */ static void -hv_nv_on_receive(netvsc_dev *net_dev, struct hn_softc *sc, - struct hv_vmbus_channel *chan, const struct vmbus_chanpkt_hdr *pkthdr) +hv_nv_on_receive(netvsc_dev *net_dev, struct hn_rx_ring *rxr, + struct vmbus_channel *chan, const struct vmbus_chanpkt_hdr *pkthdr) { const struct vmbus_chanpkt_rxbuf *pkt; const nvsp_msg *nvsp_msg_pkt; netvsc_packet vsc_pkt; netvsc_packet *net_vsc_pkt = &vsc_pkt; - device_t dev = sc->hn_dev; int count = 0; int i = 0; int status = nvsp_status_success; @@ -855,7 +851,7 @@ hv_nv_on_receive(netvsc_dev *net_dev, st /* Make sure this is a valid nvsp packet */ if (nvsp_msg_pkt->hdr.msg_type != nvsp_msg_1_type_send_rndis_pkt) { - device_printf(dev, "packet hdr type %u is invalid!\n", + if_printf(rxr->hn_ifp, "packet hdr type %u is invalid!\n", nvsp_msg_pkt->hdr.msg_type); return; } @@ -863,7 +859,7 @@ hv_nv_on_receive(netvsc_dev *net_dev, st pkt = (const struct vmbus_chanpkt_rxbuf *)pkthdr; if (pkt->cp_rxbuf_id != NETVSC_RECEIVE_BUFFER_ID) { - device_printf(dev, "rxbuf_id %d is invalid!\n", + if_printf(rxr->hn_ifp, "rxbuf_id %d is invalid!\n", pkt->cp_rxbuf_id); return; } @@ -877,7 +873,7 @@ hv_nv_on_receive(netvsc_dev *net_dev, st pkt->cp_rxbuf[i].rb_ofs); net_vsc_pkt->tot_data_buf_len = pkt->cp_rxbuf[i].rb_len; - hv_rf_on_receive(net_dev, chan, net_vsc_pkt); + hv_rf_on_receive(net_dev, rxr, net_vsc_pkt); if (net_vsc_pkt->status != nvsp_status_success) { status = nvsp_status_failure; } @@ -897,7 +893,7 @@ hv_nv_on_receive(netvsc_dev *net_dev, st * Send a receive completion packet to RNDIS device (ie NetVsp) */ static void -hv_nv_on_receive_completion(struct hv_vmbus_channel *chan, uint64_t tid, +hv_nv_on_receive_completion(struct vmbus_channel *chan, uint64_t tid, uint32_t status) { nvsp_msg rx_comp_msg; @@ -972,11 +968,10 @@ hv_nv_send_table(struct hn_softc *sc, co * Net VSC on channel callback */ static void -hv_nv_on_channel_callback(void *xchan) +hv_nv_on_channel_callback(struct vmbus_channel *chan, void *xrxr) { - struct hv_vmbus_channel *chan = xchan; - device_t dev = chan->ch_dev; - struct hn_softc *sc = device_get_softc(dev); + struct hn_rx_ring *rxr = xrxr; + struct hn_softc *sc = rxr->hn_ifp->if_softc; netvsc_dev *net_dev; void *buffer; int bufferlen = NETVSC_PACKET_SIZE; @@ -985,7 +980,7 @@ hv_nv_on_channel_callback(void *xchan) if (net_dev == NULL) return; - buffer = chan->hv_chan_rdbuf; + buffer = rxr->hn_rdbuf; do { struct vmbus_chanpkt_hdr *pkt = buffer; uint32_t bytes_rxed; @@ -1001,13 +996,13 @@ hv_nv_on_channel_callback(void *xchan) pkt); break; case VMBUS_CHANPKT_TYPE_RXBUF: - hv_nv_on_receive(net_dev, sc, chan, pkt); + hv_nv_on_receive(net_dev, rxr, chan, pkt); break; case VMBUS_CHANPKT_TYPE_INBAND: hv_nv_send_table(sc, pkt); break; default: - device_printf(dev, + if_printf(rxr->hn_ifp, "unknown chan pkt %u\n", pkt->cph_type); break; @@ -1023,7 +1018,7 @@ hv_nv_on_channel_callback(void *xchan) /* alloc new buffer */ buffer = malloc(bytes_rxed, M_NETVSC, M_NOWAIT); if (buffer == NULL) { - device_printf(dev, + if_printf(rxr->hn_ifp, "hv_cb malloc buffer failed, len=%u\n", bytes_rxed); bufferlen = 0; @@ -1039,5 +1034,5 @@ hv_nv_on_channel_callback(void *xchan) if (bufferlen > NETVSC_PACKET_SIZE) free(buffer, M_NETVSC); - hv_rf_channel_rollup(chan); + hv_rf_channel_rollup(rxr, rxr->hn_txr); } Modified: stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h Wed Oct 12 03:08:58 2016 (r307095) +++ stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h Wed Oct 12 03:18:17 2016 (r307096) @@ -53,6 +53,7 @@ #include #include +#include #include #include @@ -1065,12 +1066,12 @@ typedef struct netvsc_dev_ { nvsp_msg channel_init_packet; nvsp_msg revoke_packet; - /*uint8_t hw_mac_addr[HW_MACADDR_LEN];*/ + /*uint8_t hw_mac_addr[ETHER_ADDR_LEN];*/ /* Holds rndis device info */ void *extension; - hv_bool_uint8_t destroy; + uint8_t destroy; /* Negotiated NVSP version */ uint32_t nvsp_version; @@ -1081,9 +1082,9 @@ typedef struct netvsc_dev_ { uint32_t vrss_send_table[VRSS_SEND_TABLE_SIZE]; } netvsc_dev; -struct hv_vmbus_channel; +struct vmbus_channel; -typedef void (*pfn_on_send_rx_completion)(struct hv_vmbus_channel *, void *); +typedef void (*pfn_on_send_rx_completion)(struct vmbus_channel *, void *); #define NETVSC_DEVICE_RING_BUFFER_SIZE (128 * PAGE_SIZE) @@ -1109,7 +1110,7 @@ typedef void (*pfn_on_send_rx_completion #endif typedef struct netvsc_packet_ { - hv_bool_uint8_t is_data_pkt; /* One byte */ + uint8_t is_data_pkt; /* One byte */ uint16_t vlan_tci; uint32_t status; @@ -1140,7 +1141,7 @@ typedef struct netvsc_packet_ { typedef struct { uint8_t mac_addr[6]; /* Assumption unsigned long */ - hv_bool_uint8_t link_state; + uint8_t link_state; } netvsc_device_info; #ifndef HN_USE_TXDESC_BUFRING @@ -1150,8 +1151,12 @@ SLIST_HEAD(hn_txdesc_list, hn_txdesc); struct buf_ring; #endif +struct hn_tx_ring; + struct hn_rx_ring { struct ifnet *hn_ifp; + struct hn_tx_ring *hn_txr; + void *hn_rdbuf; int hn_rx_idx; /* Trust csum verification on host side */ @@ -1202,7 +1207,7 @@ struct hn_tx_ring { struct mtx hn_tx_lock; struct hn_softc *hn_sc; - struct hv_vmbus_channel *hn_chan; + struct vmbus_channel *hn_chan; int hn_direct_tx_size; int hn_tx_chimney_size; @@ -1242,7 +1247,7 @@ typedef struct hn_softc { /* See hv_netvsc_drv_freebsd.c for rules on how to use */ int temp_unusable; netvsc_dev *net_dev; - struct hv_vmbus_channel *hn_prichan; + struct vmbus_channel *hn_prichan; int hn_rx_ring_cnt; int hn_rx_ring_inuse; @@ -1266,12 +1271,13 @@ extern int hv_promisc_mode; void netvsc_linkstatus_callback(struct hn_softc *sc, uint32_t status); netvsc_dev *hv_nv_on_device_add(struct hn_softc *sc, - void *additional_info); + void *additional_info, struct hn_rx_ring *rxr); int hv_nv_on_device_remove(struct hn_softc *sc, boolean_t destroy_channel); -int hv_nv_on_send(struct hv_vmbus_channel *chan, netvsc_packet *pkt); +int hv_nv_on_send(struct vmbus_channel *chan, netvsc_packet *pkt); int hv_nv_get_next_send_section(netvsc_dev *net_dev); -void hv_nv_subchan_attach(struct hv_vmbus_channel *chan); +void hv_nv_subchan_attach(struct vmbus_channel *chan, + struct hn_rx_ring *rxr); #endif /* __HV_NET_VSC_H__ */ Modified: stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Wed Oct 12 03:08:58 2016 (r307095) +++ stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Wed Oct 12 03:18:17 2016 (r307096) @@ -122,9 +122,6 @@ __FBSDID("$FreeBSD$"); #include "hv_rndis_filter.h" #include "vmbus_if.h" -#define hv_chan_rxr hv_chan_priv1 -#define hv_chan_txr hv_chan_priv2 - /* Short for Hyper-V network interface */ #define NETVSC_DEVNAME "hn" @@ -347,8 +344,8 @@ static int hn_encap(struct hn_tx_ring *, static void hn_create_rx_data(struct hn_softc *sc, int); static void hn_destroy_rx_data(struct hn_softc *sc); static void hn_set_tx_chimney_size(struct hn_softc *, int); -static void hn_channel_attach(struct hn_softc *, struct hv_vmbus_channel *); -static void hn_subchan_attach(struct hn_softc *, struct hv_vmbus_channel *); +static void hn_channel_attach(struct hn_softc *, struct vmbus_channel *); +static void hn_subchan_attach(struct hn_softc *, struct vmbus_channel *); static void hn_subchan_setup(struct hn_softc *); static int hn_transmit(struct ifnet *, struct mbuf *); @@ -560,7 +557,8 @@ netvsc_attach(device_t dev) IFCAP_LRO; ifp->if_hwassist = sc->hn_tx_ring[0].hn_csum_assist | CSUM_TSO; - error = hv_rf_on_device_add(sc, &device_info, ring_cnt); + error = hv_rf_on_device_add(sc, &device_info, ring_cnt, + &sc->hn_rx_ring[0]); if (error) goto failed; KASSERT(sc->net_dev->num_channel > 0 && @@ -794,7 +792,7 @@ hn_txeof(struct hn_tx_ring *txr) } static void -hn_tx_done(struct hv_vmbus_channel *chan, void *xpkt) +hn_tx_done(struct vmbus_channel *chan, void *xpkt) { netvsc_packet *packet = xpkt; struct hn_txdesc *txd; @@ -805,9 +803,8 @@ hn_tx_done(struct hv_vmbus_channel *chan txr = txd->txr; KASSERT(txr->hn_chan == chan, - ("channel mismatch, on channel%u, should be channel%u", - chan->ch_subidx, - txr->hn_chan->ch_subidx)); + ("channel mismatch, on chan%u, should be chan%u", + vmbus_chan_subidx(chan), vmbus_chan_subidx(txr->hn_chan))); txr->hn_has_txeof = 1; hn_txdesc_put(txr, txd); @@ -821,11 +818,9 @@ hn_tx_done(struct hv_vmbus_channel *chan } void -netvsc_channel_rollup(struct hv_vmbus_channel *chan) +netvsc_channel_rollup(struct hn_rx_ring *rxr, struct hn_tx_ring *txr) { - struct hn_tx_ring *txr = chan->hv_chan_txr; #if defined(INET) || defined(INET6) - struct hn_rx_ring *rxr = chan->hv_chan_rxr; struct lro_ctrl *lro = &rxr->hn_lro; struct lro_entry *queued; @@ -1296,12 +1291,11 @@ hn_lro_rx(struct lro_ctrl *lc, struct mb * Note: This is no longer used as a callback */ int -netvsc_recv(struct hv_vmbus_channel *chan, netvsc_packet *packet, +netvsc_recv(struct hn_rx_ring *rxr, netvsc_packet *packet, const rndis_tcp_ip_csum_info *csum_info, const struct rndis_hash_info *hash_info, const struct rndis_hash_value *hash_value) { - struct hn_rx_ring *rxr = chan->hv_chan_rxr; struct ifnet *ifp = rxr->hn_ifp; struct mbuf *m_new; int size, do_lro = 0, do_csum = 1; @@ -1606,7 +1600,7 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, vmbus_subchan_drain(sc->hn_prichan); error = hv_rf_on_device_add(sc, &device_info, - sc->hn_rx_ring_inuse); + sc->hn_rx_ring_inuse, &sc->hn_rx_ring[0]); if (error) { NV_LOCK(sc); sc->temp_unusable = FALSE; @@ -2269,6 +2263,9 @@ hn_create_rx_data(struct hn_softc *sc, i if (hn_trust_hostip) rxr->hn_trust_hcsum |= HN_TRUST_HCSUM_IP; rxr->hn_ifp = sc->hn_ifp; + if (i < sc->hn_tx_ring_cnt) + rxr->hn_txr = &sc->hn_tx_ring[i]; + rxr->hn_rdbuf = malloc(NETVSC_PACKET_SIZE, M_NETVSC, M_WAITOK); rxr->hn_rx_idx = i; /* @@ -2391,17 +2388,19 @@ hn_create_rx_data(struct hn_softc *sc, i static void hn_destroy_rx_data(struct hn_softc *sc) { -#if defined(INET) || defined(INET6) int i; -#endif if (sc->hn_rx_ring_cnt == 0) return; + for (i = 0; i < sc->hn_rx_ring_cnt; ++i) { + struct hn_rx_ring *rxr = &sc->hn_rx_ring[i]; + #if defined(INET) || defined(INET6) - for (i = 0; i < sc->hn_rx_ring_cnt; ++i) - tcp_lro_free(&sc->hn_rx_ring[i].hn_lro); + tcp_lro_free(&rxr->hn_lro); #endif + free(rxr->hn_rdbuf, M_NETVSC); + } free(sc->hn_rx_ring, M_NETVSC); sc->hn_rx_ring = NULL; @@ -2969,12 +2968,12 @@ hn_xmit_txeof_taskfunc(void *xtxr, int p } static void -hn_channel_attach(struct hn_softc *sc, struct hv_vmbus_channel *chan) +hn_channel_attach(struct hn_softc *sc, struct vmbus_channel *chan) { struct hn_rx_ring *rxr; int idx; - idx = chan->ch_subidx; + idx = vmbus_chan_subidx(chan); KASSERT(idx >= 0 && idx < sc->hn_rx_ring_inuse, ("invalid channel index %d, should > 0 && < %d", @@ -2984,10 +2983,9 @@ hn_channel_attach(struct hn_softc *sc, s ("RX ring %d already attached", idx)); rxr->hn_rx_flags |= HN_RX_FLAG_ATTACHED; - chan->hv_chan_rxr = rxr; if (bootverbose) { if_printf(sc->hn_ifp, "link RX ring %d to channel%u\n", - idx, chan->ch_id); + idx, vmbus_chan_id(chan)); } if (idx < sc->hn_tx_ring_inuse) { @@ -2997,11 +2995,10 @@ hn_channel_attach(struct hn_softc *sc, s ("TX ring %d already attached", idx)); txr->hn_tx_flags |= HN_TX_FLAG_ATTACHED; - chan->hv_chan_txr = txr; txr->hn_chan = chan; if (bootverbose) { if_printf(sc->hn_ifp, "link TX ring %d to channel%u\n", - idx, chan->ch_id); + idx, vmbus_chan_id(chan)); } } @@ -3010,36 +3007,36 @@ hn_channel_attach(struct hn_softc *sc, s } static void -hn_subchan_attach(struct hn_softc *sc, struct hv_vmbus_channel *chan) +hn_subchan_attach(struct hn_softc *sc, struct vmbus_channel *chan) { - KASSERT(!VMBUS_CHAN_ISPRIMARY(chan), + KASSERT(!vmbus_chan_is_primary(chan), ("subchannel callback on primary channel")); - KASSERT(chan->ch_subidx > 0, - ("invalid channel subidx %u", - chan->ch_subidx)); hn_channel_attach(sc, chan); } static void hn_subchan_setup(struct hn_softc *sc) { - struct hv_vmbus_channel **subchan; + struct vmbus_channel **subchans; int subchan_cnt = sc->net_dev->num_channel - 1; int i; /* Wait for sub-channels setup to complete. */ - subchan = vmbus_subchan_get(sc->hn_prichan, subchan_cnt); + subchans = vmbus_subchan_get(sc->hn_prichan, subchan_cnt); /* Attach the sub-channels. */ for (i = 0; i < subchan_cnt; ++i) { + struct vmbus_channel *subchan = subchans[i]; + /* NOTE: Calling order is critical. */ - hn_subchan_attach(sc, subchan[i]); - hv_nv_subchan_attach(subchan[i]); + hn_subchan_attach(sc, subchan); + hv_nv_subchan_attach(subchan, + &sc->hn_rx_ring[vmbus_chan_subidx(subchan)]); } /* Release the sub-channels */ - vmbus_subchan_rel(subchan, subchan_cnt); + vmbus_subchan_rel(subchans, subchan_cnt); if_printf(sc->hn_ifp, "%d sub-channels setup done\n", subchan_cnt); } Modified: stable/10/sys/dev/hyperv/netvsc/hv_rndis.h ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_rndis.h Wed Oct 12 03:08:58 2016 (r307095) +++ stable/10/sys/dev/hyperv/netvsc/hv_rndis.h Wed Oct 12 03:18:17 2016 (r307096) @@ -1082,13 +1082,14 @@ typedef struct rndismp_rx_bufs_info_ { /* * Externs */ -struct hv_vmbus_channel; +struct hn_rx_ring; +struct hn_tx_ring; -int netvsc_recv(struct hv_vmbus_channel *chan, +int netvsc_recv(struct hn_rx_ring *rxr, netvsc_packet *packet, const rndis_tcp_ip_csum_info *csum_info, const struct rndis_hash_info *hash_info, const struct rndis_hash_value *hash_value); -void netvsc_channel_rollup(struct hv_vmbus_channel *chan); +void netvsc_channel_rollup(struct hn_rx_ring *rxr, struct hn_tx_ring *txr); void* hv_set_rppi_data(rndis_msg *rndis_mesg, uint32_t rppi_size, Modified: stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.c Wed Oct 12 03:08:58 2016 (r307095) +++ stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.c Wed Oct 12 03:18:17 2016 (r307096) @@ -35,7 +35,9 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include +#include #include #include #include @@ -75,8 +77,7 @@ static int hv_rf_send_request(rndis_dev static void hv_rf_receive_response(rndis_device *device, rndis_msg *response); static void hv_rf_receive_indicate_status(rndis_device *device, rndis_msg *response); -static void hv_rf_receive_data(rndis_device *device, rndis_msg *message, - struct hv_vmbus_channel *chan, +static void hv_rf_receive_data(struct hn_rx_ring *rxr, rndis_msg *message, netvsc_packet *pkt); static int hv_rf_query_device(rndis_device *device, uint32_t oid, void *result, uint32_t *result_size); @@ -86,8 +87,8 @@ static int hv_rf_set_packet_filter(rndi static int hv_rf_init_device(rndis_device *device); static int hv_rf_open_device(rndis_device *device); static int hv_rf_close_device(rndis_device *device); -static void hv_rf_on_send_request_completion(struct hv_vmbus_channel *, void *context); -static void hv_rf_on_send_request_halt_completion(struct hv_vmbus_channel *, void *context); +static void hv_rf_on_send_request_completion(struct vmbus_channel *, void *context); +static void hv_rf_on_send_request_halt_completion(struct vmbus_channel *, void *context); int hv_rf_send_offload_request(struct hn_softc *sc, rndis_offload_params *offloads); @@ -528,12 +529,11 @@ skip: * RNDIS filter receive data */ static void -hv_rf_receive_data(rndis_device *device, rndis_msg *message, - struct hv_vmbus_channel *chan, netvsc_packet *pkt) +hv_rf_receive_data(struct hn_rx_ring *rxr, rndis_msg *message, + netvsc_packet *pkt) { rndis_packet *rndis_pkt; uint32_t data_offset; - device_t dev = device->net_dev->sc->hn_dev; struct hv_rf_recvinfo info; rndis_pkt = &message->msg.packet; @@ -549,7 +549,7 @@ hv_rf_receive_data(rndis_device *device, pkt->tot_data_buf_len -= data_offset; if (pkt->tot_data_buf_len < rndis_pkt->data_length) { pkt->status = nvsp_status_failure; - device_printf(dev, + if_printf(rxr->hn_ifp, "total length %u is less than data length %u\n", pkt->tot_data_buf_len, rndis_pkt->data_length); return; @@ -560,7 +560,7 @@ hv_rf_receive_data(rndis_device *device, if (hv_rf_find_recvinfo(rndis_pkt, &info)) { pkt->status = nvsp_status_failure; - device_printf(dev, "recvinfo parsing failed\n"); + if_printf(rxr->hn_ifp, "recvinfo parsing failed\n"); return; } @@ -569,7 +569,7 @@ hv_rf_receive_data(rndis_device *device, else pkt->vlan_tci = 0; - netvsc_recv(chan, pkt, info.csum_info, info.hash_info, info.hash_value); + netvsc_recv(rxr, pkt, info.csum_info, info.hash_info, info.hash_value); } /* @@ -577,7 +577,7 @@ hv_rf_receive_data(rndis_device *device, */ int hv_rf_on_receive(netvsc_dev *net_dev, - struct hv_vmbus_channel *chan, netvsc_packet *pkt) + struct hn_rx_ring *rxr, netvsc_packet *pkt) { rndis_device *rndis_dev; rndis_msg *rndis_hdr; @@ -600,7 +600,7 @@ hv_rf_on_receive(netvsc_dev *net_dev, /* data message */ case REMOTE_NDIS_PACKET_MSG: - hv_rf_receive_data(rndis_dev, rndis_hdr, chan, pkt); + hv_rf_receive_data(rxr, rndis_hdr, pkt); break; /* completion messages */ case REMOTE_NDIS_INITIALIZE_CMPLT: @@ -700,7 +700,7 @@ cleanup: static inline int hv_rf_query_device_mac(rndis_device *device) { - uint32_t size = HW_MACADDR_LEN; + uint32_t size = ETHER_ADDR_LEN; return (hv_rf_query_device(device, RNDIS_OID_802_3_PERMANENT_ADDRESS, device->hw_mac_addr, &size)); *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-all@freebsd.org Wed Oct 12 03:32:49 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 917BDC0ECC2; Wed, 12 Oct 2016 03:32:49 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 5D114957; Wed, 12 Oct 2016 03:32:49 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9C3WmpB073012; Wed, 12 Oct 2016 03:32:48 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9C3WmAp073007; Wed, 12 Oct 2016 03:32:48 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610120332.u9C3WmAp073007@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Wed, 12 Oct 2016 03:32:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307097 - stable/10/sys/dev/hyperv/vmbus X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Oct 2016 03:32:49 -0000 Author: sephe Date: Wed Oct 12 03:32:47 2016 New Revision: 307097 URL: https://svnweb.freebsd.org/changeset/base/307097 Log: MFC 303178,303180,303182 303178 hyperv/vmbus: Cosmetic bufring cleanup. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7267 303180 hyperv/vmbus: Cleanup and augment bufring sysctl tree creation Binary state node is added, so that userland programs do not have to parse human readable state string. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7268 303182 hyperv/vmbus: Move vmbus bufring definition to vmbus_reg.h And add more comment about its fields. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7269 Modified: stable/10/sys/dev/hyperv/vmbus/hv_ring_buffer.c stable/10/sys/dev/hyperv/vmbus/hv_vmbus_priv.h stable/10/sys/dev/hyperv/vmbus/vmbus_chan.c stable/10/sys/dev/hyperv/vmbus/vmbus_chanvar.h stable/10/sys/dev/hyperv/vmbus/vmbus_reg.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/hyperv/vmbus/hv_ring_buffer.c ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/hv_ring_buffer.c Wed Oct 12 03:18:17 2016 (r307096) +++ stable/10/sys/dev/hyperv/vmbus/hv_ring_buffer.c Wed Oct 12 03:32:47 2016 (r307097) @@ -35,116 +35,148 @@ __FBSDID("$FreeBSD$"); #include #include "hv_vmbus_priv.h" +#include /* Amount of space to write to */ -#define HV_BYTES_AVAIL_TO_WRITE(r, w, z) ((w) >= (r))? \ - ((z) - ((w) - (r))):((r) - (w)) +#define HV_BYTES_AVAIL_TO_WRITE(r, w, z) \ + ((w) >= (r)) ? ((z) - ((w) - (r))) : ((r) - (w)) +static uint32_t copy_to_ring_buffer(hv_vmbus_ring_buffer_info *ring_info, + uint32_t start_write_offset, const uint8_t *src, + uint32_t src_len); +static uint32_t copy_from_ring_buffer(hv_vmbus_ring_buffer_info *ring_info, + char *dest, uint32_t dest_len, uint32_t start_read_offset); + +static int +vmbus_br_sysctl_state(SYSCTL_HANDLER_ARGS) +{ + const hv_vmbus_ring_buffer_info *br = arg1; + uint32_t rindex, windex, intr_mask, ravail, wavail; + char state[256]; + + rindex = br->ring_buffer->br_rindex; + windex = br->ring_buffer->br_windex; + intr_mask = br->ring_buffer->br_imask; + wavail = HV_BYTES_AVAIL_TO_WRITE(rindex, windex, br->ring_data_size); + ravail = br->ring_data_size - wavail; + + snprintf(state, sizeof(state), + "rindex:%u windex:%u intr_mask:%u ravail:%u wavail:%u", + rindex, windex, intr_mask, ravail, wavail); + return sysctl_handle_string(oidp, state, sizeof(state), req); +} + +/* + * Binary bufring states. + */ static int -hv_rbi_sysctl_stats(SYSCTL_HANDLER_ARGS) +vmbus_br_sysctl_state_bin(SYSCTL_HANDLER_ARGS) { - hv_vmbus_ring_buffer_info* rbi; - uint32_t read_index, write_index, interrupt_mask, sz; - uint32_t read_avail, write_avail; - char rbi_stats[256]; - - rbi = (hv_vmbus_ring_buffer_info*)arg1; - read_index = rbi->ring_buffer->read_index; - write_index = rbi->ring_buffer->write_index; - interrupt_mask = rbi->ring_buffer->interrupt_mask; - sz = rbi->ring_data_size; - write_avail = HV_BYTES_AVAIL_TO_WRITE(read_index, - write_index, sz); - read_avail = sz - write_avail; - snprintf(rbi_stats, sizeof(rbi_stats), - "r_idx:%d " - "w_idx:%d " - "int_mask:%d " - "r_avail:%d " - "w_avail:%d", - read_index, write_index, interrupt_mask, - read_avail, write_avail); +#define BR_STATE_RIDX 0 +#define BR_STATE_WIDX 1 +#define BR_STATE_IMSK 2 +#define BR_STATE_RSPC 3 +#define BR_STATE_WSPC 4 +#define BR_STATE_MAX 5 + + const hv_vmbus_ring_buffer_info *br = arg1; + uint32_t rindex, windex, wavail, state[BR_STATE_MAX]; + + rindex = br->ring_buffer->br_rindex; + windex = br->ring_buffer->br_windex; + wavail = HV_BYTES_AVAIL_TO_WRITE(rindex, windex, br->ring_data_size); + + state[BR_STATE_RIDX] = rindex; + state[BR_STATE_WIDX] = windex; + state[BR_STATE_IMSK] = br->ring_buffer->br_imask; + state[BR_STATE_WSPC] = wavail; + state[BR_STATE_RSPC] = br->ring_data_size - wavail; - return (sysctl_handle_string(oidp, rbi_stats, - sizeof(rbi_stats), req)); + return sysctl_handle_opaque(oidp, state, sizeof(state), req); } void -hv_ring_buffer_stat( - struct sysctl_ctx_list *ctx, - struct sysctl_oid_list *tree_node, - hv_vmbus_ring_buffer_info *rbi, - const char *desc) -{ - SYSCTL_ADD_PROC(ctx, tree_node, OID_AUTO, - "ring_buffer_stats", - CTLTYPE_STRING|CTLFLAG_RD|CTLFLAG_MPSAFE, rbi, 0, - hv_rbi_sysctl_stats, "A", desc); +vmbus_br_sysctl_create(struct sysctl_ctx_list *ctx, struct sysctl_oid *br_tree, + hv_vmbus_ring_buffer_info *br, const char *name) +{ + struct sysctl_oid *tree; + char desc[64]; + + tree = SYSCTL_ADD_NODE(ctx, SYSCTL_CHILDREN(br_tree), OID_AUTO, + name, CTLFLAG_RD | CTLFLAG_MPSAFE, 0, ""); + if (tree == NULL) + return; + + snprintf(desc, sizeof(desc), "%s state", name); + SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, "state", + CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, + br, 0, vmbus_br_sysctl_state, "A", desc); + + snprintf(desc, sizeof(desc), "%s binary state", name); + SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, "state_bin", + CTLTYPE_OPAQUE | CTLFLAG_RD | CTLFLAG_MPSAFE, + br, 0, vmbus_br_sysctl_state_bin, "IU", desc); } + /** * @brief Get number of bytes available to read and to write to * for the specified ring buffer */ -static inline void -get_ring_buffer_avail_bytes( - hv_vmbus_ring_buffer_info* rbi, - uint32_t* read, - uint32_t* write) +static __inline void +get_ring_buffer_avail_bytes(hv_vmbus_ring_buffer_info *rbi, uint32_t *read, + uint32_t *write) { uint32_t read_loc, write_loc; /* * Capture the read/write indices before they changed */ - read_loc = rbi->ring_buffer->read_index; - write_loc = rbi->ring_buffer->write_index; + read_loc = rbi->ring_buffer->br_rindex; + write_loc = rbi->ring_buffer->br_windex; - *write = HV_BYTES_AVAIL_TO_WRITE( - read_loc, write_loc, rbi->ring_data_size); + *write = HV_BYTES_AVAIL_TO_WRITE(read_loc, write_loc, + rbi->ring_data_size); *read = rbi->ring_data_size - *write; } /** * @brief Get the next write location for the specified ring buffer */ -static inline uint32_t -get_next_write_location(hv_vmbus_ring_buffer_info* ring_info) +static __inline uint32_t +get_next_write_location(hv_vmbus_ring_buffer_info *ring_info) { - uint32_t next = ring_info->ring_buffer->write_index; - return (next); + return ring_info->ring_buffer->br_windex; } /** * @brief Set the next write location for the specified ring buffer */ -static inline void -set_next_write_location( - hv_vmbus_ring_buffer_info* ring_info, - uint32_t next_write_location) +static __inline void +set_next_write_location(hv_vmbus_ring_buffer_info *ring_info, + uint32_t next_write_location) { - ring_info->ring_buffer->write_index = next_write_location; + ring_info->ring_buffer->br_windex = next_write_location; } /** * @brief Get the next read location for the specified ring buffer */ -static inline uint32_t -get_next_read_location(hv_vmbus_ring_buffer_info* ring_info) +static __inline uint32_t +get_next_read_location(hv_vmbus_ring_buffer_info *ring_info) { - uint32_t next = ring_info->ring_buffer->read_index; - return (next); + return ring_info->ring_buffer->br_rindex; } /** * @brief Get the next read location + offset for the specified ring buffer. * This allows the caller to skip. */ -static inline uint32_t -get_next_read_location_with_offset( - hv_vmbus_ring_buffer_info* ring_info, - uint32_t offset) +static __inline uint32_t +get_next_read_location_with_offset(hv_vmbus_ring_buffer_info *ring_info, + uint32_t offset) { - uint32_t next = ring_info->ring_buffer->read_index; + uint32_t next = ring_info->ring_buffer->br_rindex; + next += offset; next %= ring_info->ring_data_size; return (next); @@ -153,28 +185,27 @@ get_next_read_location_with_offset( /** * @brief Set the next read location for the specified ring buffer */ -static inline void -set_next_read_location( - hv_vmbus_ring_buffer_info* ring_info, - uint32_t next_read_location) +static __inline void +set_next_read_location(hv_vmbus_ring_buffer_info *ring_info, + uint32_t next_read_location) { - ring_info->ring_buffer->read_index = next_read_location; + ring_info->ring_buffer->br_rindex = next_read_location; } /** * @brief Get the start of the ring buffer */ -static inline void * -get_ring_buffer(hv_vmbus_ring_buffer_info* ring_info) +static __inline void * +get_ring_buffer(hv_vmbus_ring_buffer_info *ring_info) { - return (void *) ring_info->ring_buffer->buffer; + return ring_info->ring_buffer->br_data; } /** * @brief Get the size of the ring buffer. */ -static inline uint32_t -get_ring_buffer_size(hv_vmbus_ring_buffer_info* ring_info) +static __inline uint32_t +get_ring_buffer_size(hv_vmbus_ring_buffer_info *ring_info) { return ring_info->ring_data_size; } @@ -182,27 +213,25 @@ get_ring_buffer_size(hv_vmbus_ring_buffe /** * Get the read and write indices as uint64_t of the specified ring buffer. */ -static inline uint64_t -get_ring_buffer_indices(hv_vmbus_ring_buffer_info* ring_info) +static __inline uint64_t +get_ring_buffer_indices(hv_vmbus_ring_buffer_info *ring_info) { - return (uint64_t) ring_info->ring_buffer->write_index << 32; + return ((uint64_t)ring_info->ring_buffer->br_windex) << 32; } void -hv_ring_buffer_read_begin( - hv_vmbus_ring_buffer_info* ring_info) +hv_ring_buffer_read_begin(hv_vmbus_ring_buffer_info *ring_info) { - ring_info->ring_buffer->interrupt_mask = 1; + ring_info->ring_buffer->br_imask = 1; mb(); } uint32_t -hv_ring_buffer_read_end( - hv_vmbus_ring_buffer_info* ring_info) +hv_ring_buffer_read_end(hv_vmbus_ring_buffer_info *ring_info) { - uint32_t read, write; + uint32_t read, write; - ring_info->ring_buffer->interrupt_mask = 0; + ring_info->ring_buffer->br_imask = 0; mb(); /* @@ -211,7 +240,6 @@ hv_ring_buffer_read_end( * incoming messages. */ get_ring_buffer_avail_bytes(ring_info, &read, &write); - return (read); } @@ -231,12 +259,11 @@ hv_ring_buffer_read_end( * arrived. */ static boolean_t -hv_ring_buffer_needsig_on_write( - uint32_t old_write_location, - hv_vmbus_ring_buffer_info* rbi) +hv_ring_buffer_needsig_on_write(uint32_t old_write_location, + hv_vmbus_ring_buffer_info *rbi) { mb(); - if (rbi->ring_buffer->interrupt_mask) + if (rbi->ring_buffer->br_imask) return (FALSE); /* Read memory barrier */ @@ -245,41 +272,26 @@ hv_ring_buffer_needsig_on_write( * This is the only case we need to signal when the * ring transitions from being empty to non-empty. */ - if (old_write_location == rbi->ring_buffer->read_index) + if (old_write_location == rbi->ring_buffer->br_rindex) return (TRUE); return (FALSE); } -static uint32_t copy_to_ring_buffer( - hv_vmbus_ring_buffer_info* ring_info, - uint32_t start_write_offset, - const uint8_t *src, - uint32_t src_len); - -static uint32_t copy_from_ring_buffer( - hv_vmbus_ring_buffer_info* ring_info, - char* dest, - uint32_t dest_len, - uint32_t start_read_offset); - /** * @brief Initialize the ring buffer. */ int -hv_vmbus_ring_buffer_init( - hv_vmbus_ring_buffer_info* ring_info, - void* buffer, - uint32_t buffer_len) +hv_vmbus_ring_buffer_init(hv_vmbus_ring_buffer_info *ring_info, void *buffer, + uint32_t buffer_len) { memset(ring_info, 0, sizeof(hv_vmbus_ring_buffer_info)); - ring_info->ring_buffer = (hv_vmbus_ring_buffer*) buffer; - ring_info->ring_buffer->read_index = - ring_info->ring_buffer->write_index = 0; - - ring_info->ring_data_size = buffer_len - sizeof(hv_vmbus_ring_buffer); + ring_info->ring_buffer = buffer; + ring_info->ring_buffer->br_rindex = 0; + ring_info->ring_buffer->br_windex = 0; + ring_info->ring_data_size = buffer_len - sizeof(struct vmbus_bufring); mtx_init(&ring_info->ring_lock, "vmbus ring buffer", NULL, MTX_SPIN); return (0); @@ -288,7 +300,8 @@ hv_vmbus_ring_buffer_init( /** * @brief Cleanup the ring buffer. */ -void hv_ring_buffer_cleanup(hv_vmbus_ring_buffer_info* ring_info) +void +hv_ring_buffer_cleanup(hv_vmbus_ring_buffer_info *ring_info) { mtx_destroy(&ring_info->ring_lock); } @@ -297,24 +310,19 @@ void hv_ring_buffer_cleanup(hv_vmbus_rin * @brief Write to the ring buffer. */ int -hv_ring_buffer_write( - hv_vmbus_ring_buffer_info* out_ring_info, - const struct iovec iov[], - uint32_t iovlen, - boolean_t *need_sig) +hv_ring_buffer_write(hv_vmbus_ring_buffer_info *out_ring_info, + const struct iovec iov[], uint32_t iovlen, boolean_t *need_sig) { int i = 0; uint32_t byte_avail_to_write; uint32_t byte_avail_to_read; uint32_t old_write_location; uint32_t total_bytes_to_write = 0; - volatile uint32_t next_write_location; uint64_t prev_indices = 0; - for (i = 0; i < iovlen; i++) { - total_bytes_to_write += iov[i].iov_len; - } + for (i = 0; i < iovlen; i++) + total_bytes_to_write += iov[i].iov_len; total_bytes_to_write += sizeof(uint64_t); @@ -328,11 +336,9 @@ hv_ring_buffer_write( * Otherwise, the next time around, we think the ring buffer * is empty since the read index == write index */ - if (byte_avail_to_write <= total_bytes_to_write) { - - mtx_unlock_spin(&out_ring_info->ring_lock); - return (EAGAIN); + mtx_unlock_spin(&out_ring_info->ring_lock); + return (EAGAIN); } /* @@ -343,8 +349,8 @@ hv_ring_buffer_write( old_write_location = next_write_location; for (i = 0; i < iovlen; i++) { - next_write_location = copy_to_ring_buffer(out_ring_info, - next_write_location, iov[i].iov_base, iov[i].iov_len); + next_write_location = copy_to_ring_buffer(out_ring_info, + next_write_location, iov[i].iov_base, iov[i].iov_len); } /* @@ -352,9 +358,8 @@ hv_ring_buffer_write( */ prev_indices = get_ring_buffer_indices(out_ring_info); - next_write_location = copy_to_ring_buffer( - out_ring_info, next_write_location, - (char *) &prev_indices, sizeof(uint64_t)); + next_write_location = copy_to_ring_buffer(out_ring_info, + next_write_location, (char *)&prev_indices, sizeof(uint64_t)); /* * Full memory barrier before upding the write index. @@ -378,10 +383,8 @@ hv_ring_buffer_write( * @brief Read without advancing the read index. */ int -hv_ring_buffer_peek( - hv_vmbus_ring_buffer_info* in_ring_info, - void* buffer, - uint32_t buffer_len) +hv_ring_buffer_peek(hv_vmbus_ring_buffer_info *in_ring_info, void *buffer, + uint32_t buffer_len) { uint32_t bytesAvailToWrite; uint32_t bytesAvailToRead; @@ -390,14 +393,14 @@ hv_ring_buffer_peek( mtx_lock_spin(&in_ring_info->ring_lock); get_ring_buffer_avail_bytes(in_ring_info, &bytesAvailToRead, - &bytesAvailToWrite); + &bytesAvailToWrite); /* * Make sure there is something to read */ if (bytesAvailToRead < buffer_len) { - mtx_unlock_spin(&in_ring_info->ring_lock); - return (EAGAIN); + mtx_unlock_spin(&in_ring_info->ring_lock); + return (EAGAIN); } /* @@ -405,8 +408,8 @@ hv_ring_buffer_peek( */ nextReadLocation = get_next_read_location(in_ring_info); - nextReadLocation = copy_from_ring_buffer( - in_ring_info, (char *)buffer, buffer_len, nextReadLocation); + nextReadLocation = copy_from_ring_buffer(in_ring_info, + (char *)buffer, buffer_len, nextReadLocation); mtx_unlock_spin(&in_ring_info->ring_lock); @@ -417,11 +420,8 @@ hv_ring_buffer_peek( * @brief Read and advance the read index. */ int -hv_ring_buffer_read( - hv_vmbus_ring_buffer_info* in_ring_info, - void* buffer, - uint32_t buffer_len, - uint32_t offset) +hv_ring_buffer_read(hv_vmbus_ring_buffer_info *in_ring_info, void *buffer, + uint32_t buffer_len, uint32_t offset) { uint32_t bytes_avail_to_write; uint32_t bytes_avail_to_read; @@ -429,37 +429,29 @@ hv_ring_buffer_read( uint64_t prev_indices = 0; if (buffer_len <= 0) - return (EINVAL); + return (EINVAL); mtx_lock_spin(&in_ring_info->ring_lock); - get_ring_buffer_avail_bytes( - in_ring_info, &bytes_avail_to_read, + get_ring_buffer_avail_bytes(in_ring_info, &bytes_avail_to_read, &bytes_avail_to_write); /* * Make sure there is something to read */ if (bytes_avail_to_read < buffer_len) { - mtx_unlock_spin(&in_ring_info->ring_lock); - return (EAGAIN); + mtx_unlock_spin(&in_ring_info->ring_lock); + return (EAGAIN); } - next_read_location = get_next_read_location_with_offset( - in_ring_info, + next_read_location = get_next_read_location_with_offset(in_ring_info, offset); - next_read_location = copy_from_ring_buffer( - in_ring_info, - (char *) buffer, - buffer_len, - next_read_location); - - next_read_location = copy_from_ring_buffer( - in_ring_info, - (char *) &prev_indices, - sizeof(uint64_t), - next_read_location); + next_read_location = copy_from_ring_buffer(in_ring_info, (char *)buffer, + buffer_len, next_read_location); + + next_read_location = copy_from_ring_buffer(in_ring_info, + (char *)&prev_indices, sizeof(uint64_t), next_read_location); /* * Make sure all reads are done before we update the read index since @@ -484,23 +476,20 @@ hv_ring_buffer_read( * Assume there is enough room. Handles wrap-around in dest case only! */ static uint32_t -copy_to_ring_buffer( - hv_vmbus_ring_buffer_info* ring_info, - uint32_t start_write_offset, - const uint8_t *src, - uint32_t src_len) +copy_to_ring_buffer(hv_vmbus_ring_buffer_info *ring_info, + uint32_t start_write_offset, const uint8_t *src, uint32_t src_len) { char *ring_buffer = get_ring_buffer(ring_info); uint32_t ring_buffer_size = get_ring_buffer_size(ring_info); uint32_t fragLen; - if (src_len > ring_buffer_size - start_write_offset) { - /* wrap-around detected! */ - fragLen = ring_buffer_size - start_write_offset; - memcpy(ring_buffer + start_write_offset, src, fragLen); - memcpy(ring_buffer, src + fragLen, src_len - fragLen); + if (src_len > ring_buffer_size - start_write_offset) { + /* wrap-around detected! */ + fragLen = ring_buffer_size - start_write_offset; + memcpy(ring_buffer + start_write_offset, src, fragLen); + memcpy(ring_buffer, src + fragLen, src_len - fragLen); } else { - memcpy(ring_buffer + start_write_offset, src, src_len); + memcpy(ring_buffer + start_write_offset, src, src_len); } start_write_offset += src_len; @@ -514,24 +503,21 @@ copy_to_ring_buffer( * * Assume there is enough room. Handles wrap-around in src case only! */ -uint32_t -copy_from_ring_buffer( - hv_vmbus_ring_buffer_info* ring_info, - char* dest, - uint32_t dest_len, - uint32_t start_read_offset) +static uint32_t +copy_from_ring_buffer(hv_vmbus_ring_buffer_info *ring_info, char *dest, + uint32_t dest_len, uint32_t start_read_offset) { uint32_t fragLen; char *ring_buffer = get_ring_buffer(ring_info); uint32_t ring_buffer_size = get_ring_buffer_size(ring_info); if (dest_len > ring_buffer_size - start_read_offset) { - /* wrap-around detected at the src */ - fragLen = ring_buffer_size - start_read_offset; - memcpy(dest, ring_buffer + start_read_offset, fragLen); - memcpy(dest + fragLen, ring_buffer, dest_len - fragLen); + /* wrap-around detected at the src */ + fragLen = ring_buffer_size - start_read_offset; + memcpy(dest, ring_buffer + start_read_offset, fragLen); + memcpy(dest + fragLen, ring_buffer, dest_len - fragLen); } else { - memcpy(dest, ring_buffer + start_read_offset, dest_len); + memcpy(dest, ring_buffer + start_read_offset, dest_len); } start_read_offset += dest_len; @@ -539,4 +525,3 @@ copy_from_ring_buffer( return (start_read_offset); } - Modified: stable/10/sys/dev/hyperv/vmbus/hv_vmbus_priv.h ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/hv_vmbus_priv.h Wed Oct 12 03:18:17 2016 (r307096) +++ stable/10/sys/dev/hyperv/vmbus/hv_vmbus_priv.h Wed Oct 12 03:32:47 2016 (r307097) @@ -45,13 +45,11 @@ struct vmbus_softc; * Private, VM Bus functions */ struct sysctl_ctx_list; -struct sysctl_oid_list; +struct sysctl_oid; -void hv_ring_buffer_stat( - struct sysctl_ctx_list *ctx, - struct sysctl_oid_list *tree_node, - hv_vmbus_ring_buffer_info *rbi, - const char *desc); +void vmbus_br_sysctl_create(struct sysctl_ctx_list *ctx, + struct sysctl_oid *br_tree, hv_vmbus_ring_buffer_info *br, + const char *name); int hv_vmbus_ring_buffer_init( hv_vmbus_ring_buffer_info *ring_info, Modified: stable/10/sys/dev/hyperv/vmbus/vmbus_chan.c ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/vmbus_chan.c Wed Oct 12 03:18:17 2016 (r307096) +++ stable/10/sys/dev/hyperv/vmbus/vmbus_chan.c Wed Oct 12 03:32:47 2016 (r307097) @@ -171,24 +171,17 @@ vmbus_chan_sysctl_create(struct vmbus_ch chan, 0, vmbus_chan_sysctl_mnf, "I", "has monitor notification facilities"); - /* - * Create sysctl tree for RX bufring. - */ - br_tree = SYSCTL_ADD_NODE(ctx, SYSCTL_CHILDREN(chid_tree), OID_AUTO, - "in", CTLFLAG_RD | CTLFLAG_MPSAFE, 0, ""); - if (br_tree != NULL) { - hv_ring_buffer_stat(ctx, SYSCTL_CHILDREN(br_tree), - &chan->ch_rxbr, "inbound ring buffer stats"); - } - - /* - * Create sysctl tree for TX bufring. - */ br_tree = SYSCTL_ADD_NODE(ctx, SYSCTL_CHILDREN(chid_tree), OID_AUTO, - "out", CTLFLAG_RD | CTLFLAG_MPSAFE, 0, ""); + "br", CTLFLAG_RD | CTLFLAG_MPSAFE, 0, ""); if (br_tree != NULL) { - hv_ring_buffer_stat(ctx, SYSCTL_CHILDREN(br_tree), - &chan->ch_txbr, "outbound ring buffer stats"); + /* + * Create sysctl tree for RX bufring. + */ + vmbus_br_sysctl_create(ctx, br_tree, &chan->ch_rxbr, "rx"); + /* + * Create sysctl tree for TX bufring. + */ + vmbus_br_sysctl_create(ctx, br_tree, &chan->ch_txbr, "tx"); } } Modified: stable/10/sys/dev/hyperv/vmbus/vmbus_chanvar.h ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/vmbus_chanvar.h Wed Oct 12 03:18:17 2016 (r307096) +++ stable/10/sys/dev/hyperv/vmbus/vmbus_chanvar.h Wed Oct 12 03:32:47 2016 (r307097) @@ -41,31 +41,7 @@ #include typedef struct { - /* - * offset in bytes from the start of ring data below - */ - volatile uint32_t write_index; - /* - * offset in bytes from the start of ring data below - */ - volatile uint32_t read_index; - /* - * NOTE: The interrupt_mask field is used only for channels, but - * vmbus connection also uses this data structure - */ - volatile uint32_t interrupt_mask; - /* pad it to PAGE_SIZE so that data starts on a page */ - uint8_t reserved[4084]; - - /* - * WARNING: Ring data starts here - * !!! DO NOT place any fields below this !!! - */ - uint8_t buffer[0]; /* doubles as interrupt mask */ -} __packed hv_vmbus_ring_buffer; - -typedef struct { - hv_vmbus_ring_buffer* ring_buffer; + struct vmbus_bufring *ring_buffer; struct mtx ring_lock; uint32_t ring_data_size; /* ring_size */ } hv_vmbus_ring_buffer_info; Modified: stable/10/sys/dev/hyperv/vmbus/vmbus_reg.h ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/vmbus_reg.h Wed Oct 12 03:18:17 2016 (r307096) +++ stable/10/sys/dev/hyperv/vmbus/vmbus_reg.h Wed Oct 12 03:32:47 2016 (r307097) @@ -102,6 +102,37 @@ struct vmbus_mnf { CTASSERT(sizeof(struct vmbus_mnf) == PAGE_SIZE); /* + * Buffer ring + */ +struct vmbus_bufring { + /* + * If br_windex == br_rindex, this bufring is empty; this + * means we can _not_ write data to the bufring, if the + * write is going to make br_windex same as br_rindex. + */ + volatile uint32_t br_windex; + volatile uint32_t br_rindex; + + /* + * Interrupt mask {0,1} + * + * For TX bufring, host set this to 1, when it is processing + * the TX bufring, so that we can safely skip the TX event + * notification to host. + * + * For RX bufring, once this is set to 1 by us, host will not + * further dispatch interrupts to us, even if there are data + * pending on the RX bufring. This effectively disables the + * interrupt of the channel to which this RX bufring is attached. + */ + volatile uint32_t br_imask; + + uint8_t br_rsvd[4084]; + uint8_t br_data[]; +} __packed; +CTASSERT(sizeof(struct vmbus_bufring) == PAGE_SIZE); + +/* * Channel */ From owner-svn-src-all@freebsd.org Wed Oct 12 03:36:48 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 0B4EAC0EDC0; Wed, 12 Oct 2016 03:36:48 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id CE971BE6; Wed, 12 Oct 2016 03:36:47 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9C3akRR073332; Wed, 12 Oct 2016 03:36:46 GMT (envelope-from gonzo@FreeBSD.org) Received: (from gonzo@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9C3ak90073331; Wed, 12 Oct 2016 03:36:46 GMT (envelope-from gonzo@FreeBSD.org) Message-Id: <201610120336.u9C3ak90073331@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: gonzo set sender to gonzo@FreeBSD.org using -f From: Oleksandr Tymoshenko Date: Wed, 12 Oct 2016 03:36:46 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307098 - head/sys/dev/usb/controller X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Oct 2016 03:36:48 -0000 Author: gonzo Date: Wed Oct 12 03:36:46 2016 New Revision: 307098 URL: https://svnweb.freebsd.org/changeset/base/307098 Log: Make BCM28x USB driver compatible with upstream device tree This should have been committed in r307093: resource allocation depends on source of the device tree. upstream dts has extra interrupt that we can ignore Modified: head/sys/dev/usb/controller/dwc_otg_fdt.c Modified: head/sys/dev/usb/controller/dwc_otg_fdt.c ============================================================================== --- head/sys/dev/usb/controller/dwc_otg_fdt.c Wed Oct 12 03:32:47 2016 (r307097) +++ head/sys/dev/usb/controller/dwc_otg_fdt.c Wed Oct 12 03:36:46 2016 (r307098) @@ -121,7 +121,12 @@ dwc_otg_attach(device_t dev) sc->sc_otg.sc_io_hdl = rman_get_bushandle(sc->sc_otg.sc_io_res); sc->sc_otg.sc_io_size = rman_get_size(sc->sc_otg.sc_io_res); - rid = 0; + + /* + * brcm,bcm2708-usb FDT provides two interrupts, + * we need only second one (VC_USB) + */ + rid = ofw_bus_is_compatible(dev, "brcm,bcm2708-usb") ? 1 : 0; sc->sc_otg.sc_irq_res = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid, RF_ACTIVE); if (sc->sc_otg.sc_irq_res == NULL) From owner-svn-src-all@freebsd.org Wed Oct 12 03:37:45 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 5A1CFC0EE16; Wed, 12 Oct 2016 03:37:45 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 1E2D4D74; Wed, 12 Oct 2016 03:37:45 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9C3bi7r073414; Wed, 12 Oct 2016 03:37:44 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9C3bhjR073407; Wed, 12 Oct 2016 03:37:43 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610120337.u9C3bhjR073407@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Wed, 12 Oct 2016 03:37:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307099 - in stable/10/sys/dev/hyperv: netvsc vmbus X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Oct 2016 03:37:45 -0000 Author: sephe Date: Wed Oct 12 03:37:43 2016 New Revision: 307099 URL: https://svnweb.freebsd.org/changeset/base/307099 Log: MFC 303283 hyperv/vmbus: Rename hv_vmbus_priv.h to vmbus_brvar.h It only contains bufring related bits for a while. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7281 Added: stable/10/sys/dev/hyperv/vmbus/vmbus_brvar.h - copied unchanged from r303283, head/sys/dev/hyperv/vmbus/vmbus_brvar.h Deleted: stable/10/sys/dev/hyperv/vmbus/hv_vmbus_priv.h Modified: stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.c stable/10/sys/dev/hyperv/vmbus/hv_ring_buffer.c stable/10/sys/dev/hyperv/vmbus/hyperv.c stable/10/sys/dev/hyperv/vmbus/hyperv_reg.h stable/10/sys/dev/hyperv/vmbus/vmbus.c stable/10/sys/dev/hyperv/vmbus/vmbus_chan.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.c Wed Oct 12 03:36:46 2016 (r307098) +++ stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.c Wed Oct 12 03:37:43 2016 (r307099) @@ -47,7 +47,6 @@ __FBSDID("$FreeBSD$"); #include #include -#include #include "hv_net_vsc.h" #include "hv_rndis.h" #include "hv_rndis_filter.h" Modified: stable/10/sys/dev/hyperv/vmbus/hv_ring_buffer.c ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/hv_ring_buffer.c Wed Oct 12 03:36:46 2016 (r307098) +++ stable/10/sys/dev/hyperv/vmbus/hv_ring_buffer.c Wed Oct 12 03:37:43 2016 (r307099) @@ -34,8 +34,8 @@ __FBSDID("$FreeBSD$"); #include #include -#include "hv_vmbus_priv.h" #include +#include /* Amount of space to write to */ #define HV_BYTES_AVAIL_TO_WRITE(r, w, z) \ Modified: stable/10/sys/dev/hyperv/vmbus/hyperv.c ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/hyperv.c Wed Oct 12 03:36:46 2016 (r307098) +++ stable/10/sys/dev/hyperv/vmbus/hyperv.c Wed Oct 12 03:37:43 2016 (r307099) @@ -43,12 +43,14 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include -#include #include #include #include +#if 0 #include +#endif #define HYPERV_FREEBSD_BUILD 0ULL #define HYPERV_FREEBSD_VERSION ((uint64_t)__FreeBSD_version) Modified: stable/10/sys/dev/hyperv/vmbus/hyperv_reg.h ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/hyperv_reg.h Wed Oct 12 03:36:46 2016 (r307098) +++ stable/10/sys/dev/hyperv/vmbus/hyperv_reg.h Wed Oct 12 03:37:43 2016 (r307099) @@ -30,6 +30,7 @@ #define _HYPERV_REG_H_ #include +#include /* * Hyper-V Synthetic MSRs Modified: stable/10/sys/dev/hyperv/vmbus/vmbus.c ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/vmbus.c Wed Oct 12 03:36:46 2016 (r307098) +++ stable/10/sys/dev/hyperv/vmbus/vmbus.c Wed Oct 12 03:37:43 2016 (r307099) @@ -60,11 +60,11 @@ __FBSDID("$FreeBSD$"); #include #include -#include #include #include #include #include +#include #include #include "acpi_if.h" Copied: stable/10/sys/dev/hyperv/vmbus/vmbus_brvar.h (from r303283, head/sys/dev/hyperv/vmbus/vmbus_brvar.h) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/10/sys/dev/hyperv/vmbus/vmbus_brvar.h Wed Oct 12 03:37:43 2016 (r307099, copy of r303283, head/sys/dev/hyperv/vmbus/vmbus_brvar.h) @@ -0,0 +1,85 @@ +/*- + * Copyright (c) 2009-2012,2016 Microsoft Corp. + * Copyright (c) 2012 NetApp Inc. + * Copyright (c) 2012 Citrix Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice unmodified, 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 ``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 BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#ifndef __HYPERV_PRIV_H__ +#define __HYPERV_PRIV_H__ + +#include +#include +#include +#include +#include + +#include + +struct vmbus_softc; + +/* + * Private, VM Bus functions + */ +struct sysctl_ctx_list; +struct sysctl_oid; + +void vmbus_br_sysctl_create(struct sysctl_ctx_list *ctx, + struct sysctl_oid *br_tree, hv_vmbus_ring_buffer_info *br, + const char *name); + +int hv_vmbus_ring_buffer_init( + hv_vmbus_ring_buffer_info *ring_info, + void *buffer, + uint32_t buffer_len); + +void hv_ring_buffer_cleanup( + hv_vmbus_ring_buffer_info *ring_info); + +int hv_ring_buffer_write( + hv_vmbus_ring_buffer_info *ring_info, + const struct iovec iov[], + uint32_t iovlen, + boolean_t *need_sig); + +int hv_ring_buffer_peek( + hv_vmbus_ring_buffer_info *ring_info, + void *buffer, + uint32_t buffer_len); + +int hv_ring_buffer_read( + hv_vmbus_ring_buffer_info *ring_info, + void *buffer, + uint32_t buffer_len, + uint32_t offset); + +void hv_ring_buffer_read_begin( + hv_vmbus_ring_buffer_info *ring_info); + +uint32_t hv_ring_buffer_read_end( + hv_vmbus_ring_buffer_info *ring_info); + +#endif /* __HYPERV_PRIV_H__ */ Modified: stable/10/sys/dev/hyperv/vmbus/vmbus_chan.c ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/vmbus_chan.c Wed Oct 12 03:36:46 2016 (r307098) +++ stable/10/sys/dev/hyperv/vmbus/vmbus_chan.c Wed Oct 12 03:37:43 2016 (r307099) @@ -46,10 +46,11 @@ __FBSDID("$FreeBSD$"); #include #include -#include #include #include #include +#include +#include static void vmbus_chan_update_evtflagcnt(struct vmbus_softc *, const struct vmbus_channel *); From owner-svn-src-all@freebsd.org Wed Oct 12 05:04:37 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 6C824C0D62F; Wed, 12 Oct 2016 05:04:37 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 212C7DB4; Wed, 12 Oct 2016 05:04:37 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9C54acf008074; Wed, 12 Oct 2016 05:04:36 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9C54aGQ008073; Wed, 12 Oct 2016 05:04:36 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201610120504.u9C54aGQ008073@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Wed, 12 Oct 2016 05:04:36 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307100 - stable/11/cddl/contrib/opensolaris/lib/libzfs/common X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Oct 2016 05:04:37 -0000 Author: mav Date: Wed Oct 12 05:04:36 2016 New Revision: 307100 URL: https://svnweb.freebsd.org/changeset/base/307100 Log: MFC r305194: MFV r302642: 6876 Stack corruption after importing a pool with a too-long name illumos/illumos-gate@c971037baa5d64dfecf6d87ed602fc3116ebec41 https://github.com/illumos/illumos-gate/commit/c971037baa5d64dfecf6d87ed602fc3116ebec41 https://www.illumos.org/issues/6876 Calling dsl_dataset_name on a dataset with a 256 byte buffer is asking for trouble. We should check every dataset on import, using a 1024 byte buffer and checking each time to see if the dataset's new name is longer than 256 bytes. Reviewed by: Prakash Surya Reviewed by: Dan Kimmel Reviewed by: George Wilson Reviewed by: Yuri Pankov Approved by: Richard Lowe Author: Paul Dagnelie Modified: stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_pool.c Directory Properties: stable/11/ (props changed) Modified: stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_pool.c ============================================================================== --- stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_pool.c Wed Oct 12 03:37:43 2016 (r307099) +++ stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_pool.c Wed Oct 12 05:04:36 2016 (r307100) @@ -1799,7 +1799,12 @@ zpool_import_props(libzfs_handle_t *hdl, case EEXIST: (void) zpool_standard_error(hdl, error, desc); break; - + case ENAMETOOLONG: + zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, + "new name of at least one dataset is longer than " + "the maximum allowable length")); + (void) zfs_error(hdl, EZFS_NAMETOOLONG, desc); + break; default: (void) zpool_standard_error(hdl, error, desc); zpool_explain_recover(hdl, From owner-svn-src-all@freebsd.org Wed Oct 12 05:08:10 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C7408C0D705; Wed, 12 Oct 2016 05:08:10 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 9E64CF49; Wed, 12 Oct 2016 05:08:10 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9C589oU008261; Wed, 12 Oct 2016 05:08:09 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9C589Rr008257; Wed, 12 Oct 2016 05:08:09 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201610120508.u9C589Rr008257@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Wed, 12 Oct 2016 05:08:09 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307101 - in stable/11/sys/cddl/contrib/opensolaris: common/zfs uts/common/fs/zfs uts/common/fs/zfs/sys X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Oct 2016 05:08:10 -0000 Author: mav Date: Wed Oct 12 05:08:09 2016 New Revision: 307101 URL: https://svnweb.freebsd.org/changeset/base/307101 Log: MFC r305197: MFV r302646: 6980 6902 causes zfs send to break due to 32-bit/64-bit struct mismatch illumos/illumos-gate@ea4a67f462de0a39a9adea8197bcdef849de5371 https://github.com/illumos/illumos-gate/commit/ea4a67f462de0a39a9adea8197bcdef84 9de5371 https://www.illumos.org/issues/6980 doing zfs send -i snap1 snap2 >testfile results in internal error: Invalid argument Abort (core dumped) Reviewed by: Paul Dagnelie Reviewed by: George Wilson Approved by: Robert Mustacchi Author: Matthew Ahrens Modified: stable/11/sys/cddl/contrib/opensolaris/common/zfs/zfs_ioctl_compat.c stable/11/sys/cddl/contrib/opensolaris/common/zfs/zfs_ioctl_compat.h stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zfs_ioctl.h stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/cddl/contrib/opensolaris/common/zfs/zfs_ioctl_compat.c ============================================================================== --- stable/11/sys/cddl/contrib/opensolaris/common/zfs/zfs_ioctl_compat.c Wed Oct 12 05:04:36 2016 (r307100) +++ stable/11/sys/cddl/contrib/opensolaris/common/zfs/zfs_ioctl_compat.c Wed Oct 12 05:08:09 2016 (r307101) @@ -55,8 +55,52 @@ zfs_cmd_compat_get(zfs_cmd_t *zc, caddr_ zfs_cmd_zcmd_t *zcmd_c; zfs_cmd_edbp_t *edbp_c; zfs_cmd_resume_t *resume_c; + zfs_cmd_inlanes_t *inlanes_c; switch (cflag) { + case ZFS_CMD_COMPAT_INLANES: + inlanes_c = (void *)addr; + /* zc */ + strlcpy(zc->zc_name, inlanes_c->zc_name, MAXPATHLEN); + strlcpy(zc->zc_value, inlanes_c->zc_value, MAXPATHLEN * 2); + strlcpy(zc->zc_string, inlanes_c->zc_string, MAXPATHLEN); + +#define FIELD_COPY(field) zc->field = inlanes_c->field + FIELD_COPY(zc_nvlist_src); + FIELD_COPY(zc_nvlist_src_size); + FIELD_COPY(zc_nvlist_dst); + FIELD_COPY(zc_nvlist_dst_size); + FIELD_COPY(zc_nvlist_dst_filled); + FIELD_COPY(zc_pad2); + FIELD_COPY(zc_history); + FIELD_COPY(zc_guid); + FIELD_COPY(zc_nvlist_conf); + FIELD_COPY(zc_nvlist_conf_size); + FIELD_COPY(zc_cookie); + FIELD_COPY(zc_objset_type); + FIELD_COPY(zc_perm_action); + FIELD_COPY(zc_history_len); + FIELD_COPY(zc_history_offset); + FIELD_COPY(zc_obj); + FIELD_COPY(zc_iflags); + FIELD_COPY(zc_share); + FIELD_COPY(zc_jailid); + FIELD_COPY(zc_objset_stats); + FIELD_COPY(zc_begin_record); + FIELD_COPY(zc_inject_record); + FIELD_COPY(zc_defer_destroy); + FIELD_COPY(zc_flags); + FIELD_COPY(zc_action_handle); + FIELD_COPY(zc_cleanup_fd); + FIELD_COPY(zc_simple); + FIELD_COPY(zc_resumable); + FIELD_COPY(zc_sendobj); + FIELD_COPY(zc_fromobj); + FIELD_COPY(zc_createtxg); + FIELD_COPY(zc_stat); +#undef FIELD_COPY + break; + case ZFS_CMD_COMPAT_RESUME: resume_c = (void *)addr; /* zc */ @@ -434,8 +478,50 @@ zfs_cmd_compat_put(zfs_cmd_t *zc, caddr_ zfs_cmd_zcmd_t *zcmd_c; zfs_cmd_edbp_t *edbp_c; zfs_cmd_resume_t *resume_c; + zfs_cmd_inlanes_t *inlanes_c; switch (cflag) { + case ZFS_CMD_COMPAT_INLANES: + inlanes_c = (void *)addr; + strlcpy(inlanes_c->zc_name, zc->zc_name, MAXPATHLEN); + strlcpy(inlanes_c->zc_value, zc->zc_value, MAXPATHLEN * 2); + strlcpy(inlanes_c->zc_string, zc->zc_string, MAXPATHLEN); + +#define FIELD_COPY(field) inlanes_c->field = zc->field + FIELD_COPY(zc_nvlist_src); + FIELD_COPY(zc_nvlist_src_size); + FIELD_COPY(zc_nvlist_dst); + FIELD_COPY(zc_nvlist_dst_size); + FIELD_COPY(zc_nvlist_dst_filled); + FIELD_COPY(zc_pad2); + FIELD_COPY(zc_history); + FIELD_COPY(zc_guid); + FIELD_COPY(zc_nvlist_conf); + FIELD_COPY(zc_nvlist_conf_size); + FIELD_COPY(zc_cookie); + FIELD_COPY(zc_objset_type); + FIELD_COPY(zc_perm_action); + FIELD_COPY(zc_history_len); + FIELD_COPY(zc_history_offset); + FIELD_COPY(zc_obj); + FIELD_COPY(zc_iflags); + FIELD_COPY(zc_share); + FIELD_COPY(zc_jailid); + FIELD_COPY(zc_objset_stats); + FIELD_COPY(zc_begin_record); + FIELD_COPY(zc_inject_record); + FIELD_COPY(zc_defer_destroy); + FIELD_COPY(zc_flags); + FIELD_COPY(zc_action_handle); + FIELD_COPY(zc_cleanup_fd); + FIELD_COPY(zc_simple); + FIELD_COPY(zc_sendobj); + FIELD_COPY(zc_fromobj); + FIELD_COPY(zc_createtxg); + FIELD_COPY(zc_stat); +#undef FIELD_COPY + break; + case ZFS_CMD_COMPAT_RESUME: resume_c = (void *)addr; strlcpy(resume_c->zc_name, zc->zc_name, MAXPATHLEN); @@ -987,6 +1073,12 @@ zcmd_ioctl_compat(int fd, int request, z zp.zfs_cmd_size = sizeof(zfs_cmd_t); zp.zfs_ioctl_version = ZFS_IOCVER_CURRENT; return (ioctl(fd, ncmd, &zp)); + case ZFS_CMD_COMPAT_INLANES: + ncmd = _IOWR('Z', request, struct zfs_iocparm); + zp.zfs_cmd = (uint64_t)zc; + zp.zfs_cmd_size = sizeof(zfs_cmd_inlanes_t); + zp.zfs_ioctl_version = ZFS_IOCVER_INLANES; + return (ioctl(fd, ncmd, &zp)); case ZFS_CMD_COMPAT_RESUME: ncmd = _IOWR('Z', request, struct zfs_iocparm); zp.zfs_cmd = (uint64_t)zc; @@ -1104,7 +1196,7 @@ zfs_ioctl_compat_innvl(zfs_cmd_t *zc, nv if (cflag == ZFS_CMD_COMPAT_NONE || cflag == ZFS_CMD_COMPAT_LZC || cflag == ZFS_CMD_COMPAT_ZCMD || cflag == ZFS_CMD_COMPAT_EDBP || - cflag == ZFS_CMD_COMPAT_RESUME) + cflag == ZFS_CMD_COMPAT_RESUME || cflag == ZFS_CMD_COMPAT_INLANES) goto out; switch (vec) { @@ -1257,7 +1349,7 @@ zfs_ioctl_compat_outnvl(zfs_cmd_t *zc, n if (cflag == ZFS_CMD_COMPAT_NONE || cflag == ZFS_CMD_COMPAT_LZC || cflag == ZFS_CMD_COMPAT_ZCMD || cflag == ZFS_CMD_COMPAT_EDBP || - cflag == ZFS_CMD_COMPAT_RESUME) + cflag == ZFS_CMD_COMPAT_RESUME || cflag == ZFS_CMD_COMPAT_INLANES) return (outnvl); switch (vec) { Modified: stable/11/sys/cddl/contrib/opensolaris/common/zfs/zfs_ioctl_compat.h ============================================================================== --- stable/11/sys/cddl/contrib/opensolaris/common/zfs/zfs_ioctl_compat.h Wed Oct 12 05:04:36 2016 (r307100) +++ stable/11/sys/cddl/contrib/opensolaris/common/zfs/zfs_ioctl_compat.h Wed Oct 12 05:08:09 2016 (r307101) @@ -54,7 +54,8 @@ extern "C" { #define ZFS_IOCVER_EDBP 4 #define ZFS_IOCVER_RESUME 5 #define ZFS_IOCVER_INLANES 6 -#define ZFS_IOCVER_CURRENT ZFS_IOCVER_INLANES +#define ZFS_IOCVER_PAD 7 +#define ZFS_IOCVER_CURRENT ZFS_IOCVER_PAD /* compatibility conversion flag */ #define ZFS_CMD_COMPAT_NONE 0 @@ -65,6 +66,7 @@ extern "C" { #define ZFS_CMD_COMPAT_ZCMD 5 #define ZFS_CMD_COMPAT_EDBP 6 #define ZFS_CMD_COMPAT_RESUME 7 +#define ZFS_CMD_COMPAT_INLANES 8 #define ZFS_IOC_COMPAT_PASS 254 #define ZFS_IOC_COMPAT_FAIL 255 @@ -355,6 +357,49 @@ typedef struct zfs_cmd_resume { zfs_stat_t zc_stat; } zfs_cmd_resume_t; +typedef struct zfs_cmd_inlanes { + char zc_name[MAXPATHLEN]; /* name of pool or dataset */ + uint64_t zc_nvlist_src; /* really (char *) */ + uint64_t zc_nvlist_src_size; + uint64_t zc_nvlist_dst; /* really (char *) */ + uint64_t zc_nvlist_dst_size; + boolean_t zc_nvlist_dst_filled; /* put an nvlist in dst? */ + int zc_pad2; + + /* + * The following members are for legacy ioctls which haven't been + * converted to the new method. + */ + uint64_t zc_history; /* really (char *) */ + char zc_value[MAXPATHLEN * 2]; + char zc_string[MAXNAMELEN]; + uint64_t zc_guid; + uint64_t zc_nvlist_conf; /* really (char *) */ + uint64_t zc_nvlist_conf_size; + uint64_t zc_cookie; + uint64_t zc_objset_type; + uint64_t zc_perm_action; + uint64_t zc_history_len; + uint64_t zc_history_offset; + uint64_t zc_obj; + uint64_t zc_iflags; /* internal to zfs(7fs) */ + zfs_share_t zc_share; + uint64_t zc_jailid; + dmu_objset_stats_t zc_objset_stats; + dmu_replay_record_t zc_begin_record; + zinject_record_t zc_inject_record; + uint32_t zc_defer_destroy; + uint32_t zc_flags; + uint64_t zc_action_handle; + int zc_cleanup_fd; + uint8_t zc_simple; + boolean_t zc_resumable; + uint64_t zc_sendobj; + uint64_t zc_fromobj; + uint64_t zc_createtxg; + zfs_stat_t zc_stat; +} zfs_cmd_inlanes_t; + #ifdef _KERNEL unsigned static long zfs_ioctl_v15_to_v28[] = { 0, /* 0 ZFS_IOC_POOL_CREATE */ Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zfs_ioctl.h ============================================================================== --- stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zfs_ioctl.h Wed Oct 12 05:04:36 2016 (r307100) +++ stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zfs_ioctl.h Wed Oct 12 05:08:09 2016 (r307101) @@ -353,6 +353,12 @@ typedef enum zfs_case { ZFS_CASE_MIXED } zfs_case_t; +/* + * Note: this struct must have the same layout in 32-bit and 64-bit, so + * that 32-bit processes (like /sbin/zfs) can pass it to the 64-bit + * kernel. Therefore, we add padding to it so that no "hidden" padding + * is automatically added on 64-bit (but not on 32-bit). + */ typedef struct zfs_cmd { char zc_name[MAXPATHLEN]; /* name of pool or dataset */ uint64_t zc_nvlist_src; /* really (char *) */ @@ -389,7 +395,9 @@ typedef struct zfs_cmd { uint64_t zc_action_handle; int zc_cleanup_fd; uint8_t zc_simple; + uint8_t zc_pad3[3]; boolean_t zc_resumable; + uint32_t zc_pad4; uint64_t zc_sendobj; uint64_t zc_fromobj; uint64_t zc_createtxg; Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c ============================================================================== --- stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c Wed Oct 12 05:04:36 2016 (r307100) +++ stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c Wed Oct 12 05:08:09 2016 (r307101) @@ -6252,6 +6252,14 @@ zfsdev_ioctl(struct cdev *dev, u_long zc goto out; } break; + case ZFS_IOCVER_INLANES: + if (zc_iocparm->zfs_cmd_size != sizeof(zfs_cmd_inlanes_t)) { + error = SET_ERROR(EFAULT); + goto out; + } + compat = B_TRUE; + cflag = ZFS_CMD_COMPAT_INLANES; + break; case ZFS_IOCVER_RESUME: if (zc_iocparm->zfs_cmd_size != sizeof(zfs_cmd_resume_t)) { error = SET_ERROR(EFAULT); From owner-svn-src-all@freebsd.org Wed Oct 12 05:09:23 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id F03C5C0D83B; Wed, 12 Oct 2016 05:09:23 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id CB539117D; Wed, 12 Oct 2016 05:09:23 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9C59Mx2008356; Wed, 12 Oct 2016 05:09:22 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9C59MMx008355; Wed, 12 Oct 2016 05:09:22 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201610120509.u9C59MMx008355@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Wed, 12 Oct 2016 05:09:22 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307102 - stable/11/cddl/contrib/opensolaris/lib/libzfs/common X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Oct 2016 05:09:24 -0000 Author: mav Date: Wed Oct 12 05:09:22 2016 New Revision: 307102 URL: https://svnweb.freebsd.org/changeset/base/307102 Log: MFC r305201: MFV r302653: 6111 zfs send should ignore datasets created after the ending snapshot illumos/illumos-gate@4a20c933b148de8a1c1d3538391c64284e636653 https://github.com/illumos/illumos-gate/commit/4a20c933b148de8a1c1d3538391c64284 e636653 https://www.illumos.org/issues/6111 If you create a zfs child folder, zfs send returns an error when a recursive incremental send is done between two snapshots made prior to the folder creation. The problem can be reproduced with the following steps. root@zfs:/# zfs create pool/test root@zfs:/# zfs snapshot pool/test@snap1 root@zfs:/# zfs snapshot pool/test@snap2 root@zfs:/# zfs create pool/test/child root@zfs:/# zfs send -R -I pool/test@snap1 pool/test@snap2 > /dev/null WARNING: could not send pool/test/child@snap2: does not exist WARNING: could not send pool/test/child@snap2: does not exist root@zfs:/# echo $? 1 root@zfs:/# zfs snapshot -r pool/test@snap3 root@zfs:/# zfs send -R -I pool/test@snap1 pool/test@snap3 > /dev/null root@zfs:/# echo $? 0 root@zfs:/# zfs send -R -I pool/test@snap2 pool/test@snap3 > /dev/null root@zfs:/# echo $? 0 Since pool/test/child was created after snap2, zfs send should not expect snap2 to be in pool/test/child when doing a recursive send. It should examine the compare the creation time of the snapshot and each child folder to decide if the folder will be sent. The next incremental send between snap2 and snap3 would properly create the child folder and snap3 which first appears in the child folder. The problem is identical if '-i' is used instead of '-I'. Reviewed by: Alex Aizman alex.aizman@nexenta.com Reviewed by: Alek Pinchuk alek.pinchuk@nexenta.com Reviewed by: Roman Strashkin roman.strashkin@nexenta.com Reviewed by: Matthew Ahrens Reviewed by: Paul Dagnelie Approved by: Garrett D'Amore Author: Alex Deiter Modified: stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c Directory Properties: stable/11/ (props changed) Modified: stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c ============================================================================== --- stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c Wed Oct 12 05:08:09 2016 (r307101) +++ stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c Wed Oct 12 05:09:22 2016 (r307102) @@ -580,13 +580,30 @@ fsavl_create(nvlist_t *fss) * Routines for dealing with the giant nvlist of fs-nvlists, etc. */ typedef struct send_data { + /* + * assigned inside every recursive call, + * restored from *_save on return: + * + * guid of fromsnap snapshot in parent dataset + * txg of fromsnap snapshot in current dataset + * txg of tosnap snapshot in current dataset + */ + uint64_t parent_fromsnap_guid; + uint64_t fromsnap_txg; + uint64_t tosnap_txg; + + /* the nvlists get accumulated during depth-first traversal */ nvlist_t *parent_snaps; nvlist_t *fss; nvlist_t *snapprops; + + /* send-receive configuration, does not change during traversal */ + const char *fsname; const char *fromsnap; const char *tosnap; boolean_t recursive; + boolean_t verbose; /* * The header nvlist is of the following format: @@ -619,11 +636,23 @@ send_iterate_snap(zfs_handle_t *zhp, voi { send_data_t *sd = arg; uint64_t guid = zhp->zfs_dmustats.dds_guid; + uint64_t txg = zhp->zfs_dmustats.dds_creation_txg; char *snapname; nvlist_t *nv; snapname = strrchr(zhp->zfs_name, '@')+1; + if (sd->tosnap_txg != 0 && txg > sd->tosnap_txg) { + if (sd->verbose) { + (void) fprintf(stderr, dgettext(TEXT_DOMAIN, + "skipping snapshot %s because it was created " + "after the destination snapshot (%s)\n"), + zhp->zfs_name, sd->tosnap); + } + zfs_close(zhp); + return (0); + } + VERIFY(0 == nvlist_add_uint64(sd->parent_snaps, snapname, guid)); /* * NB: if there is no fromsnap here (it's a newly created fs in @@ -717,6 +746,31 @@ send_iterate_prop(zfs_handle_t *zhp, nvl } /* + * returns snapshot creation txg + * and returns 0 if the snapshot does not exist + */ +static uint64_t +get_snap_txg(libzfs_handle_t *hdl, const char *fs, const char *snap) +{ + char name[ZFS_MAXNAMELEN]; + uint64_t txg = 0; + + if (fs == NULL || fs[0] == '\0' || snap == NULL || snap[0] == '\0') + return (txg); + + (void) snprintf(name, sizeof (name), "%s@%s", fs, snap); + if (zfs_dataset_exists(hdl, name, ZFS_TYPE_SNAPSHOT)) { + zfs_handle_t *zhp = zfs_open(hdl, name, ZFS_TYPE_SNAPSHOT); + if (zhp != NULL) { + txg = zfs_prop_get_int(zhp, ZFS_PROP_CREATETXG); + zfs_close(zhp); + } + } + + return (txg); +} + +/* * recursively generate nvlists describing datasets. See comment * for the data structure send_data_t above for description of contents * of the nvlist. @@ -728,9 +782,48 @@ send_iterate_fs(zfs_handle_t *zhp, void nvlist_t *nvfs, *nv; int rv = 0; uint64_t parent_fromsnap_guid_save = sd->parent_fromsnap_guid; + uint64_t fromsnap_txg_save = sd->fromsnap_txg; + uint64_t tosnap_txg_save = sd->tosnap_txg; + uint64_t txg = zhp->zfs_dmustats.dds_creation_txg; uint64_t guid = zhp->zfs_dmustats.dds_guid; + uint64_t fromsnap_txg, tosnap_txg; char guidstring[64]; + fromsnap_txg = get_snap_txg(zhp->zfs_hdl, zhp->zfs_name, sd->fromsnap); + if (fromsnap_txg != 0) + sd->fromsnap_txg = fromsnap_txg; + + tosnap_txg = get_snap_txg(zhp->zfs_hdl, zhp->zfs_name, sd->tosnap); + if (tosnap_txg != 0) + sd->tosnap_txg = tosnap_txg; + + /* + * on the send side, if the current dataset does not have tosnap, + * perform two additional checks: + * + * - skip sending the current dataset if it was created later than + * the parent tosnap + * - return error if the current dataset was created earlier than + * the parent tosnap + */ + if (sd->tosnap != NULL && tosnap_txg == 0) { + if (sd->tosnap_txg != 0 && txg > sd->tosnap_txg) { + if (sd->verbose) { + (void) fprintf(stderr, dgettext(TEXT_DOMAIN, + "skipping dataset %s: snapshot %s does " + "not exist\n"), zhp->zfs_name, sd->tosnap); + } + } else { + (void) fprintf(stderr, dgettext(TEXT_DOMAIN, + "cannot send %s@%s%s: snapshot %s@%s does not " + "exist\n"), sd->fsname, sd->tosnap, sd->recursive ? + dgettext(TEXT_DOMAIN, " recursively") : "", + zhp->zfs_name, sd->tosnap); + rv = -1; + } + goto out; + } + VERIFY(0 == nvlist_alloc(&nvfs, NV_UNIQUE_NAME, 0)); VERIFY(0 == nvlist_add_string(nvfs, "name", zhp->zfs_name)); VERIFY(0 == nvlist_add_uint64(nvfs, "parentfromsnap", @@ -739,8 +832,10 @@ send_iterate_fs(zfs_handle_t *zhp, void if (zhp->zfs_dmustats.dds_origin[0]) { zfs_handle_t *origin = zfs_open(zhp->zfs_hdl, zhp->zfs_dmustats.dds_origin, ZFS_TYPE_SNAPSHOT); - if (origin == NULL) - return (-1); + if (origin == NULL) { + rv = -1; + goto out; + } VERIFY(0 == nvlist_add_uint64(nvfs, "origin", origin->zfs_dmustats.dds_guid)); } @@ -771,7 +866,10 @@ send_iterate_fs(zfs_handle_t *zhp, void if (sd->recursive) rv = zfs_iter_filesystems(zhp, send_iterate_fs, sd); +out: sd->parent_fromsnap_guid = parent_fromsnap_guid_save; + sd->fromsnap_txg = fromsnap_txg_save; + sd->tosnap_txg = tosnap_txg_save; zfs_close(zhp); return (rv); @@ -779,7 +877,8 @@ send_iterate_fs(zfs_handle_t *zhp, void static int gather_nvlist(libzfs_handle_t *hdl, const char *fsname, const char *fromsnap, - const char *tosnap, boolean_t recursive, nvlist_t **nvlp, avl_tree_t **avlp) + const char *tosnap, boolean_t recursive, boolean_t verbose, + nvlist_t **nvlp, avl_tree_t **avlp) { zfs_handle_t *zhp; send_data_t sd = { 0 }; @@ -790,9 +889,11 @@ gather_nvlist(libzfs_handle_t *hdl, cons return (EZFS_BADTYPE); VERIFY(0 == nvlist_alloc(&sd.fss, NV_UNIQUE_NAME, 0)); + sd.fsname = fsname; sd.fromsnap = fromsnap; sd.tosnap = tosnap; sd.recursive = recursive; + sd.verbose = verbose; if ((error = send_iterate_fs(zhp, &sd)) != 0) { nvlist_free(sd.fss); @@ -1700,7 +1801,8 @@ zfs_send(zfs_handle_t *zhp, const char * } err = gather_nvlist(zhp->zfs_hdl, zhp->zfs_name, - fromsnap, tosnap, flags->replicate, &fss, &fsavl); + fromsnap, tosnap, flags->replicate, flags->verbose, + &fss, &fsavl); if (err) goto err_out; VERIFY(0 == nvlist_add_nvlist(hdrnv, "fss", fss)); @@ -2316,7 +2418,7 @@ again: VERIFY(0 == nvlist_alloc(&deleted, NV_UNIQUE_NAME, 0)); if ((error = gather_nvlist(hdl, tofs, fromsnap, NULL, - recursive, &local_nv, &local_avl)) != 0) + recursive, B_FALSE, &local_nv, &local_avl)) != 0) return (error); /* @@ -3380,7 +3482,7 @@ zfs_receive_one(libzfs_handle_t *hdl, in */ *cp = '\0'; if (gather_nvlist(hdl, zc.zc_value, NULL, NULL, B_FALSE, - &local_nv, &local_avl) == 0) { + B_FALSE, &local_nv, &local_avl) == 0) { *cp = '@'; fs = fsavl_find(local_avl, drrb->drr_toguid, NULL); fsavl_destroy(local_avl); From owner-svn-src-all@freebsd.org Wed Oct 12 05:09:28 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B5A1DC0D8A6; Wed, 12 Oct 2016 05:09:28 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 50A0311B1; Wed, 12 Oct 2016 05:09:28 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9C59RPK008406; Wed, 12 Oct 2016 05:09:27 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9C59Rjh008401; Wed, 12 Oct 2016 05:09:27 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610120509.u9C59Rjh008401@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Wed, 12 Oct 2016 05:09:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307103 - stable/10/sys/dev/hyperv/vmbus X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Oct 2016 05:09:29 -0000 Author: sephe Date: Wed Oct 12 05:09:26 2016 New Revision: 307103 URL: https://svnweb.freebsd.org/changeset/base/307103 Log: MFC 303284,303329,303361,303362,303366,303368-303370 303284 hyperv/vmbus: Move bufring info definition to vmbus_brvar.h Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7282 303329 hyperv/vmbus: Nuke unnecessary accessor functions. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7303 303361 hyperv/vmbus: Initialize RX/TX bufring mutex at channel creation time Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7312 303362 hyperv/vmbus: Use different struct for RX/TX bufring. So that they can use suitable MP synchronization mechanism. While I'm here change the bufring init/read/write function names. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7313 303366 hyperv/vmbus: Update comment for bufring Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7314 303368 hyperv/vmbus: Cleanup TX bufring write process. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7315 303369 hyperv/vmbus: Stringent RX bufring data length checks. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7316 303370 hyperv/vmbus: Cleanup RX bufring read process. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7317 Modified: stable/10/sys/dev/hyperv/vmbus/hv_ring_buffer.c stable/10/sys/dev/hyperv/vmbus/vmbus_brvar.h stable/10/sys/dev/hyperv/vmbus/vmbus_chan.c stable/10/sys/dev/hyperv/vmbus/vmbus_chanvar.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/hyperv/vmbus/hv_ring_buffer.c ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/hv_ring_buffer.c Wed Oct 12 05:09:22 2016 (r307102) +++ stable/10/sys/dev/hyperv/vmbus/hv_ring_buffer.c Wed Oct 12 05:09:26 2016 (r307103) @@ -37,32 +37,29 @@ __FBSDID("$FreeBSD$"); #include #include -/* Amount of space to write to */ -#define HV_BYTES_AVAIL_TO_WRITE(r, w, z) \ - ((w) >= (r)) ? ((z) - ((w) - (r))) : ((r) - (w)) - -static uint32_t copy_to_ring_buffer(hv_vmbus_ring_buffer_info *ring_info, - uint32_t start_write_offset, const uint8_t *src, - uint32_t src_len); -static uint32_t copy_from_ring_buffer(hv_vmbus_ring_buffer_info *ring_info, - char *dest, uint32_t dest_len, uint32_t start_read_offset); +/* Amount of space available for write */ +#define VMBUS_BR_WAVAIL(r, w, z) \ + (((w) >= (r)) ? ((z) - ((w) - (r))) : ((r) - (w))) + +/* Increase bufing index */ +#define VMBUS_BR_IDXINC(idx, inc, sz) (((idx) + (inc)) % (sz)) static int vmbus_br_sysctl_state(SYSCTL_HANDLER_ARGS) { - const hv_vmbus_ring_buffer_info *br = arg1; - uint32_t rindex, windex, intr_mask, ravail, wavail; + const struct vmbus_br *br = arg1; + uint32_t rindex, windex, imask, ravail, wavail; char state[256]; - rindex = br->ring_buffer->br_rindex; - windex = br->ring_buffer->br_windex; - intr_mask = br->ring_buffer->br_imask; - wavail = HV_BYTES_AVAIL_TO_WRITE(rindex, windex, br->ring_data_size); - ravail = br->ring_data_size - wavail; + rindex = br->vbr_rindex; + windex = br->vbr_windex; + imask = br->vbr_imask; + wavail = VMBUS_BR_WAVAIL(rindex, windex, br->vbr_dsize); + ravail = br->vbr_dsize - wavail; snprintf(state, sizeof(state), - "rindex:%u windex:%u intr_mask:%u ravail:%u wavail:%u", - rindex, windex, intr_mask, ravail, wavail); + "rindex:%u windex:%u imask:%u ravail:%u wavail:%u", + rindex, windex, imask, ravail, wavail); return sysctl_handle_string(oidp, state, sizeof(state), req); } @@ -79,25 +76,25 @@ vmbus_br_sysctl_state_bin(SYSCTL_HANDLER #define BR_STATE_WSPC 4 #define BR_STATE_MAX 5 - const hv_vmbus_ring_buffer_info *br = arg1; + const struct vmbus_br *br = arg1; uint32_t rindex, windex, wavail, state[BR_STATE_MAX]; - rindex = br->ring_buffer->br_rindex; - windex = br->ring_buffer->br_windex; - wavail = HV_BYTES_AVAIL_TO_WRITE(rindex, windex, br->ring_data_size); + rindex = br->vbr_rindex; + windex = br->vbr_windex; + wavail = VMBUS_BR_WAVAIL(rindex, windex, br->vbr_dsize); state[BR_STATE_RIDX] = rindex; state[BR_STATE_WIDX] = windex; - state[BR_STATE_IMSK] = br->ring_buffer->br_imask; + state[BR_STATE_IMSK] = br->vbr_imask; state[BR_STATE_WSPC] = wavail; - state[BR_STATE_RSPC] = br->ring_data_size - wavail; + state[BR_STATE_RSPC] = br->vbr_dsize - wavail; return sysctl_handle_opaque(oidp, state, sizeof(state), req); } void vmbus_br_sysctl_create(struct sysctl_ctx_list *ctx, struct sysctl_oid *br_tree, - hv_vmbus_ring_buffer_info *br, const char *name) + struct vmbus_br *br, const char *name) { struct sysctl_oid *tree; char desc[64]; @@ -118,342 +115,291 @@ vmbus_br_sysctl_create(struct sysctl_ctx br, 0, vmbus_br_sysctl_state_bin, "IU", desc); } -/** - * @brief Get number of bytes available to read and to write to - * for the specified ring buffer - */ -static __inline void -get_ring_buffer_avail_bytes(hv_vmbus_ring_buffer_info *rbi, uint32_t *read, - uint32_t *write) +void +vmbus_rxbr_intr_mask(struct vmbus_rxbr *rbr) { - uint32_t read_loc, write_loc; - - /* - * Capture the read/write indices before they changed - */ - read_loc = rbi->ring_buffer->br_rindex; - write_loc = rbi->ring_buffer->br_windex; - - *write = HV_BYTES_AVAIL_TO_WRITE(read_loc, write_loc, - rbi->ring_data_size); - *read = rbi->ring_data_size - *write; + rbr->rxbr_imask = 1; + mb(); } -/** - * @brief Get the next write location for the specified ring buffer - */ static __inline uint32_t -get_next_write_location(hv_vmbus_ring_buffer_info *ring_info) +vmbus_rxbr_avail(const struct vmbus_rxbr *rbr) { - return ring_info->ring_buffer->br_windex; -} + uint32_t rindex, windex; -/** - * @brief Set the next write location for the specified ring buffer - */ -static __inline void -set_next_write_location(hv_vmbus_ring_buffer_info *ring_info, - uint32_t next_write_location) -{ - ring_info->ring_buffer->br_windex = next_write_location; -} + /* Get snapshot */ + rindex = rbr->rxbr_rindex; + windex = rbr->rxbr_windex; -/** - * @brief Get the next read location for the specified ring buffer - */ -static __inline uint32_t -get_next_read_location(hv_vmbus_ring_buffer_info *ring_info) -{ - return ring_info->ring_buffer->br_rindex; + return (rbr->rxbr_dsize - + VMBUS_BR_WAVAIL(rindex, windex, rbr->rxbr_dsize)); } -/** - * @brief Get the next read location + offset for the specified ring buffer. - * This allows the caller to skip. - */ -static __inline uint32_t -get_next_read_location_with_offset(hv_vmbus_ring_buffer_info *ring_info, - uint32_t offset) +uint32_t +vmbus_rxbr_intr_unmask(struct vmbus_rxbr *rbr) { - uint32_t next = ring_info->ring_buffer->br_rindex; + rbr->rxbr_imask = 0; + mb(); - next += offset; - next %= ring_info->ring_data_size; - return (next); + /* + * Now check to see if the ring buffer is still empty. + * If it is not, we raced and we need to process new + * incoming channel packets. + */ + return vmbus_rxbr_avail(rbr); } -/** - * @brief Set the next read location for the specified ring buffer - */ -static __inline void -set_next_read_location(hv_vmbus_ring_buffer_info *ring_info, - uint32_t next_read_location) +static void +vmbus_br_setup(struct vmbus_br *br, void *buf, int blen) { - ring_info->ring_buffer->br_rindex = next_read_location; + br->vbr = buf; + br->vbr_dsize = blen - sizeof(struct vmbus_bufring); } -/** - * @brief Get the start of the ring buffer - */ -static __inline void * -get_ring_buffer(hv_vmbus_ring_buffer_info *ring_info) +void +vmbus_rxbr_init(struct vmbus_rxbr *rbr) { - return ring_info->ring_buffer->br_data; + mtx_init(&rbr->rxbr_lock, "vmbus_rxbr", NULL, MTX_SPIN); } -/** - * @brief Get the size of the ring buffer. - */ -static __inline uint32_t -get_ring_buffer_size(hv_vmbus_ring_buffer_info *ring_info) +void +vmbus_rxbr_deinit(struct vmbus_rxbr *rbr) { - return ring_info->ring_data_size; + mtx_destroy(&rbr->rxbr_lock); } -/** - * Get the read and write indices as uint64_t of the specified ring buffer. - */ -static __inline uint64_t -get_ring_buffer_indices(hv_vmbus_ring_buffer_info *ring_info) +void +vmbus_rxbr_setup(struct vmbus_rxbr *rbr, void *buf, int blen) { - return ((uint64_t)ring_info->ring_buffer->br_windex) << 32; + vmbus_br_setup(&rbr->rxbr, buf, blen); } void -hv_ring_buffer_read_begin(hv_vmbus_ring_buffer_info *ring_info) +vmbus_txbr_init(struct vmbus_txbr *tbr) { - ring_info->ring_buffer->br_imask = 1; - mb(); + mtx_init(&tbr->txbr_lock, "vmbus_txbr", NULL, MTX_SPIN); } -uint32_t -hv_ring_buffer_read_end(hv_vmbus_ring_buffer_info *ring_info) +void +vmbus_txbr_deinit(struct vmbus_txbr *tbr) { - uint32_t read, write; - - ring_info->ring_buffer->br_imask = 0; - mb(); + mtx_destroy(&tbr->txbr_lock); +} - /* - * Now check to see if the ring buffer is still empty. - * If it is not, we raced and we need to process new - * incoming messages. - */ - get_ring_buffer_avail_bytes(ring_info, &read, &write); - return (read); +void +vmbus_txbr_setup(struct vmbus_txbr *tbr, void *buf, int blen) +{ + vmbus_br_setup(&tbr->txbr, buf, blen); } /* - * When we write to the ring buffer, check if the host needs to - * be signaled. Here is the details of this protocol: - * - * 1. The host guarantees that while it is draining the - * ring buffer, it will set the interrupt_mask to - * indicate it does not need to be interrupted when - * new data is placed. + * When we write to the ring buffer, check if the host needs to be + * signaled. * - * 2. The host guarantees that it will completely drain - * the ring buffer before exiting the read loop. Further, - * once the ring buffer is empty, it will clear the - * interrupt_mask and re-check to see if new data has - * arrived. + * The contract: + * - The host guarantees that while it is draining the TX bufring, + * it will set the br_imask to indicate it does not need to be + * interrupted when new data are added. + * - The host guarantees that it will completely drain the TX bufring + * before exiting the read loop. Further, once the TX bufring is + * empty, it will clear the br_imask and re-check to see if new + * data have arrived. */ -static boolean_t -hv_ring_buffer_needsig_on_write(uint32_t old_write_location, - hv_vmbus_ring_buffer_info *rbi) +static __inline boolean_t +vmbus_txbr_need_signal(const struct vmbus_txbr *tbr, uint32_t old_windex) { mb(); - if (rbi->ring_buffer->br_imask) + if (tbr->txbr_imask) return (FALSE); + /* XXX only compiler fence is needed */ /* Read memory barrier */ rmb(); + /* * This is the only case we need to signal when the * ring transitions from being empty to non-empty. */ - if (old_write_location == rbi->ring_buffer->br_rindex) + if (old_windex == tbr->txbr_rindex) return (TRUE); return (FALSE); } -/** - * @brief Initialize the ring buffer. - */ -int -hv_vmbus_ring_buffer_init(hv_vmbus_ring_buffer_info *ring_info, void *buffer, - uint32_t buffer_len) +static __inline uint32_t +vmbus_txbr_avail(const struct vmbus_txbr *tbr) { - memset(ring_info, 0, sizeof(hv_vmbus_ring_buffer_info)); - - ring_info->ring_buffer = buffer; - ring_info->ring_buffer->br_rindex = 0; - ring_info->ring_buffer->br_windex = 0; + uint32_t rindex, windex; - ring_info->ring_data_size = buffer_len - sizeof(struct vmbus_bufring); - mtx_init(&ring_info->ring_lock, "vmbus ring buffer", NULL, MTX_SPIN); + /* Get snapshot */ + rindex = tbr->txbr_rindex; + windex = tbr->txbr_windex; - return (0); + return VMBUS_BR_WAVAIL(rindex, windex, tbr->txbr_dsize); } -/** - * @brief Cleanup the ring buffer. - */ -void -hv_ring_buffer_cleanup(hv_vmbus_ring_buffer_info *ring_info) +static __inline uint32_t +vmbus_txbr_copyto(const struct vmbus_txbr *tbr, uint32_t windex, + const void *src0, uint32_t cplen) { - mtx_destroy(&ring_info->ring_lock); + const uint8_t *src = src0; + uint8_t *br_data = tbr->txbr_data; + uint32_t br_dsize = tbr->txbr_dsize; + + if (cplen > br_dsize - windex) { + uint32_t fraglen = br_dsize - windex; + + /* Wrap-around detected */ + memcpy(br_data + windex, src, fraglen); + memcpy(br_data, src + fraglen, cplen - fraglen); + } else { + memcpy(br_data + windex, src, cplen); + } + return VMBUS_BR_IDXINC(windex, cplen, br_dsize); } -/** - * @brief Write to the ring buffer. +/* + * Write scattered channel packet to TX bufring. + * + * The offset of this channel packet is written as a 64bits value + * immediately after this channel packet. */ int -hv_ring_buffer_write(hv_vmbus_ring_buffer_info *out_ring_info, - const struct iovec iov[], uint32_t iovlen, boolean_t *need_sig) +vmbus_txbr_write(struct vmbus_txbr *tbr, const struct iovec iov[], int iovlen, + boolean_t *need_sig) { - int i = 0; - uint32_t byte_avail_to_write; - uint32_t byte_avail_to_read; - uint32_t old_write_location; - uint32_t total_bytes_to_write = 0; - volatile uint32_t next_write_location; - uint64_t prev_indices = 0; + uint32_t old_windex, windex, total; + uint64_t save_windex; + int i; + total = 0; for (i = 0; i < iovlen; i++) - total_bytes_to_write += iov[i].iov_len; + total += iov[i].iov_len; + total += sizeof(save_windex); - total_bytes_to_write += sizeof(uint64_t); - - mtx_lock_spin(&out_ring_info->ring_lock); - - get_ring_buffer_avail_bytes(out_ring_info, &byte_avail_to_read, - &byte_avail_to_write); + mtx_lock_spin(&tbr->txbr_lock); /* - * If there is only room for the packet, assume it is full. - * Otherwise, the next time around, we think the ring buffer - * is empty since the read index == write index + * NOTE: + * If this write is going to make br_windex same as br_rindex, + * i.e. the available space for write is same as the write size, + * we can't do it then, since br_windex == br_rindex means that + * the bufring is empty. */ - if (byte_avail_to_write <= total_bytes_to_write) { - mtx_unlock_spin(&out_ring_info->ring_lock); + if (vmbus_txbr_avail(tbr) <= total) { + mtx_unlock_spin(&tbr->txbr_lock); return (EAGAIN); } + /* Save br_windex for later use */ + old_windex = tbr->txbr_windex; + /* - * Write to the ring buffer + * Copy the scattered channel packet to the TX bufring. */ - next_write_location = get_next_write_location(out_ring_info); - - old_write_location = next_write_location; - + windex = old_windex; for (i = 0; i < iovlen; i++) { - next_write_location = copy_to_ring_buffer(out_ring_info, - next_write_location, iov[i].iov_base, iov[i].iov_len); + windex = vmbus_txbr_copyto(tbr, windex, + iov[i].iov_base, iov[i].iov_len); } /* - * Set previous packet start + * Set the offset of the current channel packet. */ - prev_indices = get_ring_buffer_indices(out_ring_info); - - next_write_location = copy_to_ring_buffer(out_ring_info, - next_write_location, (char *)&prev_indices, sizeof(uint64_t)); + save_windex = ((uint64_t)old_windex) << 32; + windex = vmbus_txbr_copyto(tbr, windex, &save_windex, + sizeof(save_windex)); /* + * XXX only compiler fence is needed. * Full memory barrier before upding the write index. */ mb(); /* - * Now, update the write location + * Update the write index _after_ the channel packet + * is copied. */ - set_next_write_location(out_ring_info, next_write_location); + tbr->txbr_windex = windex; - mtx_unlock_spin(&out_ring_info->ring_lock); + mtx_unlock_spin(&tbr->txbr_lock); - *need_sig = hv_ring_buffer_needsig_on_write(old_write_location, - out_ring_info); + *need_sig = vmbus_txbr_need_signal(tbr, old_windex); return (0); } -/** - * @brief Read without advancing the read index. - */ -int -hv_ring_buffer_peek(hv_vmbus_ring_buffer_info *in_ring_info, void *buffer, - uint32_t buffer_len) +static __inline uint32_t +vmbus_rxbr_copyfrom(const struct vmbus_rxbr *rbr, uint32_t rindex, + void *dst0, int cplen) { - uint32_t bytesAvailToWrite; - uint32_t bytesAvailToRead; - uint32_t nextReadLocation = 0; - - mtx_lock_spin(&in_ring_info->ring_lock); + uint8_t *dst = dst0; + const uint8_t *br_data = rbr->rxbr_data; + uint32_t br_dsize = rbr->rxbr_dsize; + + if (cplen > br_dsize - rindex) { + uint32_t fraglen = br_dsize - rindex; + + /* Wrap-around detected. */ + memcpy(dst, br_data + rindex, fraglen); + memcpy(dst + fraglen, br_data, cplen - fraglen); + } else { + memcpy(dst, br_data + rindex, cplen); + } + return VMBUS_BR_IDXINC(rindex, cplen, br_dsize); +} - get_ring_buffer_avail_bytes(in_ring_info, &bytesAvailToRead, - &bytesAvailToWrite); +int +vmbus_rxbr_peek(struct vmbus_rxbr *rbr, void *data, int dlen) +{ + mtx_lock_spin(&rbr->rxbr_lock); /* - * Make sure there is something to read + * The requested data and the 64bits channel packet + * offset should be there at least. */ - if (bytesAvailToRead < buffer_len) { - mtx_unlock_spin(&in_ring_info->ring_lock); + if (vmbus_rxbr_avail(rbr) < dlen + sizeof(uint64_t)) { + mtx_unlock_spin(&rbr->rxbr_lock); return (EAGAIN); } + vmbus_rxbr_copyfrom(rbr, rbr->rxbr_rindex, data, dlen); - /* - * Convert to byte offset - */ - nextReadLocation = get_next_read_location(in_ring_info); - - nextReadLocation = copy_from_ring_buffer(in_ring_info, - (char *)buffer, buffer_len, nextReadLocation); - - mtx_unlock_spin(&in_ring_info->ring_lock); + mtx_unlock_spin(&rbr->rxbr_lock); return (0); } -/** - * @brief Read and advance the read index. +/* + * NOTE: + * We assume (dlen + skip) == sizeof(channel packet). */ int -hv_ring_buffer_read(hv_vmbus_ring_buffer_info *in_ring_info, void *buffer, - uint32_t buffer_len, uint32_t offset) +vmbus_rxbr_read(struct vmbus_rxbr *rbr, void *data, int dlen, uint32_t skip) { - uint32_t bytes_avail_to_write; - uint32_t bytes_avail_to_read; - uint32_t next_read_location = 0; - uint64_t prev_indices = 0; - - if (buffer_len <= 0) - return (EINVAL); + uint32_t rindex, br_dsize = rbr->rxbr_dsize; - mtx_lock_spin(&in_ring_info->ring_lock); + KASSERT(dlen + skip > 0, ("invalid dlen %d, offset %u", dlen, skip)); - get_ring_buffer_avail_bytes(in_ring_info, &bytes_avail_to_read, - &bytes_avail_to_write); + mtx_lock_spin(&rbr->rxbr_lock); - /* - * Make sure there is something to read - */ - if (bytes_avail_to_read < buffer_len) { - mtx_unlock_spin(&in_ring_info->ring_lock); + if (vmbus_rxbr_avail(rbr) < dlen + skip + sizeof(uint64_t)) { + mtx_unlock_spin(&rbr->rxbr_lock); return (EAGAIN); } - next_read_location = get_next_read_location_with_offset(in_ring_info, - offset); - - next_read_location = copy_from_ring_buffer(in_ring_info, (char *)buffer, - buffer_len, next_read_location); + /* + * Copy channel packet from RX bufring. + */ + rindex = VMBUS_BR_IDXINC(rbr->rxbr_rindex, skip, br_dsize); + rindex = vmbus_rxbr_copyfrom(rbr, rindex, data, dlen); - next_read_location = copy_from_ring_buffer(in_ring_info, - (char *)&prev_indices, sizeof(uint64_t), next_read_location); + /* + * Discard this channel packet's 64bits offset, which is useless to us. + */ + rindex = VMBUS_BR_IDXINC(rindex, sizeof(uint64_t), br_dsize); /* + * XXX only compiler fence is needed. * Make sure all reads are done before we update the read index since * the writer may start writing to the read area once the read index * is updated. @@ -461,67 +407,11 @@ hv_ring_buffer_read(hv_vmbus_ring_buffer wmb(); /* - * Update the read index + * Update the read index _after_ the channel packet is fetched. */ - set_next_read_location(in_ring_info, next_read_location); + rbr->rxbr_rindex = rindex; - mtx_unlock_spin(&in_ring_info->ring_lock); + mtx_unlock_spin(&rbr->rxbr_lock); return (0); } - -/** - * @brief Helper routine to copy from source to ring buffer. - * - * Assume there is enough room. Handles wrap-around in dest case only! - */ -static uint32_t -copy_to_ring_buffer(hv_vmbus_ring_buffer_info *ring_info, - uint32_t start_write_offset, const uint8_t *src, uint32_t src_len) -{ - char *ring_buffer = get_ring_buffer(ring_info); - uint32_t ring_buffer_size = get_ring_buffer_size(ring_info); - uint32_t fragLen; - - if (src_len > ring_buffer_size - start_write_offset) { - /* wrap-around detected! */ - fragLen = ring_buffer_size - start_write_offset; - memcpy(ring_buffer + start_write_offset, src, fragLen); - memcpy(ring_buffer, src + fragLen, src_len - fragLen); - } else { - memcpy(ring_buffer + start_write_offset, src, src_len); - } - - start_write_offset += src_len; - start_write_offset %= ring_buffer_size; - - return (start_write_offset); -} - -/** - * @brief Helper routine to copy to source from ring buffer. - * - * Assume there is enough room. Handles wrap-around in src case only! - */ -static uint32_t -copy_from_ring_buffer(hv_vmbus_ring_buffer_info *ring_info, char *dest, - uint32_t dest_len, uint32_t start_read_offset) -{ - uint32_t fragLen; - char *ring_buffer = get_ring_buffer(ring_info); - uint32_t ring_buffer_size = get_ring_buffer_size(ring_info); - - if (dest_len > ring_buffer_size - start_read_offset) { - /* wrap-around detected at the src */ - fragLen = ring_buffer_size - start_read_offset; - memcpy(dest, ring_buffer + start_read_offset, fragLen); - memcpy(dest + fragLen, ring_buffer, dest_len - fragLen); - } else { - memcpy(dest, ring_buffer + start_read_offset, dest_len); - } - - start_read_offset += dest_len; - start_read_offset %= ring_buffer_size; - - return (start_read_offset); -} Modified: stable/10/sys/dev/hyperv/vmbus/vmbus_brvar.h ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/vmbus_brvar.h Wed Oct 12 05:09:22 2016 (r307102) +++ stable/10/sys/dev/hyperv/vmbus/vmbus_brvar.h Wed Oct 12 05:09:26 2016 (r307103) @@ -28,58 +28,66 @@ * $FreeBSD$ */ -#ifndef __HYPERV_PRIV_H__ -#define __HYPERV_PRIV_H__ +#ifndef _VMBUS_BRVAR_H_ +#define _VMBUS_BRVAR_H_ #include #include #include -#include #include -#include +struct vmbus_br { + struct vmbus_bufring *vbr; + uint32_t vbr_dsize; /* total data size */ +}; + +#define vbr_windex vbr->br_windex +#define vbr_rindex vbr->br_rindex +#define vbr_imask vbr->br_imask +#define vbr_data vbr->br_data + +struct vmbus_rxbr { + struct mtx rxbr_lock; + struct vmbus_br rxbr; +}; + +#define rxbr_windex rxbr.vbr_windex +#define rxbr_rindex rxbr.vbr_rindex +#define rxbr_imask rxbr.vbr_imask +#define rxbr_data rxbr.vbr_data +#define rxbr_dsize rxbr.vbr_dsize + +struct vmbus_txbr { + struct mtx txbr_lock; + struct vmbus_br txbr; +}; + +#define txbr_windex txbr.vbr_windex +#define txbr_rindex txbr.vbr_rindex +#define txbr_imask txbr.vbr_imask +#define txbr_data txbr.vbr_data +#define txbr_dsize txbr.vbr_dsize -struct vmbus_softc; - -/* - * Private, VM Bus functions - */ struct sysctl_ctx_list; struct sysctl_oid; -void vmbus_br_sysctl_create(struct sysctl_ctx_list *ctx, - struct sysctl_oid *br_tree, hv_vmbus_ring_buffer_info *br, - const char *name); - -int hv_vmbus_ring_buffer_init( - hv_vmbus_ring_buffer_info *ring_info, - void *buffer, - uint32_t buffer_len); - -void hv_ring_buffer_cleanup( - hv_vmbus_ring_buffer_info *ring_info); - -int hv_ring_buffer_write( - hv_vmbus_ring_buffer_info *ring_info, - const struct iovec iov[], - uint32_t iovlen, - boolean_t *need_sig); - -int hv_ring_buffer_peek( - hv_vmbus_ring_buffer_info *ring_info, - void *buffer, - uint32_t buffer_len); - -int hv_ring_buffer_read( - hv_vmbus_ring_buffer_info *ring_info, - void *buffer, - uint32_t buffer_len, - uint32_t offset); - -void hv_ring_buffer_read_begin( - hv_vmbus_ring_buffer_info *ring_info); - -uint32_t hv_ring_buffer_read_end( - hv_vmbus_ring_buffer_info *ring_info); +void vmbus_br_sysctl_create(struct sysctl_ctx_list *ctx, + struct sysctl_oid *br_tree, struct vmbus_br *br, + const char *name); + +void vmbus_rxbr_init(struct vmbus_rxbr *rbr); +void vmbus_rxbr_deinit(struct vmbus_rxbr *rbr); +void vmbus_rxbr_setup(struct vmbus_rxbr *rbr, void *buf, int blen); +int vmbus_rxbr_peek(struct vmbus_rxbr *rbr, void *data, int dlen); +int vmbus_rxbr_read(struct vmbus_rxbr *rbr, void *data, int dlen, + uint32_t skip); +void vmbus_rxbr_intr_mask(struct vmbus_rxbr *rbr); +uint32_t vmbus_rxbr_intr_unmask(struct vmbus_rxbr *rbr); + +void vmbus_txbr_init(struct vmbus_txbr *tbr); +void vmbus_txbr_deinit(struct vmbus_txbr *tbr); +void vmbus_txbr_setup(struct vmbus_txbr *tbr, void *buf, int blen); +int vmbus_txbr_write(struct vmbus_txbr *tbr, + const struct iovec iov[], int iovlen, boolean_t *need_sig); -#endif /* __HYPERV_PRIV_H__ */ +#endif /* _VMBUS_BRVAR_H_ */ Modified: stable/10/sys/dev/hyperv/vmbus/vmbus_chan.c ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/vmbus_chan.c Wed Oct 12 05:09:22 2016 (r307102) +++ stable/10/sys/dev/hyperv/vmbus/vmbus_chan.c Wed Oct 12 05:09:26 2016 (r307103) @@ -178,11 +178,11 @@ vmbus_chan_sysctl_create(struct vmbus_ch /* * Create sysctl tree for RX bufring. */ - vmbus_br_sysctl_create(ctx, br_tree, &chan->ch_rxbr, "rx"); + vmbus_br_sysctl_create(ctx, br_tree, &chan->ch_rxbr.rxbr, "rx"); /* * Create sysctl tree for TX bufring. */ - vmbus_br_sysctl_create(ctx, br_tree, &chan->ch_txbr, "tx"); + vmbus_br_sysctl_create(ctx, br_tree, &chan->ch_txbr.txbr, "tx"); } } @@ -239,9 +239,9 @@ vmbus_chan_open(struct vmbus_channel *ch chan->ch_bufring = br; /* TX bufring comes first */ - hv_vmbus_ring_buffer_init(&chan->ch_txbr, br, txbr_size); + vmbus_txbr_setup(&chan->ch_txbr, br, txbr_size); /* RX bufring immediately follows TX bufring */ - hv_vmbus_ring_buffer_init(&chan->ch_rxbr, br + txbr_size, rxbr_size); + vmbus_rxbr_setup(&chan->ch_rxbr, br + txbr_size, rxbr_size); /* Create sysctl tree for this channel */ vmbus_chan_sysctl_create(chan); @@ -549,8 +549,6 @@ vmbus_chan_close_internal(struct vmbus_c /* * Destroy the TX+RX bufrings. */ - hv_ring_buffer_cleanup(&chan->ch_txbr); - hv_ring_buffer_cleanup(&chan->ch_rxbr); if (chan->ch_bufring != NULL) { hyperv_dmamem_free(&chan->ch_bufring_dma, chan->ch_bufring); chan->ch_bufring = NULL; @@ -620,7 +618,7 @@ vmbus_chan_send(struct vmbus_channel *ch iov[2].iov_base = &pad; iov[2].iov_len = pad_pktlen - pktlen; - error = hv_ring_buffer_write(&chan->ch_txbr, iov, 3, &send_evt); + error = vmbus_txbr_write(&chan->ch_txbr, iov, 3, &send_evt); if (!error && send_evt) vmbus_chan_signal_tx(chan); return error; @@ -660,7 +658,7 @@ vmbus_chan_send_sglist(struct vmbus_chan iov[3].iov_base = &pad; iov[3].iov_len = pad_pktlen - pktlen; - error = hv_ring_buffer_write(&chan->ch_txbr, iov, 4, &send_evt); + error = vmbus_txbr_write(&chan->ch_txbr, iov, 4, &send_evt); if (!error && send_evt) vmbus_chan_signal_tx(chan); return error; @@ -702,7 +700,7 @@ vmbus_chan_send_prplist(struct vmbus_cha iov[3].iov_base = &pad; iov[3].iov_len = pad_pktlen - pktlen; - error = hv_ring_buffer_write(&chan->ch_txbr, iov, 4, &send_evt); + error = vmbus_txbr_write(&chan->ch_txbr, iov, 4, &send_evt); if (!error && send_evt) vmbus_chan_signal_tx(chan); return error; @@ -715,7 +713,7 @@ vmbus_chan_recv(struct vmbus_channel *ch struct vmbus_chanpkt_hdr pkt; int error, dlen, hlen; - error = hv_ring_buffer_peek(&chan->ch_rxbr, &pkt, sizeof(pkt)); + error = vmbus_rxbr_peek(&chan->ch_rxbr, &pkt, sizeof(pkt)); if (error) return error; @@ -732,8 +730,8 @@ vmbus_chan_recv(struct vmbus_channel *ch *dlen0 = dlen; /* Skip packet header */ - error = hv_ring_buffer_read(&chan->ch_rxbr, data, dlen, hlen); - KASSERT(!error, ("hv_ring_buffer_read failed")); + error = vmbus_rxbr_read(&chan->ch_rxbr, data, dlen, hlen); + KASSERT(!error, ("vmbus_rxbr_read failed")); return 0; } @@ -745,7 +743,7 @@ vmbus_chan_recv_pkt(struct vmbus_channel struct vmbus_chanpkt_hdr pkt; int error, pktlen; - error = hv_ring_buffer_peek(&chan->ch_rxbr, &pkt, sizeof(pkt)); + error = vmbus_rxbr_peek(&chan->ch_rxbr, &pkt, sizeof(pkt)); if (error) return error; @@ -758,8 +756,8 @@ vmbus_chan_recv_pkt(struct vmbus_channel *pktlen0 = pktlen; /* Include packet header */ - error = hv_ring_buffer_read(&chan->ch_rxbr, pkt0, pktlen, 0); - KASSERT(!error, ("hv_ring_buffer_read failed")); + error = vmbus_rxbr_read(&chan->ch_rxbr, pkt0, pktlen, 0); + KASSERT(!error, ("vmbus_rxbr_read failed")); return 0; } @@ -788,12 +786,12 @@ vmbus_chan_task(void *xchan, int pending cb(chan, cbarg); - left = hv_ring_buffer_read_end(&chan->ch_rxbr); + left = vmbus_rxbr_intr_unmask(&chan->ch_rxbr); if (left == 0) { /* No more data in RX bufring; done */ break; } - hv_ring_buffer_read_begin(&chan->ch_rxbr); + vmbus_rxbr_intr_mask(&chan->ch_rxbr); } } @@ -835,7 +833,7 @@ vmbus_event_flags_proc(struct vmbus_soft continue; if (chan->ch_flags & VMBUS_CHAN_FLAG_BATCHREAD) - hv_ring_buffer_read_begin(&chan->ch_rxbr); + vmbus_rxbr_intr_mask(&chan->ch_rxbr); taskqueue_enqueue(chan->ch_tq, &chan->ch_task); } } @@ -914,6 +912,8 @@ vmbus_chan_alloc(struct vmbus_softc *sc) mtx_init(&chan->ch_subchan_lock, "vmbus subchan", NULL, MTX_DEF); TAILQ_INIT(&chan->ch_subchans); TASK_INIT(&chan->ch_detach_task, 0, vmbus_chan_detach_task, chan); + vmbus_rxbr_init(&chan->ch_rxbr); + vmbus_txbr_init(&chan->ch_txbr); return chan; } @@ -926,6 +926,8 @@ vmbus_chan_free(struct vmbus_channel *ch /* TODO: asset no longer on the vmbus channel list */ hyperv_dmamem_free(&chan->ch_monprm_dma, chan->ch_monprm); mtx_destroy(&chan->ch_subchan_lock); + vmbus_rxbr_deinit(&chan->ch_rxbr); + vmbus_txbr_deinit(&chan->ch_txbr); free(chan, M_DEVBUF); } Modified: stable/10/sys/dev/hyperv/vmbus/vmbus_chanvar.h ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/vmbus_chanvar.h Wed Oct 12 05:09:22 2016 (r307102) +++ stable/10/sys/dev/hyperv/vmbus/vmbus_chanvar.h Wed Oct 12 05:09:26 2016 (r307103) @@ -39,12 +39,7 @@ #include #include #include - -typedef struct { - struct vmbus_bufring *ring_buffer; - struct mtx ring_lock; - uint32_t ring_data_size; /* ring_size */ -} hv_vmbus_ring_buffer_info; +#include struct vmbus_channel { /* @@ -57,7 +52,7 @@ struct vmbus_channel { /* * RX bufring; immediately following ch_txbr. */ - hv_vmbus_ring_buffer_info ch_rxbr; + struct vmbus_rxbr ch_rxbr; struct taskqueue *ch_tq; struct task ch_task; @@ -76,7 +71,7 @@ struct vmbus_channel { * TX bufring and following MNF/evtflags do _not_ fit in * one 64B cacheline. */ - hv_vmbus_ring_buffer_info ch_txbr __aligned(CACHE_LINE_SIZE); + struct vmbus_txbr ch_txbr __aligned(CACHE_LINE_SIZE); uint32_t ch_txflags; /* VMBUS_CHAN_TXF_ */ /* From owner-svn-src-all@freebsd.org Wed Oct 12 05:10:06 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A1ECAC0D941; Wed, 12 Oct 2016 05:10:06 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 70E7A14BB; Wed, 12 Oct 2016 05:10:06 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9C5A5GH008503; Wed, 12 Oct 2016 05:10:05 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9C5A5vj008502; Wed, 12 Oct 2016 05:10:05 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201610120510.u9C5A5vj008502@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Wed, 12 Oct 2016 05:10:05 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307104 - stable/11/cddl/contrib/opensolaris/lib/libzfs/common X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Oct 2016 05:10:06 -0000 Author: mav Date: Wed Oct 12 05:10:05 2016 New Revision: 307104 URL: https://svnweb.freebsd.org/changeset/base/307104 Log: MFC r305202: MFV r302654: 6879 incorrect endianness swap for drr_spill.drr_length in libzfs_sendrecv.c illumos/illumos-gate@20fea7a47472aceb64d3ed48cc2a3ea268bc4795 https://github.com/illumos/illumos-gate/commit/20fea7a47472aceb64d3ed48cc2a3ea26 8bc4795 https://www.illumos.org/issues/6879 In libzfs_sendrecv, there's a typo: case DRR_SPILL: if (byteswap) { drr->drr_u.drr_write.drr_length = BSWAP_64(drr->drr_u.drr_spill.drr_length); } Instead of drr_write.drr_length, we should be assigning the result of the byteswap to drr_spill.drr_length. Reviewed by: Matthew Ahrens Reviewed by: Paul Dagnelie Approved by: Robert Mustacchi Author: Dan Kimmel Modified: stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c Directory Properties: stable/11/ (props changed) Modified: stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c ============================================================================== --- stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c Wed Oct 12 05:09:26 2016 (r307103) +++ stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c Wed Oct 12 05:10:05 2016 (r307104) @@ -2968,7 +2968,7 @@ recv_skip(libzfs_handle_t *hdl, int fd, break; case DRR_SPILL: if (byteswap) { - drr->drr_u.drr_write.drr_length = + drr->drr_u.drr_spill.drr_length = BSWAP_64(drr->drr_u.drr_spill.drr_length); } (void) recv_read(hdl, fd, buf, From owner-svn-src-all@freebsd.org Wed Oct 12 05:10:50 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 0B3A5C0D9BC; Wed, 12 Oct 2016 05:10:50 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id CB3E01669; Wed, 12 Oct 2016 05:10:49 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9C5AmHR008584; Wed, 12 Oct 2016 05:10:48 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9C5Amht008583; Wed, 12 Oct 2016 05:10:48 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201610120510.u9C5Amht008583@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Wed, 12 Oct 2016 05:10:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307105 - stable/11/cddl/contrib/opensolaris/lib/libzfs/common X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Oct 2016 05:10:50 -0000 Author: mav Date: Wed Oct 12 05:10:48 2016 New Revision: 307105 URL: https://svnweb.freebsd.org/changeset/base/307105 Log: MFC r305203: MFV r302655: 6873 zfs_destroy_snaps_nvl leaks errlist illumos/illumos-gate@4cde22c29999ffb907ca39d2ebd512812f7e5168 https://github.com/illumos/illumos-gate/commit/4cde22c29999ffb907ca39d2ebd512812 f7e5168 https://www.illumos.org/issues/6873 lzc_destroy_snaps() returns an nvlist in errlist. zfs_destroy_snaps_nvl() should nvlist_free() it before returning. Reviewed by: Matthew Ahrens Reviewed by: Paul Dagnelie Approved by: Dan McDonald Author: Chris Williamson Modified: stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c Directory Properties: stable/11/ (props changed) Modified: stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c ============================================================================== --- stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c Wed Oct 12 05:10:05 2016 (r307104) +++ stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c Wed Oct 12 05:10:48 2016 (r307105) @@ -3455,12 +3455,14 @@ int zfs_destroy_snaps_nvl(libzfs_handle_t *hdl, nvlist_t *snaps, boolean_t defer) { int ret; - nvlist_t *errlist; + nvlist_t *errlist = NULL; ret = lzc_destroy_snaps(snaps, defer, &errlist); - if (ret == 0) + if (ret == 0) { + nvlist_free(errlist); return (0); + } if (nvlist_empty(errlist)) { char errbuf[1024]; @@ -3488,6 +3490,7 @@ zfs_destroy_snaps_nvl(libzfs_handle_t *h } } + nvlist_free(errlist); return (ret); } From owner-svn-src-all@freebsd.org Wed Oct 12 05:13:14 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 9137CC0DB31; Wed, 12 Oct 2016 05:13:14 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 533BD19E6; Wed, 12 Oct 2016 05:13:14 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9C5DDXA012011; Wed, 12 Oct 2016 05:13:13 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9C5DDY5012007; Wed, 12 Oct 2016 05:13:13 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201610120513.u9C5DDY5012007@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Wed, 12 Oct 2016 05:13:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307106 - in stable/11/cddl/contrib/opensolaris: cmd/zfs lib/libzfs/common X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Oct 2016 05:13:14 -0000 Author: mav Date: Wed Oct 12 05:13:12 2016 New Revision: 307106 URL: https://svnweb.freebsd.org/changeset/base/307106 Log: MFC r305205: MFV r302657: 4521 zfstest is trying to execute evil "zfs unmount -a" illumos/illumos-gate@8808ac5dae118369991f158b6ab736cb2691ecde https://github.com/illumos/illumos-gate/commit/8808ac5dae118369991f158b6ab736cb2 691ecde https://www.illumos.org/issues/4521 zfstest is trying to execute evil "zfs unmount -a", which fails (fortunately, as it would otherwise leave me with my ~ missing): 03:44:11.86 cannot unmount '/export/home/yuri': Device busy cannot unmount '/ export/home': Device busy 03:44:11.86 ERROR: /usr/sbin/zfs unmount -a exited 1 This affects, at least, zfs_mount_009_neg and zfs_mount_all_001_pos, both failing on that step. The pool containing the /export/home hierarchy is included in KEEP variable, but it doesn't seem to affect anything here. Reviewed by: Andriy Gapon Reviewed by: Dan McDonald Reviewed by: Matthew Ahrens Reviewed by: John Kennedy Approved by: Robert Mustacchi Author: Yuri Pankov Modified: stable/11/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs.h stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_config.c stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c Directory Properties: stable/11/ (props changed) Modified: stable/11/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c ============================================================================== --- stable/11/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c Wed Oct 12 05:10:48 2016 (r307105) +++ stable/11/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c Wed Oct 12 05:13:12 2016 (r307106) @@ -27,9 +27,9 @@ * Copyright (c) 2011-2012 Pawel Jakub Dawidek. All rights reserved. * Copyright (c) 2012 Martin Matuska . All rights reserved. * Copyright (c) 2013 Steven Hartland. All rights reserved. - * Copyright 2013 Nexenta Systems, Inc. All rights reserved. * Copyright (c) 2014 Integros [integros.com] * Copyright 2016 Igor Kozhukhov . + * Copyright 2016 Nexenta Systems, Inc. */ #include @@ -6483,6 +6483,15 @@ unshare_unmount(int op, int argc, char * continue; } + /* + * Ignore datasets that are excluded/restricted by + * parent pool name. + */ + if (zpool_skip_pool(zfs_get_pool_name(zhp))) { + zfs_close(zhp); + continue; + } + switch (op) { case OP_SHARE: verify(zfs_prop_get(zhp, ZFS_PROP_SHARENFS, Modified: stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs.h ============================================================================== --- stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs.h Wed Oct 12 05:10:48 2016 (r307105) +++ stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs.h Wed Oct 12 05:13:12 2016 (r307106) @@ -26,8 +26,8 @@ * Copyright (c) 2012, Joyent, Inc. All rights reserved. * Copyright (c) 2012 Martin Matuska . All rights reserved. * Copyright (c) 2013 Steven Hartland. All rights reserved. - * Copyright 2013 Nexenta Systems, Inc. All rights reserved. * Copyright (c) 2014 Integros [integros.com] + * Copyright 2016 Nexenta Systems, Inc. */ #ifndef _LIBZFS_H @@ -221,6 +221,7 @@ extern void zpool_free_handles(libzfs_ha */ typedef int (*zpool_iter_f)(zpool_handle_t *, void *); extern int zpool_iter(libzfs_handle_t *, zpool_iter_f, void *); +extern boolean_t zpool_skip_pool(const char *); /* * Functions to create and destroy pools @@ -411,6 +412,7 @@ extern void zfs_close(zfs_handle_t *); extern zfs_type_t zfs_get_type(const zfs_handle_t *); extern const char *zfs_get_name(const zfs_handle_t *); extern zpool_handle_t *zfs_get_pool_handle(const zfs_handle_t *); +extern const char *zfs_get_pool_name(const zfs_handle_t *); /* * Property management functions. Some functions are shared with the kernel, Modified: stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_config.c ============================================================================== --- stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_config.c Wed Oct 12 05:10:48 2016 (r307105) +++ stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_config.c Wed Oct 12 05:13:12 2016 (r307106) @@ -27,6 +27,7 @@ /* * Copyright (c) 2012 by Delphix. All rights reserved. * Copyright (c) 2015 by Syneto S.R.L. All rights reserved. + * Copyright 2016 Nexenta Systems, Inc. */ /* @@ -338,33 +339,47 @@ zpool_refresh_stats(zpool_handle_t *zhp, } /* - * If the __ZFS_POOL_RESTRICT environment variable is set we only iterate over - * pools it lists. + * The following environment variables are undocumented + * and should be used for testing purposes only: * - * This is an undocumented feature for use during testing only. + * __ZFS_POOL_EXCLUDE - don't iterate over the pools it lists + * __ZFS_POOL_RESTRICT - iterate only over the pools it lists * * This function returns B_TRUE if the pool should be skipped * during iteration. */ -static boolean_t -check_restricted(const char *poolname) +boolean_t +zpool_skip_pool(const char *poolname) { static boolean_t initialized = B_FALSE; - static char *restricted = NULL; + static const char *exclude = NULL; + static const char *restricted = NULL; const char *cur, *end; - int len, namelen; + int len; + int namelen = strlen(poolname); if (!initialized) { initialized = B_TRUE; + exclude = getenv("__ZFS_POOL_EXCLUDE"); restricted = getenv("__ZFS_POOL_RESTRICT"); } + if (exclude != NULL) { + cur = exclude; + do { + end = strchr(cur, ' '); + len = (NULL == end) ? strlen(cur) : (end - cur); + if (len == namelen && 0 == strncmp(cur, poolname, len)) + return (B_TRUE); + cur += (len + 1); + } while (NULL != end); + } + if (NULL == restricted) return (B_FALSE); cur = restricted; - namelen = strlen(poolname); do { end = strchr(cur, ' '); len = (NULL == end) ? strlen(cur) : (end - cur); @@ -402,7 +417,7 @@ zpool_iter(libzfs_handle_t *hdl, zpool_i for (cn = uu_avl_first(hdl->libzfs_ns_avl); cn != NULL; cn = uu_avl_next(hdl->libzfs_ns_avl, cn)) { - if (check_restricted(cn->cn_name)) + if (zpool_skip_pool(cn->cn_name)) continue; if (zpool_open_silent(hdl, cn->cn_name, &zhp) != 0) { @@ -440,7 +455,7 @@ zfs_iter_root(libzfs_handle_t *hdl, zfs_ for (cn = uu_avl_first(hdl->libzfs_ns_avl); cn != NULL; cn = uu_avl_next(hdl->libzfs_ns_avl, cn)) { - if (check_restricted(cn->cn_name)) + if (zpool_skip_pool(cn->cn_name)) continue; if ((zhp = make_dataset_handle(hdl, cn->cn_name)) == NULL) Modified: stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c ============================================================================== --- stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c Wed Oct 12 05:10:48 2016 (r307105) +++ stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c Wed Oct 12 05:13:12 2016 (r307106) @@ -27,9 +27,9 @@ * Copyright (c) 2011-2012 Pawel Jakub Dawidek. All rights reserved. * Copyright (c) 2013 Martin Matuska. All rights reserved. * Copyright (c) 2013 Steven Hartland. All rights reserved. - * Copyright 2013 Nexenta Systems, Inc. All rights reserved. * Copyright (c) 2014 Integros [integros.com] * Copyright 2016 Igor Kozhukhov + * Copyright 2016 Nexenta Systems, Inc. */ #include @@ -2951,6 +2951,15 @@ zfs_get_name(const zfs_handle_t *zhp) } /* + * Returns the name of the parent pool for the given zfs handle. + */ +const char * +zfs_get_pool_name(const zfs_handle_t *zhp) +{ + return (zhp->zpool_hdl->zpool_name); +} + +/* * Returns the type of the given zfs handle. */ zfs_type_t From owner-svn-src-all@freebsd.org Wed Oct 12 05:14:06 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 62050C0DBCD; Wed, 12 Oct 2016 05:14:06 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 235981BF6; Wed, 12 Oct 2016 05:14:06 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9C5E58d012100; Wed, 12 Oct 2016 05:14:05 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9C5E40j012096; Wed, 12 Oct 2016 05:14:04 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201610120514.u9C5E40j012096@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Wed, 12 Oct 2016 05:14:04 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307107 - in stable/11/cddl/contrib/opensolaris: cmd/zpool lib/libzfs/common X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Oct 2016 05:14:06 -0000 Author: mav Date: Wed Oct 12 05:14:04 2016 New Revision: 307107 URL: https://svnweb.freebsd.org/changeset/base/307107 Log: MFC r305206: MFV r302658: 6872 zfs libraries should not allow uninitialized variables illumos/illumos-gate@f83b46baf98d276f5f84fa84c8b461f412ac1f5e https://github.com/illumos/illumos-gate/commit/f83b46baf98d276f5f84fa84c8b461f41 2ac1f5e https://www.illumos.org/issues/6872 We compile the zfs libraries with -Wno-uninitialized. We should remove this. Change makefiles, fix new warnings, fix pbchk errors. Reviewed by: Dan Kimmel Reviewed by: George Wilson Reviewed by: Prakash Surya Reviewed by: Yuri Pankov Approved by: Robert Mustacchi Author: Paul Dagnelie Modified: stable/11/cddl/contrib/opensolaris/cmd/zpool/zpool_vdev.c stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_import.c stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_util.c Directory Properties: stable/11/ (props changed) Modified: stable/11/cddl/contrib/opensolaris/cmd/zpool/zpool_vdev.c ============================================================================== --- stable/11/cddl/contrib/opensolaris/cmd/zpool/zpool_vdev.c Wed Oct 12 05:13:12 2016 (r307106) +++ stable/11/cddl/contrib/opensolaris/cmd/zpool/zpool_vdev.c Wed Oct 12 05:14:04 2016 (r307107) @@ -21,7 +21,7 @@ /* * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2013 by Delphix. All rights reserved. + * Copyright (c) 2013, 2015 by Delphix. All rights reserved. * Copyright 2016 Igor Kozhukhov . */ @@ -597,7 +597,6 @@ get_replication(nvlist_t *nvroot, boolea verify(nvlist_lookup_nvlist_array(nvroot, ZPOOL_CONFIG_CHILDREN, &top, &toplevels) == 0); - lastrep.zprl_type = NULL; for (t = 0; t < toplevels; t++) { uint64_t is_log = B_FALSE; Modified: stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c ============================================================================== --- stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c Wed Oct 12 05:13:12 2016 (r307106) +++ stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c Wed Oct 12 05:14:04 2016 (r307107) @@ -1570,7 +1570,7 @@ zfs_prop_set_list(zfs_handle_t *zhp, nvl libzfs_handle_t *hdl = zhp->zfs_hdl; nvlist_t *nvl; int nvl_len; - int added_resv; + int added_resv = 0; (void) snprintf(errbuf, sizeof (errbuf), dgettext(TEXT_DOMAIN, "cannot set property for '%s'"), @@ -3201,7 +3201,7 @@ zfs_create_ancestors(libzfs_handle_t *hd { int prefix; char *path_copy; - int rc; + int rc = 0; if (check_parents(hdl, path, NULL, B_TRUE, &prefix) != 0) return (-1); @@ -3843,7 +3843,7 @@ zfs_rollback(zfs_handle_t *zhp, zfs_hand rollback_data_t cb = { 0 }; int err; boolean_t restore_resv = 0; - uint64_t old_volsize, new_volsize; + uint64_t old_volsize = 0, new_volsize; zfs_prop_t resv_prop; assert(zhp->zfs_type == ZFS_TYPE_FILESYSTEM || @@ -4060,6 +4060,7 @@ zfs_rename(zfs_handle_t *zhp, const char "child dataset with inherited mountpoint is used " "in a non-global zone")); (void) zfs_error(hdl, EZFS_ZONED, errbuf); + ret = -1; goto error; } Modified: stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_import.c ============================================================================== --- stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_import.c Wed Oct 12 05:13:12 2016 (r307106) +++ stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_import.c Wed Oct 12 05:14:04 2016 (r307107) @@ -21,7 +21,7 @@ /* * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2013 by Delphix. All rights reserved. + * Copyright (c) 2012, 2015 by Delphix. All rights reserved. * Copyright 2015 RackTop Systems. * Copyright 2016 Nexenta Systems, Inc. */ @@ -440,12 +440,12 @@ get_configs(libzfs_handle_t *hdl, pool_l pool_entry_t *pe; vdev_entry_t *ve; config_entry_t *ce; - nvlist_t *ret = NULL, *config = NULL, *tmp, *nvtop, *nvroot; + nvlist_t *ret = NULL, *config = NULL, *tmp = NULL, *nvtop, *nvroot; nvlist_t **spares, **l2cache; uint_t i, nspares, nl2cache; boolean_t config_seen; uint64_t best_txg; - char *name, *hostname; + char *name, *hostname = NULL; uint64_t guid; uint_t children = 0; nvlist_t **child = NULL; Modified: stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_util.c ============================================================================== --- stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_util.c Wed Oct 12 05:13:12 2016 (r307106) +++ stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_util.c Wed Oct 12 05:14:04 2016 (r307107) @@ -1011,7 +1011,7 @@ zprop_print_one_property(const char *nam const char *source, const char *recvd_value) { int i; - const char *str; + const char *str = NULL; char buf[128]; /* From owner-svn-src-all@freebsd.org Wed Oct 12 05:15:12 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 3535DC0DC62; Wed, 12 Oct 2016 05:15:12 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id C6E401D5F; Wed, 12 Oct 2016 05:15:11 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9C5FB25012210; Wed, 12 Oct 2016 05:15:11 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9C5F9ZM012192; Wed, 12 Oct 2016 05:15:09 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201610120515.u9C5F9ZM012192@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Wed, 12 Oct 2016 05:15:09 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307108 - in stable/11: cddl/contrib/opensolaris/cmd/zdb cddl/contrib/opensolaris/cmd/zfs cddl/contrib/opensolaris/cmd/zhack cddl/contrib/opensolaris/cmd/zpool cddl/contrib/opensolaris/... X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Oct 2016 05:15:12 -0000 Author: mav Date: Wed Oct 12 05:15:09 2016 New Revision: 307108 URL: https://svnweb.freebsd.org/changeset/base/307108 Log: MFC r305209: MFV r302660: 6314 buffer overflow in dsl_dataset_name illumos/illumos-gate@9adfa60d484ce2435f5af77cc99dcd4e692b6660 https://github.com/illumos/illumos-gate/commit/9adfa60d484ce2435f5af77cc99dcd4e6 92b6660 https://www.illumos.org/issues/6314 Callers of dsl_dataset_name pass a buffer of size ZFS_MAXNAMELEN, but dsl_dataset_name copies the datasets' name PLUS the snapshot name to it, resulting in a max of 2 * ZFS_MAXNAMELEN + '@'. Reviewed by: George Wilson Reviewed by: Prakash Surya Reviewed by: Igor Kozhukhov Approved by: Dan McDonald Author: Matthew Ahrens Modified: stable/11/cddl/contrib/opensolaris/cmd/zdb/zdb.c stable/11/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c stable/11/cddl/contrib/opensolaris/cmd/zhack/zhack.c stable/11/cddl/contrib/opensolaris/cmd/zpool/zpool_main.c stable/11/cddl/contrib/opensolaris/cmd/ztest/ztest.c stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs.h stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_changelist.c stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_diff.c stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_impl.h stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_iter.c stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_mount.c stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_pool.c stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c stable/11/cddl/contrib/opensolaris/lib/libzfs_core/common/libzfs_core.c stable/11/cddl/usr.sbin/zfsd/tests/zfsd_unittest.cc stable/11/sys/cddl/contrib/opensolaris/common/zfs/zfs_namecheck.c stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_objset.c stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_send.c stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_bookmark.c stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_dataset.c stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_deleg.c stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_dir.c stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_prop.c stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_scan.c stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_userhold.c stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_history.c stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dmu.h stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dsl_dataset.h stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dsl_dir.h stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/spa_impl.h stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zap.h stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zfs_znode.h stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ctldir.c stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zil.c stable/11/sys/cddl/contrib/opensolaris/uts/common/sys/fs/zfs.h Directory Properties: stable/11/ (props changed) Modified: stable/11/cddl/contrib/opensolaris/cmd/zdb/zdb.c ============================================================================== --- stable/11/cddl/contrib/opensolaris/cmd/zdb/zdb.c Wed Oct 12 05:14:04 2016 (r307107) +++ stable/11/cddl/contrib/opensolaris/cmd/zdb/zdb.c Wed Oct 12 05:15:09 2016 (r307108) @@ -60,7 +60,6 @@ #include #include #include -#undef ZFS_MAXNAMELEN #undef verify #include @@ -1945,7 +1944,7 @@ dump_dir(objset_t *os) uint64_t refdbytes, usedobjs, scratch; char numbuf[32]; char blkbuf[BP_SPRINTF_LEN + 20]; - char osname[MAXNAMELEN]; + char osname[ZFS_MAX_DATASET_NAME_LEN]; char *type = "UNKNOWN"; int verbosity = dump_opt['d']; int print_header = 1; @@ -3482,7 +3481,7 @@ find_zpool(char **target, nvlist_t **con nvlist_t *match = NULL; char *name = NULL; char *sepp = NULL; - char sep; + char sep = '\0'; int count = 0; importargs_t args = { 0 }; Modified: stable/11/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c ============================================================================== --- stable/11/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c Wed Oct 12 05:14:04 2016 (r307107) +++ stable/11/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c Wed Oct 12 05:15:09 2016 (r307108) @@ -1510,7 +1510,7 @@ get_callback(zfs_handle_t *zhp, void *da char buf[ZFS_MAXPROPLEN]; char rbuf[ZFS_MAXPROPLEN]; zprop_source_t sourcetype; - char source[ZFS_MAXNAMELEN]; + char source[ZFS_MAX_DATASET_NAME_LEN]; zprop_get_cbdata_t *cbp = data; nvlist_t *user_props = zfs_get_user_props(zhp); zprop_list_t *pl = cbp->cb_proplist; @@ -1990,7 +1990,7 @@ typedef struct upgrade_cbdata { uint64_t cb_version; boolean_t cb_newer; boolean_t cb_foundone; - char cb_lastfs[ZFS_MAXNAMELEN]; + char cb_lastfs[ZFS_MAX_DATASET_NAME_LEN]; } upgrade_cbdata_t; static int @@ -2436,7 +2436,7 @@ userspace_cb(void *arg, const char *doma if (domain != NULL && domain[0] != '\0') { /* SMB */ - char sid[ZFS_MAXNAMELEN + 32]; + char sid[MAXNAMELEN + 32]; uid_t id; #ifdef illumos int err; @@ -2573,7 +2573,7 @@ print_us_node(boolean_t scripted, boolea size_t *width, us_node_t *node) { nvlist_t *nvl = node->usn_nvl; - char valstr[ZFS_MAXNAMELEN]; + char valstr[MAXNAMELEN]; boolean_t first = B_TRUE; int cfield = 0; int field; @@ -3472,7 +3472,7 @@ zfs_do_rollback(int argc, char **argv) boolean_t force = B_FALSE; rollback_cbdata_t cb = { 0 }; zfs_handle_t *zhp, *snap; - char parentname[ZFS_MAXNAMELEN]; + char parentname[ZFS_MAX_DATASET_NAME_LEN]; char *delim; /* check options */ @@ -3872,7 +3872,7 @@ zfs_do_send(int argc, char **argv) */ if (strchr(argv[0], '@') == NULL || (fromname && strchr(fromname, '#') != NULL)) { - char frombuf[ZFS_MAXNAMELEN]; + char frombuf[ZFS_MAX_DATASET_NAME_LEN]; enum lzc_send_flags lzc_flags = 0; if (flags.replicate || flags.doall || flags.props || @@ -3924,7 +3924,7 @@ zfs_do_send(int argc, char **argv) * case if they specify the origin. */ if (fromname && (cp = strchr(fromname, '@')) != NULL) { - char origin[ZFS_MAXNAMELEN]; + char origin[ZFS_MAX_DATASET_NAME_LEN]; zprop_source_t src; (void) zfs_prop_get(zhp, ZFS_PROP_ORIGIN, @@ -4058,7 +4058,7 @@ zfs_do_receive(int argc, char **argv) usage(B_FALSE); } - char namebuf[ZFS_MAXNAMELEN]; + char namebuf[ZFS_MAX_DATASET_NAME_LEN]; (void) snprintf(namebuf, sizeof (namebuf), "%s/%%recv", argv[0]); @@ -4916,7 +4916,7 @@ store_allow_perm(zfs_deleg_who_type_t ty { int i; char ld[2] = { '\0', '\0' }; - char who_buf[ZFS_MAXNAMELEN+32]; + char who_buf[MAXNAMELEN + 32]; char base_type = '\0'; char set_type = '\0'; nvlist_t *base_nvl = NULL; @@ -5284,7 +5284,7 @@ static void print_fs_perms(fs_perm_set_t *fspset) { fs_perm_node_t *node = NULL; - char buf[ZFS_MAXNAMELEN+32]; + char buf[MAXNAMELEN + 32]; const char *dsname = buf; for (node = uu_list_first(fspset->fsps_list); node != NULL; @@ -5293,7 +5293,7 @@ print_fs_perms(fs_perm_set_t *fspset) uu_avl_t *uge_avl = node->fspn_fsperm.fsp_uge_avl; int left = 0; - (void) snprintf(buf, ZFS_MAXNAMELEN+32, + (void) snprintf(buf, sizeof (buf), gettext("---- Permissions on %s "), node->fspn_fsperm.fsp_name); (void) printf(dsname); @@ -5490,7 +5490,7 @@ zfs_do_hold_rele_impl(int argc, char **a for (i = 0; i < argc; ++i) { zfs_handle_t *zhp; - char parent[ZFS_MAXNAMELEN]; + char parent[ZFS_MAX_DATASET_NAME_LEN]; const char *delim; char *path = argv[i]; @@ -5623,7 +5623,7 @@ holds_callback(zfs_handle_t *zhp, void * nvlist_t *nvl = NULL; nvpair_t *nvp = NULL; const char *zname = zfs_get_name(zhp); - size_t znamelen = strnlen(zname, ZFS_MAXNAMELEN); + size_t znamelen = strlen(zname); if (cbp->cb_recursive && cbp->cb_snapname != NULL) { const char *snapname; @@ -5644,7 +5644,7 @@ holds_callback(zfs_handle_t *zhp, void * while ((nvp = nvlist_next_nvpair(nvl, nvp)) != NULL) { const char *tag = nvpair_name(nvp); - size_t taglen = strnlen(tag, MAXNAMELEN); + size_t taglen = strlen(tag); if (taglen > cbp->cb_max_taglen) cbp->cb_max_taglen = taglen; } @@ -6981,7 +6981,7 @@ zfs_do_diff(int argc, char **argv) static int zfs_do_bookmark(int argc, char **argv) { - char snapname[ZFS_MAXNAMELEN]; + char snapname[ZFS_MAX_DATASET_NAME_LEN]; zfs_handle_t *zhp; nvlist_t *nvl; int ret = 0; Modified: stable/11/cddl/contrib/opensolaris/cmd/zhack/zhack.c ============================================================================== --- stable/11/cddl/contrib/opensolaris/cmd/zhack/zhack.c Wed Oct 12 05:14:04 2016 (r307107) +++ stable/11/cddl/contrib/opensolaris/cmd/zhack/zhack.c Wed Oct 12 05:15:09 2016 (r307108) @@ -48,7 +48,6 @@ #include #include #include -#undef ZFS_MAXNAMELEN #undef verify #include Modified: stable/11/cddl/contrib/opensolaris/cmd/zpool/zpool_main.c ============================================================================== --- stable/11/cddl/contrib/opensolaris/cmd/zpool/zpool_main.c Wed Oct 12 05:14:04 2016 (r307107) +++ stable/11/cddl/contrib/opensolaris/cmd/zpool/zpool_main.c Wed Oct 12 05:15:09 2016 (r307108) @@ -4540,7 +4540,7 @@ zpool_do_status(int argc, char **argv) typedef struct upgrade_cbdata { boolean_t cb_first; boolean_t cb_unavail; - char cb_poolname[ZPOOL_MAXNAMELEN]; + char cb_poolname[ZFS_MAX_DATASET_NAME_LEN]; int cb_argc; uint64_t cb_version; char **cb_argv; Modified: stable/11/cddl/contrib/opensolaris/cmd/ztest/ztest.c ============================================================================== --- stable/11/cddl/contrib/opensolaris/cmd/ztest/ztest.c Wed Oct 12 05:14:04 2016 (r307107) +++ stable/11/cddl/contrib/opensolaris/cmd/ztest/ztest.c Wed Oct 12 05:15:09 2016 (r307108) @@ -141,8 +141,8 @@ typedef struct ztest_shared_hdr { static ztest_shared_hdr_t *ztest_shared_hdr; typedef struct ztest_shared_opts { - char zo_pool[MAXNAMELEN]; - char zo_dir[MAXNAMELEN]; + char zo_pool[ZFS_MAX_DATASET_NAME_LEN]; + char zo_dir[ZFS_MAX_DATASET_NAME_LEN]; char zo_alt_ztest[MAXNAMELEN]; char zo_alt_libpath[MAXNAMELEN]; uint64_t zo_vdevs; @@ -268,7 +268,7 @@ typedef struct ztest_od { uint64_t od_crblocksize; uint64_t od_gen; uint64_t od_crgen; - char od_name[MAXNAMELEN]; + char od_name[ZFS_MAX_DATASET_NAME_LEN]; } ztest_od_t; /* @@ -280,7 +280,7 @@ typedef struct ztest_ds { rwlock_t zd_zilog_lock; zilog_t *zd_zilog; ztest_od_t *zd_od; /* debugging aid */ - char zd_name[MAXNAMELEN]; + char zd_name[ZFS_MAX_DATASET_NAME_LEN]; mutex_t zd_dirobj_lock; rll_t zd_object_lock[ZTEST_OBJECT_LOCKS]; rll_t zd_range_lock[ZTEST_RANGE_LOCKS]; @@ -3227,7 +3227,7 @@ ztest_objset_destroy_cb(const char *name static boolean_t ztest_snapshot_create(char *osname, uint64_t id) { - char snapname[MAXNAMELEN]; + char snapname[ZFS_MAX_DATASET_NAME_LEN]; int error; (void) snprintf(snapname, sizeof (snapname), "%llu", (u_longlong_t)id); @@ -3247,10 +3247,10 @@ ztest_snapshot_create(char *osname, uint static boolean_t ztest_snapshot_destroy(char *osname, uint64_t id) { - char snapname[MAXNAMELEN]; + char snapname[ZFS_MAX_DATASET_NAME_LEN]; int error; - (void) snprintf(snapname, MAXNAMELEN, "%s@%llu", osname, + (void) snprintf(snapname, sizeof (snapname), "%s@%llu", osname, (u_longlong_t)id); error = dsl_destroy_snapshot(snapname, B_FALSE); @@ -3267,12 +3267,12 @@ ztest_dmu_objset_create_destroy(ztest_ds int iters; int error; objset_t *os, *os2; - char name[MAXNAMELEN]; + char name[ZFS_MAX_DATASET_NAME_LEN]; zilog_t *zilog; (void) rw_rdlock(&ztest_name_lock); - (void) snprintf(name, MAXNAMELEN, "%s/temp_%llu", + (void) snprintf(name, sizeof (name), "%s/temp_%llu", ztest_opts.zo_pool, (u_longlong_t)id); /* @@ -3378,18 +3378,23 @@ ztest_dmu_snapshot_create_destroy(ztest_ void ztest_dsl_dataset_cleanup(char *osname, uint64_t id) { - char snap1name[MAXNAMELEN]; - char clone1name[MAXNAMELEN]; - char snap2name[MAXNAMELEN]; - char clone2name[MAXNAMELEN]; - char snap3name[MAXNAMELEN]; + char snap1name[ZFS_MAX_DATASET_NAME_LEN]; + char clone1name[ZFS_MAX_DATASET_NAME_LEN]; + char snap2name[ZFS_MAX_DATASET_NAME_LEN]; + char clone2name[ZFS_MAX_DATASET_NAME_LEN]; + char snap3name[ZFS_MAX_DATASET_NAME_LEN]; int error; - (void) snprintf(snap1name, MAXNAMELEN, "%s@s1_%llu", osname, id); - (void) snprintf(clone1name, MAXNAMELEN, "%s/c1_%llu", osname, id); - (void) snprintf(snap2name, MAXNAMELEN, "%s@s2_%llu", clone1name, id); - (void) snprintf(clone2name, MAXNAMELEN, "%s/c2_%llu", osname, id); - (void) snprintf(snap3name, MAXNAMELEN, "%s@s3_%llu", clone1name, id); + (void) snprintf(snap1name, sizeof (snap1name), + "%s@s1_%llu", osname, id); + (void) snprintf(clone1name, sizeof (clone1name), + "%s/c1_%llu", osname, id); + (void) snprintf(snap2name, sizeof (snap2name), + "%s@s2_%llu", clone1name, id); + (void) snprintf(clone2name, sizeof (clone2name), + "%s/c2_%llu", osname, id); + (void) snprintf(snap3name, sizeof (snap3name), + "%s@s3_%llu", clone1name, id); error = dsl_destroy_head(clone2name); if (error && error != ENOENT) @@ -3415,11 +3420,11 @@ void ztest_dsl_dataset_promote_busy(ztest_ds_t *zd, uint64_t id) { objset_t *os; - char snap1name[MAXNAMELEN]; - char clone1name[MAXNAMELEN]; - char snap2name[MAXNAMELEN]; - char clone2name[MAXNAMELEN]; - char snap3name[MAXNAMELEN]; + char snap1name[ZFS_MAX_DATASET_NAME_LEN]; + char clone1name[ZFS_MAX_DATASET_NAME_LEN]; + char snap2name[ZFS_MAX_DATASET_NAME_LEN]; + char clone2name[ZFS_MAX_DATASET_NAME_LEN]; + char snap3name[ZFS_MAX_DATASET_NAME_LEN]; char *osname = zd->zd_name; int error; @@ -3427,11 +3432,16 @@ ztest_dsl_dataset_promote_busy(ztest_ds_ ztest_dsl_dataset_cleanup(osname, id); - (void) snprintf(snap1name, MAXNAMELEN, "%s@s1_%llu", osname, id); - (void) snprintf(clone1name, MAXNAMELEN, "%s/c1_%llu", osname, id); - (void) snprintf(snap2name, MAXNAMELEN, "%s@s2_%llu", clone1name, id); - (void) snprintf(clone2name, MAXNAMELEN, "%s/c2_%llu", osname, id); - (void) snprintf(snap3name, MAXNAMELEN, "%s@s3_%llu", clone1name, id); + (void) snprintf(snap1name, sizeof (snap1name), + "%s@s1_%llu", osname, id); + (void) snprintf(clone1name, sizeof (clone1name), + "%s/c1_%llu", osname, id); + (void) snprintf(snap2name, sizeof (snap2name), + "%s@s2_%llu", clone1name, id); + (void) snprintf(clone2name, sizeof (clone2name), + "%s/c2_%llu", osname, id); + (void) snprintf(snap3name, sizeof (snap3name), + "%s@s3_%llu", clone1name, id); error = dmu_objset_snapshot_one(osname, strchr(snap1name, '@') + 1); if (error && error != EEXIST) { @@ -4249,7 +4259,7 @@ ztest_fzap(ztest_ds_t *zd, uint64_t id) * 2050 entries we should see ptrtbl growth and leaf-block split. */ for (int i = 0; i < 2050; i++) { - char name[MAXNAMELEN]; + char name[ZFS_MAX_DATASET_NAME_LEN]; uint64_t value = i; dmu_tx_t *tx; int error; @@ -4654,7 +4664,7 @@ ztest_dmu_snapshot_hold(ztest_ds_t *zd, char fullname[100]; char clonename[100]; char tag[100]; - char osname[MAXNAMELEN]; + char osname[ZFS_MAX_DATASET_NAME_LEN]; nvlist_t *holds; (void) rw_rdlock(&ztest_name_lock); @@ -5450,13 +5460,13 @@ ztest_thread(void *arg) static void ztest_dataset_name(char *dsname, char *pool, int d) { - (void) snprintf(dsname, MAXNAMELEN, "%s/ds_%d", pool, d); + (void) snprintf(dsname, ZFS_MAX_DATASET_NAME_LEN, "%s/ds_%d", pool, d); } static void ztest_dataset_destroy(int d) { - char name[MAXNAMELEN]; + char name[ZFS_MAX_DATASET_NAME_LEN]; ztest_dataset_name(name, ztest_opts.zo_pool, d); @@ -5505,7 +5515,7 @@ ztest_dataset_open(int d) uint64_t committed_seq = ZTEST_GET_SHARED_DS(d)->zd_seq; objset_t *os; zilog_t *zilog; - char name[MAXNAMELEN]; + char name[ZFS_MAX_DATASET_NAME_LEN]; int error; ztest_dataset_name(name, ztest_opts.zo_pool, d); @@ -5728,8 +5738,8 @@ ztest_run(ztest_shared_t *zs) * different name. */ if (ztest_random(2) == 0) { - char name[MAXNAMELEN]; - (void) snprintf(name, MAXNAMELEN, "%s_import", + char name[ZFS_MAX_DATASET_NAME_LEN]; + (void) snprintf(name, sizeof (name), "%s_import", ztest_opts.zo_pool); ztest_spa_import_export(ztest_opts.zo_pool, name); ztest_spa_import_export(name, ztest_opts.zo_pool); @@ -6297,7 +6307,7 @@ main(int argc, char **argv) if (spa_open(ztest_opts.zo_pool, &spa, FTAG) == 0) { spa_close(spa, FTAG); } else { - char tmpname[MAXNAMELEN]; + char tmpname[ZFS_MAX_DATASET_NAME_LEN]; kernel_fini(); kernel_init(FREAD | FWRITE); (void) snprintf(tmpname, sizeof (tmpname), "%s_tmp", Modified: stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs.h ============================================================================== --- stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs.h Wed Oct 12 05:14:04 2016 (r307107) +++ stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs.h Wed Oct 12 05:15:09 2016 (r307108) @@ -51,8 +51,6 @@ extern "C" { /* * Miscellaneous ZFS constants */ -#define ZFS_MAXNAMELEN MAXNAMELEN -#define ZPOOL_MAXNAMELEN MAXNAMELEN #define ZFS_MAXPROPLEN MAXPATHLEN #define ZPOOL_MAXPROPLEN MAXPATHLEN Modified: stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_changelist.c ============================================================================== --- stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_changelist.c Wed Oct 12 05:14:04 2016 (r307107) +++ stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_changelist.c Wed Oct 12 05:15:09 2016 (r307108) @@ -26,6 +26,7 @@ * Portions Copyright 2007 Ramprakash Jelari * Copyright (c) 2011 Pawel Jakub Dawidek . * All rights reserved. + * Copyright (c) 2014, 2015 by Delphix. All rights reserved. * Copyright 2016 Igor Kozhukhov */ @@ -296,7 +297,7 @@ void changelist_rename(prop_changelist_t *clp, const char *src, const char *dst) { prop_changenode_t *cn; - char newname[ZFS_MAXNAMELEN]; + char newname[ZFS_MAX_DATASET_NAME_LEN]; for (cn = uu_list_first(clp->cl_list); cn != NULL; cn = uu_list_next(clp->cl_list, cn)) { Modified: stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c ============================================================================== --- stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c Wed Oct 12 05:14:04 2016 (r307107) +++ stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c Wed Oct 12 05:15:09 2016 (r307108) @@ -554,7 +554,7 @@ zfs_bookmark_exists(const char *path) { nvlist_t *bmarks; nvlist_t *props; - char fsname[ZFS_MAXNAMELEN]; + char fsname[ZFS_MAX_DATASET_NAME_LEN]; char *bmark_name; char *pound; int err; @@ -2181,7 +2181,7 @@ struct get_clones_arg { uint64_t numclones; nvlist_t *value; const char *origin; - char buf[ZFS_MAXNAMELEN]; + char buf[ZFS_MAX_DATASET_NAME_LEN]; }; int @@ -2236,7 +2236,7 @@ zfs_get_clones_nvl(zfs_handle_t *zhp) if (gca.numclones != 0) { zfs_handle_t *root; - char pool[ZFS_MAXNAMELEN]; + char pool[ZFS_MAX_DATASET_NAME_LEN]; char *cp = pool; /* get the pool name */ @@ -3021,7 +3021,7 @@ check_parents(libzfs_handle_t *hdl, cons boolean_t accept_ancestor, int *prefixlen) { zfs_cmd_t zc = { 0 }; - char parent[ZFS_MAXNAMELEN]; + char parent[ZFS_MAX_DATASET_NAME_LEN]; char *slash; zfs_handle_t *zhp; char errbuf[1024]; @@ -3260,7 +3260,7 @@ zfs_create(libzfs_handle_t *hdl, const c ost = LZC_DATSET_TYPE_ZFS; /* open zpool handle for prop validation */ - char pool_path[MAXNAMELEN]; + char pool_path[ZFS_MAX_DATASET_NAME_LEN]; (void) strlcpy(pool_path, path, sizeof (pool_path)); /* truncate pool_path at first slash */ @@ -3329,7 +3329,7 @@ zfs_create(libzfs_handle_t *hdl, const c /* check for failure */ if (ret != 0) { - char parent[ZFS_MAXNAMELEN]; + char parent[ZFS_MAX_DATASET_NAME_LEN]; (void) parent_name(path, parent, sizeof (parent)); switch (errno) { @@ -3419,7 +3419,7 @@ static int zfs_check_snap_cb(zfs_handle_t *zhp, void *arg) { struct destroydata *dd = arg; - char name[ZFS_MAXNAMELEN]; + char name[ZFS_MAX_DATASET_NAME_LEN]; int rv = 0; (void) snprintf(name, sizeof (name), @@ -3509,7 +3509,7 @@ zfs_destroy_snaps_nvl(libzfs_handle_t *h int zfs_clone(zfs_handle_t *zhp, const char *target, nvlist_t *props) { - char parent[ZFS_MAXNAMELEN]; + char parent[ZFS_MAX_DATASET_NAME_LEN]; int ret; char errbuf[1024]; libzfs_handle_t *hdl = zhp->zfs_hdl; @@ -3639,7 +3639,7 @@ static int zfs_snapshot_cb(zfs_handle_t *zhp, void *arg) { snapdata_t *sd = arg; - char name[ZFS_MAXNAMELEN]; + char name[ZFS_MAX_DATASET_NAME_LEN]; int rv = 0; if (zfs_prop_get_int(zhp, ZFS_PROP_INCONSISTENT) == 0) { @@ -3688,7 +3688,7 @@ zfs_snapshot_nvl(libzfs_handle_t *hdl, n * get pool handle for prop validation. assumes all snaps are in the * same pool, as does lzc_snapshot (below). */ - char pool[MAXNAMELEN]; + char pool[ZFS_MAX_DATASET_NAME_LEN]; elem = nvlist_next_nvpair(snaps, NULL); (void) strlcpy(pool, nvpair_name(elem), sizeof (pool)); pool[strcspn(pool, "/@")] = '\0'; @@ -3742,7 +3742,7 @@ zfs_snapshot(libzfs_handle_t *hdl, const { int ret; snapdata_t sd = { 0 }; - char fsname[ZFS_MAXNAMELEN]; + char fsname[ZFS_MAX_DATASET_NAME_LEN]; char *cp; zfs_handle_t *zhp; char errbuf[1024]; @@ -3921,7 +3921,7 @@ zfs_rename(zfs_handle_t *zhp, const char prop_changelist_t *cl = NULL; zfs_handle_t *zhrp = NULL; char *parentname = NULL; - char parent[ZFS_MAXNAMELEN]; + char parent[ZFS_MAX_DATASET_NAME_LEN]; char property[ZFS_MAXPROPLEN]; libzfs_handle_t *hdl = zhp->zfs_hdl; char errbuf[1024]; @@ -4435,7 +4435,7 @@ static int zfs_hold_one(zfs_handle_t *zhp, void *arg) { struct holdarg *ha = arg; - char name[ZFS_MAXNAMELEN]; + char name[ZFS_MAX_DATASET_NAME_LEN]; int rv = 0; (void) snprintf(name, sizeof (name), @@ -4554,7 +4554,7 @@ static int zfs_release_one(zfs_handle_t *zhp, void *arg) { struct holdarg *ha = arg; - char name[ZFS_MAXNAMELEN]; + char name[ZFS_MAX_DATASET_NAME_LEN]; int rv = 0; nvlist_t *existing_holds; @@ -4683,7 +4683,7 @@ tryagain: zc.zc_nvlist_dst_size = nvsz; zc.zc_nvlist_dst = (uintptr_t)nvbuf; - (void) strlcpy(zc.zc_name, zhp->zfs_name, ZFS_MAXNAMELEN); + (void) strlcpy(zc.zc_name, zhp->zfs_name, sizeof (zc.zc_name)); if (ioctl(hdl->libzfs_fd, ZFS_IOC_GET_FSACL, &zc) != 0) { (void) snprintf(errbuf, sizeof (errbuf), Modified: stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_diff.c ============================================================================== --- stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_diff.c Wed Oct 12 05:14:04 2016 (r307107) +++ stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_diff.c Wed Oct 12 05:15:09 2016 (r307108) @@ -22,6 +22,7 @@ /* * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. * Copyright 2015 Nexenta Systems, Inc. All rights reserved. + * Copyright (c) 2015 by Delphix. All rights reserved. * Copyright 2016 Joyent, Inc. * Copyright 2016 Igor Kozhukhov */ @@ -618,7 +619,7 @@ get_snapshot_names(differ_info_t *di, co * not the same dataset name, might be okay if * tosnap is a clone of a fromsnap descendant. */ - char origin[ZFS_MAXNAMELEN]; + char origin[ZFS_MAX_DATASET_NAME_LEN]; zprop_source_t src; zfs_handle_t *zhp; Modified: stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_impl.h ============================================================================== --- stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_impl.h Wed Oct 12 05:14:04 2016 (r307107) +++ stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_impl.h Wed Oct 12 05:15:09 2016 (r307108) @@ -22,18 +22,18 @@ /* * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2011 Pawel Jakub Dawidek. All rights reserved. - * Copyright (c) 2013 by Delphix. All rights reserved. + * Copyright (c) 2011, 2015 by Delphix. All rights reserved. * Copyright (c) 2013 Martin Matuska . All rights reserved. */ #ifndef _LIBZFS_IMPL_H #define _LIBZFS_IMPL_H -#include #include -#include #include #include +#include +#include #include #include @@ -86,7 +86,7 @@ struct libzfs_handle { struct zfs_handle { libzfs_handle_t *zfs_hdl; zpool_handle_t *zpool_hdl; - char zfs_name[ZFS_MAXNAMELEN]; + char zfs_name[ZFS_MAX_DATASET_NAME_LEN]; zfs_type_t zfs_type; /* type including snapshot */ zfs_type_t zfs_head_type; /* type excluding snapshot */ dmu_objset_stats_t zfs_dmustats; @@ -107,7 +107,7 @@ struct zfs_handle { struct zpool_handle { libzfs_handle_t *zpool_hdl; zpool_handle_t *zpool_next; - char zpool_name[ZPOOL_MAXNAMELEN]; + char zpool_name[ZFS_MAX_DATASET_NAME_LEN]; int zpool_state; size_t zpool_config_size; nvlist_t *zpool_config; Modified: stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_iter.c ============================================================================== --- stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_iter.c Wed Oct 12 05:14:04 2016 (r307107) +++ stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_iter.c Wed Oct 12 05:15:09 2016 (r307108) @@ -197,7 +197,7 @@ zfs_iter_bookmarks(zfs_handle_t *zhp, zf for (nvpair_t *pair = nvlist_next_nvpair(bmarks, NULL); pair != NULL; pair = nvlist_next_nvpair(bmarks, pair)) { - char name[ZFS_MAXNAMELEN]; + char name[ZFS_MAX_DATASET_NAME_LEN]; char *bmark_name; nvlist_t *bmark_props; @@ -385,7 +385,7 @@ zfs_iter_snapspec(zfs_handle_t *fs_zhp, * exists. */ if (ssa.ssa_last[0] != '\0') { - char snapname[ZFS_MAXNAMELEN]; + char snapname[ZFS_MAX_DATASET_NAME_LEN]; (void) snprintf(snapname, sizeof (snapname), "%s@%s", zfs_get_name(fs_zhp), ssa.ssa_last); @@ -405,7 +405,7 @@ zfs_iter_snapspec(zfs_handle_t *fs_zhp, ret = ENOENT; } } else { - char snapname[ZFS_MAXNAMELEN]; + char snapname[ZFS_MAX_DATASET_NAME_LEN]; zfs_handle_t *snap_zhp; (void) snprintf(snapname, sizeof (snapname), "%s@%s", zfs_get_name(fs_zhp), comma_separated); Modified: stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_mount.c ============================================================================== --- stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_mount.c Wed Oct 12 05:14:04 2016 (r307107) +++ stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_mount.c Wed Oct 12 05:15:09 2016 (r307108) @@ -236,7 +236,7 @@ static boolean_t zfs_is_mountable(zfs_handle_t *zhp, char *buf, size_t buflen, zprop_source_t *source) { - char sourceloc[ZFS_MAXNAMELEN]; + char sourceloc[MAXNAMELEN]; zprop_source_t sourcetype; if (!zfs_prop_valid_for_type(ZFS_PROP_MOUNTPOINT, zhp->zfs_type)) Modified: stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_pool.c ============================================================================== --- stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_pool.c Wed Oct 12 05:14:04 2016 (r307107) +++ stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_pool.c Wed Oct 12 05:15:09 2016 (r307108) @@ -407,7 +407,7 @@ bootfs_name_valid(const char *pool, char boolean_t zpool_is_bootable(zpool_handle_t *zhp) { - char bootfs[ZPOOL_MAXNAMELEN]; + char bootfs[ZFS_MAX_DATASET_NAME_LEN]; return (zpool_get_prop(zhp, ZPOOL_PROP_BOOTFS, bootfs, sizeof (bootfs), NULL, B_FALSE) == 0 && strncmp(bootfs, "-", @@ -3803,7 +3803,7 @@ zpool_obj_to_path(zpool_handle_t *zhp, u zfs_cmd_t zc = { 0 }; boolean_t mounted = B_FALSE; char *mntpnt = NULL; - char dsname[MAXNAMELEN]; + char dsname[ZFS_MAX_DATASET_NAME_LEN]; if (dsobj == 0) { /* special case for the MOS */ @@ -4064,7 +4064,7 @@ zvol_check_dump_config(char *arg) uint_t toplevels; libzfs_handle_t *hdl; char errbuf[1024]; - char poolname[ZPOOL_MAXNAMELEN]; + char poolname[ZFS_MAX_DATASET_NAME_LEN]; int pathlen = strlen(ZVOL_FULL_DEV_DIR); int ret = 1; @@ -4087,7 +4087,7 @@ zvol_check_dump_config(char *arg) "malformed dataset name")); (void) zfs_error(hdl, EZFS_INVALIDNAME, errbuf); return (1); - } else if (p - volname >= ZFS_MAXNAMELEN) { + } else if (p - volname >= ZFS_MAX_DATASET_NAME_LEN) { zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, "dataset name is too long")); (void) zfs_error(hdl, EZFS_NAMETOOLONG, errbuf); Modified: stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c ============================================================================== --- stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c Wed Oct 12 05:14:04 2016 (r307107) +++ stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c Wed Oct 12 05:15:09 2016 (r307108) @@ -752,7 +752,7 @@ send_iterate_prop(zfs_handle_t *zhp, nvl static uint64_t get_snap_txg(libzfs_handle_t *hdl, const char *fs, const char *snap) { - char name[ZFS_MAXNAMELEN]; + char name[ZFS_MAX_DATASET_NAME_LEN]; uint64_t txg = 0; if (fs == NULL || fs[0] == '\0' || snap == NULL || snap[0] == '\0') @@ -920,7 +920,7 @@ typedef struct send_dump_data { /* these are all just the short snapname (the part after the @) */ const char *fromsnap; const char *tosnap; - char prevsnap[ZFS_MAXNAMELEN]; + char prevsnap[ZFS_MAX_DATASET_NAME_LEN]; uint64_t prevsnap_obj; boolean_t seenfrom, seento, replicate, doall, fromorigin; boolean_t verbose, dryrun, parsable, progress, embed_data, std_out; @@ -933,7 +933,7 @@ typedef struct send_dump_data { snapfilter_cb_t *filter_cb; void *filter_cb_arg; nvlist_t *debugnv; - char holdtag[ZFS_MAXNAMELEN]; + char holdtag[ZFS_MAX_DATASET_NAME_LEN]; int cleanup_fd; uint64_t size; } send_dump_data_t; @@ -1569,7 +1569,7 @@ zfs_send_resume(libzfs_handle_t *hdl, se uint64_t resumeobj, resumeoff, toguid, fromguid, bytes; zfs_handle_t *zhp; int error = 0; - char name[ZFS_MAXNAMELEN]; + char name[ZFS_MAX_DATASET_NAME_LEN]; enum lzc_send_flags lzc_flags = 0; (void) snprintf(errbuf, sizeof (errbuf), dgettext(TEXT_DOMAIN, @@ -2163,8 +2163,8 @@ recv_rename(libzfs_handle_t *hdl, const if (err != 0 && strncmp(name + baselen, "recv-", 5) != 0) { seq++; - (void) snprintf(newname, ZFS_MAXNAMELEN, "%.*srecv-%u-%u", - baselen, name, getpid(), seq); + (void) snprintf(newname, ZFS_MAX_DATASET_NAME_LEN, + "%.*srecv-%u-%u", baselen, name, getpid(), seq); (void) strlcpy(zc.zc_value, newname, sizeof (zc.zc_value)); if (flags->verbose) { @@ -2292,7 +2292,7 @@ static int guid_to_name(libzfs_handle_t *hdl, const char *parent, uint64_t guid, boolean_t bookmark_ok, char *name) { - char pname[ZFS_MAXNAMELEN]; + char pname[ZFS_MAX_DATASET_NAME_LEN]; guid_to_name_data_t gtnd; gtnd.guid = guid; @@ -2347,7 +2347,7 @@ created_before(libzfs_handle_t *hdl, avl { nvlist_t *nvfs; char *fsname, *snapname; - char buf[ZFS_MAXNAMELEN]; + char buf[ZFS_MAX_DATASET_NAME_LEN]; int rv; zfs_handle_t *guid1hdl, *guid2hdl; uint64_t create1, create2; @@ -2398,7 +2398,7 @@ recv_incremental_replication(libzfs_hand avl_tree_t *local_avl; nvpair_t *fselem, *nextfselem; char *fromsnap; - char newname[ZFS_MAXNAMELEN]; + char newname[ZFS_MAX_DATASET_NAME_LEN]; char guidname[32]; int error; boolean_t needagain, progress, recursive; @@ -2517,7 +2517,7 @@ again: /* check for delete */ if (found == NULL) { - char name[ZFS_MAXNAMELEN]; + char name[ZFS_MAX_DATASET_NAME_LEN]; if (!flags->force) continue; @@ -2557,8 +2557,8 @@ again: /* check for different snapname */ if (strcmp(nvpair_name(snapelem), stream_snapname) != 0) { - char name[ZFS_MAXNAMELEN]; - char tryname[ZFS_MAXNAMELEN]; + char name[ZFS_MAX_DATASET_NAME_LEN]; + char tryname[ZFS_MAX_DATASET_NAME_LEN]; (void) snprintf(name, sizeof (name), "%s@%s", fsname, nvpair_name(snapelem)); @@ -2640,7 +2640,7 @@ again: ((flags->isprefix || strcmp(tofs, fsname) != 0) && (s1 != NULL) && (s2 != NULL) && strcmp(s1, s2) != 0)) { nvlist_t *parent; - char tryname[ZFS_MAXNAMELEN]; + char tryname[ZFS_MAX_DATASET_NAME_LEN]; parent = fsavl_find(local_avl, stream_parent_fromsnap_guid, NULL); @@ -2708,8 +2708,8 @@ zfs_receive_package(libzfs_handle_t *hdl char *fromsnap = NULL; char *sendsnap = NULL; char *cp; - char tofs[ZFS_MAXNAMELEN]; - char sendfs[ZFS_MAXNAMELEN]; + char tofs[ZFS_MAX_DATASET_NAME_LEN]; + char sendfs[ZFS_MAX_DATASET_NAME_LEN]; char errbuf[1024]; dmu_replay_record_t drre; int error; @@ -2793,7 +2793,7 @@ zfs_receive_package(libzfs_handle_t *hdl nvlist_t *renamed = NULL; nvpair_t *pair = NULL; - (void) strlcpy(tofs, destname, ZFS_MAXNAMELEN); + (void) strlcpy(tofs, destname, sizeof (tofs)); if (flags->isprefix) { struct drr_begin *drrb = &drr->drr_u.drr_begin; int i; @@ -2802,7 +2802,7 @@ zfs_receive_package(libzfs_handle_t *hdl cp = strrchr(drrb->drr_toname, '/'); if (cp == NULL) { (void) strlcat(tofs, "/", - ZFS_MAXNAMELEN); + sizeof (tofs)); i = 0; } else { i = (cp - drrb->drr_toname); @@ -2812,7 +2812,7 @@ zfs_receive_package(libzfs_handle_t *hdl } /* zfs_receive_one() will create_parents() */ (void) strlcat(tofs, &drrb->drr_toname[i], - ZFS_MAXNAMELEN); + sizeof (tofs)); *strchr(tofs, '@') = '\0'; } @@ -2854,7 +2854,7 @@ zfs_receive_package(libzfs_handle_t *hdl * zfs_receive_one(). */ (void) strlcpy(sendfs, drr->drr_u.drr_begin.drr_toname, - ZFS_MAXNAMELEN); + sizeof (sendfs)); if ((cp = strchr(sendfs, '@')) != NULL) { *cp = '\0'; /* @@ -3004,7 +3004,7 @@ static void recv_ecksum_set_aux(libzfs_handle_t *hdl, const char *target_snap, boolean_t resumable) { - char target_fs[ZFS_MAXNAMELEN]; + char target_fs[ZFS_MAX_DATASET_NAME_LEN]; zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, "checksum mismatch or incomplete stream")); @@ -3207,7 +3207,7 @@ zfs_receive_one(libzfs_handle_t *hdl, in if (flags->verbose) (void) printf("found clone origin %s\n", zc.zc_string); } else if (originsnap) { - (void) strncpy(zc.zc_string, originsnap, ZFS_MAXNAMELEN); + (void) strncpy(zc.zc_string, originsnap, sizeof (zc.zc_string)); if (flags->verbose) (void) printf("using provided clone origin %s\n", zc.zc_string); @@ -3232,7 +3232,7 @@ zfs_receive_one(libzfs_handle_t *hdl, in *cp = '\0'; if (cp && !zfs_dataset_exists(hdl, zc.zc_name, ZFS_TYPE_DATASET)) { - char suffix[ZFS_MAXNAMELEN]; + char suffix[ZFS_MAX_DATASET_NAME_LEN]; (void) strcpy(suffix, strrchr(zc.zc_value, '/')); if (guid_to_name(hdl, zc.zc_name, parent_snapguid, B_FALSE, zc.zc_value) == 0) { @@ -3259,7 +3259,7 @@ zfs_receive_one(libzfs_handle_t *hdl, in if ((flags->isprefix || (*(chopprefix = drrb->drr_toname + strlen(sendfs)) != '\0' && *chopprefix != '@')) && !zfs_dataset_exists(hdl, zc.zc_name, ZFS_TYPE_DATASET)) { - char snap[ZFS_MAXNAMELEN]; + char snap[ZFS_MAX_DATASET_NAME_LEN]; (void) strcpy(snap, strchr(zc.zc_value, '@')); if (guid_to_name(hdl, zc.zc_name, drrb->drr_fromguid, B_FALSE, zc.zc_value) == 0) { @@ -3709,7 +3709,7 @@ zfs_receive_impl(libzfs_handle_t *hdl, c } if (DMU_GET_STREAM_HDRTYPE(drrb->drr_versioninfo) == DMU_SUBSTREAM) { - char nonpackage_sendfs[ZFS_MAXNAMELEN]; + char nonpackage_sendfs[ZFS_MAX_DATASET_NAME_LEN]; if (sendfs == NULL) { /* * We were not called from zfs_receive_package(). Get @@ -3717,7 +3717,8 @@ zfs_receive_impl(libzfs_handle_t *hdl, c */ char *cp; (void) strlcpy(nonpackage_sendfs, - drr.drr_u.drr_begin.drr_toname, ZFS_MAXNAMELEN); + drr.drr_u.drr_begin.drr_toname, + sizeof (nonpackage_sendfs)); if ((cp = strchr(nonpackage_sendfs, '@')) != NULL) *cp = '\0'; sendfs = nonpackage_sendfs; Modified: stable/11/cddl/contrib/opensolaris/lib/libzfs_core/common/libzfs_core.c ============================================================================== --- stable/11/cddl/contrib/opensolaris/lib/libzfs_core/common/libzfs_core.c Wed Oct 12 05:14:04 2016 (r307107) +++ stable/11/cddl/contrib/opensolaris/lib/libzfs_core/common/libzfs_core.c Wed Oct 12 05:15:09 2016 (r307108) @@ -265,7 +265,7 @@ lzc_snapshot(nvlist_t *snaps, nvlist_t * nvpair_t *elem; nvlist_t *args; int error; - char pool[MAXNAMELEN]; + char pool[ZFS_MAX_DATASET_NAME_LEN]; *errlist = NULL; @@ -317,7 +317,7 @@ lzc_destroy_snaps(nvlist_t *snaps, boole nvpair_t *elem; nvlist_t *args; int error; - char pool[MAXNAMELEN]; + char pool[ZFS_MAX_DATASET_NAME_LEN]; /* determine the pool name */ elem = nvlist_next_nvpair(snaps, NULL); @@ -344,7 +344,7 @@ lzc_snaprange_space(const char *firstsna nvlist_t *args; nvlist_t *result; int err; - char fs[MAXNAMELEN]; + char fs[ZFS_MAX_DATASET_NAME_LEN]; char *atp; /* determine the fs name */ @@ -409,7 +409,7 @@ lzc_exists(const char *dataset) int lzc_hold(nvlist_t *holds, int cleanup_fd, nvlist_t **errlist) { - char pool[MAXNAMELEN]; + char pool[ZFS_MAX_DATASET_NAME_LEN]; nvlist_t *args; nvpair_t *elem; int error; @@ -456,7 +456,7 @@ lzc_hold(nvlist_t *holds, int cleanup_fd int lzc_release(nvlist_t *holds, nvlist_t **errlist) { - char pool[MAXNAMELEN]; + char pool[ZFS_MAX_DATASET_NAME_LEN]; nvpair_t *elem; /* determine the pool name */ @@ -743,7 +743,7 @@ lzc_bookmark(nvlist_t *bookmarks, nvlist { nvpair_t *elem; int error; - char pool[MAXNAMELEN]; + char pool[ZFS_MAX_DATASET_NAME_LEN]; /* determine the pool name */ elem = nvlist_next_nvpair(bookmarks, NULL); @@ -805,7 +805,7 @@ lzc_destroy_bookmarks(nvlist_t *bmarks, { nvpair_t *elem; int error; - char pool[MAXNAMELEN]; + char pool[ZFS_MAX_DATASET_NAME_LEN]; /* determine the pool name */ elem = nvlist_next_nvpair(bmarks, NULL); Modified: stable/11/cddl/usr.sbin/zfsd/tests/zfsd_unittest.cc ============================================================================== --- stable/11/cddl/usr.sbin/zfsd/tests/zfsd_unittest.cc Wed Oct 12 05:14:04 2016 (r307107) +++ stable/11/cddl/usr.sbin/zfsd/tests/zfsd_unittest.cc Wed Oct 12 05:15:09 2016 (r307108) @@ -82,7 +82,7 @@ struct zpool_handle { libzfs_handle_t *zpool_hdl; zpool_handle_t *zpool_next; - char zpool_name[ZPOOL_MAXNAMELEN]; + char zpool_name[ZFS_MAX_DATASET_NAME_LEN]; int zpool_state; size_t zpool_config_size; nvlist_t *zpool_config; Modified: stable/11/sys/cddl/contrib/opensolaris/common/zfs/zfs_namecheck.c ============================================================================== --- stable/11/sys/cddl/contrib/opensolaris/common/zfs/zfs_namecheck.c Wed Oct 12 05:14:04 2016 (r307107) +++ stable/11/sys/cddl/contrib/opensolaris/common/zfs/zfs_namecheck.c Wed Oct 12 05:15:09 2016 (r307108) @@ -69,7 +69,7 @@ zfs_component_namecheck(const char *path { const char *loc; - if (strlen(path) >= MAXNAMELEN) { + if (strlen(path) >= ZFS_MAX_DATASET_NAME_LEN) { if (why) *why = NAME_ERR_TOOLONG; return (-1); @@ -140,14 +140,9 @@ dataset_namecheck(const char *path, name /* * Make sure the name is not too long. - * - * ZFS_MAXNAMELEN is the maximum dataset length used in the userland - * which is the same as MAXNAMELEN used in the kernel. - * If ZFS_MAXNAMELEN value is changed, make sure to cleanup all - * places using MAXNAMELEN. */ *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-all@freebsd.org Wed Oct 12 05:15:54 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id EAD35C0DCC2; Wed, 12 Oct 2016 05:15:54 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id A231E1ECA; Wed, 12 Oct 2016 05:15:54 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9C5FrkT012287; Wed, 12 Oct 2016 05:15:53 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9C5FrTx012286; Wed, 12 Oct 2016 05:15:53 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201610120515.u9C5FrTx012286@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Wed, 12 Oct 2016 05:15:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307109 - stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Oct 2016 05:15:55 -0000 Author: mav Date: Wed Oct 12 05:15:53 2016 New Revision: 307109 URL: https://svnweb.freebsd.org/changeset/base/307109 Log: MFC r305210: MFV r302661: 7082 bptree_iterate() passes wrong args to zfs_dbgmsg() illumos/illumos-gate@10e67aa0db0823d5464aafdd681f3c966155c68e https://github.com/illumos/illumos-gate/commit/10e67aa0db0823d5464aafdd681f3c966 155c68e https://www.illumos.org/issues/7082 upstream DLPX-40542 bptree_iterate() passes wrong args to zfs_dbgmsg() Reviewed by: Dan Kimmel Reviewed by: George Wilson Reviewed by: Igor Kozhukhov Approved by: Dan McDonald Author: Matthew Ahrens Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/bptree.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/bptree.c ============================================================================== --- stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/bptree.c Wed Oct 12 05:15:09 2016 (r307108) +++ stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/bptree.c Wed Oct 12 05:15:53 2016 (r307109) @@ -20,7 +20,7 @@ */ /* - * Copyright (c) 2011, 2014 by Delphix. All rights reserved. + * Copyright (c) 2011, 2015 by Delphix. All rights reserved. * Copyright (c) 2014 Integros [integros.com] */ @@ -220,9 +220,10 @@ bptree_iterate(objset_t *os, uint64_t ob if (zfs_free_leak_on_eio) flags |= TRAVERSE_HARD; - zfs_dbgmsg("bptree index %d: traversing from min_txg=%lld " + zfs_dbgmsg("bptree index %lld: traversing from min_txg=%lld " "bookmark %lld/%lld/%lld/%lld", - i, (longlong_t)bte.be_birth_txg, + (longlong_t)i, + (longlong_t)bte.be_birth_txg, (longlong_t)bte.be_zb.zb_objset, (longlong_t)bte.be_zb.zb_object, (longlong_t)bte.be_zb.zb_level, From owner-svn-src-all@freebsd.org Wed Oct 12 05:16:34 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C1572C0DD2F; Wed, 12 Oct 2016 05:16:34 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 9E79973; Wed, 12 Oct 2016 05:16:34 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9C5GXGW012368; Wed, 12 Oct 2016 05:16:33 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9C5GX5L012366; Wed, 12 Oct 2016 05:16:33 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201610120516.u9C5GX5L012366@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Wed, 12 Oct 2016 05:16:33 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307110 - in stable/11: cddl/contrib/opensolaris/lib/libnvpair sys/cddl/contrib/opensolaris/common/nvpair X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Oct 2016 05:16:34 -0000 Author: mav Date: Wed Oct 12 05:16:33 2016 New Revision: 307110 URL: https://svnweb.freebsd.org/changeset/base/307110 Log: MFC r305211: MFV r302662: 6447 handful of nvpair cleanups illumos/illumos-gate@759e89be359f2af635e4122d147df56bce948773 https://github.com/illumos/illumos-gate/commit/759e89be359f2af635e4122d147df56bc e948773 https://www.illumos.org/issues/6447 I got a patch from someone who uses nvpair code outside of illumos. It fixes a couple of gcc warnings/bugs for him. 1. silence uninitialized use warnings 2. add parentheses around assignment used as truth value 3. fix printf format specifier (ll is for integers only) 4. strstr, strspn, strcspn, and strcmp are declared in string.h, not strings.h. 5. avoid scanning integer into boolean variable Reviewed by: Josef 'Jeff' Sipek Reviewed by: Andy Stormont Reviewed by: Garrett D'Amore Approved by: Robert Mustacchi Author: Steve Dougherty Modified: stable/11/cddl/contrib/opensolaris/lib/libnvpair/libnvpair.c stable/11/sys/cddl/contrib/opensolaris/common/nvpair/opensolaris_nvpair.c Directory Properties: stable/11/ (props changed) Modified: stable/11/cddl/contrib/opensolaris/lib/libnvpair/libnvpair.c ============================================================================== --- stable/11/cddl/contrib/opensolaris/lib/libnvpair/libnvpair.c Wed Oct 12 05:15:53 2016 (r307109) +++ stable/11/cddl/contrib/opensolaris/lib/libnvpair/libnvpair.c Wed Oct 12 05:16:33 2016 (r307110) @@ -26,7 +26,7 @@ #include #include #include -#include +#include #include #include #include "libnvpair.h" @@ -1228,7 +1228,8 @@ nvpair_value_match_regex(nvpair_t *nvp, break; } case DATA_TYPE_BOOLEAN_VALUE: { - boolean_t val, val_arg; + int32_t val_arg; + boolean_t val; /* scanf boolean_t from value and check for match */ sr = sscanf(value, "%"SCNi32, &val_arg); @@ -1239,7 +1240,8 @@ nvpair_value_match_regex(nvpair_t *nvp, break; } case DATA_TYPE_BOOLEAN_ARRAY: { - boolean_t *val_array, val_arg; + boolean_t *val_array; + int32_t val_arg; /* check indexed value of array for match */ sr = sscanf(value, "%"SCNi32, &val_arg); Modified: stable/11/sys/cddl/contrib/opensolaris/common/nvpair/opensolaris_nvpair.c ============================================================================== --- stable/11/sys/cddl/contrib/opensolaris/common/nvpair/opensolaris_nvpair.c Wed Oct 12 05:15:53 2016 (r307109) +++ stable/11/sys/cddl/contrib/opensolaris/common/nvpair/opensolaris_nvpair.c Wed Oct 12 05:16:33 2016 (r307110) @@ -1629,6 +1629,8 @@ nvlist_lookup_nvpair_ei_sep(nvlist_t *nv if ((nvl == NULL) || (name == NULL)) return (EINVAL); + sepp = NULL; + idx = 0; /* step through components of name */ for (np = name; np && *np; np = sepp) { /* ensure unique names */ @@ -2386,7 +2388,7 @@ nvlist_xpack(nvlist_t *nvl, char **bufp, */ nv_priv_init(&nvpriv, nva, 0); - if (err = nvlist_size(nvl, &alloc_size, encoding)) + if ((err = nvlist_size(nvl, &alloc_size, encoding))) return (err); if ((buf = nv_mem_zalloc(&nvpriv, alloc_size)) == NULL) From owner-svn-src-all@freebsd.org Wed Oct 12 05:17:19 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 32AFCC0DDCA; Wed, 12 Oct 2016 05:17:19 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id F2AFA1F2; Wed, 12 Oct 2016 05:17:18 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9C5HIpt012453; Wed, 12 Oct 2016 05:17:18 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9C5HIPX012452; Wed, 12 Oct 2016 05:17:18 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201610120517.u9C5HIPX012452@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Wed, 12 Oct 2016 05:17:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307111 - stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Oct 2016 05:17:19 -0000 Author: mav Date: Wed Oct 12 05:17:17 2016 New Revision: 307111 URL: https://svnweb.freebsd.org/changeset/base/307111 Log: MFC r305221: MFV r302992: 7071 lzc_snapshot does not fill in errlist on ENOENT illumos/illumos-gate@25f7d993adbfb3452ac4625b3791670746d35ae3 https://github.com/illumos/illumos-gate/commit/25f7d993adbfb3452ac4625b379167074 6d35ae3 https://www.illumos.org/issues/7071 upstream DLPX-40482 lzc_snapshot does not fill in errlist on ENOENT Reviewed by: Igor Kozhukhov Reviewed by: George Wilson Reviewed by: Dan Kimmel Approved by: Robert Mustacchi Author: Matthew Ahrens Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c ============================================================================== --- stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c Wed Oct 12 05:16:33 2016 (r307110) +++ stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c Wed Oct 12 05:17:17 2016 (r307111) @@ -500,6 +500,14 @@ zfs_secpolicy_write_perms(const char *na dsl_dataset_t *ds; dsl_pool_t *dp; + /* + * First do a quick check for root in the global zone, which + * is allowed to do all write_perms. This ensures that zfs_ioc_* + * will get to handle nonexistent datasets. + */ + if (INGLOBALZONE(curthread) && secpolicy_zfs(cr) == 0) + return (0); + error = dsl_pool_hold(name, FTAG, &dp); if (error != 0) return (error); From owner-svn-src-all@freebsd.org Wed Oct 12 05:19:10 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 53361C0DE8A; Wed, 12 Oct 2016 05:19:10 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 2D142396; Wed, 12 Oct 2016 05:19:10 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9C5J9OW012579; Wed, 12 Oct 2016 05:19:09 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9C5J8R2012575; Wed, 12 Oct 2016 05:19:08 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201610120519.u9C5J8R2012575@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Wed, 12 Oct 2016 05:19:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307112 - in stable/11/sys/cddl/contrib/opensolaris/uts/common: fs/zfs fs/zfs/sys sys/fs X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Oct 2016 05:19:10 -0000 Author: mav Date: Wed Oct 12 05:19:08 2016 New Revision: 307112 URL: https://svnweb.freebsd.org/changeset/base/307112 Log: MFC r305222: MFV r302993: 7104 increase indirect block size illumos/illumos-gate@4b5c8e93cab28d3c65ba9d407fd8f46e3be1db1c https://github.com/illumos/illumos-gate/commit/4b5c8e93cab28d3c65ba9d407fd8f46e3 be1db1c https://www.illumos.org/issues/7104 The current default indirect block size is 16KB. We can improve performance by increasing it to 128KB. This is especially helpful for any workload that needs to read most of the metadata, e.g. scrub/resilver, file deletion, filesystem deletion, and zfs send. We also need to fix a few space estimation errors to make the tests pass. Reviewed by: George Wilson Reviewed by: Paul Dagnelie Reviewed by: Dan McDonald Approved by: Robert Mustacchi Author: Matthew Ahrens Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_objset.c stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_misc.c stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dnode.h stable/11/sys/cddl/contrib/opensolaris/uts/common/sys/fs/zfs.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_objset.c ============================================================================== --- stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_objset.c Wed Oct 12 05:17:17 2016 (r307111) +++ stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_objset.c Wed Oct 12 05:19:08 2016 (r307112) @@ -791,11 +791,17 @@ dmu_objset_create_impl(spa_t *spa, dsl_d /* * Determine the number of levels necessary for the meta-dnode - * to contain DN_MAX_OBJECT dnodes. + * to contain DN_MAX_OBJECT dnodes. Note that in order to + * ensure that we do not overflow 64 bits, there has to be + * a nlevels that gives us a number of blocks > DN_MAX_OBJECT + * but < 2^64. Therefore, + * (mdn->dn_indblkshift - SPA_BLKPTRSHIFT) (10) must be + * less than (64 - log2(DN_MAX_OBJECT)) (16). */ - while ((uint64_t)mdn->dn_nblkptr << (mdn->dn_datablkshift + + while ((uint64_t)mdn->dn_nblkptr << + (mdn->dn_datablkshift - DNODE_SHIFT + (levels - 1) * (mdn->dn_indblkshift - SPA_BLKPTRSHIFT)) < - DN_MAX_OBJECT * sizeof (dnode_phys_t)) + DN_MAX_OBJECT) levels++; mdn->dn_next_nlevels[tx->tx_txg & TXG_MASK] = Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_misc.c ============================================================================== --- stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_misc.c Wed Oct 12 05:17:17 2016 (r307111) +++ stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_misc.c Wed Oct 12 05:19:08 2016 (r307112) @@ -411,12 +411,20 @@ zfs_deadman_init() * it is possible to run the pool completely out of space, causing it to * be permanently read-only. * + * Note that on very small pools, the slop space will be larger than + * 3.2%, in an effort to have it be at least spa_min_slop (128MB), + * but we never allow it to be more than half the pool size. + * * See also the comments in zfs_space_check_t. */ int spa_slop_shift = 5; SYSCTL_INT(_vfs_zfs, OID_AUTO, spa_slop_shift, CTLFLAG_RWTUN, &spa_slop_shift, 0, "Shift value of reserved space (1/(2^spa_slop_shift))."); +uint64_t spa_min_slop = 128 * 1024 * 1024; +SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, spa_min_slop, CTLFLAG_RWTUN, + &spa_min_slop, 0, + "Minimal value of reserved space"); /* * ========================================================================== @@ -1723,14 +1731,16 @@ spa_get_asize(spa_t *spa, uint64_t lsize /* * Return the amount of slop space in bytes. It is 1/32 of the pool (3.2%), - * or at least 32MB. + * or at least 128MB, unless that would cause it to be more than half the + * pool size. * * See the comment above spa_slop_shift for details. */ uint64_t -spa_get_slop_space(spa_t *spa) { +spa_get_slop_space(spa_t *spa) +{ uint64_t space = spa_get_dspace(spa); - return (MAX(space >> spa_slop_shift, SPA_MINDEVSIZE >> 1)); + return (MAX(space >> spa_slop_shift, MIN(space >> 1, spa_min_slop))); } uint64_t Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dnode.h ============================================================================== --- stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dnode.h Wed Oct 12 05:17:17 2016 (r307111) +++ stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dnode.h Wed Oct 12 05:19:08 2016 (r307112) @@ -58,7 +58,7 @@ extern "C" { */ #define DNODE_SHIFT 9 /* 512 bytes */ #define DN_MIN_INDBLKSHIFT 12 /* 4k */ -#define DN_MAX_INDBLKSHIFT 14 /* 16k */ +#define DN_MAX_INDBLKSHIFT 17 /* 128k */ #define DNODE_BLOCK_SHIFT 14 /* 16k */ #define DNODE_CORE_SIZE 64 /* 64 bytes for dnode sans blkptrs */ #define DN_MAX_OBJECT_SHIFT 48 /* 256 trillion (zfs_fid_t limit) */ @@ -88,6 +88,11 @@ extern "C" { #define DNODES_PER_BLOCK_SHIFT (DNODE_BLOCK_SHIFT - DNODE_SHIFT) #define DNODES_PER_BLOCK (1ULL << DNODES_PER_BLOCK_SHIFT) + +/* + * This is inaccurate if the indblkshift of the particular object is not the + * max. But it's only used by userland to calculate the zvol reservation. + */ #define DNODES_PER_LEVEL_SHIFT (DN_MAX_INDBLKSHIFT - SPA_BLKPTRSHIFT) #define DNODES_PER_LEVEL (1ULL << DNODES_PER_LEVEL_SHIFT) Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/sys/fs/zfs.h ============================================================================== --- stable/11/sys/cddl/contrib/opensolaris/uts/common/sys/fs/zfs.h Wed Oct 12 05:17:17 2016 (r307111) +++ stable/11/sys/cddl/contrib/opensolaris/uts/common/sys/fs/zfs.h Wed Oct 12 05:19:08 2016 (r307112) @@ -610,6 +610,8 @@ typedef struct zpool_rewind_policy { /* * This is needed in userland to report the minimum necessary device size. + * + * Note that the zfs test suite uses 64MB vdevs. */ #define SPA_MINDEVSIZE (64ULL << 20) From owner-svn-src-all@freebsd.org Wed Oct 12 05:20:07 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 52930C0DF49; Wed, 12 Oct 2016 05:20:07 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 12DCA79F; Wed, 12 Oct 2016 05:20:07 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9C5K6nU012687; Wed, 12 Oct 2016 05:20:06 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9C5K63R012686; Wed, 12 Oct 2016 05:20:06 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201610120520.u9C5K63R012686@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Wed, 12 Oct 2016 05:20:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307113 - stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Oct 2016 05:20:07 -0000 Author: mav Date: Wed Oct 12 05:20:06 2016 New Revision: 307113 URL: https://svnweb.freebsd.org/changeset/base/307113 Log: MFC r305224: MFV r304158: 7136 ESC_VDEV_REMOVE_AUX ought to always include vdev information 7115 6922 generates ESC_ZFS_VDEV_REMOVE_AUX a bit too often illumos/illumos-gate@b72b6bb10ad55121a1b352c6f68ebdc8e20c9086 https://github.com/illumos/illumos-gate/commit/b72b6bb10ad55121a1b352c6f68ebdc8e 20c9086 https://www.illumos.org/issues/7136 6922 added ESC_ZFS_VDEV_REMOVE_AUX and ESC_ZFS_VDEV_REMOVE_DEV sysevents whenever an aux device gets removed from a pool. However, those sysevents will be created without the vdev_guid and vdev_path fields. It would be better to always populate those fields. https://www.illumos.org/issues/7115 The addition of spa_event_notify in vdev removal code (see #6922) causes event s to be generated even if the spare failed to be removed with EBUSY. Reviewed by: George Wilson Reviewed by: Josef 'Jeff' Sipek Approved by: Robert Mustacchi Author: Alan Somers Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c ============================================================================== --- stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c Wed Oct 12 05:19:08 2016 (r307112) +++ stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c Wed Oct 12 05:20:06 2016 (r307113) @@ -151,6 +151,8 @@ const zio_taskq_info_t zio_taskqs[ZIO_TY { ZTI_ONE, ZTI_NULL, ZTI_ONE, ZTI_NULL }, /* IOCTL */ }; +static sysevent_t *spa_event_create(spa_t *spa, vdev_t *vd, const char *name); +static void spa_event_post(sysevent_t *ev); static void spa_sync_version(void *arg, dmu_tx_t *tx); static void spa_sync_props(void *arg, dmu_tx_t *tx); static boolean_t spa_has_active_shared_spare(spa_t *spa); @@ -5738,6 +5740,7 @@ int spa_vdev_remove(spa_t *spa, uint64_t guid, boolean_t unspare) { vdev_t *vd; + sysevent_t *ev = NULL; metaslab_group_t *mg; nvlist_t **spares, **l2cache, *nv; uint64_t txg = 0; @@ -5761,6 +5764,9 @@ spa_vdev_remove(spa_t *spa, uint64_t gui * in this pool. */ if (vd == NULL || unspare) { + if (vd == NULL) + vd = spa_lookup_by_guid(spa, guid, B_TRUE); + ev = spa_event_create(spa, vd, ESC_ZFS_VDEV_REMOVE_AUX); spa_vdev_remove_aux(spa->spa_spares.sav_config, ZPOOL_CONFIG_SPARES, spares, nspares, nv); spa_load_spares(spa); @@ -5768,7 +5774,6 @@ spa_vdev_remove(spa_t *spa, uint64_t gui } else { error = SET_ERROR(EBUSY); } - spa_event_notify(spa, vd, ESC_ZFS_VDEV_REMOVE_AUX); } else if (spa->spa_l2cache.sav_vdevs != NULL && nvlist_lookup_nvlist_array(spa->spa_l2cache.sav_config, ZPOOL_CONFIG_L2CACHE, &l2cache, &nl2cache) == 0 && @@ -5776,11 +5781,12 @@ spa_vdev_remove(spa_t *spa, uint64_t gui /* * Cache devices can always be removed. */ + vd = spa_lookup_by_guid(spa, guid, B_TRUE); + ev = spa_event_create(spa, vd, ESC_ZFS_VDEV_REMOVE_AUX); spa_vdev_remove_aux(spa->spa_l2cache.sav_config, ZPOOL_CONFIG_L2CACHE, l2cache, nl2cache, nv); spa_load_l2cache(spa); spa->spa_l2cache.sav_sync = B_TRUE; - spa_event_notify(spa, vd, ESC_ZFS_VDEV_REMOVE_AUX); } else if (vd != NULL && vd->vdev_islog) { ASSERT(!locked); ASSERT(vd == vd->vdev_top); @@ -5817,9 +5823,9 @@ spa_vdev_remove(spa_t *spa, uint64_t gui /* * Clean up the vdev namespace. */ + ev = spa_event_create(spa, vd, ESC_ZFS_VDEV_REMOVE_DEV); spa_vdev_remove_from_namespace(spa, vd); - spa_event_notify(spa, vd, ESC_ZFS_VDEV_REMOVE_DEV); } else if (vd != NULL) { /* * Normal vdevs cannot be removed (yet). @@ -5835,6 +5841,9 @@ spa_vdev_remove(spa_t *spa, uint64_t gui if (!locked) error = spa_vdev_exit(spa, NULL, txg, error); + if (ev) + spa_event_post(ev); + return (error); } @@ -7229,24 +7238,17 @@ spa_has_active_shared_spare(spa_t *spa) return (B_FALSE); } -/* - * Post a sysevent corresponding to the given event. The 'name' must be one of - * the event definitions in sys/sysevent/eventdefs.h. The payload will be - * filled in from the spa and (optionally) the vdev. This doesn't do anything - * in the userland libzpool, as we don't want consumers to misinterpret ztest - * or zdb as real changes. - */ -void -spa_event_notify(spa_t *spa, vdev_t *vd, const char *name) +static sysevent_t * +spa_event_create(spa_t *spa, vdev_t *vd, const char *name) { + sysevent_t *ev = NULL; #ifdef _KERNEL - sysevent_t *ev; sysevent_attr_list_t *attr = NULL; sysevent_value_t value; - sysevent_id_t eid; ev = sysevent_alloc(EC_ZFS, (char *)name, SUNW_KERN_PUB "zfs", SE_SLEEP); + ASSERT(ev != NULL); value.value_type = SE_DATA_TYPE_STRING; value.value.sv_string = spa_name(spa); @@ -7278,11 +7280,34 @@ spa_event_notify(spa_t *spa, vdev_t *vd, goto done; attr = NULL; - (void) log_sysevent(ev, SE_SLEEP, &eid); - done: if (attr) sysevent_free_attr(attr); + +#endif + return (ev); +} + +static void +spa_event_post(sysevent_t *ev) +{ +#ifdef _KERNEL + sysevent_id_t eid; + + (void) log_sysevent(ev, SE_SLEEP, &eid); sysevent_free(ev); #endif } + +/* + * Post a sysevent corresponding to the given event. The 'name' must be one of + * the event definitions in sys/sysevent/eventdefs.h. The payload will be + * filled in from the spa and (optionally) the vdev. This doesn't do anything + * in the userland libzpool, as we don't want consumers to misinterpret ztest + * or zdb as real changes. + */ +void +spa_event_notify(spa_t *spa, vdev_t *vd, const char *name) +{ + spa_event_post(spa_event_create(spa, vd, name)); +} From owner-svn-src-all@freebsd.org Wed Oct 12 05:28:26 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 9F651C0E1AF; Wed, 12 Oct 2016 05:28:26 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 7703EC5C; Wed, 12 Oct 2016 05:28:26 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9C5SPJI016937; Wed, 12 Oct 2016 05:28:25 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9C5SPGp016933; Wed, 12 Oct 2016 05:28:25 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610120528.u9C5SPGp016933@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Wed, 12 Oct 2016 05:28:25 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307114 - in stable/10/sys: conf dev/hyperv/vmbus modules/hyperv/vmbus X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Oct 2016 05:28:26 -0000 Author: sephe Date: Wed Oct 12 05:28:24 2016 New Revision: 307114 URL: https://svnweb.freebsd.org/changeset/base/307114 Log: MFC 303379 hyperv/vmbus: Rename cleaned up bufring code Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7318 Added: stable/10/sys/dev/hyperv/vmbus/vmbus_br.c - copied, changed from r303379, head/sys/dev/hyperv/vmbus/vmbus_br.c Deleted: stable/10/sys/dev/hyperv/vmbus/hv_ring_buffer.c Modified: stable/10/sys/conf/files.amd64 stable/10/sys/conf/files.i386 stable/10/sys/modules/hyperv/vmbus/Makefile Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/conf/files.amd64 ============================================================================== --- stable/10/sys/conf/files.amd64 Wed Oct 12 05:20:06 2016 (r307113) +++ stable/10/sys/conf/files.amd64 Wed Oct 12 05:28:24 2016 (r307114) @@ -271,10 +271,10 @@ dev/hyperv/utilities/hv_kvp.c optiona dev/hyperv/utilities/hv_shutdown.c optional hyperv dev/hyperv/utilities/hv_timesync.c optional hyperv dev/hyperv/utilities/hv_util.c optional hyperv -dev/hyperv/vmbus/hv_ring_buffer.c optional hyperv dev/hyperv/vmbus/hyperv.c optional hyperv dev/hyperv/vmbus/hyperv_busdma.c optional hyperv dev/hyperv/vmbus/vmbus.c optional hyperv +dev/hyperv/vmbus/vmbus_br.c optional hyperv dev/hyperv/vmbus/vmbus_chan.c optional hyperv dev/hyperv/vmbus/vmbus_et.c optional hyperv dev/hyperv/vmbus/vmbus_if.m optional hyperv Modified: stable/10/sys/conf/files.i386 ============================================================================== --- stable/10/sys/conf/files.i386 Wed Oct 12 05:20:06 2016 (r307113) +++ stable/10/sys/conf/files.i386 Wed Oct 12 05:28:24 2016 (r307114) @@ -248,10 +248,10 @@ dev/hyperv/utilities/hv_kvp.c optiona dev/hyperv/utilities/hv_shutdown.c optional hyperv dev/hyperv/utilities/hv_timesync.c optional hyperv dev/hyperv/utilities/hv_util.c optional hyperv -dev/hyperv/vmbus/hv_ring_buffer.c optional hyperv dev/hyperv/vmbus/hyperv.c optional hyperv dev/hyperv/vmbus/hyperv_busdma.c optional hyperv dev/hyperv/vmbus/vmbus.c optional hyperv +dev/hyperv/vmbus/vmbus_br.c optional hyperv dev/hyperv/vmbus/vmbus_chan.c optional hyperv dev/hyperv/vmbus/vmbus_et.c optional hyperv dev/hyperv/vmbus/vmbus_if.m optional hyperv Copied and modified: stable/10/sys/dev/hyperv/vmbus/vmbus_br.c (from r303379, head/sys/dev/hyperv/vmbus/vmbus_br.c) ============================================================================== --- head/sys/dev/hyperv/vmbus/vmbus_br.c Wed Jul 27 09:27:08 2016 (r303379, copy source) +++ stable/10/sys/dev/hyperv/vmbus/vmbus_br.c Wed Oct 12 05:28:24 2016 (r307114) @@ -26,6 +26,9 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include +__FBSDID("$FreeBSD$"); + #include #include #include Modified: stable/10/sys/modules/hyperv/vmbus/Makefile ============================================================================== --- stable/10/sys/modules/hyperv/vmbus/Makefile Wed Oct 12 05:20:06 2016 (r307113) +++ stable/10/sys/modules/hyperv/vmbus/Makefile Wed Oct 12 05:28:24 2016 (r307114) @@ -4,11 +4,11 @@ ${.CURDIR}/../../../dev/hyperv/vmbus/${MACHINE_CPUARCH} KMOD= hv_vmbus -SRCS= hv_ring_buffer.c \ - hyperv.c \ +SRCS= hyperv.c \ hyperv_busdma.c \ hyperv_machdep.c \ vmbus.c \ + vmbus_br.c \ vmbus_chan.c \ vmbus_et.c SRCS+= acpi_if.h bus_if.h device_if.h opt_acpi.h vmbus_if.h From owner-svn-src-all@freebsd.org Wed Oct 12 05:35:58 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E9034C0E401; Wed, 12 Oct 2016 05:35:58 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id A9C55117; Wed, 12 Oct 2016 05:35:58 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9C5ZvNf021080; Wed, 12 Oct 2016 05:35:57 GMT (envelope-from gonzo@FreeBSD.org) Received: (from gonzo@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9C5Zv03021079; Wed, 12 Oct 2016 05:35:57 GMT (envelope-from gonzo@FreeBSD.org) Message-Id: <201610120535.u9C5Zv03021079@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: gonzo set sender to gonzo@FreeBSD.org using -f From: Oleksandr Tymoshenko Date: Wed, 12 Oct 2016 05:35:57 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307115 - head/sys/arm/broadcom/bcm2835 X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Oct 2016 05:35:59 -0000 Author: gonzo Date: Wed Oct 12 05:35:57 2016 New Revision: 307115 URL: https://svnweb.freebsd.org/changeset/base/307115 Log: Fix typo in comment Spotted by: loos Modified: head/sys/arm/broadcom/bcm2835/bcm2835_gpio.c Modified: head/sys/arm/broadcom/bcm2835/bcm2835_gpio.c ============================================================================== --- head/sys/arm/broadcom/bcm2835/bcm2835_gpio.c Wed Oct 12 05:28:24 2016 (r307114) +++ head/sys/arm/broadcom/bcm2835/bcm2835_gpio.c Wed Oct 12 05:35:57 2016 (r307115) @@ -676,7 +676,7 @@ bcm_gpio_get_reserved_pins(struct bcm_gp phandle_t gpio, node, reserved; ssize_t len; - /* Get read-only pins if they're porvided */ + /* Get read-only pins if they're provided */ gpio = ofw_bus_get_node(sc->sc_dev); if (bcm_gpio_get_ro_pins(sc, gpio, "broadcom,read-only", "read-only") != 0) From owner-svn-src-all@freebsd.org Wed Oct 12 05:36:56 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E9B70C0E457; Wed, 12 Oct 2016 05:36:56 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 9B0FB2B1; Wed, 12 Oct 2016 05:36:56 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9C5atRV021171; Wed, 12 Oct 2016 05:36:55 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9C5atPW021170; Wed, 12 Oct 2016 05:36:55 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201610120536.u9C5atPW021170@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Wed, 12 Oct 2016 05:36:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307116 - stable/10/cddl/contrib/opensolaris/lib/libzfs/common X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Oct 2016 05:36:57 -0000 Author: mav Date: Wed Oct 12 05:36:55 2016 New Revision: 307116 URL: https://svnweb.freebsd.org/changeset/base/307116 Log: MFC r305194: MFV r302642: 6876 Stack corruption after importing a pool with a too-long name illumos/illumos-gate@c971037baa5d64dfecf6d87ed602fc3116ebec41 https://github.com/illumos/illumos-gate/commit/c971037baa5d64dfecf6d87ed602fc3116ebec41 https://www.illumos.org/issues/6876 Calling dsl_dataset_name on a dataset with a 256 byte buffer is asking for trouble. We should check every dataset on import, using a 1024 byte buffer and checking each time to see if the dataset's new name is longer than 256 bytes. Reviewed by: Prakash Surya Reviewed by: Dan Kimmel Reviewed by: George Wilson Reviewed by: Yuri Pankov Approved by: Richard Lowe Author: Paul Dagnelie Modified: stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_pool.c Directory Properties: stable/10/ (props changed) Modified: stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_pool.c ============================================================================== --- stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_pool.c Wed Oct 12 05:35:57 2016 (r307115) +++ stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_pool.c Wed Oct 12 05:36:55 2016 (r307116) @@ -1799,7 +1799,12 @@ zpool_import_props(libzfs_handle_t *hdl, case EEXIST: (void) zpool_standard_error(hdl, error, desc); break; - + case ENAMETOOLONG: + zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, + "new name of at least one dataset is longer than " + "the maximum allowable length")); + (void) zfs_error(hdl, EZFS_NAMETOOLONG, desc); + break; default: (void) zpool_standard_error(hdl, error, desc); zpool_explain_recover(hdl, From owner-svn-src-all@freebsd.org Wed Oct 12 05:37:56 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 199A1C0E4C3; Wed, 12 Oct 2016 05:37:56 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id E64D6651; Wed, 12 Oct 2016 05:37:55 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9C5bscu021262; Wed, 12 Oct 2016 05:37:54 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9C5bsRS021261; Wed, 12 Oct 2016 05:37:54 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201610120537.u9C5bsRS021261@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Wed, 12 Oct 2016 05:37:54 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307117 - stable/10/cddl/contrib/opensolaris/lib/libzfs/common X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Oct 2016 05:37:56 -0000 Author: mav Date: Wed Oct 12 05:37:54 2016 New Revision: 307117 URL: https://svnweb.freebsd.org/changeset/base/307117 Log: MFC r305201: MFV r302653: 6111 zfs send should ignore datasets created after the ending snapshot illumos/illumos-gate@4a20c933b148de8a1c1d3538391c64284e636653 https://github.com/illumos/illumos-gate/commit/4a20c933b148de8a1c1d3538391c64284 e636653 https://www.illumos.org/issues/6111 If you create a zfs child folder, zfs send returns an error when a recursive incremental send is done between two snapshots made prior to the folder creation. The problem can be reproduced with the following steps. root@zfs:/# zfs create pool/test root@zfs:/# zfs snapshot pool/test@snap1 root@zfs:/# zfs snapshot pool/test@snap2 root@zfs:/# zfs create pool/test/child root@zfs:/# zfs send -R -I pool/test@snap1 pool/test@snap2 > /dev/null WARNING: could not send pool/test/child@snap2: does not exist WARNING: could not send pool/test/child@snap2: does not exist root@zfs:/# echo $? 1 root@zfs:/# zfs snapshot -r pool/test@snap3 root@zfs:/# zfs send -R -I pool/test@snap1 pool/test@snap3 > /dev/null root@zfs:/# echo $? 0 root@zfs:/# zfs send -R -I pool/test@snap2 pool/test@snap3 > /dev/null root@zfs:/# echo $? 0 Since pool/test/child was created after snap2, zfs send should not expect snap2 to be in pool/test/child when doing a recursive send. It should examine the compare the creation time of the snapshot and each child folder to decide if the folder will be sent. The next incremental send between snap2 and snap3 would properly create the child folder and snap3 which first appears in the child folder. The problem is identical if '-i' is used instead of '-I'. Reviewed by: Alex Aizman alex.aizman@nexenta.com Reviewed by: Alek Pinchuk alek.pinchuk@nexenta.com Reviewed by: Roman Strashkin roman.strashkin@nexenta.com Reviewed by: Matthew Ahrens Reviewed by: Paul Dagnelie Approved by: Garrett D'Amore Author: Alex Deiter Modified: stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c Directory Properties: stable/10/ (props changed) Modified: stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c ============================================================================== --- stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c Wed Oct 12 05:36:55 2016 (r307116) +++ stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c Wed Oct 12 05:37:54 2016 (r307117) @@ -580,13 +580,30 @@ fsavl_create(nvlist_t *fss) * Routines for dealing with the giant nvlist of fs-nvlists, etc. */ typedef struct send_data { + /* + * assigned inside every recursive call, + * restored from *_save on return: + * + * guid of fromsnap snapshot in parent dataset + * txg of fromsnap snapshot in current dataset + * txg of tosnap snapshot in current dataset + */ + uint64_t parent_fromsnap_guid; + uint64_t fromsnap_txg; + uint64_t tosnap_txg; + + /* the nvlists get accumulated during depth-first traversal */ nvlist_t *parent_snaps; nvlist_t *fss; nvlist_t *snapprops; + + /* send-receive configuration, does not change during traversal */ + const char *fsname; const char *fromsnap; const char *tosnap; boolean_t recursive; + boolean_t verbose; /* * The header nvlist is of the following format: @@ -619,11 +636,23 @@ send_iterate_snap(zfs_handle_t *zhp, voi { send_data_t *sd = arg; uint64_t guid = zhp->zfs_dmustats.dds_guid; + uint64_t txg = zhp->zfs_dmustats.dds_creation_txg; char *snapname; nvlist_t *nv; snapname = strrchr(zhp->zfs_name, '@')+1; + if (sd->tosnap_txg != 0 && txg > sd->tosnap_txg) { + if (sd->verbose) { + (void) fprintf(stderr, dgettext(TEXT_DOMAIN, + "skipping snapshot %s because it was created " + "after the destination snapshot (%s)\n"), + zhp->zfs_name, sd->tosnap); + } + zfs_close(zhp); + return (0); + } + VERIFY(0 == nvlist_add_uint64(sd->parent_snaps, snapname, guid)); /* * NB: if there is no fromsnap here (it's a newly created fs in @@ -717,6 +746,31 @@ send_iterate_prop(zfs_handle_t *zhp, nvl } /* + * returns snapshot creation txg + * and returns 0 if the snapshot does not exist + */ +static uint64_t +get_snap_txg(libzfs_handle_t *hdl, const char *fs, const char *snap) +{ + char name[ZFS_MAXNAMELEN]; + uint64_t txg = 0; + + if (fs == NULL || fs[0] == '\0' || snap == NULL || snap[0] == '\0') + return (txg); + + (void) snprintf(name, sizeof (name), "%s@%s", fs, snap); + if (zfs_dataset_exists(hdl, name, ZFS_TYPE_SNAPSHOT)) { + zfs_handle_t *zhp = zfs_open(hdl, name, ZFS_TYPE_SNAPSHOT); + if (zhp != NULL) { + txg = zfs_prop_get_int(zhp, ZFS_PROP_CREATETXG); + zfs_close(zhp); + } + } + + return (txg); +} + +/* * recursively generate nvlists describing datasets. See comment * for the data structure send_data_t above for description of contents * of the nvlist. @@ -728,9 +782,48 @@ send_iterate_fs(zfs_handle_t *zhp, void nvlist_t *nvfs, *nv; int rv = 0; uint64_t parent_fromsnap_guid_save = sd->parent_fromsnap_guid; + uint64_t fromsnap_txg_save = sd->fromsnap_txg; + uint64_t tosnap_txg_save = sd->tosnap_txg; + uint64_t txg = zhp->zfs_dmustats.dds_creation_txg; uint64_t guid = zhp->zfs_dmustats.dds_guid; + uint64_t fromsnap_txg, tosnap_txg; char guidstring[64]; + fromsnap_txg = get_snap_txg(zhp->zfs_hdl, zhp->zfs_name, sd->fromsnap); + if (fromsnap_txg != 0) + sd->fromsnap_txg = fromsnap_txg; + + tosnap_txg = get_snap_txg(zhp->zfs_hdl, zhp->zfs_name, sd->tosnap); + if (tosnap_txg != 0) + sd->tosnap_txg = tosnap_txg; + + /* + * on the send side, if the current dataset does not have tosnap, + * perform two additional checks: + * + * - skip sending the current dataset if it was created later than + * the parent tosnap + * - return error if the current dataset was created earlier than + * the parent tosnap + */ + if (sd->tosnap != NULL && tosnap_txg == 0) { + if (sd->tosnap_txg != 0 && txg > sd->tosnap_txg) { + if (sd->verbose) { + (void) fprintf(stderr, dgettext(TEXT_DOMAIN, + "skipping dataset %s: snapshot %s does " + "not exist\n"), zhp->zfs_name, sd->tosnap); + } + } else { + (void) fprintf(stderr, dgettext(TEXT_DOMAIN, + "cannot send %s@%s%s: snapshot %s@%s does not " + "exist\n"), sd->fsname, sd->tosnap, sd->recursive ? + dgettext(TEXT_DOMAIN, " recursively") : "", + zhp->zfs_name, sd->tosnap); + rv = -1; + } + goto out; + } + VERIFY(0 == nvlist_alloc(&nvfs, NV_UNIQUE_NAME, 0)); VERIFY(0 == nvlist_add_string(nvfs, "name", zhp->zfs_name)); VERIFY(0 == nvlist_add_uint64(nvfs, "parentfromsnap", @@ -739,8 +832,10 @@ send_iterate_fs(zfs_handle_t *zhp, void if (zhp->zfs_dmustats.dds_origin[0]) { zfs_handle_t *origin = zfs_open(zhp->zfs_hdl, zhp->zfs_dmustats.dds_origin, ZFS_TYPE_SNAPSHOT); - if (origin == NULL) - return (-1); + if (origin == NULL) { + rv = -1; + goto out; + } VERIFY(0 == nvlist_add_uint64(nvfs, "origin", origin->zfs_dmustats.dds_guid)); } @@ -771,7 +866,10 @@ send_iterate_fs(zfs_handle_t *zhp, void if (sd->recursive) rv = zfs_iter_filesystems(zhp, send_iterate_fs, sd); +out: sd->parent_fromsnap_guid = parent_fromsnap_guid_save; + sd->fromsnap_txg = fromsnap_txg_save; + sd->tosnap_txg = tosnap_txg_save; zfs_close(zhp); return (rv); @@ -779,7 +877,8 @@ send_iterate_fs(zfs_handle_t *zhp, void static int gather_nvlist(libzfs_handle_t *hdl, const char *fsname, const char *fromsnap, - const char *tosnap, boolean_t recursive, nvlist_t **nvlp, avl_tree_t **avlp) + const char *tosnap, boolean_t recursive, boolean_t verbose, + nvlist_t **nvlp, avl_tree_t **avlp) { zfs_handle_t *zhp; send_data_t sd = { 0 }; @@ -790,9 +889,11 @@ gather_nvlist(libzfs_handle_t *hdl, cons return (EZFS_BADTYPE); VERIFY(0 == nvlist_alloc(&sd.fss, NV_UNIQUE_NAME, 0)); + sd.fsname = fsname; sd.fromsnap = fromsnap; sd.tosnap = tosnap; sd.recursive = recursive; + sd.verbose = verbose; if ((error = send_iterate_fs(zhp, &sd)) != 0) { nvlist_free(sd.fss); @@ -1700,7 +1801,8 @@ zfs_send(zfs_handle_t *zhp, const char * } err = gather_nvlist(zhp->zfs_hdl, zhp->zfs_name, - fromsnap, tosnap, flags->replicate, &fss, &fsavl); + fromsnap, tosnap, flags->replicate, flags->verbose, + &fss, &fsavl); if (err) goto err_out; VERIFY(0 == nvlist_add_nvlist(hdrnv, "fss", fss)); @@ -2316,7 +2418,7 @@ again: VERIFY(0 == nvlist_alloc(&deleted, NV_UNIQUE_NAME, 0)); if ((error = gather_nvlist(hdl, tofs, fromsnap, NULL, - recursive, &local_nv, &local_avl)) != 0) + recursive, B_FALSE, &local_nv, &local_avl)) != 0) return (error); /* @@ -3380,7 +3482,7 @@ zfs_receive_one(libzfs_handle_t *hdl, in */ *cp = '\0'; if (gather_nvlist(hdl, zc.zc_value, NULL, NULL, B_FALSE, - &local_nv, &local_avl) == 0) { + B_FALSE, &local_nv, &local_avl) == 0) { *cp = '@'; fs = fsavl_find(local_avl, drrb->drr_toguid, NULL); fsavl_destroy(local_avl); From owner-svn-src-all@freebsd.org Wed Oct 12 05:38:46 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 497B8C0E52A; Wed, 12 Oct 2016 05:38:46 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 17256828; Wed, 12 Oct 2016 05:38:46 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9C5cj25021345; Wed, 12 Oct 2016 05:38:45 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9C5cjlf021344; Wed, 12 Oct 2016 05:38:45 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201610120538.u9C5cjlf021344@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Wed, 12 Oct 2016 05:38:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307118 - stable/10/cddl/contrib/opensolaris/lib/libzfs/common X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Oct 2016 05:38:46 -0000 Author: mav Date: Wed Oct 12 05:38:44 2016 New Revision: 307118 URL: https://svnweb.freebsd.org/changeset/base/307118 Log: MFC r305202: MFV r302654: 6879 incorrect endianness swap for drr_spill.drr_length in libzfs_sendrecv.c illumos/illumos-gate@20fea7a47472aceb64d3ed48cc2a3ea268bc4795 https://github.com/illumos/illumos-gate/commit/20fea7a47472aceb64d3ed48cc2a3ea26 8bc4795 https://www.illumos.org/issues/6879 In libzfs_sendrecv, there's a typo: case DRR_SPILL: if (byteswap) { drr->drr_u.drr_write.drr_length = BSWAP_64(drr->drr_u.drr_spill.drr_length); } Instead of drr_write.drr_length, we should be assigning the result of the byteswap to drr_spill.drr_length. Reviewed by: Matthew Ahrens Reviewed by: Paul Dagnelie Approved by: Robert Mustacchi Author: Dan Kimmel Modified: stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c Directory Properties: stable/10/ (props changed) Modified: stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c ============================================================================== --- stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c Wed Oct 12 05:37:54 2016 (r307117) +++ stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c Wed Oct 12 05:38:44 2016 (r307118) @@ -2968,7 +2968,7 @@ recv_skip(libzfs_handle_t *hdl, int fd, break; case DRR_SPILL: if (byteswap) { - drr->drr_u.drr_write.drr_length = + drr->drr_u.drr_spill.drr_length = BSWAP_64(drr->drr_u.drr_spill.drr_length); } (void) recv_read(hdl, fd, buf, From owner-svn-src-all@freebsd.org Wed Oct 12 05:39:30 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id AF1D7C0E58C; Wed, 12 Oct 2016 05:39:30 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 8040998E; Wed, 12 Oct 2016 05:39:30 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9C5dTGU021432; Wed, 12 Oct 2016 05:39:29 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9C5dT6N021431; Wed, 12 Oct 2016 05:39:29 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201610120539.u9C5dT6N021431@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Wed, 12 Oct 2016 05:39:29 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307119 - stable/10/cddl/contrib/opensolaris/lib/libzfs/common X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Oct 2016 05:39:30 -0000 Author: mav Date: Wed Oct 12 05:39:29 2016 New Revision: 307119 URL: https://svnweb.freebsd.org/changeset/base/307119 Log: MFC r305203: MFV r302655: 6873 zfs_destroy_snaps_nvl leaks errlist illumos/illumos-gate@4cde22c29999ffb907ca39d2ebd512812f7e5168 https://github.com/illumos/illumos-gate/commit/4cde22c29999ffb907ca39d2ebd512812 f7e5168 https://www.illumos.org/issues/6873 lzc_destroy_snaps() returns an nvlist in errlist. zfs_destroy_snaps_nvl() should nvlist_free() it before returning. Reviewed by: Matthew Ahrens Reviewed by: Paul Dagnelie Approved by: Dan McDonald Author: Chris Williamson Modified: stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c Directory Properties: stable/10/ (props changed) Modified: stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c ============================================================================== --- stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c Wed Oct 12 05:38:44 2016 (r307118) +++ stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c Wed Oct 12 05:39:29 2016 (r307119) @@ -3449,12 +3449,14 @@ int zfs_destroy_snaps_nvl(libzfs_handle_t *hdl, nvlist_t *snaps, boolean_t defer) { int ret; - nvlist_t *errlist; + nvlist_t *errlist = NULL; ret = lzc_destroy_snaps(snaps, defer, &errlist); - if (ret == 0) + if (ret == 0) { + nvlist_free(errlist); return (0); + } if (nvlist_empty(errlist)) { char errbuf[1024]; @@ -3482,6 +3484,7 @@ zfs_destroy_snaps_nvl(libzfs_handle_t *h } } + nvlist_free(errlist); return (ret); } From owner-svn-src-all@freebsd.org Wed Oct 12 05:41:12 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 1007FC0E63F; Wed, 12 Oct 2016 05:41:12 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id C6A35B9A; Wed, 12 Oct 2016 05:41:11 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9C5fAVr021585; Wed, 12 Oct 2016 05:41:10 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9C5fAWa021581; Wed, 12 Oct 2016 05:41:10 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201610120541.u9C5fAWa021581@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Wed, 12 Oct 2016 05:41:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307120 - in stable/10/cddl/contrib/opensolaris: cmd/zfs lib/libzfs/common X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Oct 2016 05:41:12 -0000 Author: mav Date: Wed Oct 12 05:41:10 2016 New Revision: 307120 URL: https://svnweb.freebsd.org/changeset/base/307120 Log: MFC r305205: MFV r302657: 4521 zfstest is trying to execute evil "zfs unmount -a" illumos/illumos-gate@8808ac5dae118369991f158b6ab736cb2691ecde https://github.com/illumos/illumos-gate/commit/8808ac5dae118369991f158b6ab736cb2 691ecde https://www.illumos.org/issues/4521 zfstest is trying to execute evil "zfs unmount -a", which fails (fortunately, as it would otherwise leave me with my ~ missing): 03:44:11.86 cannot unmount '/export/home/yuri': Device busy cannot unmount '/ export/home': Device busy 03:44:11.86 ERROR: /usr/sbin/zfs unmount -a exited 1 This affects, at least, zfs_mount_009_neg and zfs_mount_all_001_pos, both failing on that step. The pool containing the /export/home hierarchy is included in KEEP variable, but it doesn't seem to affect anything here. Reviewed by: Andriy Gapon Reviewed by: Dan McDonald Reviewed by: Matthew Ahrens Reviewed by: John Kennedy Approved by: Robert Mustacchi Author: Yuri Pankov Modified: stable/10/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs.h stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_config.c stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c Directory Properties: stable/10/ (props changed) Modified: stable/10/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c ============================================================================== --- stable/10/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c Wed Oct 12 05:39:29 2016 (r307119) +++ stable/10/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c Wed Oct 12 05:41:10 2016 (r307120) @@ -27,9 +27,9 @@ * Copyright (c) 2011-2012 Pawel Jakub Dawidek. All rights reserved. * Copyright (c) 2012 Martin Matuska . All rights reserved. * Copyright (c) 2013 Steven Hartland. All rights reserved. - * Copyright 2013 Nexenta Systems, Inc. All rights reserved. * Copyright (c) 2014 Integros [integros.com] * Copyright 2016 Igor Kozhukhov . + * Copyright 2016 Nexenta Systems, Inc. */ #include @@ -6469,6 +6469,15 @@ unshare_unmount(int op, int argc, char * continue; } + /* + * Ignore datasets that are excluded/restricted by + * parent pool name. + */ + if (zpool_skip_pool(zfs_get_pool_name(zhp))) { + zfs_close(zhp); + continue; + } + switch (op) { case OP_SHARE: verify(zfs_prop_get(zhp, ZFS_PROP_SHARENFS, Modified: stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs.h ============================================================================== --- stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs.h Wed Oct 12 05:39:29 2016 (r307119) +++ stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs.h Wed Oct 12 05:41:10 2016 (r307120) @@ -26,8 +26,8 @@ * Copyright (c) 2012, Joyent, Inc. All rights reserved. * Copyright (c) 2012 Martin Matuska . All rights reserved. * Copyright (c) 2013 Steven Hartland. All rights reserved. - * Copyright 2013 Nexenta Systems, Inc. All rights reserved. * Copyright (c) 2014 Integros [integros.com] + * Copyright 2016 Nexenta Systems, Inc. */ #ifndef _LIBZFS_H @@ -221,6 +221,7 @@ extern void zpool_free_handles(libzfs_ha */ typedef int (*zpool_iter_f)(zpool_handle_t *, void *); extern int zpool_iter(libzfs_handle_t *, zpool_iter_f, void *); +extern boolean_t zpool_skip_pool(const char *); /* * Functions to create and destroy pools @@ -411,6 +412,7 @@ extern void zfs_close(zfs_handle_t *); extern zfs_type_t zfs_get_type(const zfs_handle_t *); extern const char *zfs_get_name(const zfs_handle_t *); extern zpool_handle_t *zfs_get_pool_handle(const zfs_handle_t *); +extern const char *zfs_get_pool_name(const zfs_handle_t *); /* * Property management functions. Some functions are shared with the kernel, Modified: stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_config.c ============================================================================== --- stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_config.c Wed Oct 12 05:39:29 2016 (r307119) +++ stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_config.c Wed Oct 12 05:41:10 2016 (r307120) @@ -27,6 +27,7 @@ /* * Copyright (c) 2012 by Delphix. All rights reserved. * Copyright (c) 2015 by Syneto S.R.L. All rights reserved. + * Copyright 2016 Nexenta Systems, Inc. */ /* @@ -338,33 +339,47 @@ zpool_refresh_stats(zpool_handle_t *zhp, } /* - * If the __ZFS_POOL_RESTRICT environment variable is set we only iterate over - * pools it lists. + * The following environment variables are undocumented + * and should be used for testing purposes only: * - * This is an undocumented feature for use during testing only. + * __ZFS_POOL_EXCLUDE - don't iterate over the pools it lists + * __ZFS_POOL_RESTRICT - iterate only over the pools it lists * * This function returns B_TRUE if the pool should be skipped * during iteration. */ -static boolean_t -check_restricted(const char *poolname) +boolean_t +zpool_skip_pool(const char *poolname) { static boolean_t initialized = B_FALSE; - static char *restricted = NULL; + static const char *exclude = NULL; + static const char *restricted = NULL; const char *cur, *end; - int len, namelen; + int len; + int namelen = strlen(poolname); if (!initialized) { initialized = B_TRUE; + exclude = getenv("__ZFS_POOL_EXCLUDE"); restricted = getenv("__ZFS_POOL_RESTRICT"); } + if (exclude != NULL) { + cur = exclude; + do { + end = strchr(cur, ' '); + len = (NULL == end) ? strlen(cur) : (end - cur); + if (len == namelen && 0 == strncmp(cur, poolname, len)) + return (B_TRUE); + cur += (len + 1); + } while (NULL != end); + } + if (NULL == restricted) return (B_FALSE); cur = restricted; - namelen = strlen(poolname); do { end = strchr(cur, ' '); len = (NULL == end) ? strlen(cur) : (end - cur); @@ -402,7 +417,7 @@ zpool_iter(libzfs_handle_t *hdl, zpool_i for (cn = uu_avl_first(hdl->libzfs_ns_avl); cn != NULL; cn = uu_avl_next(hdl->libzfs_ns_avl, cn)) { - if (check_restricted(cn->cn_name)) + if (zpool_skip_pool(cn->cn_name)) continue; if (zpool_open_silent(hdl, cn->cn_name, &zhp) != 0) { @@ -440,7 +455,7 @@ zfs_iter_root(libzfs_handle_t *hdl, zfs_ for (cn = uu_avl_first(hdl->libzfs_ns_avl); cn != NULL; cn = uu_avl_next(hdl->libzfs_ns_avl, cn)) { - if (check_restricted(cn->cn_name)) + if (zpool_skip_pool(cn->cn_name)) continue; if ((zhp = make_dataset_handle(hdl, cn->cn_name)) == NULL) Modified: stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c ============================================================================== --- stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c Wed Oct 12 05:39:29 2016 (r307119) +++ stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c Wed Oct 12 05:41:10 2016 (r307120) @@ -27,9 +27,9 @@ * Copyright (c) 2011-2012 Pawel Jakub Dawidek. All rights reserved. * Copyright (c) 2013 Martin Matuska. All rights reserved. * Copyright (c) 2013 Steven Hartland. All rights reserved. - * Copyright 2013 Nexenta Systems, Inc. All rights reserved. * Copyright (c) 2014 Integros [integros.com] * Copyright 2016 Igor Kozhukhov + * Copyright 2016 Nexenta Systems, Inc. */ #include @@ -2945,6 +2945,15 @@ zfs_get_name(const zfs_handle_t *zhp) } /* + * Returns the name of the parent pool for the given zfs handle. + */ +const char * +zfs_get_pool_name(const zfs_handle_t *zhp) +{ + return (zhp->zpool_hdl->zpool_name); +} + +/* * Returns the type of the given zfs handle. */ zfs_type_t From owner-svn-src-all@freebsd.org Wed Oct 12 05:42:02 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 5A6CCC0E6A0; Wed, 12 Oct 2016 05:42:02 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 1C4AAD98; Wed, 12 Oct 2016 05:42:02 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9C5g1Sa024958; Wed, 12 Oct 2016 05:42:01 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9C5g0RB024953; Wed, 12 Oct 2016 05:42:00 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201610120542.u9C5g0RB024953@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Wed, 12 Oct 2016 05:42:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307121 - in stable/10/cddl/contrib/opensolaris: cmd/zpool lib/libzfs/common X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Oct 2016 05:42:02 -0000 Author: mav Date: Wed Oct 12 05:42:00 2016 New Revision: 307121 URL: https://svnweb.freebsd.org/changeset/base/307121 Log: MFC r305206: MFV r302658: 6872 zfs libraries should not allow uninitialized variables illumos/illumos-gate@f83b46baf98d276f5f84fa84c8b461f412ac1f5e https://github.com/illumos/illumos-gate/commit/f83b46baf98d276f5f84fa84c8b461f41 2ac1f5e https://www.illumos.org/issues/6872 We compile the zfs libraries with -Wno-uninitialized. We should remove this. Change makefiles, fix new warnings, fix pbchk errors. Reviewed by: Dan Kimmel Reviewed by: George Wilson Reviewed by: Prakash Surya Reviewed by: Yuri Pankov Approved by: Robert Mustacchi Author: Paul Dagnelie Modified: stable/10/cddl/contrib/opensolaris/cmd/zpool/zpool_vdev.c stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_import.c stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_util.c Directory Properties: stable/10/ (props changed) Modified: stable/10/cddl/contrib/opensolaris/cmd/zpool/zpool_vdev.c ============================================================================== --- stable/10/cddl/contrib/opensolaris/cmd/zpool/zpool_vdev.c Wed Oct 12 05:41:10 2016 (r307120) +++ stable/10/cddl/contrib/opensolaris/cmd/zpool/zpool_vdev.c Wed Oct 12 05:42:00 2016 (r307121) @@ -21,7 +21,7 @@ /* * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2013 by Delphix. All rights reserved. + * Copyright (c) 2013, 2015 by Delphix. All rights reserved. * Copyright 2016 Igor Kozhukhov . */ @@ -597,7 +597,6 @@ get_replication(nvlist_t *nvroot, boolea verify(nvlist_lookup_nvlist_array(nvroot, ZPOOL_CONFIG_CHILDREN, &top, &toplevels) == 0); - lastrep.zprl_type = NULL; for (t = 0; t < toplevels; t++) { uint64_t is_log = B_FALSE; Modified: stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c ============================================================================== --- stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c Wed Oct 12 05:41:10 2016 (r307120) +++ stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c Wed Oct 12 05:42:00 2016 (r307121) @@ -1564,7 +1564,7 @@ zfs_prop_set_list(zfs_handle_t *zhp, nvl libzfs_handle_t *hdl = zhp->zfs_hdl; nvlist_t *nvl; int nvl_len; - int added_resv; + int added_resv = 0; (void) snprintf(errbuf, sizeof (errbuf), dgettext(TEXT_DOMAIN, "cannot set property for '%s'"), @@ -3195,7 +3195,7 @@ zfs_create_ancestors(libzfs_handle_t *hd { int prefix; char *path_copy; - int rc; + int rc = 0; if (check_parents(hdl, path, NULL, B_TRUE, &prefix) != 0) return (-1); @@ -3837,7 +3837,7 @@ zfs_rollback(zfs_handle_t *zhp, zfs_hand rollback_data_t cb = { 0 }; int err; boolean_t restore_resv = 0; - uint64_t old_volsize, new_volsize; + uint64_t old_volsize = 0, new_volsize; zfs_prop_t resv_prop; assert(zhp->zfs_type == ZFS_TYPE_FILESYSTEM || @@ -4054,6 +4054,7 @@ zfs_rename(zfs_handle_t *zhp, const char "child dataset with inherited mountpoint is used " "in a non-global zone")); (void) zfs_error(hdl, EZFS_ZONED, errbuf); + ret = -1; goto error; } Modified: stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_import.c ============================================================================== --- stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_import.c Wed Oct 12 05:41:10 2016 (r307120) +++ stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_import.c Wed Oct 12 05:42:00 2016 (r307121) @@ -21,7 +21,7 @@ /* * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2013 by Delphix. All rights reserved. + * Copyright (c) 2012, 2015 by Delphix. All rights reserved. * Copyright 2015 RackTop Systems. * Copyright 2016 Nexenta Systems, Inc. */ @@ -440,12 +440,12 @@ get_configs(libzfs_handle_t *hdl, pool_l pool_entry_t *pe; vdev_entry_t *ve; config_entry_t *ce; - nvlist_t *ret = NULL, *config = NULL, *tmp, *nvtop, *nvroot; + nvlist_t *ret = NULL, *config = NULL, *tmp = NULL, *nvtop, *nvroot; nvlist_t **spares, **l2cache; uint_t i, nspares, nl2cache; boolean_t config_seen; uint64_t best_txg; - char *name, *hostname; + char *name, *hostname = NULL; uint64_t guid; uint_t children = 0; nvlist_t **child = NULL; Modified: stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_util.c ============================================================================== --- stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_util.c Wed Oct 12 05:41:10 2016 (r307120) +++ stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_util.c Wed Oct 12 05:42:00 2016 (r307121) @@ -1011,7 +1011,7 @@ zprop_print_one_property(const char *nam const char *source, const char *recvd_value) { int i; - const char *str; + const char *str = NULL; char buf[128]; /* From owner-svn-src-all@freebsd.org Wed Oct 12 05:43:28 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 8F88CC0E815; Wed, 12 Oct 2016 05:43:28 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 2F513BB; Wed, 12 Oct 2016 05:43:28 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9C5hR70025074; Wed, 12 Oct 2016 05:43:27 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9C5hPST025057; Wed, 12 Oct 2016 05:43:25 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201610120543.u9C5hPST025057@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Wed, 12 Oct 2016 05:43:25 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307122 - in stable/10: cddl/contrib/opensolaris/cmd/zdb cddl/contrib/opensolaris/cmd/zfs cddl/contrib/opensolaris/cmd/zhack cddl/contrib/opensolaris/cmd/zpool cddl/contrib/opensolaris/... X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Oct 2016 05:43:28 -0000 Author: mav Date: Wed Oct 12 05:43:25 2016 New Revision: 307122 URL: https://svnweb.freebsd.org/changeset/base/307122 Log: MFC r305209: MFV r302660: 6314 buffer overflow in dsl_dataset_name illumos/illumos-gate@9adfa60d484ce2435f5af77cc99dcd4e692b6660 https://github.com/illumos/illumos-gate/commit/9adfa60d484ce2435f5af77cc99dcd4e6 92b6660 https://www.illumos.org/issues/6314 Callers of dsl_dataset_name pass a buffer of size ZFS_MAXNAMELEN, but dsl_dataset_name copies the datasets' name PLUS the snapshot name to it, resulting in a max of 2 * ZFS_MAXNAMELEN + '@'. Reviewed by: George Wilson Reviewed by: Prakash Surya Reviewed by: Igor Kozhukhov Approved by: Dan McDonald Author: Matthew Ahrens Modified: stable/10/cddl/contrib/opensolaris/cmd/zdb/zdb.c stable/10/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c stable/10/cddl/contrib/opensolaris/cmd/zhack/zhack.c stable/10/cddl/contrib/opensolaris/cmd/zpool/zpool_main.c stable/10/cddl/contrib/opensolaris/cmd/ztest/ztest.c stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs.h stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_changelist.c stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_diff.c stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_impl.h stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_iter.c stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_mount.c stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_pool.c stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c stable/10/cddl/contrib/opensolaris/lib/libzfs_core/common/libzfs_core.c stable/10/sys/cddl/contrib/opensolaris/common/zfs/zfs_namecheck.c stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_objset.c stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_send.c stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_bookmark.c stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_dataset.c stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_deleg.c stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_dir.c stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_prop.c stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_scan.c stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_userhold.c stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_history.c stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dmu.h stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dsl_dataset.h stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dsl_dir.h stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/spa_impl.h stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zap.h stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zfs_znode.h stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ctldir.c stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zil.c stable/10/sys/cddl/contrib/opensolaris/uts/common/sys/fs/zfs.h Directory Properties: stable/10/ (props changed) Modified: stable/10/cddl/contrib/opensolaris/cmd/zdb/zdb.c ============================================================================== --- stable/10/cddl/contrib/opensolaris/cmd/zdb/zdb.c Wed Oct 12 05:42:00 2016 (r307121) +++ stable/10/cddl/contrib/opensolaris/cmd/zdb/zdb.c Wed Oct 12 05:43:25 2016 (r307122) @@ -60,7 +60,6 @@ #include #include #include -#undef ZFS_MAXNAMELEN #undef verify #include @@ -1946,7 +1945,7 @@ dump_dir(objset_t *os) uint64_t refdbytes, usedobjs, scratch; char numbuf[32]; char blkbuf[BP_SPRINTF_LEN + 20]; - char osname[MAXNAMELEN]; + char osname[ZFS_MAX_DATASET_NAME_LEN]; char *type = "UNKNOWN"; int verbosity = dump_opt['d']; int print_header = 1; @@ -3483,7 +3482,7 @@ find_zpool(char **target, nvlist_t **con nvlist_t *match = NULL; char *name = NULL; char *sepp = NULL; - char sep; + char sep = '\0'; int count = 0; importargs_t args = { 0 }; Modified: stable/10/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c ============================================================================== --- stable/10/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c Wed Oct 12 05:42:00 2016 (r307121) +++ stable/10/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c Wed Oct 12 05:43:25 2016 (r307122) @@ -1509,7 +1509,7 @@ get_callback(zfs_handle_t *zhp, void *da char buf[ZFS_MAXPROPLEN]; char rbuf[ZFS_MAXPROPLEN]; zprop_source_t sourcetype; - char source[ZFS_MAXNAMELEN]; + char source[ZFS_MAX_DATASET_NAME_LEN]; zprop_get_cbdata_t *cbp = data; nvlist_t *user_props = zfs_get_user_props(zhp); zprop_list_t *pl = cbp->cb_proplist; @@ -1989,7 +1989,7 @@ typedef struct upgrade_cbdata { uint64_t cb_version; boolean_t cb_newer; boolean_t cb_foundone; - char cb_lastfs[ZFS_MAXNAMELEN]; + char cb_lastfs[ZFS_MAX_DATASET_NAME_LEN]; } upgrade_cbdata_t; static int @@ -2435,7 +2435,7 @@ userspace_cb(void *arg, const char *doma if (domain != NULL && domain[0] != '\0') { /* SMB */ - char sid[ZFS_MAXNAMELEN + 32]; + char sid[MAXNAMELEN + 32]; uid_t id; #ifdef illumos int err; @@ -2572,7 +2572,7 @@ print_us_node(boolean_t scripted, boolea size_t *width, us_node_t *node) { nvlist_t *nvl = node->usn_nvl; - char valstr[ZFS_MAXNAMELEN]; + char valstr[MAXNAMELEN]; boolean_t first = B_TRUE; int cfield = 0; int field; @@ -3471,7 +3471,7 @@ zfs_do_rollback(int argc, char **argv) boolean_t force = B_FALSE; rollback_cbdata_t cb = { 0 }; zfs_handle_t *zhp, *snap; - char parentname[ZFS_MAXNAMELEN]; + char parentname[ZFS_MAX_DATASET_NAME_LEN]; char *delim; /* check options */ @@ -3871,7 +3871,7 @@ zfs_do_send(int argc, char **argv) */ if (strchr(argv[0], '@') == NULL || (fromname && strchr(fromname, '#') != NULL)) { - char frombuf[ZFS_MAXNAMELEN]; + char frombuf[ZFS_MAX_DATASET_NAME_LEN]; enum lzc_send_flags lzc_flags = 0; if (flags.replicate || flags.doall || flags.props || @@ -3923,7 +3923,7 @@ zfs_do_send(int argc, char **argv) * case if they specify the origin. */ if (fromname && (cp = strchr(fromname, '@')) != NULL) { - char origin[ZFS_MAXNAMELEN]; + char origin[ZFS_MAX_DATASET_NAME_LEN]; zprop_source_t src; (void) zfs_prop_get(zhp, ZFS_PROP_ORIGIN, @@ -4057,7 +4057,7 @@ zfs_do_receive(int argc, char **argv) usage(B_FALSE); } - char namebuf[ZFS_MAXNAMELEN]; + char namebuf[ZFS_MAX_DATASET_NAME_LEN]; (void) snprintf(namebuf, sizeof (namebuf), "%s/%%recv", argv[0]); @@ -4915,7 +4915,7 @@ store_allow_perm(zfs_deleg_who_type_t ty { int i; char ld[2] = { '\0', '\0' }; - char who_buf[ZFS_MAXNAMELEN+32]; + char who_buf[MAXNAMELEN + 32]; char base_type = '\0'; char set_type = '\0'; nvlist_t *base_nvl = NULL; @@ -5283,7 +5283,7 @@ static void print_fs_perms(fs_perm_set_t *fspset) { fs_perm_node_t *node = NULL; - char buf[ZFS_MAXNAMELEN+32]; + char buf[MAXNAMELEN + 32]; const char *dsname = buf; for (node = uu_list_first(fspset->fsps_list); node != NULL; @@ -5292,7 +5292,7 @@ print_fs_perms(fs_perm_set_t *fspset) uu_avl_t *uge_avl = node->fspn_fsperm.fsp_uge_avl; int left = 0; - (void) snprintf(buf, ZFS_MAXNAMELEN+32, + (void) snprintf(buf, sizeof (buf), gettext("---- Permissions on %s "), node->fspn_fsperm.fsp_name); (void) printf(dsname); @@ -5489,7 +5489,7 @@ zfs_do_hold_rele_impl(int argc, char **a for (i = 0; i < argc; ++i) { zfs_handle_t *zhp; - char parent[ZFS_MAXNAMELEN]; + char parent[ZFS_MAX_DATASET_NAME_LEN]; const char *delim; char *path = argv[i]; @@ -5617,7 +5617,7 @@ holds_callback(zfs_handle_t *zhp, void * nvlist_t *nvl = NULL; nvpair_t *nvp = NULL; const char *zname = zfs_get_name(zhp); - size_t znamelen = strnlen(zname, ZFS_MAXNAMELEN); + size_t znamelen = strlen(zname); if (cbp->cb_recursive) { const char *snapname; @@ -5638,7 +5638,7 @@ holds_callback(zfs_handle_t *zhp, void * while ((nvp = nvlist_next_nvpair(nvl, nvp)) != NULL) { const char *tag = nvpair_name(nvp); - size_t taglen = strnlen(tag, MAXNAMELEN); + size_t taglen = strlen(tag); if (taglen > cbp->cb_max_taglen) cbp->cb_max_taglen = taglen; } @@ -6967,7 +6967,7 @@ zfs_do_diff(int argc, char **argv) static int zfs_do_bookmark(int argc, char **argv) { - char snapname[ZFS_MAXNAMELEN]; + char snapname[ZFS_MAX_DATASET_NAME_LEN]; zfs_handle_t *zhp; nvlist_t *nvl; int ret = 0; Modified: stable/10/cddl/contrib/opensolaris/cmd/zhack/zhack.c ============================================================================== --- stable/10/cddl/contrib/opensolaris/cmd/zhack/zhack.c Wed Oct 12 05:42:00 2016 (r307121) +++ stable/10/cddl/contrib/opensolaris/cmd/zhack/zhack.c Wed Oct 12 05:43:25 2016 (r307122) @@ -48,7 +48,6 @@ #include #include #include -#undef ZFS_MAXNAMELEN #undef verify #include Modified: stable/10/cddl/contrib/opensolaris/cmd/zpool/zpool_main.c ============================================================================== --- stable/10/cddl/contrib/opensolaris/cmd/zpool/zpool_main.c Wed Oct 12 05:42:00 2016 (r307121) +++ stable/10/cddl/contrib/opensolaris/cmd/zpool/zpool_main.c Wed Oct 12 05:43:25 2016 (r307122) @@ -4540,7 +4540,7 @@ zpool_do_status(int argc, char **argv) typedef struct upgrade_cbdata { boolean_t cb_first; boolean_t cb_unavail; - char cb_poolname[ZPOOL_MAXNAMELEN]; + char cb_poolname[ZFS_MAX_DATASET_NAME_LEN]; int cb_argc; uint64_t cb_version; char **cb_argv; Modified: stable/10/cddl/contrib/opensolaris/cmd/ztest/ztest.c ============================================================================== --- stable/10/cddl/contrib/opensolaris/cmd/ztest/ztest.c Wed Oct 12 05:42:00 2016 (r307121) +++ stable/10/cddl/contrib/opensolaris/cmd/ztest/ztest.c Wed Oct 12 05:43:25 2016 (r307122) @@ -141,8 +141,8 @@ typedef struct ztest_shared_hdr { static ztest_shared_hdr_t *ztest_shared_hdr; typedef struct ztest_shared_opts { - char zo_pool[MAXNAMELEN]; - char zo_dir[MAXNAMELEN]; + char zo_pool[ZFS_MAX_DATASET_NAME_LEN]; + char zo_dir[ZFS_MAX_DATASET_NAME_LEN]; char zo_alt_ztest[MAXNAMELEN]; char zo_alt_libpath[MAXNAMELEN]; uint64_t zo_vdevs; @@ -268,7 +268,7 @@ typedef struct ztest_od { uint64_t od_crblocksize; uint64_t od_gen; uint64_t od_crgen; - char od_name[MAXNAMELEN]; + char od_name[ZFS_MAX_DATASET_NAME_LEN]; } ztest_od_t; /* @@ -280,7 +280,7 @@ typedef struct ztest_ds { rwlock_t zd_zilog_lock; zilog_t *zd_zilog; ztest_od_t *zd_od; /* debugging aid */ - char zd_name[MAXNAMELEN]; + char zd_name[ZFS_MAX_DATASET_NAME_LEN]; mutex_t zd_dirobj_lock; rll_t zd_object_lock[ZTEST_OBJECT_LOCKS]; rll_t zd_range_lock[ZTEST_RANGE_LOCKS]; @@ -3227,7 +3227,7 @@ ztest_objset_destroy_cb(const char *name static boolean_t ztest_snapshot_create(char *osname, uint64_t id) { - char snapname[MAXNAMELEN]; + char snapname[ZFS_MAX_DATASET_NAME_LEN]; int error; (void) snprintf(snapname, sizeof (snapname), "%llu", (u_longlong_t)id); @@ -3247,10 +3247,10 @@ ztest_snapshot_create(char *osname, uint static boolean_t ztest_snapshot_destroy(char *osname, uint64_t id) { - char snapname[MAXNAMELEN]; + char snapname[ZFS_MAX_DATASET_NAME_LEN]; int error; - (void) snprintf(snapname, MAXNAMELEN, "%s@%llu", osname, + (void) snprintf(snapname, sizeof (snapname), "%s@%llu", osname, (u_longlong_t)id); error = dsl_destroy_snapshot(snapname, B_FALSE); @@ -3267,12 +3267,12 @@ ztest_dmu_objset_create_destroy(ztest_ds int iters; int error; objset_t *os, *os2; - char name[MAXNAMELEN]; + char name[ZFS_MAX_DATASET_NAME_LEN]; zilog_t *zilog; (void) rw_rdlock(&ztest_name_lock); - (void) snprintf(name, MAXNAMELEN, "%s/temp_%llu", + (void) snprintf(name, sizeof (name), "%s/temp_%llu", ztest_opts.zo_pool, (u_longlong_t)id); /* @@ -3378,18 +3378,23 @@ ztest_dmu_snapshot_create_destroy(ztest_ void ztest_dsl_dataset_cleanup(char *osname, uint64_t id) { - char snap1name[MAXNAMELEN]; - char clone1name[MAXNAMELEN]; - char snap2name[MAXNAMELEN]; - char clone2name[MAXNAMELEN]; - char snap3name[MAXNAMELEN]; + char snap1name[ZFS_MAX_DATASET_NAME_LEN]; + char clone1name[ZFS_MAX_DATASET_NAME_LEN]; + char snap2name[ZFS_MAX_DATASET_NAME_LEN]; + char clone2name[ZFS_MAX_DATASET_NAME_LEN]; + char snap3name[ZFS_MAX_DATASET_NAME_LEN]; int error; - (void) snprintf(snap1name, MAXNAMELEN, "%s@s1_%llu", osname, id); - (void) snprintf(clone1name, MAXNAMELEN, "%s/c1_%llu", osname, id); - (void) snprintf(snap2name, MAXNAMELEN, "%s@s2_%llu", clone1name, id); - (void) snprintf(clone2name, MAXNAMELEN, "%s/c2_%llu", osname, id); - (void) snprintf(snap3name, MAXNAMELEN, "%s@s3_%llu", clone1name, id); + (void) snprintf(snap1name, sizeof (snap1name), + "%s@s1_%llu", osname, id); + (void) snprintf(clone1name, sizeof (clone1name), + "%s/c1_%llu", osname, id); + (void) snprintf(snap2name, sizeof (snap2name), + "%s@s2_%llu", clone1name, id); + (void) snprintf(clone2name, sizeof (clone2name), + "%s/c2_%llu", osname, id); + (void) snprintf(snap3name, sizeof (snap3name), + "%s@s3_%llu", clone1name, id); error = dsl_destroy_head(clone2name); if (error && error != ENOENT) @@ -3415,11 +3420,11 @@ void ztest_dsl_dataset_promote_busy(ztest_ds_t *zd, uint64_t id) { objset_t *os; - char snap1name[MAXNAMELEN]; - char clone1name[MAXNAMELEN]; - char snap2name[MAXNAMELEN]; - char clone2name[MAXNAMELEN]; - char snap3name[MAXNAMELEN]; + char snap1name[ZFS_MAX_DATASET_NAME_LEN]; + char clone1name[ZFS_MAX_DATASET_NAME_LEN]; + char snap2name[ZFS_MAX_DATASET_NAME_LEN]; + char clone2name[ZFS_MAX_DATASET_NAME_LEN]; + char snap3name[ZFS_MAX_DATASET_NAME_LEN]; char *osname = zd->zd_name; int error; @@ -3427,11 +3432,16 @@ ztest_dsl_dataset_promote_busy(ztest_ds_ ztest_dsl_dataset_cleanup(osname, id); - (void) snprintf(snap1name, MAXNAMELEN, "%s@s1_%llu", osname, id); - (void) snprintf(clone1name, MAXNAMELEN, "%s/c1_%llu", osname, id); - (void) snprintf(snap2name, MAXNAMELEN, "%s@s2_%llu", clone1name, id); - (void) snprintf(clone2name, MAXNAMELEN, "%s/c2_%llu", osname, id); - (void) snprintf(snap3name, MAXNAMELEN, "%s@s3_%llu", clone1name, id); + (void) snprintf(snap1name, sizeof (snap1name), + "%s@s1_%llu", osname, id); + (void) snprintf(clone1name, sizeof (clone1name), + "%s/c1_%llu", osname, id); + (void) snprintf(snap2name, sizeof (snap2name), + "%s@s2_%llu", clone1name, id); + (void) snprintf(clone2name, sizeof (clone2name), + "%s/c2_%llu", osname, id); + (void) snprintf(snap3name, sizeof (snap3name), + "%s@s3_%llu", clone1name, id); error = dmu_objset_snapshot_one(osname, strchr(snap1name, '@') + 1); if (error && error != EEXIST) { @@ -4249,7 +4259,7 @@ ztest_fzap(ztest_ds_t *zd, uint64_t id) * 2050 entries we should see ptrtbl growth and leaf-block split. */ for (int i = 0; i < 2050; i++) { - char name[MAXNAMELEN]; + char name[ZFS_MAX_DATASET_NAME_LEN]; uint64_t value = i; dmu_tx_t *tx; int error; @@ -4654,7 +4664,7 @@ ztest_dmu_snapshot_hold(ztest_ds_t *zd, char fullname[100]; char clonename[100]; char tag[100]; - char osname[MAXNAMELEN]; + char osname[ZFS_MAX_DATASET_NAME_LEN]; nvlist_t *holds; (void) rw_rdlock(&ztest_name_lock); @@ -5450,13 +5460,13 @@ ztest_thread(void *arg) static void ztest_dataset_name(char *dsname, char *pool, int d) { - (void) snprintf(dsname, MAXNAMELEN, "%s/ds_%d", pool, d); + (void) snprintf(dsname, ZFS_MAX_DATASET_NAME_LEN, "%s/ds_%d", pool, d); } static void ztest_dataset_destroy(int d) { - char name[MAXNAMELEN]; + char name[ZFS_MAX_DATASET_NAME_LEN]; ztest_dataset_name(name, ztest_opts.zo_pool, d); @@ -5505,7 +5515,7 @@ ztest_dataset_open(int d) uint64_t committed_seq = ZTEST_GET_SHARED_DS(d)->zd_seq; objset_t *os; zilog_t *zilog; - char name[MAXNAMELEN]; + char name[ZFS_MAX_DATASET_NAME_LEN]; int error; ztest_dataset_name(name, ztest_opts.zo_pool, d); @@ -5728,8 +5738,8 @@ ztest_run(ztest_shared_t *zs) * different name. */ if (ztest_random(2) == 0) { - char name[MAXNAMELEN]; - (void) snprintf(name, MAXNAMELEN, "%s_import", + char name[ZFS_MAX_DATASET_NAME_LEN]; + (void) snprintf(name, sizeof (name), "%s_import", ztest_opts.zo_pool); ztest_spa_import_export(ztest_opts.zo_pool, name); ztest_spa_import_export(name, ztest_opts.zo_pool); @@ -6297,7 +6307,7 @@ main(int argc, char **argv) if (spa_open(ztest_opts.zo_pool, &spa, FTAG) == 0) { spa_close(spa, FTAG); } else { - char tmpname[MAXNAMELEN]; + char tmpname[ZFS_MAX_DATASET_NAME_LEN]; kernel_fini(); kernel_init(FREAD | FWRITE); (void) snprintf(tmpname, sizeof (tmpname), "%s_tmp", Modified: stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs.h ============================================================================== --- stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs.h Wed Oct 12 05:42:00 2016 (r307121) +++ stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs.h Wed Oct 12 05:43:25 2016 (r307122) @@ -51,8 +51,6 @@ extern "C" { /* * Miscellaneous ZFS constants */ -#define ZFS_MAXNAMELEN MAXNAMELEN -#define ZPOOL_MAXNAMELEN MAXNAMELEN #define ZFS_MAXPROPLEN MAXPATHLEN #define ZPOOL_MAXPROPLEN MAXPATHLEN Modified: stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_changelist.c ============================================================================== --- stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_changelist.c Wed Oct 12 05:42:00 2016 (r307121) +++ stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_changelist.c Wed Oct 12 05:43:25 2016 (r307122) @@ -26,6 +26,7 @@ * Portions Copyright 2007 Ramprakash Jelari * Copyright (c) 2011 Pawel Jakub Dawidek . * All rights reserved. + * Copyright (c) 2014, 2015 by Delphix. All rights reserved. * Copyright 2016 Igor Kozhukhov */ @@ -296,7 +297,7 @@ void changelist_rename(prop_changelist_t *clp, const char *src, const char *dst) { prop_changenode_t *cn; - char newname[ZFS_MAXNAMELEN]; + char newname[ZFS_MAX_DATASET_NAME_LEN]; for (cn = uu_list_first(clp->cl_list); cn != NULL; cn = uu_list_next(clp->cl_list, cn)) { Modified: stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c ============================================================================== --- stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c Wed Oct 12 05:42:00 2016 (r307121) +++ stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c Wed Oct 12 05:43:25 2016 (r307122) @@ -554,7 +554,7 @@ zfs_bookmark_exists(const char *path) { nvlist_t *bmarks; nvlist_t *props; - char fsname[ZFS_MAXNAMELEN]; + char fsname[ZFS_MAX_DATASET_NAME_LEN]; char *bmark_name; char *pound; int err; @@ -2175,7 +2175,7 @@ struct get_clones_arg { uint64_t numclones; nvlist_t *value; const char *origin; - char buf[ZFS_MAXNAMELEN]; + char buf[ZFS_MAX_DATASET_NAME_LEN]; }; int @@ -2230,7 +2230,7 @@ zfs_get_clones_nvl(zfs_handle_t *zhp) if (gca.numclones != 0) { zfs_handle_t *root; - char pool[ZFS_MAXNAMELEN]; + char pool[ZFS_MAX_DATASET_NAME_LEN]; char *cp = pool; /* get the pool name */ @@ -3015,7 +3015,7 @@ check_parents(libzfs_handle_t *hdl, cons boolean_t accept_ancestor, int *prefixlen) { zfs_cmd_t zc = { 0 }; - char parent[ZFS_MAXNAMELEN]; + char parent[ZFS_MAX_DATASET_NAME_LEN]; char *slash; zfs_handle_t *zhp; char errbuf[1024]; @@ -3254,7 +3254,7 @@ zfs_create(libzfs_handle_t *hdl, const c ost = LZC_DATSET_TYPE_ZFS; /* open zpool handle for prop validation */ - char pool_path[MAXNAMELEN]; + char pool_path[ZFS_MAX_DATASET_NAME_LEN]; (void) strlcpy(pool_path, path, sizeof (pool_path)); /* truncate pool_path at first slash */ @@ -3323,7 +3323,7 @@ zfs_create(libzfs_handle_t *hdl, const c /* check for failure */ if (ret != 0) { - char parent[ZFS_MAXNAMELEN]; + char parent[ZFS_MAX_DATASET_NAME_LEN]; (void) parent_name(path, parent, sizeof (parent)); switch (errno) { @@ -3413,7 +3413,7 @@ static int zfs_check_snap_cb(zfs_handle_t *zhp, void *arg) { struct destroydata *dd = arg; - char name[ZFS_MAXNAMELEN]; + char name[ZFS_MAX_DATASET_NAME_LEN]; int rv = 0; (void) snprintf(name, sizeof (name), @@ -3503,7 +3503,7 @@ zfs_destroy_snaps_nvl(libzfs_handle_t *h int zfs_clone(zfs_handle_t *zhp, const char *target, nvlist_t *props) { - char parent[ZFS_MAXNAMELEN]; + char parent[ZFS_MAX_DATASET_NAME_LEN]; int ret; char errbuf[1024]; libzfs_handle_t *hdl = zhp->zfs_hdl; @@ -3633,7 +3633,7 @@ static int zfs_snapshot_cb(zfs_handle_t *zhp, void *arg) { snapdata_t *sd = arg; - char name[ZFS_MAXNAMELEN]; + char name[ZFS_MAX_DATASET_NAME_LEN]; int rv = 0; if (zfs_prop_get_int(zhp, ZFS_PROP_INCONSISTENT) == 0) { @@ -3682,7 +3682,7 @@ zfs_snapshot_nvl(libzfs_handle_t *hdl, n * get pool handle for prop validation. assumes all snaps are in the * same pool, as does lzc_snapshot (below). */ - char pool[MAXNAMELEN]; + char pool[ZFS_MAX_DATASET_NAME_LEN]; elem = nvlist_next_nvpair(snaps, NULL); (void) strlcpy(pool, nvpair_name(elem), sizeof (pool)); pool[strcspn(pool, "/@")] = '\0'; @@ -3736,7 +3736,7 @@ zfs_snapshot(libzfs_handle_t *hdl, const { int ret; snapdata_t sd = { 0 }; - char fsname[ZFS_MAXNAMELEN]; + char fsname[ZFS_MAX_DATASET_NAME_LEN]; char *cp; zfs_handle_t *zhp; char errbuf[1024]; @@ -3915,7 +3915,7 @@ zfs_rename(zfs_handle_t *zhp, const char prop_changelist_t *cl = NULL; zfs_handle_t *zhrp = NULL; char *parentname = NULL; - char parent[ZFS_MAXNAMELEN]; + char parent[ZFS_MAX_DATASET_NAME_LEN]; char property[ZFS_MAXPROPLEN]; libzfs_handle_t *hdl = zhp->zfs_hdl; char errbuf[1024]; @@ -4429,7 +4429,7 @@ static int zfs_hold_one(zfs_handle_t *zhp, void *arg) { struct holdarg *ha = arg; - char name[ZFS_MAXNAMELEN]; + char name[ZFS_MAX_DATASET_NAME_LEN]; int rv = 0; (void) snprintf(name, sizeof (name), @@ -4548,7 +4548,7 @@ static int zfs_release_one(zfs_handle_t *zhp, void *arg) { struct holdarg *ha = arg; - char name[ZFS_MAXNAMELEN]; + char name[ZFS_MAX_DATASET_NAME_LEN]; int rv = 0; nvlist_t *existing_holds; @@ -4677,7 +4677,7 @@ tryagain: zc.zc_nvlist_dst_size = nvsz; zc.zc_nvlist_dst = (uintptr_t)nvbuf; - (void) strlcpy(zc.zc_name, zhp->zfs_name, ZFS_MAXNAMELEN); + (void) strlcpy(zc.zc_name, zhp->zfs_name, sizeof (zc.zc_name)); if (ioctl(hdl->libzfs_fd, ZFS_IOC_GET_FSACL, &zc) != 0) { (void) snprintf(errbuf, sizeof (errbuf), Modified: stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_diff.c ============================================================================== --- stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_diff.c Wed Oct 12 05:42:00 2016 (r307121) +++ stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_diff.c Wed Oct 12 05:43:25 2016 (r307122) @@ -22,6 +22,7 @@ /* * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. * Copyright 2015 Nexenta Systems, Inc. All rights reserved. + * Copyright (c) 2015 by Delphix. All rights reserved. * Copyright 2016 Joyent, Inc. * Copyright 2016 Igor Kozhukhov */ @@ -618,7 +619,7 @@ get_snapshot_names(differ_info_t *di, co * not the same dataset name, might be okay if * tosnap is a clone of a fromsnap descendant. */ - char origin[ZFS_MAXNAMELEN]; + char origin[ZFS_MAX_DATASET_NAME_LEN]; zprop_source_t src; zfs_handle_t *zhp; Modified: stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_impl.h ============================================================================== --- stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_impl.h Wed Oct 12 05:42:00 2016 (r307121) +++ stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_impl.h Wed Oct 12 05:43:25 2016 (r307122) @@ -22,18 +22,18 @@ /* * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2011 Pawel Jakub Dawidek. All rights reserved. - * Copyright (c) 2013 by Delphix. All rights reserved. + * Copyright (c) 2011, 2015 by Delphix. All rights reserved. * Copyright (c) 2013 Martin Matuska . All rights reserved. */ #ifndef _LIBZFS_IMPL_H #define _LIBZFS_IMPL_H -#include #include -#include #include #include +#include +#include #include #include @@ -86,7 +86,7 @@ struct libzfs_handle { struct zfs_handle { libzfs_handle_t *zfs_hdl; zpool_handle_t *zpool_hdl; - char zfs_name[ZFS_MAXNAMELEN]; + char zfs_name[ZFS_MAX_DATASET_NAME_LEN]; zfs_type_t zfs_type; /* type including snapshot */ zfs_type_t zfs_head_type; /* type excluding snapshot */ dmu_objset_stats_t zfs_dmustats; @@ -107,7 +107,7 @@ struct zfs_handle { struct zpool_handle { libzfs_handle_t *zpool_hdl; zpool_handle_t *zpool_next; - char zpool_name[ZPOOL_MAXNAMELEN]; + char zpool_name[ZFS_MAX_DATASET_NAME_LEN]; int zpool_state; size_t zpool_config_size; nvlist_t *zpool_config; Modified: stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_iter.c ============================================================================== --- stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_iter.c Wed Oct 12 05:42:00 2016 (r307121) +++ stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_iter.c Wed Oct 12 05:43:25 2016 (r307122) @@ -197,7 +197,7 @@ zfs_iter_bookmarks(zfs_handle_t *zhp, zf for (nvpair_t *pair = nvlist_next_nvpair(bmarks, NULL); pair != NULL; pair = nvlist_next_nvpair(bmarks, pair)) { - char name[ZFS_MAXNAMELEN]; + char name[ZFS_MAX_DATASET_NAME_LEN]; char *bmark_name; nvlist_t *bmark_props; @@ -385,7 +385,7 @@ zfs_iter_snapspec(zfs_handle_t *fs_zhp, * exists. */ if (ssa.ssa_last[0] != '\0') { - char snapname[ZFS_MAXNAMELEN]; + char snapname[ZFS_MAX_DATASET_NAME_LEN]; (void) snprintf(snapname, sizeof (snapname), "%s@%s", zfs_get_name(fs_zhp), ssa.ssa_last); @@ -405,7 +405,7 @@ zfs_iter_snapspec(zfs_handle_t *fs_zhp, ret = ENOENT; } } else { - char snapname[ZFS_MAXNAMELEN]; + char snapname[ZFS_MAX_DATASET_NAME_LEN]; zfs_handle_t *snap_zhp; (void) snprintf(snapname, sizeof (snapname), "%s@%s", zfs_get_name(fs_zhp), comma_separated); Modified: stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_mount.c ============================================================================== --- stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_mount.c Wed Oct 12 05:42:00 2016 (r307121) +++ stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_mount.c Wed Oct 12 05:43:25 2016 (r307122) @@ -236,7 +236,7 @@ static boolean_t zfs_is_mountable(zfs_handle_t *zhp, char *buf, size_t buflen, zprop_source_t *source) { - char sourceloc[ZFS_MAXNAMELEN]; + char sourceloc[MAXNAMELEN]; zprop_source_t sourcetype; if (!zfs_prop_valid_for_type(ZFS_PROP_MOUNTPOINT, zhp->zfs_type)) Modified: stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_pool.c ============================================================================== --- stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_pool.c Wed Oct 12 05:42:00 2016 (r307121) +++ stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_pool.c Wed Oct 12 05:43:25 2016 (r307122) @@ -407,7 +407,7 @@ bootfs_name_valid(const char *pool, char boolean_t zpool_is_bootable(zpool_handle_t *zhp) { - char bootfs[ZPOOL_MAXNAMELEN]; + char bootfs[ZFS_MAX_DATASET_NAME_LEN]; return (zpool_get_prop(zhp, ZPOOL_PROP_BOOTFS, bootfs, sizeof (bootfs), NULL, B_FALSE) == 0 && strncmp(bootfs, "-", @@ -3803,7 +3803,7 @@ zpool_obj_to_path(zpool_handle_t *zhp, u zfs_cmd_t zc = { 0 }; boolean_t mounted = B_FALSE; char *mntpnt = NULL; - char dsname[MAXNAMELEN]; + char dsname[ZFS_MAX_DATASET_NAME_LEN]; if (dsobj == 0) { /* special case for the MOS */ @@ -4064,7 +4064,7 @@ zvol_check_dump_config(char *arg) uint_t toplevels; libzfs_handle_t *hdl; char errbuf[1024]; - char poolname[ZPOOL_MAXNAMELEN]; + char poolname[ZFS_MAX_DATASET_NAME_LEN]; int pathlen = strlen(ZVOL_FULL_DEV_DIR); int ret = 1; @@ -4087,7 +4087,7 @@ zvol_check_dump_config(char *arg) "malformed dataset name")); (void) zfs_error(hdl, EZFS_INVALIDNAME, errbuf); return (1); - } else if (p - volname >= ZFS_MAXNAMELEN) { + } else if (p - volname >= ZFS_MAX_DATASET_NAME_LEN) { zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, "dataset name is too long")); (void) zfs_error(hdl, EZFS_NAMETOOLONG, errbuf); Modified: stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c ============================================================================== --- stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c Wed Oct 12 05:42:00 2016 (r307121) +++ stable/10/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c Wed Oct 12 05:43:25 2016 (r307122) @@ -752,7 +752,7 @@ send_iterate_prop(zfs_handle_t *zhp, nvl static uint64_t get_snap_txg(libzfs_handle_t *hdl, const char *fs, const char *snap) { - char name[ZFS_MAXNAMELEN]; + char name[ZFS_MAX_DATASET_NAME_LEN]; uint64_t txg = 0; if (fs == NULL || fs[0] == '\0' || snap == NULL || snap[0] == '\0') @@ -920,7 +920,7 @@ typedef struct send_dump_data { /* these are all just the short snapname (the part after the @) */ const char *fromsnap; const char *tosnap; - char prevsnap[ZFS_MAXNAMELEN]; + char prevsnap[ZFS_MAX_DATASET_NAME_LEN]; uint64_t prevsnap_obj; boolean_t seenfrom, seento, replicate, doall, fromorigin; boolean_t verbose, dryrun, parsable, progress, embed_data, std_out; @@ -933,7 +933,7 @@ typedef struct send_dump_data { snapfilter_cb_t *filter_cb; void *filter_cb_arg; nvlist_t *debugnv; - char holdtag[ZFS_MAXNAMELEN]; + char holdtag[ZFS_MAX_DATASET_NAME_LEN]; int cleanup_fd; uint64_t size; } send_dump_data_t; @@ -1569,7 +1569,7 @@ zfs_send_resume(libzfs_handle_t *hdl, se uint64_t resumeobj, resumeoff, toguid, fromguid, bytes; zfs_handle_t *zhp; int error = 0; - char name[ZFS_MAXNAMELEN]; + char name[ZFS_MAX_DATASET_NAME_LEN]; enum lzc_send_flags lzc_flags = 0; (void) snprintf(errbuf, sizeof (errbuf), dgettext(TEXT_DOMAIN, @@ -2163,8 +2163,8 @@ recv_rename(libzfs_handle_t *hdl, const if (err != 0 && strncmp(name + baselen, "recv-", 5) != 0) { seq++; - (void) snprintf(newname, ZFS_MAXNAMELEN, "%.*srecv-%u-%u", - baselen, name, getpid(), seq); + (void) snprintf(newname, ZFS_MAX_DATASET_NAME_LEN, + "%.*srecv-%u-%u", baselen, name, getpid(), seq); (void) strlcpy(zc.zc_value, newname, sizeof (zc.zc_value)); if (flags->verbose) { @@ -2292,7 +2292,7 @@ static int guid_to_name(libzfs_handle_t *hdl, const char *parent, uint64_t guid, boolean_t bookmark_ok, char *name) { - char pname[ZFS_MAXNAMELEN]; + char pname[ZFS_MAX_DATASET_NAME_LEN]; guid_to_name_data_t gtnd; gtnd.guid = guid; @@ -2347,7 +2347,7 @@ created_before(libzfs_handle_t *hdl, avl { nvlist_t *nvfs; char *fsname, *snapname; - char buf[ZFS_MAXNAMELEN]; + char buf[ZFS_MAX_DATASET_NAME_LEN]; int rv; zfs_handle_t *guid1hdl, *guid2hdl; uint64_t create1, create2; @@ -2398,7 +2398,7 @@ recv_incremental_replication(libzfs_hand avl_tree_t *local_avl; nvpair_t *fselem, *nextfselem; char *fromsnap; - char newname[ZFS_MAXNAMELEN]; + char newname[ZFS_MAX_DATASET_NAME_LEN]; char guidname[32]; int error; boolean_t needagain, progress, recursive; @@ -2517,7 +2517,7 @@ again: /* check for delete */ if (found == NULL) { - char name[ZFS_MAXNAMELEN]; + char name[ZFS_MAX_DATASET_NAME_LEN]; if (!flags->force) continue; @@ -2557,8 +2557,8 @@ again: /* check for different snapname */ if (strcmp(nvpair_name(snapelem), stream_snapname) != 0) { - char name[ZFS_MAXNAMELEN]; - char tryname[ZFS_MAXNAMELEN]; + char name[ZFS_MAX_DATASET_NAME_LEN]; + char tryname[ZFS_MAX_DATASET_NAME_LEN]; (void) snprintf(name, sizeof (name), "%s@%s", fsname, nvpair_name(snapelem)); @@ -2640,7 +2640,7 @@ again: ((flags->isprefix || strcmp(tofs, fsname) != 0) && (s1 != NULL) && (s2 != NULL) && strcmp(s1, s2) != 0)) { nvlist_t *parent; - char tryname[ZFS_MAXNAMELEN]; + char tryname[ZFS_MAX_DATASET_NAME_LEN]; parent = fsavl_find(local_avl, stream_parent_fromsnap_guid, NULL); @@ -2708,8 +2708,8 @@ zfs_receive_package(libzfs_handle_t *hdl char *fromsnap = NULL; char *sendsnap = NULL; char *cp; - char tofs[ZFS_MAXNAMELEN]; - char sendfs[ZFS_MAXNAMELEN]; + char tofs[ZFS_MAX_DATASET_NAME_LEN]; + char sendfs[ZFS_MAX_DATASET_NAME_LEN]; char errbuf[1024]; dmu_replay_record_t drre; int error; @@ -2793,7 +2793,7 @@ zfs_receive_package(libzfs_handle_t *hdl nvlist_t *renamed = NULL; nvpair_t *pair = NULL; - (void) strlcpy(tofs, destname, ZFS_MAXNAMELEN); + (void) strlcpy(tofs, destname, sizeof (tofs)); if (flags->isprefix) { struct drr_begin *drrb = &drr->drr_u.drr_begin; int i; @@ -2802,7 +2802,7 @@ zfs_receive_package(libzfs_handle_t *hdl cp = strrchr(drrb->drr_toname, '/'); if (cp == NULL) { (void) strlcat(tofs, "/", - ZFS_MAXNAMELEN); + sizeof (tofs)); i = 0; } else { i = (cp - drrb->drr_toname); @@ -2812,7 +2812,7 @@ zfs_receive_package(libzfs_handle_t *hdl } /* zfs_receive_one() will create_parents() */ (void) strlcat(tofs, &drrb->drr_toname[i], - ZFS_MAXNAMELEN); + sizeof (tofs)); *strchr(tofs, '@') = '\0'; } @@ -2854,7 +2854,7 @@ zfs_receive_package(libzfs_handle_t *hdl * zfs_receive_one(). */ (void) strlcpy(sendfs, drr->drr_u.drr_begin.drr_toname, - ZFS_MAXNAMELEN); + sizeof (sendfs)); if ((cp = strchr(sendfs, '@')) != NULL) { *cp = '\0'; /* @@ -3004,7 +3004,7 @@ static void recv_ecksum_set_aux(libzfs_handle_t *hdl, const char *target_snap, boolean_t resumable) { - char target_fs[ZFS_MAXNAMELEN]; + char target_fs[ZFS_MAX_DATASET_NAME_LEN]; zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, "checksum mismatch or incomplete stream")); @@ -3207,7 +3207,7 @@ zfs_receive_one(libzfs_handle_t *hdl, in if (flags->verbose) (void) printf("found clone origin %s\n", zc.zc_string); } else if (originsnap) { - (void) strncpy(zc.zc_string, originsnap, ZFS_MAXNAMELEN); + (void) strncpy(zc.zc_string, originsnap, sizeof (zc.zc_string)); if (flags->verbose) (void) printf("using provided clone origin %s\n", zc.zc_string); @@ -3232,7 +3232,7 @@ zfs_receive_one(libzfs_handle_t *hdl, in *cp = '\0'; if (cp && !zfs_dataset_exists(hdl, zc.zc_name, ZFS_TYPE_DATASET)) { - char suffix[ZFS_MAXNAMELEN]; + char suffix[ZFS_MAX_DATASET_NAME_LEN]; (void) strcpy(suffix, strrchr(zc.zc_value, '/')); if (guid_to_name(hdl, zc.zc_name, parent_snapguid, B_FALSE, zc.zc_value) == 0) { @@ -3259,7 +3259,7 @@ zfs_receive_one(libzfs_handle_t *hdl, in if ((flags->isprefix || (*(chopprefix = drrb->drr_toname + strlen(sendfs)) != '\0' && *chopprefix != '@')) && !zfs_dataset_exists(hdl, zc.zc_name, ZFS_TYPE_DATASET)) { - char snap[ZFS_MAXNAMELEN]; + char snap[ZFS_MAX_DATASET_NAME_LEN]; (void) strcpy(snap, strchr(zc.zc_value, '@')); if (guid_to_name(hdl, zc.zc_name, drrb->drr_fromguid, B_FALSE, zc.zc_value) == 0) { @@ -3709,7 +3709,7 @@ zfs_receive_impl(libzfs_handle_t *hdl, c } if (DMU_GET_STREAM_HDRTYPE(drrb->drr_versioninfo) == DMU_SUBSTREAM) { - char nonpackage_sendfs[ZFS_MAXNAMELEN]; + char nonpackage_sendfs[ZFS_MAX_DATASET_NAME_LEN]; if (sendfs == NULL) { /* * We were not called from zfs_receive_package(). Get @@ -3717,7 +3717,8 @@ zfs_receive_impl(libzfs_handle_t *hdl, c */ char *cp; (void) strlcpy(nonpackage_sendfs, - drr.drr_u.drr_begin.drr_toname, ZFS_MAXNAMELEN); + drr.drr_u.drr_begin.drr_toname, + sizeof (nonpackage_sendfs)); if ((cp = strchr(nonpackage_sendfs, '@')) != NULL) *cp = '\0'; sendfs = nonpackage_sendfs; Modified: stable/10/cddl/contrib/opensolaris/lib/libzfs_core/common/libzfs_core.c ============================================================================== --- stable/10/cddl/contrib/opensolaris/lib/libzfs_core/common/libzfs_core.c Wed Oct 12 05:42:00 2016 (r307121) +++ stable/10/cddl/contrib/opensolaris/lib/libzfs_core/common/libzfs_core.c Wed Oct 12 05:43:25 2016 (r307122) @@ -265,7 +265,7 @@ lzc_snapshot(nvlist_t *snaps, nvlist_t * nvpair_t *elem; nvlist_t *args; int error; - char pool[MAXNAMELEN]; + char pool[ZFS_MAX_DATASET_NAME_LEN]; *errlist = NULL; @@ -317,7 +317,7 @@ lzc_destroy_snaps(nvlist_t *snaps, boole nvpair_t *elem; nvlist_t *args; int error; - char pool[MAXNAMELEN]; + char pool[ZFS_MAX_DATASET_NAME_LEN]; /* determine the pool name */ elem = nvlist_next_nvpair(snaps, NULL); @@ -344,7 +344,7 @@ lzc_snaprange_space(const char *firstsna nvlist_t *args; nvlist_t *result; int err; - char fs[MAXNAMELEN]; + char fs[ZFS_MAX_DATASET_NAME_LEN]; char *atp; /* determine the fs name */ @@ -409,7 +409,7 @@ lzc_exists(const char *dataset) int lzc_hold(nvlist_t *holds, int cleanup_fd, nvlist_t **errlist) { - char pool[MAXNAMELEN]; + char pool[ZFS_MAX_DATASET_NAME_LEN]; nvlist_t *args; nvpair_t *elem; int error; @@ -456,7 +456,7 @@ lzc_hold(nvlist_t *holds, int cleanup_fd int lzc_release(nvlist_t *holds, nvlist_t **errlist) { - char pool[MAXNAMELEN]; + char pool[ZFS_MAX_DATASET_NAME_LEN]; nvpair_t *elem; /* determine the pool name */ @@ -743,7 +743,7 @@ lzc_bookmark(nvlist_t *bookmarks, nvlist { nvpair_t *elem; int error; - char pool[MAXNAMELEN]; + char pool[ZFS_MAX_DATASET_NAME_LEN]; /* determine the pool name */ elem = nvlist_next_nvpair(bookmarks, NULL); @@ -805,7 +805,7 @@ lzc_destroy_bookmarks(nvlist_t *bmarks, { nvpair_t *elem; int error; - char pool[MAXNAMELEN]; + char pool[ZFS_MAX_DATASET_NAME_LEN]; /* determine the pool name */ elem = nvlist_next_nvpair(bmarks, NULL); Modified: stable/10/sys/cddl/contrib/opensolaris/common/zfs/zfs_namecheck.c ============================================================================== --- stable/10/sys/cddl/contrib/opensolaris/common/zfs/zfs_namecheck.c Wed Oct 12 05:42:00 2016 (r307121) +++ stable/10/sys/cddl/contrib/opensolaris/common/zfs/zfs_namecheck.c Wed Oct 12 05:43:25 2016 (r307122) @@ -69,7 +69,7 @@ zfs_component_namecheck(const char *path { const char *loc; - if (strlen(path) >= MAXNAMELEN) { + if (strlen(path) >= ZFS_MAX_DATASET_NAME_LEN) { if (why) *why = NAME_ERR_TOOLONG; return (-1); @@ -140,14 +140,9 @@ dataset_namecheck(const char *path, name /* * Make sure the name is not too long. - * - * ZFS_MAXNAMELEN is the maximum dataset length used in the userland - * which is the same as MAXNAMELEN used in the kernel. - * If ZFS_MAXNAMELEN value is changed, make sure to cleanup all - * places using MAXNAMELEN. */ - if (strlen(path) >= MAXNAMELEN) { + if (strlen(path) >= ZFS_MAX_DATASET_NAME_LEN) { if (why) *why = NAME_ERR_TOOLONG; return (-1); @@ -276,7 +271,7 @@ mountpoint_namecheck(const char *path, n while (*end != '/' && *end != '\0') end++; - if (end - start >= MAXNAMELEN) { *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-all@freebsd.org Wed Oct 12 05:44:13 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id DEE9AC0E8B6; Wed, 12 Oct 2016 05:44:13 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 961B2264; Wed, 12 Oct 2016 05:44:13 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9C5iCf5025173; Wed, 12 Oct 2016 05:44:12 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9C5iC4b025172; Wed, 12 Oct 2016 05:44:12 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201610120544.u9C5iC4b025172@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Wed, 12 Oct 2016 05:44:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307123 - stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Oct 2016 05:44:14 -0000 Author: mav Date: Wed Oct 12 05:44:12 2016 New Revision: 307123 URL: https://svnweb.freebsd.org/changeset/base/307123 Log: MFC r305210: MFV r302661: 7082 bptree_iterate() passes wrong args to zfs_dbgmsg() illumos/illumos-gate@10e67aa0db0823d5464aafdd681f3c966155c68e https://github.com/illumos/illumos-gate/commit/10e67aa0db0823d5464aafdd681f3c966 155c68e https://www.illumos.org/issues/7082 upstream DLPX-40542 bptree_iterate() passes wrong args to zfs_dbgmsg() Reviewed by: Dan Kimmel Reviewed by: George Wilson Reviewed by: Igor Kozhukhov Approved by: Dan McDonald Author: Matthew Ahrens Modified: stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/bptree.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/bptree.c ============================================================================== --- stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/bptree.c Wed Oct 12 05:43:25 2016 (r307122) +++ stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/bptree.c Wed Oct 12 05:44:12 2016 (r307123) @@ -20,7 +20,7 @@ */ /* - * Copyright (c) 2011, 2014 by Delphix. All rights reserved. + * Copyright (c) 2011, 2015 by Delphix. All rights reserved. * Copyright (c) 2014 Integros [integros.com] */ @@ -220,9 +220,10 @@ bptree_iterate(objset_t *os, uint64_t ob if (zfs_free_leak_on_eio) flags |= TRAVERSE_HARD; - zfs_dbgmsg("bptree index %d: traversing from min_txg=%lld " + zfs_dbgmsg("bptree index %lld: traversing from min_txg=%lld " "bookmark %lld/%lld/%lld/%lld", - i, (longlong_t)bte.be_birth_txg, + (longlong_t)i, + (longlong_t)bte.be_birth_txg, (longlong_t)bte.be_zb.zb_objset, (longlong_t)bte.be_zb.zb_object, (longlong_t)bte.be_zb.zb_level, From owner-svn-src-all@freebsd.org Wed Oct 12 05:44:55 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 68222C0E93F; Wed, 12 Oct 2016 05:44:55 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 44CD4656; Wed, 12 Oct 2016 05:44:55 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9C5is35025250; Wed, 12 Oct 2016 05:44:54 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9C5iswq025248; Wed, 12 Oct 2016 05:44:54 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201610120544.u9C5iswq025248@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Wed, 12 Oct 2016 05:44:54 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307124 - in stable/10: cddl/contrib/opensolaris/lib/libnvpair sys/cddl/contrib/opensolaris/common/nvpair X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Oct 2016 05:44:55 -0000 Author: mav Date: Wed Oct 12 05:44:54 2016 New Revision: 307124 URL: https://svnweb.freebsd.org/changeset/base/307124 Log: MFC r305211: MFV r302662: 6447 handful of nvpair cleanups illumos/illumos-gate@759e89be359f2af635e4122d147df56bce948773 https://github.com/illumos/illumos-gate/commit/759e89be359f2af635e4122d147df56bc e948773 https://www.illumos.org/issues/6447 I got a patch from someone who uses nvpair code outside of illumos. It fixes a couple of gcc warnings/bugs for him. 1. silence uninitialized use warnings 2. add parentheses around assignment used as truth value 3. fix printf format specifier (ll is for integers only) 4. strstr, strspn, strcspn, and strcmp are declared in string.h, not strings.h. 5. avoid scanning integer into boolean variable Reviewed by: Josef 'Jeff' Sipek Reviewed by: Andy Stormont Reviewed by: Garrett D'Amore Approved by: Robert Mustacchi Author: Steve Dougherty Modified: stable/10/cddl/contrib/opensolaris/lib/libnvpair/libnvpair.c stable/10/sys/cddl/contrib/opensolaris/common/nvpair/opensolaris_nvpair.c Directory Properties: stable/10/ (props changed) Modified: stable/10/cddl/contrib/opensolaris/lib/libnvpair/libnvpair.c ============================================================================== --- stable/10/cddl/contrib/opensolaris/lib/libnvpair/libnvpair.c Wed Oct 12 05:44:12 2016 (r307123) +++ stable/10/cddl/contrib/opensolaris/lib/libnvpair/libnvpair.c Wed Oct 12 05:44:54 2016 (r307124) @@ -26,7 +26,7 @@ #include #include #include -#include +#include #include #include #include "libnvpair.h" @@ -1228,7 +1228,8 @@ nvpair_value_match_regex(nvpair_t *nvp, break; } case DATA_TYPE_BOOLEAN_VALUE: { - boolean_t val, val_arg; + int32_t val_arg; + boolean_t val; /* scanf boolean_t from value and check for match */ sr = sscanf(value, "%"SCNi32, &val_arg); @@ -1239,7 +1240,8 @@ nvpair_value_match_regex(nvpair_t *nvp, break; } case DATA_TYPE_BOOLEAN_ARRAY: { - boolean_t *val_array, val_arg; + boolean_t *val_array; + int32_t val_arg; /* check indexed value of array for match */ sr = sscanf(value, "%"SCNi32, &val_arg); Modified: stable/10/sys/cddl/contrib/opensolaris/common/nvpair/opensolaris_nvpair.c ============================================================================== --- stable/10/sys/cddl/contrib/opensolaris/common/nvpair/opensolaris_nvpair.c Wed Oct 12 05:44:12 2016 (r307123) +++ stable/10/sys/cddl/contrib/opensolaris/common/nvpair/opensolaris_nvpair.c Wed Oct 12 05:44:54 2016 (r307124) @@ -1629,6 +1629,8 @@ nvlist_lookup_nvpair_ei_sep(nvlist_t *nv if ((nvl == NULL) || (name == NULL)) return (EINVAL); + sepp = NULL; + idx = 0; /* step through components of name */ for (np = name; np && *np; np = sepp) { /* ensure unique names */ @@ -2386,7 +2388,7 @@ nvlist_xpack(nvlist_t *nvl, char **bufp, */ nv_priv_init(&nvpriv, nva, 0); - if (err = nvlist_size(nvl, &alloc_size, encoding)) + if ((err = nvlist_size(nvl, &alloc_size, encoding))) return (err); if ((buf = nv_mem_zalloc(&nvpriv, alloc_size)) == NULL) From owner-svn-src-all@freebsd.org Wed Oct 12 05:45:42 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 2B65DC0E9C7; Wed, 12 Oct 2016 05:45:42 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id EEF8C846; Wed, 12 Oct 2016 05:45:41 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9C5jfA7025337; Wed, 12 Oct 2016 05:45:41 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9C5jfmT025336; Wed, 12 Oct 2016 05:45:41 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201610120545.u9C5jfmT025336@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Wed, 12 Oct 2016 05:45:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307125 - stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Oct 2016 05:45:42 -0000 Author: mav Date: Wed Oct 12 05:45:40 2016 New Revision: 307125 URL: https://svnweb.freebsd.org/changeset/base/307125 Log: MFC r305221: MFV r302992: 7071 lzc_snapshot does not fill in errlist on ENOENT illumos/illumos-gate@25f7d993adbfb3452ac4625b3791670746d35ae3 https://github.com/illumos/illumos-gate/commit/25f7d993adbfb3452ac4625b379167074 6d35ae3 https://www.illumos.org/issues/7071 upstream DLPX-40482 lzc_snapshot does not fill in errlist on ENOENT Reviewed by: Igor Kozhukhov Reviewed by: George Wilson Reviewed by: Dan Kimmel Approved by: Robert Mustacchi Author: Matthew Ahrens Modified: stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c ============================================================================== --- stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c Wed Oct 12 05:44:54 2016 (r307124) +++ stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c Wed Oct 12 05:45:40 2016 (r307125) @@ -499,6 +499,14 @@ zfs_secpolicy_write_perms(const char *na dsl_dataset_t *ds; dsl_pool_t *dp; + /* + * First do a quick check for root in the global zone, which + * is allowed to do all write_perms. This ensures that zfs_ioc_* + * will get to handle nonexistent datasets. + */ + if (INGLOBALZONE(curthread) && secpolicy_zfs(cr) == 0) + return (0); + error = dsl_pool_hold(name, FTAG, &dp); if (error != 0) return (error); From owner-svn-src-all@freebsd.org Wed Oct 12 05:46:22 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id DE62EC0EA23; Wed, 12 Oct 2016 05:46:22 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id B7BD59B2; Wed, 12 Oct 2016 05:46:22 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9C5kLHs025420; Wed, 12 Oct 2016 05:46:21 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9C5kL7T025416; Wed, 12 Oct 2016 05:46:21 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201610120546.u9C5kL7T025416@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Wed, 12 Oct 2016 05:46:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307126 - in stable/10/sys/cddl/contrib/opensolaris/uts/common: fs/zfs fs/zfs/sys sys/fs X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Oct 2016 05:46:23 -0000 Author: mav Date: Wed Oct 12 05:46:21 2016 New Revision: 307126 URL: https://svnweb.freebsd.org/changeset/base/307126 Log: MFC r305222: MFV r302993: 7104 increase indirect block size illumos/illumos-gate@4b5c8e93cab28d3c65ba9d407fd8f46e3be1db1c https://github.com/illumos/illumos-gate/commit/4b5c8e93cab28d3c65ba9d407fd8f46e3 be1db1c https://www.illumos.org/issues/7104 The current default indirect block size is 16KB. We can improve performance by increasing it to 128KB. This is especially helpful for any workload that needs to read most of the metadata, e.g. scrub/resilver, file deletion, filesystem deletion, and zfs send. We also need to fix a few space estimation errors to make the tests pass. Reviewed by: George Wilson Reviewed by: Paul Dagnelie Reviewed by: Dan McDonald Approved by: Robert Mustacchi Author: Matthew Ahrens Modified: stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_objset.c stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_misc.c stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dnode.h stable/10/sys/cddl/contrib/opensolaris/uts/common/sys/fs/zfs.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_objset.c ============================================================================== --- stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_objset.c Wed Oct 12 05:45:40 2016 (r307125) +++ stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_objset.c Wed Oct 12 05:46:21 2016 (r307126) @@ -791,11 +791,17 @@ dmu_objset_create_impl(spa_t *spa, dsl_d /* * Determine the number of levels necessary for the meta-dnode - * to contain DN_MAX_OBJECT dnodes. + * to contain DN_MAX_OBJECT dnodes. Note that in order to + * ensure that we do not overflow 64 bits, there has to be + * a nlevels that gives us a number of blocks > DN_MAX_OBJECT + * but < 2^64. Therefore, + * (mdn->dn_indblkshift - SPA_BLKPTRSHIFT) (10) must be + * less than (64 - log2(DN_MAX_OBJECT)) (16). */ - while ((uint64_t)mdn->dn_nblkptr << (mdn->dn_datablkshift + + while ((uint64_t)mdn->dn_nblkptr << + (mdn->dn_datablkshift - DNODE_SHIFT + (levels - 1) * (mdn->dn_indblkshift - SPA_BLKPTRSHIFT)) < - DN_MAX_OBJECT * sizeof (dnode_phys_t)) + DN_MAX_OBJECT) levels++; mdn->dn_next_nlevels[tx->tx_txg & TXG_MASK] = Modified: stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_misc.c ============================================================================== --- stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_misc.c Wed Oct 12 05:45:40 2016 (r307125) +++ stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_misc.c Wed Oct 12 05:46:21 2016 (r307126) @@ -411,12 +411,20 @@ zfs_deadman_init() * it is possible to run the pool completely out of space, causing it to * be permanently read-only. * + * Note that on very small pools, the slop space will be larger than + * 3.2%, in an effort to have it be at least spa_min_slop (128MB), + * but we never allow it to be more than half the pool size. + * * See also the comments in zfs_space_check_t. */ int spa_slop_shift = 5; SYSCTL_INT(_vfs_zfs, OID_AUTO, spa_slop_shift, CTLFLAG_RWTUN, &spa_slop_shift, 0, "Shift value of reserved space (1/(2^spa_slop_shift))."); +uint64_t spa_min_slop = 128 * 1024 * 1024; +SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, spa_min_slop, CTLFLAG_RWTUN, + &spa_min_slop, 0, + "Minimal value of reserved space"); /* * ========================================================================== @@ -1723,14 +1731,16 @@ spa_get_asize(spa_t *spa, uint64_t lsize /* * Return the amount of slop space in bytes. It is 1/32 of the pool (3.2%), - * or at least 32MB. + * or at least 128MB, unless that would cause it to be more than half the + * pool size. * * See the comment above spa_slop_shift for details. */ uint64_t -spa_get_slop_space(spa_t *spa) { +spa_get_slop_space(spa_t *spa) +{ uint64_t space = spa_get_dspace(spa); - return (MAX(space >> spa_slop_shift, SPA_MINDEVSIZE >> 1)); + return (MAX(space >> spa_slop_shift, MIN(space >> 1, spa_min_slop))); } uint64_t Modified: stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dnode.h ============================================================================== --- stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dnode.h Wed Oct 12 05:45:40 2016 (r307125) +++ stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dnode.h Wed Oct 12 05:46:21 2016 (r307126) @@ -58,7 +58,7 @@ extern "C" { */ #define DNODE_SHIFT 9 /* 512 bytes */ #define DN_MIN_INDBLKSHIFT 12 /* 4k */ -#define DN_MAX_INDBLKSHIFT 14 /* 16k */ +#define DN_MAX_INDBLKSHIFT 17 /* 128k */ #define DNODE_BLOCK_SHIFT 14 /* 16k */ #define DNODE_CORE_SIZE 64 /* 64 bytes for dnode sans blkptrs */ #define DN_MAX_OBJECT_SHIFT 48 /* 256 trillion (zfs_fid_t limit) */ @@ -88,6 +88,11 @@ extern "C" { #define DNODES_PER_BLOCK_SHIFT (DNODE_BLOCK_SHIFT - DNODE_SHIFT) #define DNODES_PER_BLOCK (1ULL << DNODES_PER_BLOCK_SHIFT) + +/* + * This is inaccurate if the indblkshift of the particular object is not the + * max. But it's only used by userland to calculate the zvol reservation. + */ #define DNODES_PER_LEVEL_SHIFT (DN_MAX_INDBLKSHIFT - SPA_BLKPTRSHIFT) #define DNODES_PER_LEVEL (1ULL << DNODES_PER_LEVEL_SHIFT) Modified: stable/10/sys/cddl/contrib/opensolaris/uts/common/sys/fs/zfs.h ============================================================================== --- stable/10/sys/cddl/contrib/opensolaris/uts/common/sys/fs/zfs.h Wed Oct 12 05:45:40 2016 (r307125) +++ stable/10/sys/cddl/contrib/opensolaris/uts/common/sys/fs/zfs.h Wed Oct 12 05:46:21 2016 (r307126) @@ -607,6 +607,8 @@ typedef struct zpool_rewind_policy { /* * This is needed in userland to report the minimum necessary device size. + * + * Note that the zfs test suite uses 64MB vdevs. */ #define SPA_MINDEVSIZE (64ULL << 20) From owner-svn-src-all@freebsd.org Wed Oct 12 05:47:07 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 68483C0EA8C; Wed, 12 Oct 2016 05:47:07 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 29A38B1D; Wed, 12 Oct 2016 05:47:07 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9C5l6Rc025509; Wed, 12 Oct 2016 05:47:06 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9C5l6MF025508; Wed, 12 Oct 2016 05:47:06 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201610120547.u9C5l6MF025508@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Wed, 12 Oct 2016 05:47:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307127 - stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Oct 2016 05:47:07 -0000 Author: mav Date: Wed Oct 12 05:47:06 2016 New Revision: 307127 URL: https://svnweb.freebsd.org/changeset/base/307127 Log: MFC r305224: MFV r304158: 7136 ESC_VDEV_REMOVE_AUX ought to always include vdev information 7115 6922 generates ESC_ZFS_VDEV_REMOVE_AUX a bit too often illumos/illumos-gate@b72b6bb10ad55121a1b352c6f68ebdc8e20c9086 https://github.com/illumos/illumos-gate/commit/b72b6bb10ad55121a1b352c6f68ebdc8e 20c9086 https://www.illumos.org/issues/7136 6922 added ESC_ZFS_VDEV_REMOVE_AUX and ESC_ZFS_VDEV_REMOVE_DEV sysevents whenever an aux device gets removed from a pool. However, those sysevents will be created without the vdev_guid and vdev_path fields. It would be better to always populate those fields. https://www.illumos.org/issues/7115 The addition of spa_event_notify in vdev removal code (see #6922) causes event s to be generated even if the spare failed to be removed with EBUSY. Reviewed by: George Wilson Reviewed by: Josef 'Jeff' Sipek Approved by: Robert Mustacchi Author: Alan Somers Modified: stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c ============================================================================== --- stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c Wed Oct 12 05:46:21 2016 (r307126) +++ stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c Wed Oct 12 05:47:06 2016 (r307127) @@ -152,6 +152,8 @@ const zio_taskq_info_t zio_taskqs[ZIO_TY { ZTI_ONE, ZTI_NULL, ZTI_ONE, ZTI_NULL }, /* IOCTL */ }; +static sysevent_t *spa_event_create(spa_t *spa, vdev_t *vd, const char *name); +static void spa_event_post(sysevent_t *ev); static void spa_sync_version(void *arg, dmu_tx_t *tx); static void spa_sync_props(void *arg, dmu_tx_t *tx); static boolean_t spa_has_active_shared_spare(spa_t *spa); @@ -5645,6 +5647,7 @@ int spa_vdev_remove(spa_t *spa, uint64_t guid, boolean_t unspare) { vdev_t *vd; + sysevent_t *ev = NULL; metaslab_group_t *mg; nvlist_t **spares, **l2cache, *nv; uint64_t txg = 0; @@ -5668,6 +5671,9 @@ spa_vdev_remove(spa_t *spa, uint64_t gui * in this pool. */ if (vd == NULL || unspare) { + if (vd == NULL) + vd = spa_lookup_by_guid(spa, guid, B_TRUE); + ev = spa_event_create(spa, vd, ESC_ZFS_VDEV_REMOVE_AUX); spa_vdev_remove_aux(spa->spa_spares.sav_config, ZPOOL_CONFIG_SPARES, spares, nspares, nv); spa_load_spares(spa); @@ -5675,7 +5681,6 @@ spa_vdev_remove(spa_t *spa, uint64_t gui } else { error = SET_ERROR(EBUSY); } - spa_event_notify(spa, vd, ESC_ZFS_VDEV_REMOVE_AUX); } else if (spa->spa_l2cache.sav_vdevs != NULL && nvlist_lookup_nvlist_array(spa->spa_l2cache.sav_config, ZPOOL_CONFIG_L2CACHE, &l2cache, &nl2cache) == 0 && @@ -5683,11 +5688,12 @@ spa_vdev_remove(spa_t *spa, uint64_t gui /* * Cache devices can always be removed. */ + vd = spa_lookup_by_guid(spa, guid, B_TRUE); + ev = spa_event_create(spa, vd, ESC_ZFS_VDEV_REMOVE_AUX); spa_vdev_remove_aux(spa->spa_l2cache.sav_config, ZPOOL_CONFIG_L2CACHE, l2cache, nl2cache, nv); spa_load_l2cache(spa); spa->spa_l2cache.sav_sync = B_TRUE; - spa_event_notify(spa, vd, ESC_ZFS_VDEV_REMOVE_AUX); } else if (vd != NULL && vd->vdev_islog) { ASSERT(!locked); ASSERT(vd == vd->vdev_top); @@ -5724,9 +5730,9 @@ spa_vdev_remove(spa_t *spa, uint64_t gui /* * Clean up the vdev namespace. */ + ev = spa_event_create(spa, vd, ESC_ZFS_VDEV_REMOVE_DEV); spa_vdev_remove_from_namespace(spa, vd); - spa_event_notify(spa, vd, ESC_ZFS_VDEV_REMOVE_DEV); } else if (vd != NULL) { /* * Normal vdevs cannot be removed (yet). @@ -5742,6 +5748,9 @@ spa_vdev_remove(spa_t *spa, uint64_t gui if (!locked) error = spa_vdev_exit(spa, NULL, txg, error); + if (ev) + spa_event_post(ev); + return (error); } @@ -7019,24 +7028,17 @@ spa_has_active_shared_spare(spa_t *spa) return (B_FALSE); } -/* - * Post a sysevent corresponding to the given event. The 'name' must be one of - * the event definitions in sys/sysevent/eventdefs.h. The payload will be - * filled in from the spa and (optionally) the vdev. This doesn't do anything - * in the userland libzpool, as we don't want consumers to misinterpret ztest - * or zdb as real changes. - */ -void -spa_event_notify(spa_t *spa, vdev_t *vd, const char *name) +static sysevent_t * +spa_event_create(spa_t *spa, vdev_t *vd, const char *name) { + sysevent_t *ev = NULL; #ifdef _KERNEL - sysevent_t *ev; sysevent_attr_list_t *attr = NULL; sysevent_value_t value; - sysevent_id_t eid; ev = sysevent_alloc(EC_ZFS, (char *)name, SUNW_KERN_PUB "zfs", SE_SLEEP); + ASSERT(ev != NULL); value.value_type = SE_DATA_TYPE_STRING; value.value.sv_string = spa_name(spa); @@ -7068,11 +7070,34 @@ spa_event_notify(spa_t *spa, vdev_t *vd, goto done; attr = NULL; - (void) log_sysevent(ev, SE_SLEEP, &eid); - done: if (attr) sysevent_free_attr(attr); + +#endif + return (ev); +} + +static void +spa_event_post(sysevent_t *ev) +{ +#ifdef _KERNEL + sysevent_id_t eid; + + (void) log_sysevent(ev, SE_SLEEP, &eid); sysevent_free(ev); #endif } + +/* + * Post a sysevent corresponding to the given event. The 'name' must be one of + * the event definitions in sys/sysevent/eventdefs.h. The payload will be + * filled in from the spa and (optionally) the vdev. This doesn't do anything + * in the userland libzpool, as we don't want consumers to misinterpret ztest + * or zdb as real changes. + */ +void +spa_event_notify(spa_t *spa, vdev_t *vd, const char *name) +{ + spa_event_post(spa_event_create(spa, vd, name)); +} From owner-svn-src-all@freebsd.org Wed Oct 12 05:50:14 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 8A8BFC0EB01; Wed, 12 Oct 2016 05:50:14 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 56B23CC2; Wed, 12 Oct 2016 05:50:14 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9C5oD0b025705; Wed, 12 Oct 2016 05:50:13 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9C5oDGb025704; Wed, 12 Oct 2016 05:50:13 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201610120550.u9C5oDGb025704@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Wed, 12 Oct 2016 05:50:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307128 - stable/11/sys/cam/scsi X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Oct 2016 05:50:14 -0000 Author: mav Date: Wed Oct 12 05:50:13 2016 New Revision: 307128 URL: https://svnweb.freebsd.org/changeset/base/307128 Log: MFC 306699: Do not retry on some security sense codes. Modified: stable/11/sys/cam/scsi/scsi_all.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/cam/scsi/scsi_all.c ============================================================================== --- stable/11/sys/cam/scsi/scsi_all.c Wed Oct 12 05:47:06 2016 (r307127) +++ stable/11/sys/cam/scsi/scsi_all.c Wed Oct 12 05:50:13 2016 (r307128) @@ -3192,10 +3192,10 @@ static struct asc_table_entry asc_table[ { SST(0x74, 0x6F, SS_RDEF, /* XXX TBD */ "External data encryption control error") }, /* DT R M E V */ - { SST(0x74, 0x71, SS_RDEF, /* XXX TBD */ + { SST(0x74, 0x71, SS_FATAL | EACCES, "Logical unit access not authorized") }, /* D */ - { SST(0x74, 0x79, SS_RDEF, /* XXX TBD */ + { SST(0x74, 0x79, SS_FATAL | EACCES, "Security conflict in translated device") } }; From owner-svn-src-all@freebsd.org Wed Oct 12 05:50:48 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id BBB96C0EB52; Wed, 12 Oct 2016 05:50:48 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 8AC02E43; Wed, 12 Oct 2016 05:50:48 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9C5olqw027784; Wed, 12 Oct 2016 05:50:47 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9C5olvg027783; Wed, 12 Oct 2016 05:50:47 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201610120550.u9C5olvg027783@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Wed, 12 Oct 2016 05:50:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307129 - stable/10/sys/cam/scsi X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Oct 2016 05:50:48 -0000 Author: mav Date: Wed Oct 12 05:50:47 2016 New Revision: 307129 URL: https://svnweb.freebsd.org/changeset/base/307129 Log: MFC 306699: Do not retry on some security sense codes. Modified: stable/10/sys/cam/scsi/scsi_all.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/cam/scsi/scsi_all.c ============================================================================== --- stable/10/sys/cam/scsi/scsi_all.c Wed Oct 12 05:50:13 2016 (r307128) +++ stable/10/sys/cam/scsi/scsi_all.c Wed Oct 12 05:50:47 2016 (r307129) @@ -3191,10 +3191,10 @@ static struct asc_table_entry asc_table[ { SST(0x74, 0x6F, SS_RDEF, /* XXX TBD */ "External data encryption control error") }, /* DT R M E V */ - { SST(0x74, 0x71, SS_RDEF, /* XXX TBD */ + { SST(0x74, 0x71, SS_FATAL | EACCES, "Logical unit access not authorized") }, /* D */ - { SST(0x74, 0x79, SS_RDEF, /* XXX TBD */ + { SST(0x74, 0x79, SS_FATAL | EACCES, "Security conflict in translated device") } }; From owner-svn-src-all@freebsd.org Wed Oct 12 06:58:03 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 1E3CCC0EC73; Wed, 12 Oct 2016 06:58:03 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id EF1302B5; Wed, 12 Oct 2016 06:58:02 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9C6w2de052006; Wed, 12 Oct 2016 06:58:02 GMT (envelope-from avg@FreeBSD.org) Received: (from avg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9C6w2Af052004; Wed, 12 Oct 2016 06:58:02 GMT (envelope-from avg@FreeBSD.org) Message-Id: <201610120658.u9C6w2Af052004@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avg set sender to avg@FreeBSD.org using -f From: Andriy Gapon Date: Wed, 12 Oct 2016 06:58:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307130 - head/sys/dev/smbus X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Oct 2016 06:58:03 -0000 Author: avg Date: Wed Oct 12 06:58:01 2016 New Revision: 307130 URL: https://svnweb.freebsd.org/changeset/base/307130 Log: smbus: allow child devices to be added via hints This will allow to add slave drivers in the same fashion as for iicbus. Also, allow other code to add a child device and set its 'addr' ivar. The ivar can only be set if it's unset, it can not be changed. That could be used, for example, by a platform driver that has a precise description of the hardware and, thus, knows what drivers can handle what slaves. The slave auto-probing code is unsafe and broken because it uses 7-bit slave addresses. It's going to be removed. Note: internally the driver uses address of zero as an unset address while smbus_get_addr() returns it as -1 for compatibility reasons. The address is expected to be unset only for children that do not work with slaves like, for example, smb(4). Reviewed by: jhb Differential Revision: https://reviews.freebsd.org/D8173 Modified: head/sys/dev/smbus/smbconf.h head/sys/dev/smbus/smbus.c Modified: head/sys/dev/smbus/smbconf.h ============================================================================== --- head/sys/dev/smbus/smbconf.h Wed Oct 12 05:50:47 2016 (r307129) +++ head/sys/dev/smbus/smbconf.h Wed Oct 12 06:58:01 2016 (r307130) @@ -34,6 +34,10 @@ #define n(flags) (~(flags) & (flags)) +/* Order constants for smbus children. */ +#define SMBUS_ORDER_HINTED 20 +#define SMBUS_ORDER_PNP 40 + /* * How tsleep() is called in smb_request_bus(). */ Modified: head/sys/dev/smbus/smbus.c ============================================================================== --- head/sys/dev/smbus/smbus.c Wed Oct 12 05:50:47 2016 (r307129) +++ head/sys/dev/smbus/smbus.c Wed Oct 12 06:58:01 2016 (r307130) @@ -31,6 +31,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -41,54 +42,16 @@ __FBSDID("$FreeBSD$"); #include "smbus_if.h" #include "bus_if.h" +struct smbus_ivar +{ + uint8_t addr; +}; /* * Autoconfiguration and support routines for System Management bus */ +static void smbus_probe_device(device_t dev, u_char addr); -/* - * Device methods - */ -static int smbus_probe(device_t); -static int smbus_attach(device_t); -static int smbus_detach(device_t); - -static int smbus_child_location_str(device_t parent, device_t child, - char *buf, size_t buflen); -static int smbus_print_child(device_t parent, device_t child); -static void smbus_probe_device(device_t dev, u_char* addr); -static int smbus_read_ivar(device_t parent, device_t child, int which, - uintptr_t *result); - -static device_method_t smbus_methods[] = { - /* device interface */ - DEVMETHOD(device_probe, smbus_probe), - DEVMETHOD(device_attach, smbus_attach), - DEVMETHOD(device_detach, smbus_detach), - - /* bus interface */ - DEVMETHOD(bus_add_child, bus_generic_add_child), - DEVMETHOD(bus_child_location_str, smbus_child_location_str), - DEVMETHOD(bus_driver_added, bus_generic_driver_added), - DEVMETHOD(bus_print_child, smbus_print_child), - DEVMETHOD(bus_read_ivar, smbus_read_ivar), - - DEVMETHOD_END -}; - -driver_t smbus_driver = { - "smbus", - smbus_methods, - sizeof(struct smbus_softc), -}; - -devclass_t smbus_devclass; - -/* - * At 'probe' time, we add all the devices which we know about to the - * bus. The generic attach routine will probe and attach them if they - * are alive. - */ static int smbus_probe(device_t dev) { @@ -107,9 +70,9 @@ smbus_attach(device_t dev) mtx_init(&sc->lock, device_get_nameunit(dev), "smbus", MTX_DEF); bus_generic_probe(dev); for (addr = SMBUS_ADDR_MIN; addr < SMBUS_ADDR_MAX; ++addr) { - sc->addrs[addr] = addr; - smbus_probe_device(dev, &sc->addrs[addr]); + smbus_probe_device(dev, addr); } + bus_enumerate_hinted_children(dev); bus_generic_attach(dev); return (0); @@ -124,6 +87,7 @@ smbus_detach(device_t dev) error = bus_generic_detach(dev); if (error) return (error); + device_delete_children(dev); mtx_destroy(&sc->lock); return (0); @@ -135,34 +99,78 @@ smbus_generic_intr(device_t dev, u_char } static void -smbus_probe_device(device_t dev, u_char* addr) +smbus_probe_device(device_t dev, u_char addr) { device_t child; int error; u_char cmd; u_char buf[2]; + struct smbus_ivar *devi; cmd = 0x01; - error = smbus_trans(dev, *addr, cmd, + error = smbus_trans(dev, addr, cmd, SMB_TRANS_NOCNT | SMB_TRANS_NOREPORT, NULL, 0, buf, 1, NULL); if (error == 0) { if (bootverbose) - device_printf(dev, "Probed address 0x%02x\n", *addr); - child = device_add_child(dev, NULL, -1); - device_set_ivars(child, addr); + device_printf(dev, "Probed address 0x%02x\n", addr); + child = BUS_ADD_CHILD(dev, SMBUS_ORDER_PNP, NULL, -1); + if (child == NULL) + return; + devi = device_get_ivars(child); + devi->addr = addr; + } +} + +static device_t +smbus_add_child(device_t dev, u_int order, const char *name, int unit) +{ + struct smbus_ivar *devi; + device_t child; + + child = device_add_child_ordered(dev, order, name, unit); + if (child == NULL) + return (child); + devi = malloc(sizeof(struct smbus_ivar), M_DEVBUF, M_NOWAIT | M_ZERO); + if (devi == NULL) { + device_delete_child(dev, child); + return (NULL); + } + device_set_ivars(child, devi); + return (child); +} + +static void +smbus_hinted_child(device_t bus, const char *dname, int dunit) +{ + struct smbus_ivar *devi; + device_t child; + int addr; + + addr = 0; + resource_int_value(dname, dunit, "addr", &addr); + if (addr > UINT8_MAX) { + device_printf(bus, "ignored incorrect slave address hint 0x%x" + " for %s%d\n", addr, dname, dunit); + return; } + child = BUS_ADD_CHILD(bus, SMBUS_ORDER_HINTED, dname, dunit); + if (child == NULL) + return; + devi = device_get_ivars(child); + devi->addr = addr; } + static int smbus_child_location_str(device_t parent, device_t child, char *buf, size_t buflen) { - unsigned char *addr; + struct smbus_ivar *devi; - addr = device_get_ivars(child); - if (addr) - snprintf(buf, buflen, "addr=0x%x", *addr); + devi = device_get_ivars(child); + if (devi->addr != 0) + snprintf(buf, buflen, "addr=0x%x", devi->addr); else if (buflen) buf[0] = 0; return (0); @@ -171,28 +179,49 @@ smbus_child_location_str(device_t parent static int smbus_print_child(device_t parent, device_t child) { - unsigned char *addr; + struct smbus_ivar *devi; int retval; - addr = device_get_ivars(child); + devi = device_get_ivars(child); retval = bus_print_child_header(parent, child); - if (addr) - retval += printf(" at addr 0x%x", *addr); + if (devi->addr != 0) + retval += printf(" at addr 0x%x", devi->addr); retval += bus_print_child_footer(parent, child); return (retval); } static int -smbus_read_ivar(device_t parent, device_t child, int which, - uintptr_t *result) +smbus_read_ivar(device_t parent, device_t child, int which, uintptr_t *result) +{ + struct smbus_ivar *devi; + + devi = device_get_ivars(child); + switch (which) { + case SMBUS_IVAR_ADDR: + if (devi->addr != 0) + *result = devi->addr; + else + *result = -1; + break; + default: + return (ENOENT); + } + return (0); +} + +static int +smbus_write_ivar(device_t parent, device_t child, int which, uintptr_t value) { - unsigned char *addr; + struct smbus_ivar *devi; - addr = device_get_ivars(child); + devi = device_get_ivars(child); switch (which) { case SMBUS_IVAR_ADDR: - *result = (addr == NULL) ? -1 : *addr; + /* Allow to set but no change the slave address. */ + if (devi->addr != 0) + return (EINVAL); + devi->addr = value; break; default: return (ENOENT); @@ -200,4 +229,47 @@ smbus_read_ivar(device_t parent, device_ return (0); } +static void +smbus_probe_nomatch(device_t bus, device_t child) +{ + struct smbus_ivar *devi = device_get_ivars(child); + + /* + * Ignore (self-identified) devices without a slave address set. + * For example, smb(4). + */ + if (devi->addr != 0) + device_printf(bus, " at addr %#x\n", + devi->addr); +} + +/* + * Device methods + */ +static device_method_t smbus_methods[] = { + /* device interface */ + DEVMETHOD(device_probe, smbus_probe), + DEVMETHOD(device_attach, smbus_attach), + DEVMETHOD(device_detach, smbus_detach), + + /* bus interface */ + DEVMETHOD(bus_add_child, smbus_add_child), + DEVMETHOD(bus_hinted_child, smbus_hinted_child), + DEVMETHOD(bus_probe_nomatch, smbus_probe_nomatch), + DEVMETHOD(bus_child_location_str, smbus_child_location_str), + DEVMETHOD(bus_print_child, smbus_print_child), + DEVMETHOD(bus_read_ivar, smbus_read_ivar), + DEVMETHOD(bus_write_ivar, smbus_write_ivar), + + DEVMETHOD_END +}; + +driver_t smbus_driver = { + "smbus", + smbus_methods, + sizeof(struct smbus_softc), +}; + +devclass_t smbus_devclass; + MODULE_VERSION(smbus, SMBUS_MODVER); From owner-svn-src-all@freebsd.org Wed Oct 12 07:08:33 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A33DEC0EEA1; Wed, 12 Oct 2016 07:08:33 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 755DEA99; Wed, 12 Oct 2016 07:08:33 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9C78WYw055833; Wed, 12 Oct 2016 07:08:32 GMT (envelope-from avg@FreeBSD.org) Received: (from avg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9C78WCw055832; Wed, 12 Oct 2016 07:08:32 GMT (envelope-from avg@FreeBSD.org) Message-Id: <201610120708.u9C78WCw055832@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avg set sender to avg@FreeBSD.org using -f From: Andriy Gapon Date: Wed, 12 Oct 2016 07:08:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307131 - head/include X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Oct 2016 07:08:33 -0000 Author: avg Date: Wed Oct 12 07:08:32 2016 New Revision: 307131 URL: https://svnweb.freebsd.org/changeset/base/307131 Log: install header files required development with libzfs_core libzfs_core provides a rather limited but committed (stable) interface for working with ZFS. We install libzfs_core shared library but we do not install header files required for developing programs that use the library. This change is to install the required header files libzfs_core.h, libnvpair.h and sys/nvpair.h. The headers are installed into the same locations as on illumos. Reviewed by: mav, markj Differential Revision: https://reviews.freebsd.org/D8005 Modified: head/include/Makefile Modified: head/include/Makefile ============================================================================== --- head/include/Makefile Wed Oct 12 06:58:01 2016 (r307130) +++ head/include/Makefile Wed Oct 12 07:08:32 2016 (r307131) @@ -237,6 +237,17 @@ copies: .PHONY .META cd ${.CURDIR}/../sys/teken; \ ${INSTALL} -C ${TAG_ARGS} -o ${BINOWN} -g ${BINGRP} -m 444 teken.h \ ${DESTDIR}${INCLUDEDIR}/teken +.if ${MK_CDDL} != "no" + cd ${.CURDIR}/../cddl/contrib/opensolaris/lib/libzfs_core/common; \ + ${INSTALL} -C ${TAG_ARGS} -o ${BINOWN} -g ${BINGRP} -m 444 libzfs_core.h \ + ${DESTDIR}${INCLUDEDIR} + cd ${.CURDIR}/../cddl/contrib/opensolaris/lib/libnvpair; \ + ${INSTALL} -C ${TAG_ARGS} -o ${BINOWN} -g ${BINGRP} -m 444 libnvpair.h \ + ${DESTDIR}${INCLUDEDIR} + cd ${.CURDIR}/../sys/cddl/contrib/opensolaris/uts/common/sys; \ + ${INSTALL} -C ${TAG_ARGS} -o ${BINOWN} -g ${BINGRP} -m 444 nvpair.h \ + ${DESTDIR}${INCLUDEDIR}/sys +.endif symlinks: .PHONY .META @${ECHO} "Setting up symlinks to kernel source tree..." From owner-svn-src-all@freebsd.org Wed Oct 12 08:25:14 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 6D5C0C0D778; Wed, 12 Oct 2016 08:25:14 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 3BA19199; Wed, 12 Oct 2016 08:25:14 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9C8PDAa085316; Wed, 12 Oct 2016 08:25:13 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9C8PD1U085315; Wed, 12 Oct 2016 08:25:13 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201610120825.u9C8PD1U085315@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Wed, 12 Oct 2016 08:25:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307132 - head/sys/cam/scsi X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Oct 2016 08:25:14 -0000 Author: mav Date: Wed Oct 12 08:25:13 2016 New Revision: 307132 URL: https://svnweb.freebsd.org/changeset/base/307132 Log: Use copyout() instead of pointing sbuf to user-space buffer. MFC after: 2 weeks Modified: head/sys/cam/scsi/scsi_enc_ses.c Modified: head/sys/cam/scsi/scsi_enc_ses.c ============================================================================== --- head/sys/cam/scsi/scsi_enc_ses.c Wed Oct 12 07:08:32 2016 (r307131) +++ head/sys/cam/scsi/scsi_enc_ses.c Wed Oct 12 08:25:13 2016 (r307132) @@ -2672,13 +2672,13 @@ ses_get_elm_devnames(enc_softc_t *enc, e if (len < 0) return (EINVAL); - sbuf_new(&sb, elmdn->elm_devnames, len, 0); - cam_periph_unlock(enc->periph); + sbuf_new(&sb, NULL, len, SBUF_FIXEDLEN); ses_paths_iter(enc, &enc->enc_cache.elm_map[elmdn->elm_idx], ses_elmdevname_callback, &sb); sbuf_finish(&sb); elmdn->elm_names_len = sbuf_len(&sb); + copyout(sbuf_data(&sb), elmdn->elm_devnames, elmdn->elm_names_len + 1); cam_periph_lock(enc->periph); return (elmdn->elm_names_len > 0 ? 0 : ENODEV); } From owner-svn-src-all@freebsd.org Wed Oct 12 08:58:06 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C4368C0E498; Wed, 12 Oct 2016 08:58:06 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 87CB5F66; Wed, 12 Oct 2016 08:58:06 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9C8w5p7096724; Wed, 12 Oct 2016 08:58:05 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9C8w491096708; Wed, 12 Oct 2016 08:58:04 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610120858.u9C8w491096708@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Wed, 12 Oct 2016 08:58:04 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307133 - in stable/10/sys/dev/hyperv: include netvsc storvsc utilities vmbus X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Oct 2016 08:58:06 -0000 Author: sephe Date: Wed Oct 12 08:58:03 2016 New Revision: 307133 URL: https://svnweb.freebsd.org/changeset/base/307133 Log: MFC 303421,303422,303470-303473 303421 hyperv/vmbus: Avoid unnecessary mb() Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7333 303422 hyperv/vmbus: Inclusion cleanup Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7334 303470 hyperv/vmbus: Reindent function declarations. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7344 303471 hyperv/vmbus: Forward declare static functions Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7346 303472 hyperv/vmbus: Move driver glue to the beginning of the files Just as most of other drivers do. And move sysinit function close to its SYSINIT. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7347 303473 hyperv/vmbus: Revoke unnecessary exposure of vmbus softc Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7348 Modified: stable/10/sys/dev/hyperv/include/hyperv.h stable/10/sys/dev/hyperv/include/hyperv_busdma.h stable/10/sys/dev/hyperv/include/vmbus.h stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c stable/10/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c stable/10/sys/dev/hyperv/utilities/hv_heartbeat.c stable/10/sys/dev/hyperv/utilities/hv_shutdown.c stable/10/sys/dev/hyperv/utilities/hv_timesync.c stable/10/sys/dev/hyperv/vmbus/hyperv.c stable/10/sys/dev/hyperv/vmbus/vmbus.c stable/10/sys/dev/hyperv/vmbus/vmbus_br.c stable/10/sys/dev/hyperv/vmbus/vmbus_chan.c stable/10/sys/dev/hyperv/vmbus/vmbus_chanvar.h stable/10/sys/dev/hyperv/vmbus/vmbus_et.c stable/10/sys/dev/hyperv/vmbus/vmbus_var.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/hyperv/include/hyperv.h ============================================================================== --- stable/10/sys/dev/hyperv/include/hyperv.h Wed Oct 12 08:25:13 2016 (r307132) +++ stable/10/sys/dev/hyperv/include/hyperv.h Wed Oct 12 08:58:03 2016 (r307133) @@ -28,43 +28,21 @@ * $FreeBSD$ */ -/** - * HyperV definitions for messages that are sent between instances of the - * Channel Management Library in separate partitions, or in some cases, - * back to itself. - */ - -#ifndef __HYPERV_H__ -#define __HYPERV_H__ +#ifndef _HYPERV_H_ +#define _HYPERV_H_ #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include + #include -#include #include -#include -#include -#include - struct hyperv_guid { uint8_t hv_guid[16]; } __packed; #define HYPERV_GUID_STRLEN 40 -int hyperv_guid2str(const struct hyperv_guid *, char *, size_t); +int hyperv_guid2str(const struct hyperv_guid *, char *, size_t); /** * @brief Get physical address from virtual @@ -77,4 +55,4 @@ hv_get_phys_addr(void *virt) return (ret); } -#endif /* __HYPERV_H__ */ +#endif /* _HYPERV_H_ */ Modified: stable/10/sys/dev/hyperv/include/hyperv_busdma.h ============================================================================== --- stable/10/sys/dev/hyperv/include/hyperv_busdma.h Wed Oct 12 08:25:13 2016 (r307132) +++ stable/10/sys/dev/hyperv/include/hyperv_busdma.h Wed Oct 12 08:58:03 2016 (r307133) @@ -39,11 +39,11 @@ struct hyperv_dma { bus_dmamap_t hv_dmap; }; -void hyperv_dma_map_paddr(void *arg, bus_dma_segment_t *segs, int nseg, - int error); -void *hyperv_dmamem_alloc(bus_dma_tag_t parent_dtag, bus_size_t alignment, - bus_addr_t boundary, bus_size_t size, struct hyperv_dma *dma, - int flags); -void hyperv_dmamem_free(struct hyperv_dma *dma, void *ptr); +void hyperv_dma_map_paddr(void *arg, bus_dma_segment_t *segs, + int nseg, int error); +void *hyperv_dmamem_alloc(bus_dma_tag_t parent_dtag, + bus_size_t alignment, bus_addr_t boundary, bus_size_t size, + struct hyperv_dma *dma, int flags); +void hyperv_dmamem_free(struct hyperv_dma *dma, void *ptr); #endif /* !_HYPERV_BUSDMA_H_ */ Modified: stable/10/sys/dev/hyperv/include/vmbus.h ============================================================================== --- stable/10/sys/dev/hyperv/include/vmbus.h Wed Oct 12 08:25:13 2016 (r307132) +++ stable/10/sys/dev/hyperv/include/vmbus.h Wed Oct 12 08:58:03 2016 (r307133) @@ -30,6 +30,8 @@ #define _VMBUS_H_ #include +#include +#include /* * VMBUS version is 32 bit, upper 16 bit for major_number and lower @@ -115,45 +117,47 @@ vmbus_get_channel(device_t dev) return device_get_ivars(dev); } -int vmbus_chan_open(struct vmbus_channel *chan, - int txbr_size, int rxbr_size, const void *udata, int udlen, - vmbus_chan_callback_t cb, void *cbarg); -void vmbus_chan_close(struct vmbus_channel *chan); - -int vmbus_chan_gpadl_connect(struct vmbus_channel *chan, - bus_addr_t paddr, int size, uint32_t *gpadl); -int vmbus_chan_gpadl_disconnect(struct vmbus_channel *chan, - uint32_t gpadl); +int vmbus_chan_open(struct vmbus_channel *chan, + int txbr_size, int rxbr_size, const void *udata, int udlen, + vmbus_chan_callback_t cb, void *cbarg); +void vmbus_chan_close(struct vmbus_channel *chan); + +int vmbus_chan_gpadl_connect(struct vmbus_channel *chan, + bus_addr_t paddr, int size, uint32_t *gpadl); +int vmbus_chan_gpadl_disconnect(struct vmbus_channel *chan, + uint32_t gpadl); -void vmbus_chan_cpu_set(struct vmbus_channel *chan, int cpu); -void vmbus_chan_cpu_rr(struct vmbus_channel *chan); +void vmbus_chan_cpu_set(struct vmbus_channel *chan, int cpu); +void vmbus_chan_cpu_rr(struct vmbus_channel *chan); struct vmbus_channel * - vmbus_chan_cpu2chan(struct vmbus_channel *chan, int cpu); -void vmbus_chan_set_readbatch(struct vmbus_channel *chan, bool on); + vmbus_chan_cpu2chan(struct vmbus_channel *chan, int cpu); +void vmbus_chan_set_readbatch(struct vmbus_channel *chan, bool on); struct vmbus_channel ** - vmbus_subchan_get(struct vmbus_channel *pri_chan, int subchan_cnt); -void vmbus_subchan_rel(struct vmbus_channel **subchan, int subchan_cnt); -void vmbus_subchan_drain(struct vmbus_channel *pri_chan); - -int vmbus_chan_recv(struct vmbus_channel *chan, void *data, int *dlen, - uint64_t *xactid); -int vmbus_chan_recv_pkt(struct vmbus_channel *chan, - struct vmbus_chanpkt_hdr *pkt, int *pktlen); - -int vmbus_chan_send(struct vmbus_channel *chan, uint16_t type, - uint16_t flags, void *data, int dlen, uint64_t xactid); -int vmbus_chan_send_sglist(struct vmbus_channel *chan, - struct vmbus_gpa sg[], int sglen, void *data, int dlen, - uint64_t xactid); -int vmbus_chan_send_prplist(struct vmbus_channel *chan, - struct vmbus_gpa_range *prp, int prp_cnt, void *data, int dlen, - uint64_t xactid); - -uint32_t vmbus_chan_id(const struct vmbus_channel *chan); -uint32_t vmbus_chan_subidx(const struct vmbus_channel *chan); -bool vmbus_chan_is_primary(const struct vmbus_channel *chan); + vmbus_subchan_get(struct vmbus_channel *pri_chan, + int subchan_cnt); +void vmbus_subchan_rel(struct vmbus_channel **subchan, + int subchan_cnt); +void vmbus_subchan_drain(struct vmbus_channel *pri_chan); + +int vmbus_chan_recv(struct vmbus_channel *chan, void *data, int *dlen, + uint64_t *xactid); +int vmbus_chan_recv_pkt(struct vmbus_channel *chan, + struct vmbus_chanpkt_hdr *pkt, int *pktlen); + +int vmbus_chan_send(struct vmbus_channel *chan, uint16_t type, + uint16_t flags, void *data, int dlen, uint64_t xactid); +int vmbus_chan_send_sglist(struct vmbus_channel *chan, + struct vmbus_gpa sg[], int sglen, void *data, int dlen, + uint64_t xactid); +int vmbus_chan_send_prplist(struct vmbus_channel *chan, + struct vmbus_gpa_range *prp, int prp_cnt, void *data, + int dlen, uint64_t xactid); + +uint32_t vmbus_chan_id(const struct vmbus_channel *chan); +uint32_t vmbus_chan_subidx(const struct vmbus_channel *chan); +bool vmbus_chan_is_primary(const struct vmbus_channel *chan); const struct hyperv_guid * - vmbus_chan_guid_inst(const struct vmbus_channel *chan); + vmbus_chan_guid_inst(const struct vmbus_channel *chan); #endif /* !_VMBUS_H_ */ Modified: stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h Wed Oct 12 08:25:13 2016 (r307132) +++ stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h Wed Oct 12 08:58:03 2016 (r307133) @@ -44,6 +44,7 @@ #include #include #include +#include #include #include Modified: stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Wed Oct 12 08:25:13 2016 (r307132) +++ stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Wed Oct 12 08:58:03 2016 (r307133) @@ -70,6 +70,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include Modified: stable/10/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c ============================================================================== --- stable/10/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c Wed Oct 12 08:25:13 2016 (r307132) +++ stable/10/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c Wed Oct 12 08:58:03 2016 (r307133) @@ -52,6 +52,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include Modified: stable/10/sys/dev/hyperv/utilities/hv_heartbeat.c ============================================================================== --- stable/10/sys/dev/hyperv/utilities/hv_heartbeat.c Wed Oct 12 08:25:13 2016 (r307132) +++ stable/10/sys/dev/hyperv/utilities/hv_heartbeat.c Wed Oct 12 08:58:03 2016 (r307133) @@ -33,6 +33,7 @@ #include #include #include +#include #include #include Modified: stable/10/sys/dev/hyperv/utilities/hv_shutdown.c ============================================================================== --- stable/10/sys/dev/hyperv/utilities/hv_shutdown.c Wed Oct 12 08:25:13 2016 (r307132) +++ stable/10/sys/dev/hyperv/utilities/hv_shutdown.c Wed Oct 12 08:58:03 2016 (r307133) @@ -38,6 +38,7 @@ #include #include #include +#include #include #include Modified: stable/10/sys/dev/hyperv/utilities/hv_timesync.c ============================================================================== --- stable/10/sys/dev/hyperv/utilities/hv_timesync.c Wed Oct 12 08:25:13 2016 (r307132) +++ stable/10/sys/dev/hyperv/utilities/hv_timesync.c Wed Oct 12 08:58:03 2016 (r307133) @@ -38,6 +38,8 @@ #include #include #include +#include +#include #include #include Modified: stable/10/sys/dev/hyperv/vmbus/hyperv.c ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/hyperv.c Wed Oct 12 08:25:13 2016 (r307132) +++ stable/10/sys/dev/hyperv/vmbus/hyperv.c Wed Oct 12 08:58:03 2016 (r307133) @@ -34,23 +34,14 @@ __FBSDID("$FreeBSD$"); #include #include -#include -#include +#include #include -#include -#include -#include -#include -#include #include #include #include #include #include -#if 0 -#include -#endif #define HYPERV_FREEBSD_BUILD 0ULL #define HYPERV_FREEBSD_VERSION ((uint64_t)__FreeBSD_version) @@ -76,13 +67,15 @@ struct hypercall_ctx { struct hyperv_dma hc_dma; }; -static u_int hyperv_get_timecount(struct timecounter *tc); +static u_int hyperv_get_timecount(struct timecounter *); +static bool hyperv_identify(void); +static void hypercall_memfree(void); -u_int hyperv_features; -u_int hyperv_recommends; +u_int hyperv_features; +u_int hyperv_recommends; -static u_int hyperv_pm_features; -static u_int hyperv_features3; +static u_int hyperv_pm_features; +static u_int hyperv_features3; static struct timecounter hyperv_timecounter = { .tc_get_timecount = hyperv_get_timecount, Modified: stable/10/sys/dev/hyperv/vmbus/vmbus.c ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/vmbus.c Wed Oct 12 08:25:13 2016 (r307132) +++ stable/10/sys/dev/hyperv/vmbus/vmbus.c Wed Oct 12 08:58:03 2016 (r307133) @@ -38,26 +38,18 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include +#include #include -#include #include -#include -#include -#include #include -#include -#include -#include -#include - -#include #include -#include -#include -#include #include +#include + +#include #include #include @@ -66,7 +58,6 @@ __FBSDID("$FreeBSD$"); #include #include -#include #include "acpi_if.h" #include "vmbus_if.h" @@ -92,6 +83,17 @@ struct vmbus_msghc_ctx { #define VMBUS_MSGHC_CTXF_DESTROY 0x0001 +static int vmbus_probe(device_t); +static int vmbus_attach(device_t); +static int vmbus_detach(device_t); +static int vmbus_read_ivar(device_t, device_t, int, + uintptr_t *); +static int vmbus_child_pnpinfo_str(device_t, device_t, + char *, size_t); +static uint32_t vmbus_get_version_method(device_t, device_t); +static int vmbus_probe_guid_method(device_t, device_t, + const struct hyperv_guid *); + static int vmbus_init(struct vmbus_softc *); static int vmbus_connect(struct vmbus_softc *, uint32_t); static int vmbus_req_channels(struct vmbus_softc *sc); @@ -104,8 +106,17 @@ static void vmbus_scan_done(struct vmb const struct vmbus_message *); static void vmbus_chanmsg_handle(struct vmbus_softc *, const struct vmbus_message *); - +static void vmbus_msg_task(void *, int); +static void vmbus_synic_setup(void *); +static void vmbus_synic_teardown(void *); static int vmbus_sysctl_version(SYSCTL_HANDLER_ARGS); +static int vmbus_dma_alloc(struct vmbus_softc *); +static void vmbus_dma_free(struct vmbus_softc *); +static int vmbus_intr_setup(struct vmbus_softc *); +static void vmbus_intr_teardown(struct vmbus_softc *); +static int vmbus_doattach(struct vmbus_softc *); +static void vmbus_event_proc_dummy(struct vmbus_softc *, + int); static struct vmbus_msghc_ctx *vmbus_msghc_ctx_create(bus_dma_tag_t); static void vmbus_msghc_ctx_destroy( @@ -116,7 +127,7 @@ static void vmbus_msghc_free(struct vm static struct vmbus_msghc *vmbus_msghc_get1(struct vmbus_msghc_ctx *, uint32_t); -struct vmbus_softc *vmbus_sc; +static struct vmbus_softc *vmbus_sc; extern inthand_t IDTVEC(rsvd), IDTVEC(vmbus_isr); @@ -133,6 +144,46 @@ vmbus_chanmsg_handlers[VMBUS_CHANMSG_TYP VMBUS_CHANMSG_PROC_WAKEUP(CONNECT_RESP) }; +static device_method_t vmbus_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, vmbus_probe), + DEVMETHOD(device_attach, vmbus_attach), + DEVMETHOD(device_detach, vmbus_detach), + DEVMETHOD(device_shutdown, bus_generic_shutdown), + DEVMETHOD(device_suspend, bus_generic_suspend), + DEVMETHOD(device_resume, bus_generic_resume), + + /* Bus interface */ + DEVMETHOD(bus_add_child, bus_generic_add_child), + DEVMETHOD(bus_print_child, bus_generic_print_child), + DEVMETHOD(bus_read_ivar, vmbus_read_ivar), + DEVMETHOD(bus_child_pnpinfo_str, vmbus_child_pnpinfo_str), + + /* Vmbus interface */ + DEVMETHOD(vmbus_get_version, vmbus_get_version_method), + DEVMETHOD(vmbus_probe_guid, vmbus_probe_guid_method), + + DEVMETHOD_END +}; + +static driver_t vmbus_driver = { + "vmbus", + vmbus_methods, + sizeof(struct vmbus_softc) +}; + +static devclass_t vmbus_devclass; + +DRIVER_MODULE(vmbus, acpi, vmbus_driver, vmbus_devclass, NULL, NULL); +MODULE_DEPEND(vmbus, acpi, 1, 1, 1); +MODULE_VERSION(vmbus, 1); + +static __inline struct vmbus_softc * +vmbus_get_softc(void) +{ + return vmbus_sc; +} + static struct vmbus_msghc * vmbus_msghc_alloc(bus_dma_tag_t parent_dtag) { @@ -1316,24 +1367,6 @@ vmbus_attach(device_t dev) return (0); } -static void -vmbus_sysinit(void *arg __unused) -{ - struct vmbus_softc *sc = vmbus_get_softc(); - - if (vm_guest != VM_GUEST_HV || sc == NULL) - return; - - /* - * If the system has already booted and thread - * scheduling is possible, as indicated by the - * global cold set to zero, we just call the driver - * initialization directly. - */ - if (!cold) - vmbus_doattach(sc); -} - static int vmbus_detach(device_t dev) { @@ -1363,44 +1396,26 @@ vmbus_detach(device_t dev) return (0); } -static device_method_t vmbus_methods[] = { - /* Device interface */ - DEVMETHOD(device_probe, vmbus_probe), - DEVMETHOD(device_attach, vmbus_attach), - DEVMETHOD(device_detach, vmbus_detach), - DEVMETHOD(device_shutdown, bus_generic_shutdown), - DEVMETHOD(device_suspend, bus_generic_suspend), - DEVMETHOD(device_resume, bus_generic_resume), - - /* Bus interface */ - DEVMETHOD(bus_add_child, bus_generic_add_child), - DEVMETHOD(bus_print_child, bus_generic_print_child), - DEVMETHOD(bus_read_ivar, vmbus_read_ivar), - DEVMETHOD(bus_child_pnpinfo_str, vmbus_child_pnpinfo_str), - - /* Vmbus interface */ - DEVMETHOD(vmbus_get_version, vmbus_get_version_method), - DEVMETHOD(vmbus_probe_guid, vmbus_probe_guid_method), - - DEVMETHOD_END -}; - -static driver_t vmbus_driver = { - "vmbus", - vmbus_methods, - sizeof(struct vmbus_softc) -}; - -static devclass_t vmbus_devclass; +static void +vmbus_sysinit(void *arg __unused) +{ + struct vmbus_softc *sc = vmbus_get_softc(); -DRIVER_MODULE(vmbus, acpi, vmbus_driver, vmbus_devclass, NULL, NULL); -MODULE_DEPEND(vmbus, acpi, 1, 1, 1); -MODULE_VERSION(vmbus, 1); + if (vm_guest != VM_GUEST_HV || sc == NULL) + return; + /* + * If the system has already booted and thread + * scheduling is possible, as indicated by the + * global cold set to zero, we just call the driver + * initialization directly. + */ + if (!cold) + vmbus_doattach(sc); +} /* * NOTE: * We have to start as the last step of SI_SUB_SMP, i.e. after SMP is * initialized. */ SYSINIT(vmbus_initialize, SI_SUB_SMP, SI_ORDER_ANY, vmbus_sysinit, NULL); - Modified: stable/10/sys/dev/hyperv/vmbus/vmbus_br.c ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/vmbus_br.c Wed Oct 12 08:25:13 2016 (r307132) +++ stable/10/sys/dev/hyperv/vmbus/vmbus_br.c Wed Oct 12 08:58:03 2016 (r307133) @@ -44,6 +44,10 @@ __FBSDID("$FreeBSD$"); /* Increase bufing index */ #define VMBUS_BR_IDXINC(idx, inc, sz) (((idx) + (inc)) % (sz)) +static int vmbus_br_sysctl_state(SYSCTL_HANDLER_ARGS); +static int vmbus_br_sysctl_state_bin(SYSCTL_HANDLER_ARGS); +static void vmbus_br_setup(struct vmbus_br *, void *, int); + static int vmbus_br_sysctl_state(SYSCTL_HANDLER_ARGS) { @@ -212,9 +216,7 @@ vmbus_txbr_need_signal(const struct vmbu if (tbr->txbr_imask) return (FALSE); - /* XXX only compiler fence is needed */ - /* Read memory barrier */ - rmb(); + __compiler_membar(); /* * This is the only case we need to signal when the @@ -311,15 +313,10 @@ vmbus_txbr_write(struct vmbus_txbr *tbr, sizeof(save_windex)); /* - * XXX only compiler fence is needed. - * Full memory barrier before upding the write index. - */ - mb(); - - /* * Update the write index _after_ the channel packet * is copied. */ + __compiler_membar(); tbr->txbr_windex = windex; mtx_unlock_spin(&tbr->txbr_lock); @@ -399,16 +396,9 @@ vmbus_rxbr_read(struct vmbus_rxbr *rbr, rindex = VMBUS_BR_IDXINC(rindex, sizeof(uint64_t), br_dsize); /* - * XXX only compiler fence is needed. - * Make sure all reads are done before we update the read index since - * the writer may start writing to the read area once the read index - * is updated. - */ - wmb(); - - /* * Update the read index _after_ the channel packet is fetched. */ + __compiler_membar(); rbr->rxbr_rindex = rindex; mtx_unlock_spin(&rbr->rxbr_lock); Modified: stable/10/sys/dev/hyperv/vmbus/vmbus_chan.c ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/vmbus_chan.c Wed Oct 12 08:25:13 2016 (r307132) +++ stable/10/sys/dev/hyperv/vmbus/vmbus_chan.c Wed Oct 12 08:58:03 2016 (r307133) @@ -31,19 +31,14 @@ __FBSDID("$FreeBSD$"); #include #include -#include -#include -#include #include +#include #include +#include #include +#include #include -#include - -#include -#include -#include #include #include @@ -52,17 +47,28 @@ __FBSDID("$FreeBSD$"); #include #include -static void vmbus_chan_update_evtflagcnt(struct vmbus_softc *, - const struct vmbus_channel *); - -static void vmbus_chan_task(void *, int); -static void vmbus_chan_task_nobatch(void *, int); -static void vmbus_chan_detach_task(void *, int); - -static void vmbus_chan_msgproc_choffer(struct vmbus_softc *, - const struct vmbus_message *); -static void vmbus_chan_msgproc_chrescind(struct vmbus_softc *, - const struct vmbus_message *); +static void vmbus_chan_update_evtflagcnt( + struct vmbus_softc *, + const struct vmbus_channel *); +static void vmbus_chan_close_internal( + struct vmbus_channel *); +static int vmbus_chan_sysctl_mnf(SYSCTL_HANDLER_ARGS); +static void vmbus_chan_sysctl_create( + struct vmbus_channel *); +static struct vmbus_channel *vmbus_chan_alloc(struct vmbus_softc *); +static void vmbus_chan_free(struct vmbus_channel *); +static int vmbus_chan_add(struct vmbus_channel *); +static void vmbus_chan_cpu_default(struct vmbus_channel *); + +static void vmbus_chan_task(void *, int); +static void vmbus_chan_task_nobatch(void *, int); +static void vmbus_chan_detach_task(void *, int); + +static void vmbus_chan_msgproc_choffer(struct vmbus_softc *, + const struct vmbus_message *); +static void vmbus_chan_msgproc_chrescind( + struct vmbus_softc *, + const struct vmbus_message *); /* * Vmbus channel message processing. Modified: stable/10/sys/dev/hyperv/vmbus/vmbus_chanvar.h ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/vmbus_chanvar.h Wed Oct 12 08:25:13 2016 (r307132) +++ stable/10/sys/dev/hyperv/vmbus/vmbus_chanvar.h Wed Oct 12 08:58:03 2016 (r307133) @@ -155,9 +155,10 @@ struct vmbus_channel { struct vmbus_softc; struct vmbus_message; -void vmbus_event_proc(struct vmbus_softc *, int); -void vmbus_event_proc_compat(struct vmbus_softc *, int); -void vmbus_chan_msgproc(struct vmbus_softc *, const struct vmbus_message *); -void vmbus_chan_destroy_all(struct vmbus_softc *); +void vmbus_event_proc(struct vmbus_softc *, int); +void vmbus_event_proc_compat(struct vmbus_softc *, int); +void vmbus_chan_msgproc(struct vmbus_softc *, + const struct vmbus_message *); +void vmbus_chan_destroy_all(struct vmbus_softc *); #endif /* !_VMBUS_CHANVAR_H_ */ Modified: stable/10/sys/dev/hyperv/vmbus/vmbus_et.c ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/vmbus_et.c Wed Oct 12 08:25:13 2016 (r307132) +++ stable/10/sys/dev/hyperv/vmbus/vmbus_et.c Wed Oct 12 08:58:03 2016 (r307133) @@ -32,9 +32,8 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #include -#include +#include #include #include @@ -59,8 +58,35 @@ __FBSDID("$FreeBSD$"); CPUID_HV_MSR_SYNIC | \ CPUID_HV_MSR_SYNTIMER) +static void vmbus_et_identify(driver_t *, device_t); +static int vmbus_et_probe(device_t); +static int vmbus_et_attach(device_t); +static int vmbus_et_detach(device_t); +static int vmbus_et_start(struct eventtimer *, sbintime_t, + sbintime_t); + static struct eventtimer vmbus_et; +static device_method_t vmbus_et_methods[] = { + DEVMETHOD(device_identify, vmbus_et_identify), + DEVMETHOD(device_probe, vmbus_et_probe), + DEVMETHOD(device_attach, vmbus_et_attach), + DEVMETHOD(device_detach, vmbus_et_detach), + + DEVMETHOD_END +}; + +static driver_t vmbus_et_driver = { + VMBUS_ET_NAME, + vmbus_et_methods, + 0 +}; + +static devclass_t vmbus_et_devclass; + +DRIVER_MODULE(hv_et, vmbus, vmbus_et_driver, vmbus_et_devclass, NULL, NULL); +MODULE_VERSION(hv_et, 1); + static __inline uint64_t hyperv_sbintime2count(sbintime_t time) { @@ -177,22 +203,3 @@ vmbus_et_detach(device_t dev) { return (et_deregister(&vmbus_et)); } - -static device_method_t vmbus_et_methods[] = { - DEVMETHOD(device_identify, vmbus_et_identify), - DEVMETHOD(device_probe, vmbus_et_probe), - DEVMETHOD(device_attach, vmbus_et_attach), - DEVMETHOD(device_detach, vmbus_et_detach), - - DEVMETHOD_END -}; - -static driver_t vmbus_et_driver = { - VMBUS_ET_NAME, - vmbus_et_methods, - 0 -}; - -static devclass_t vmbus_et_devclass; -DRIVER_MODULE(hv_et, vmbus, vmbus_et_driver, vmbus_et_devclass, NULL, NULL); -MODULE_VERSION(hv_et, 1); Modified: stable/10/sys/dev/hyperv/vmbus/vmbus_var.h ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/vmbus_var.h Wed Oct 12 08:25:13 2016 (r307132) +++ stable/10/sys/dev/hyperv/vmbus/vmbus_var.h Wed Oct 12 08:58:03 2016 (r307133) @@ -120,20 +120,6 @@ struct vmbus_softc { #define VMBUS_FLAG_ATTACHED 0x0001 /* vmbus was attached */ #define VMBUS_FLAG_SYNIC 0x0002 /* SynIC was setup */ -extern struct vmbus_softc *vmbus_sc; - -static __inline struct vmbus_softc * -vmbus_get_softc(void) -{ - return vmbus_sc; -} - -static __inline device_t -vmbus_get_device(void) -{ - return vmbus_sc->vmbus_dev; -} - #define VMBUS_PCPU_GET(sc, field, cpu) (sc)->vmbus_pcpu[(cpu)].field #define VMBUS_PCPU_PTR(sc, field, cpu) &(sc)->vmbus_pcpu[(cpu)].field @@ -142,20 +128,23 @@ struct trapframe; struct vmbus_message; struct vmbus_msghc; -void vmbus_handle_intr(struct trapframe *); -int vmbus_add_child(struct vmbus_channel *); -int vmbus_delete_child(struct vmbus_channel *); -void vmbus_et_intr(struct trapframe *); -uint32_t vmbus_gpadl_alloc(struct vmbus_softc *); - -struct vmbus_msghc *vmbus_msghc_get(struct vmbus_softc *, size_t); -void vmbus_msghc_put(struct vmbus_softc *, struct vmbus_msghc *); -void *vmbus_msghc_dataptr(struct vmbus_msghc *); -int vmbus_msghc_exec_noresult(struct vmbus_msghc *); -int vmbus_msghc_exec(struct vmbus_softc *, struct vmbus_msghc *); -const struct vmbus_message *vmbus_msghc_wait_result(struct vmbus_softc *, - struct vmbus_msghc *); -void vmbus_msghc_wakeup(struct vmbus_softc *, const struct vmbus_message *); -void vmbus_msghc_reset(struct vmbus_msghc *, size_t); +void vmbus_handle_intr(struct trapframe *); +int vmbus_add_child(struct vmbus_channel *); +int vmbus_delete_child(struct vmbus_channel *); +void vmbus_et_intr(struct trapframe *); +uint32_t vmbus_gpadl_alloc(struct vmbus_softc *); + +struct vmbus_msghc * + vmbus_msghc_get(struct vmbus_softc *, size_t); +void vmbus_msghc_put(struct vmbus_softc *, struct vmbus_msghc *); +void *vmbus_msghc_dataptr(struct vmbus_msghc *); +int vmbus_msghc_exec_noresult(struct vmbus_msghc *); +int vmbus_msghc_exec(struct vmbus_softc *, struct vmbus_msghc *); +const struct vmbus_message * + vmbus_msghc_wait_result(struct vmbus_softc *, + struct vmbus_msghc *); +void vmbus_msghc_wakeup(struct vmbus_softc *, + const struct vmbus_message *); +void vmbus_msghc_reset(struct vmbus_msghc *, size_t); #endif /* !_VMBUS_VAR_H_ */ From owner-svn-src-all@freebsd.org Wed Oct 12 09:13:17 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 73285C0EA2E; Wed, 12 Oct 2016 09:13:17 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 425FED9C; Wed, 12 Oct 2016 09:13:17 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9C9DGeN004707; Wed, 12 Oct 2016 09:13:16 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9C9DG2l004706; Wed, 12 Oct 2016 09:13:16 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610120913.u9C9DG2l004706@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Wed, 12 Oct 2016 09:13:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307134 - stable/10/sys/dev/hyperv/storvsc X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Oct 2016 09:13:17 -0000 Author: sephe Date: Wed Oct 12 09:13:16 2016 New Revision: 307134 URL: https://svnweb.freebsd.org/changeset/base/307134 Log: MFC 303474 hyperv/storvsc: Use busdma(9) and enable PIM_UNMAPPED by default. The UNMAPPED I/O greatly improves userland direct disk I/O performance by 35% ~ 135%. Submitted by: Hongjiang Zhang Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7195 Modified: stable/10/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c ============================================================================== --- stable/10/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c Wed Oct 12 08:58:03 2016 (r307133) +++ stable/10/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c Wed Oct 12 09:13:16 2016 (r307134) @@ -40,6 +40,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -87,7 +88,10 @@ __FBSDID("$FreeBSD$"); #define VSTOR_PKT_SIZE (sizeof(struct vstor_packet) - vmscsi_size_delta) -#define HV_ALIGN(x, a) roundup2(x, a) +#define STORVSC_DATA_SEGCNT_MAX VMBUS_CHAN_PRPLIST_MAX +#define STORVSC_DATA_SEGSZ_MAX PAGE_SIZE +#define STORVSC_DATA_SIZE_MAX \ + (STORVSC_DATA_SEGCNT_MAX * STORVSC_DATA_SEGSZ_MAX) struct storvsc_softc; @@ -102,7 +106,7 @@ struct hv_sgl_page_pool{ boolean_t is_init; } g_hv_sgl_page_pool; -#define STORVSC_MAX_SG_PAGE_CNT STORVSC_MAX_IO_REQUESTS * VMBUS_CHAN_PRPLIST_MAX +#define STORVSC_MAX_SG_PAGE_CNT STORVSC_MAX_IO_REQUESTS * STORVSC_DATA_SEGCNT_MAX enum storvsc_request_type { WRITE_TYPE, @@ -110,26 +114,41 @@ enum storvsc_request_type { UNKNOWN_TYPE }; -struct hvs_gpa_range { +SYSCTL_NODE(_hw, OID_AUTO, storvsc, CTLFLAG_RD | CTLFLAG_MPSAFE, NULL, + "Hyper-V storage interface"); + +static u_int hv_storvsc_use_pim_unmapped = 1; +SYSCTL_INT(_hw_storvsc, OID_AUTO, use_pim_unmapped, CTLFLAG_RDTUN, + &hv_storvsc_use_pim_unmapped, 0, + "Optimize storvsc by using unmapped I/O"); + +struct hv_storvsc_sysctl { + u_long data_bio_cnt; + u_long data_vaddr_cnt; + u_long data_sg_cnt; +}; + +struct storvsc_gpa_range { struct vmbus_gpa_range gpa_range; - uint64_t gpa_page[VMBUS_CHAN_PRPLIST_MAX]; + uint64_t gpa_page[STORVSC_DATA_SEGCNT_MAX]; } __packed; struct hv_storvsc_request { - LIST_ENTRY(hv_storvsc_request) link; - struct vstor_packet vstor_packet; - int prp_cnt; - struct hvs_gpa_range prp_list; - void *sense_data; - uint8_t sense_info_len; - uint8_t retries; - union ccb *ccb; - struct storvsc_softc *softc; - struct callout callout; - struct sema synch_sema; /*Synchronize the request/response if needed */ - struct sglist *bounce_sgl; - unsigned int bounce_sgl_count; - uint64_t not_aligned_seg_bits; + LIST_ENTRY(hv_storvsc_request) link; + struct vstor_packet vstor_packet; + int prp_cnt; + struct storvsc_gpa_range prp_list; + void *sense_data; + uint8_t sense_info_len; + uint8_t retries; + union ccb *ccb; + struct storvsc_softc *softc; + struct callout callout; + struct sema synch_sema; /*Synchronize the request/response if needed */ + struct sglist *bounce_sgl; + unsigned int bounce_sgl_count; + uint64_t not_aligned_seg_bits; + bus_dmamap_t data_dmap; }; struct storvsc_softc { @@ -148,6 +167,8 @@ struct storvsc_softc { struct hv_storvsc_request hs_init_req; struct hv_storvsc_request hs_reset_req; device_t hs_dev; + bus_dma_tag_t storvsc_req_dtag; + struct hv_storvsc_sysctl sysctl_data; struct vmbus_channel *hs_cpu2chan[MAXCPU]; }; @@ -884,6 +905,77 @@ storvsc_create_cpu2chan(struct storvsc_s } } +static int +storvsc_init_requests(device_t dev) +{ + struct storvsc_softc *sc = device_get_softc(dev); + struct hv_storvsc_request *reqp; + int error, i; + + LIST_INIT(&sc->hs_free_list); + + error = bus_dma_tag_create( + bus_get_dma_tag(dev), /* parent */ + 1, /* alignment */ + PAGE_SIZE, /* boundary */ + BUS_SPACE_MAXADDR, /* lowaddr */ + BUS_SPACE_MAXADDR, /* highaddr */ + NULL, NULL, /* filter, filterarg */ + STORVSC_DATA_SIZE_MAX, /* maxsize */ + STORVSC_DATA_SEGCNT_MAX, /* nsegments */ + STORVSC_DATA_SEGSZ_MAX, /* maxsegsize */ + 0, /* flags */ + NULL, /* lockfunc */ + NULL, /* lockfuncarg */ + &sc->storvsc_req_dtag); + if (error) { + device_printf(dev, "failed to create storvsc dma tag\n"); + return (error); + } + + for (i = 0; i < sc->hs_drv_props->drv_max_ios_per_target; ++i) { + reqp = malloc(sizeof(struct hv_storvsc_request), + M_DEVBUF, M_WAITOK|M_ZERO); + reqp->softc = sc; + error = bus_dmamap_create(sc->storvsc_req_dtag, 0, + &reqp->data_dmap); + if (error) { + device_printf(dev, "failed to allocate storvsc " + "data dmamap\n"); + goto cleanup; + } + LIST_INSERT_HEAD(&sc->hs_free_list, reqp, link); + } + return (0); + +cleanup: + while ((reqp = LIST_FIRST(&sc->hs_free_list)) != NULL) { + LIST_REMOVE(reqp, link); + bus_dmamap_destroy(sc->storvsc_req_dtag, reqp->data_dmap); + free(reqp, M_DEVBUF); + } + return (error); +} + +static void +storvsc_sysctl(device_t dev) +{ + struct sysctl_oid_list *child; + struct sysctl_ctx_list *ctx; + struct storvsc_softc *sc; + + sc = device_get_softc(dev); + ctx = device_get_sysctl_ctx(dev); + child = SYSCTL_CHILDREN(device_get_sysctl_tree(dev)); + + SYSCTL_ADD_ULONG(ctx, child, OID_AUTO, "data_bio_cnt", CTLFLAG_RW, + &sc->sysctl_data.data_bio_cnt, "# of bio data block"); + SYSCTL_ADD_ULONG(ctx, child, OID_AUTO, "data_vaddr_cnt", CTLFLAG_RW, + &sc->sysctl_data.data_vaddr_cnt, "# of vaddr data block"); + SYSCTL_ADD_ULONG(ctx, child, OID_AUTO, "data_sg_cnt", CTLFLAG_RW, + &sc->sysctl_data.data_sg_cnt, "# of sg data block"); +} + /** * @brief StorVSC attach function * @@ -928,16 +1020,11 @@ storvsc_attach(device_t dev) sc->hs_unit = device_get_unit(dev); sc->hs_dev = dev; - LIST_INIT(&sc->hs_free_list); mtx_init(&sc->hs_lock, "hvslck", NULL, MTX_DEF); - for (i = 0; i < sc->hs_drv_props->drv_max_ios_per_target; ++i) { - reqp = malloc(sizeof(struct hv_storvsc_request), - M_DEVBUF, M_WAITOK|M_ZERO); - reqp->softc = sc; - - LIST_INSERT_HEAD(&sc->hs_free_list, reqp, link); - } + ret = storvsc_init_requests(dev); + if (ret != 0) + goto cleanup; /* create sg-list page pool */ if (FALSE == g_hv_sgl_page_pool.is_init) { @@ -947,7 +1034,7 @@ storvsc_attach(device_t dev) /* * Pre-create SG list, each SG list with - * VMBUS_CHAN_PRPLIST_MAX segments, each + * STORVSC_DATA_SEGCNT_MAX segments, each * segment has one page buffer */ for (i = 0; i < STORVSC_MAX_IO_REQUESTS; i++) { @@ -955,10 +1042,10 @@ storvsc_attach(device_t dev) M_DEVBUF, M_WAITOK|M_ZERO); sgl_node->sgl_data = - sglist_alloc(VMBUS_CHAN_PRPLIST_MAX, + sglist_alloc(STORVSC_DATA_SEGCNT_MAX, M_WAITOK|M_ZERO); - for (j = 0; j < VMBUS_CHAN_PRPLIST_MAX; j++) { + for (j = 0; j < STORVSC_DATA_SEGCNT_MAX; j++) { tmp_buff = malloc(PAGE_SIZE, M_DEVBUF, M_WAITOK|M_ZERO); @@ -1033,6 +1120,8 @@ storvsc_attach(device_t dev) mtx_unlock(&sc->hs_lock); + storvsc_sysctl(dev); + root_mount_rel(root_mount_token); return (0); @@ -1042,13 +1131,14 @@ cleanup: while (!LIST_EMPTY(&sc->hs_free_list)) { reqp = LIST_FIRST(&sc->hs_free_list); LIST_REMOVE(reqp, link); + bus_dmamap_destroy(sc->storvsc_req_dtag, reqp->data_dmap); free(reqp, M_DEVBUF); } while (!LIST_EMPTY(&g_hv_sgl_page_pool.free_sgl_list)) { sgl_node = LIST_FIRST(&g_hv_sgl_page_pool.free_sgl_list); LIST_REMOVE(sgl_node, link); - for (j = 0; j < VMBUS_CHAN_PRPLIST_MAX; j++) { + for (j = 0; j < STORVSC_DATA_SEGCNT_MAX; j++) { if (NULL != (void*)sgl_node->sgl_data->sg_segs[j].ss_paddr) { free((void*)sgl_node->sgl_data->sg_segs[j].ss_paddr, M_DEVBUF); @@ -1103,7 +1193,7 @@ storvsc_detach(device_t dev) while (!LIST_EMPTY(&sc->hs_free_list)) { reqp = LIST_FIRST(&sc->hs_free_list); LIST_REMOVE(reqp, link); - + bus_dmamap_destroy(sc->storvsc_req_dtag, reqp->data_dmap); free(reqp, M_DEVBUF); } mtx_unlock(&sc->hs_lock); @@ -1111,7 +1201,7 @@ storvsc_detach(device_t dev) while (!LIST_EMPTY(&g_hv_sgl_page_pool.free_sgl_list)) { sgl_node = LIST_FIRST(&g_hv_sgl_page_pool.free_sgl_list); LIST_REMOVE(sgl_node, link); - for (j = 0; j < VMBUS_CHAN_PRPLIST_MAX; j++){ + for (j = 0; j < STORVSC_DATA_SEGCNT_MAX; j++){ if (NULL != (void*)sgl_node->sgl_data->sg_segs[j].ss_paddr) { free((void*)sgl_node->sgl_data->sg_segs[j].ss_paddr, M_DEVBUF); @@ -1296,6 +1386,8 @@ storvsc_action(struct cam_sim *sim, unio cpi->hba_inquiry = PI_TAG_ABLE|PI_SDTR_ABLE; cpi->target_sprt = 0; cpi->hba_misc = PIM_NOBUSRESET; + if (hv_storvsc_use_pim_unmapped) + cpi->hba_misc |= PIM_UNMAPPED; cpi->hba_eng_cnt = 0; cpi->max_target = STORVSC_MAX_TARGETS; cpi->max_lun = sc->hs_drv_props->drv_max_luns_per_target; @@ -1370,6 +1462,7 @@ storvsc_action(struct cam_sim *sim, unio case XPT_SCSI_IO: case XPT_IMMED_NOTIFY: { struct hv_storvsc_request *reqp = NULL; + bus_dmamap_t dmap_saved; if (ccb->csio.cdb_len == 0) { panic("cdl_len is 0\n"); @@ -1388,7 +1481,14 @@ storvsc_action(struct cam_sim *sim, unio reqp = LIST_FIRST(&sc->hs_free_list); LIST_REMOVE(reqp, link); + /* Save the data_dmap before reset request */ + dmap_saved = reqp->data_dmap; + + /* XXX this is ugly */ bzero(reqp, sizeof(struct hv_storvsc_request)); + + /* Restore necessary bits */ + reqp->data_dmap = dmap_saved; reqp->softc = sc; ccb->ccb_h.status |= CAM_SIM_QUEUED; @@ -1644,6 +1744,35 @@ storvsc_check_bounce_buffer_sgl(bus_dma_ } /** + * Copy bus_dma segments to multiple page buffer, which requires + * the pages are compact composed except for the 1st and last pages. + */ +static void +storvsc_xferbuf_prepare(void *arg, bus_dma_segment_t *segs, int nsegs, int error) +{ + struct hv_storvsc_request *reqp = arg; + union ccb *ccb = reqp->ccb; + struct ccb_scsiio *csio = &ccb->csio; + struct storvsc_gpa_range *prplist; + int i; + + prplist = &reqp->prp_list; + prplist->gpa_range.gpa_len = csio->dxfer_len; + prplist->gpa_range.gpa_ofs = segs[0].ds_addr & PAGE_MASK; + + for (i = 0; i < nsegs; i++) { + prplist->gpa_page[i] = atop(segs[i].ds_addr); +#ifdef INVARIANTS + if (i != 0 && i != nsegs - 1) { + KASSERT((segs[i].ds_addr & PAGE_MASK) == 0 && + segs[i].ds_len == PAGE_SIZE, ("not a full page")); + } +#endif + } + reqp->prp_cnt = nsegs; +} + +/** * @brief Fill in a request structure based on a CAM control block * * Fills in a request structure based on the contents of a CAM control @@ -1658,11 +1787,9 @@ create_storvsc_request(union ccb *ccb, s { struct ccb_scsiio *csio = &ccb->csio; uint64_t phys_addr; - uint32_t bytes_to_copy = 0; - uint32_t pfn_num = 0; uint32_t pfn; uint64_t not_aligned_seg_bits = 0; - struct hvs_gpa_range *prplist; + int error; /* refer to struct vmscsi_req for meanings of these two fields */ reqp->vstor_packet.u.vm_srb.port = @@ -1706,36 +1833,26 @@ create_storvsc_request(union ccb *ccb, s return (0); } - prplist = &reqp->prp_list; - prplist->gpa_range.gpa_len = csio->dxfer_len; - switch (ccb->ccb_h.flags & CAM_DATA_MASK) { + case CAM_DATA_BIO: case CAM_DATA_VADDR: - { - bytes_to_copy = csio->dxfer_len; - phys_addr = vtophys(csio->data_ptr); - prplist->gpa_range.gpa_ofs = phys_addr & PAGE_MASK; - - while (bytes_to_copy != 0) { - int bytes, page_offset; - phys_addr = - vtophys(&csio->data_ptr[prplist->gpa_range.gpa_len - - bytes_to_copy]); - pfn = phys_addr >> PAGE_SHIFT; - prplist->gpa_page[pfn_num] = pfn; - page_offset = phys_addr & PAGE_MASK; - - bytes = min(PAGE_SIZE - page_offset, bytes_to_copy); - - bytes_to_copy -= bytes; - pfn_num++; + error = bus_dmamap_load_ccb(reqp->softc->storvsc_req_dtag, + reqp->data_dmap, ccb, storvsc_xferbuf_prepare, reqp, + BUS_DMA_NOWAIT); + if (error) { + xpt_print(ccb->ccb_h.path, + "bus_dmamap_load_ccb failed: %d\n", error); + return (error); } - reqp->prp_cnt = pfn_num; + if ((ccb->ccb_h.flags & CAM_DATA_MASK) == CAM_DATA_BIO) + reqp->softc->sysctl_data.data_bio_cnt++; + else + reqp->softc->sysctl_data.data_vaddr_cnt++; break; - } case CAM_DATA_SG: { + struct storvsc_gpa_range *prplist; int i = 0; int offset = 0; int ret; @@ -1744,13 +1861,16 @@ create_storvsc_request(union ccb *ccb, s (bus_dma_segment_t *)ccb->csio.data_ptr; u_int16_t storvsc_sg_count = ccb->csio.sglist_cnt; + prplist = &reqp->prp_list; + prplist->gpa_range.gpa_len = csio->dxfer_len; + printf("Storvsc: get SG I/O operation, %d\n", reqp->vstor_packet.u.vm_srb.data_in); - if (storvsc_sg_count > VMBUS_CHAN_PRPLIST_MAX){ + if (storvsc_sg_count > STORVSC_DATA_SEGCNT_MAX){ printf("Storvsc: %d segments is too much, " "only support %d segments\n", - storvsc_sg_count, VMBUS_CHAN_PRPLIST_MAX); + storvsc_sg_count, STORVSC_DATA_SEGCNT_MAX); return (EINVAL); } @@ -1847,6 +1967,7 @@ create_storvsc_request(union ccb *ccb, s reqp->bounce_sgl_count = 0; } + reqp->softc->sysctl_data.data_sg_cnt++; break; } default: From owner-svn-src-all@freebsd.org Wed Oct 12 09:16:17 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 53502C0EB3E; Wed, 12 Oct 2016 09:16:17 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 2301591; Wed, 12 Oct 2016 09:16:17 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9C9GGWe004859; Wed, 12 Oct 2016 09:16:16 GMT (envelope-from ed@FreeBSD.org) Received: (from ed@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9C9GGev004858; Wed, 12 Oct 2016 09:16:16 GMT (envelope-from ed@FreeBSD.org) Message-Id: <201610120916.u9C9GGev004858@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ed set sender to ed@FreeBSD.org using -f From: Ed Schouten Date: Wed, 12 Oct 2016 09:16:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307135 - stable/11/sys/compat/ia32 X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Oct 2016 09:16:17 -0000 Author: ed Date: Wed Oct 12 09:16:16 2016 New Revision: 307135 URL: https://svnweb.freebsd.org/changeset/base/307135 Log: MFC r304740: Add missing header dependency. This header depends on sigaltstack32 being declared. Modified: stable/11/sys/compat/ia32/ia32_signal.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/compat/ia32/ia32_signal.h ============================================================================== --- stable/11/sys/compat/ia32/ia32_signal.h Wed Oct 12 09:13:16 2016 (r307134) +++ stable/11/sys/compat/ia32/ia32_signal.h Wed Oct 12 09:16:16 2016 (r307135) @@ -32,6 +32,8 @@ #ifndef _COMPAT_IA32_IA32_SIGNAL_H #define _COMPAT_IA32_IA32_SIGNAL_H +#include + #define _MC_IA32_HASSEGS 0x1 #define _MC_IA32_HASBASES 0x2 #define _MC_IA32_HASFPXSTATE 0x4 From owner-svn-src-all@freebsd.org Wed Oct 12 09:17:43 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 822C8C0EBBF; Wed, 12 Oct 2016 09:17:43 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 3FCED216; Wed, 12 Oct 2016 09:17:43 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9C9HgVi004981; Wed, 12 Oct 2016 09:17:42 GMT (envelope-from ed@FreeBSD.org) Received: (from ed@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9C9Hfii004975; Wed, 12 Oct 2016 09:17:41 GMT (envelope-from ed@FreeBSD.org) Message-Id: <201610120917.u9C9Hfii004975@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ed set sender to ed@FreeBSD.org using -f From: Ed Schouten Date: Wed, 12 Oct 2016 09:17:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307136 - in stable/11/sys/arm: arm include X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Oct 2016 09:17:43 -0000 Author: ed Date: Wed Oct 12 09:17:41 2016 New Revision: 307136 URL: https://svnweb.freebsd.org/changeset/base/307136 Log: MFC r306162: Make it possible to safely use TPIDRURW from userspace. On amd64, arm64 and i386, we have the possibility to switch between TLS areas in userspace. The nice thing about this is that it makes it easier to do light-weight threading, if we ever feel like doing that. On armv6, let's go into the same direction by making it possible to safely use the TPIDRURW register, which is intended for this purpose. Clean up the ARMv6 code to remove md_tp entirely. Simply add a dedicated field to the PCB to hold the value of TPIDRURW across context switches, like we do for any other register. As userspace currently uses the read-only TPIDRURO register, simply ensure that we keep both values in sync where possible. The system calls for modifying the read-only register will simply write the intended value into both registers, so that it lazily ends up in the PCB during the next context switch. Approved by: andrew Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D7951 Modified: stable/11/sys/arm/arm/genassym.c stable/11/sys/arm/arm/swtch-v6.S stable/11/sys/arm/arm/sys_machdep.c stable/11/sys/arm/arm/vm_machdep.c stable/11/sys/arm/include/frame.h stable/11/sys/arm/include/pcpu.h stable/11/sys/arm/include/proc.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/arm/arm/genassym.c ============================================================================== --- stable/11/sys/arm/arm/genassym.c Wed Oct 12 09:16:16 2016 (r307135) +++ stable/11/sys/arm/arm/genassym.c Wed Oct 12 09:17:41 2016 (r307136) @@ -81,6 +81,9 @@ ASSYM(PCB_R12, offsetof(struct pcb, pcb_ ASSYM(PCB_SP, offsetof(struct pcb, pcb_regs.sf_sp)); ASSYM(PCB_LR, offsetof(struct pcb, pcb_regs.sf_lr)); ASSYM(PCB_PC, offsetof(struct pcb, pcb_regs.sf_pc)); +#if __ARM_ARCH >= 6 +ASSYM(PCB_TPIDRURW, offsetof(struct pcb, pcb_regs.sf_tpidrurw)); +#endif ASSYM(PC_CURPCB, offsetof(struct pcpu, pc_curpcb)); ASSYM(PC_CURTHREAD, offsetof(struct pcpu, pc_curthread)); @@ -100,8 +103,8 @@ ASSYM(TD_FLAGS, offsetof(struct thread, ASSYM(TD_PROC, offsetof(struct thread, td_proc)); ASSYM(TD_MD, offsetof(struct thread, td_md)); ASSYM(TD_LOCK, offsetof(struct thread, td_lock)); -ASSYM(MD_TP, offsetof(struct mdthread, md_tp)); #if __ARM_ARCH < 6 +ASSYM(MD_TP, offsetof(struct mdthread, md_tp)); ASSYM(MD_RAS_START, offsetof(struct mdthread, md_ras_start)); ASSYM(MD_RAS_END, offsetof(struct mdthread, md_ras_end)); #endif Modified: stable/11/sys/arm/arm/swtch-v6.S ============================================================================== --- stable/11/sys/arm/arm/swtch-v6.S Wed Oct 12 09:16:16 2016 (r307135) +++ stable/11/sys/arm/arm/swtch-v6.S Wed Oct 12 09:17:41 2016 (r307136) @@ -291,6 +291,8 @@ ENTRY(cpu_switch) ldr r3, [r0, #(TD_PCB)] add r3, #(PCB_R4) stmia r3, {r4-r12, sp, lr, pc} + mrc CP15_TPIDRURW(r4) + str r4, [r3, #(PCB_TPIDRURW - PCB_R4)] #ifdef INVARIANTS cmp r1, #0 /* new thread? */ @@ -437,9 +439,6 @@ sw1: cmp r3, r6 beq 1b #endif - /* Set the new tls */ - ldr r0, [r11, #(TD_MD + MD_TP)] - mcr CP15_TPIDRURO(r0) /* write tls thread reg 2 */ /* We have a new curthread now so make a note it */ str r11, [r8, #PC_CURTHREAD] @@ -452,7 +451,14 @@ sw1: * Restore all saved registers and return. Note that some saved * registers can be changed when either cpu_fork(), cpu_copy_thread(), * cpu_fork_kthread_handler(), or makectx() was called. - */ + * + * The value of TPIDRURW is also written into TPIDRURO, as + * userspace still uses TPIDRURO, modifying it through + * sysarch(ARM_SET_TP, addr). + */ + ldr r3, [r7, #PCB_TPIDRURW] + mcr CP15_TPIDRURW(r3) /* write tls thread reg 2 */ + mcr CP15_TPIDRURO(r3) /* write tls thread reg 3 */ add r3, r7, #PCB_R4 ldmia r3, {r4-r12, sp, pc} Modified: stable/11/sys/arm/arm/sys_machdep.c ============================================================================== --- stable/11/sys/arm/arm/sys_machdep.c Wed Oct 12 09:16:16 2016 (r307135) +++ stable/11/sys/arm/arm/sys_machdep.c Wed Oct 12 09:17:41 2016 (r307136) @@ -166,10 +166,10 @@ static int arm32_set_tp(struct thread *td, void *args) { - td->td_md.md_tp = (register_t)args; #if __ARM_ARCH >= 6 set_tls(args); #else + td->td_md.md_tp = (register_t)args; *(register_t *)ARM_TP_ADDRESS = (register_t)args; #endif return (0); @@ -180,7 +180,7 @@ arm32_get_tp(struct thread *td, void *ar { #if __ARM_ARCH >= 6 - td->td_retval[0] = td->td_md.md_tp; + td->td_retval[0] = (register_t)get_tls(); #else td->td_retval[0] = *(register_t *)ARM_TP_ADDRESS; #endif Modified: stable/11/sys/arm/arm/vm_machdep.c ============================================================================== --- stable/11/sys/arm/arm/vm_machdep.c Wed Oct 12 09:16:16 2016 (r307135) +++ stable/11/sys/arm/arm/vm_machdep.c Wed Oct 12 09:17:41 2016 (r307136) @@ -82,8 +82,8 @@ __FBSDID("$FreeBSD$"); * struct switchframe and trapframe must both be a multiple of 8 * for correct stack alignment. */ -CTASSERT(sizeof(struct switchframe) == 48); -CTASSERT(sizeof(struct trapframe) == 80); +_Static_assert((sizeof(struct switchframe) % 8) == 0, "Bad alignment"); +_Static_assert((sizeof(struct trapframe) % 8) == 0, "Bad alignment"); uint32_t initial_fpscr = VFPSCR_DN | VFPSCR_FZ; @@ -134,6 +134,9 @@ cpu_fork(register struct thread *td1, re pcb2->pcb_regs.sf_r5 = (register_t)td2; pcb2->pcb_regs.sf_lr = (register_t)fork_trampoline; pcb2->pcb_regs.sf_sp = STACKALIGN(td2->td_frame); +#if __ARM_ARCH >= 6 + pcb2->pcb_regs.sf_tpidrurw = (register_t)get_tls(); +#endif pcb2->pcb_vfpcpu = -1; pcb2->pcb_vfpstate.fpscr = initial_fpscr; @@ -147,9 +150,7 @@ cpu_fork(register struct thread *td1, re /* Setup to release spin count in fork_exit(). */ td2->td_md.md_spinlock_count = 1; td2->td_md.md_saved_cspr = PSR_SVC32_MODE; -#if __ARM_ARCH >= 6 - td2->td_md.md_tp = td1->td_md.md_tp; -#else +#if __ARM_ARCH < 6 td2->td_md.md_tp = *(register_t *)ARM_TP_ADDRESS; #endif } @@ -272,16 +273,18 @@ int cpu_set_user_tls(struct thread *td, void *tls_base) { - td->td_md.md_tp = (register_t)tls_base; - if (td == curthread) { - critical_enter(); #if __ARM_ARCH >= 6 + td->td_pcb->pcb_regs.sf_tpidrurw = (register_t)tls_base; + if (td == curthread) set_tls(tls_base); #else + td->td_md.md_tp = (register_t)tls_base; + if (td == curthread) { + critical_enter(); *(register_t *)ARM_TP_ADDRESS = (register_t)tls_base; -#endif critical_exit(); } +#endif return (0); } Modified: stable/11/sys/arm/include/frame.h ============================================================================== --- stable/11/sys/arm/include/frame.h Wed Oct 12 09:16:16 2016 (r307135) +++ stable/11/sys/arm/include/frame.h Wed Oct 12 09:17:41 2016 (r307136) @@ -117,6 +117,10 @@ struct switchframe register_t sf_sp; register_t sf_lr; register_t sf_pc; +#if __ARM_ARCH >= 6 + register_t sf_tpidrurw; + register_t sf_spare0; +#endif }; Modified: stable/11/sys/arm/include/pcpu.h ============================================================================== --- stable/11/sys/arm/include/pcpu.h Wed Oct 12 09:16:16 2016 (r307135) +++ stable/11/sys/arm/include/pcpu.h Wed Oct 12 09:17:41 2016 (r307136) @@ -103,7 +103,8 @@ get_tls(void) { void *tls; - __asm __volatile("mrc p15, 0, %0, c13, c0, 3" : "=r" (tls)); + /* TPIDRURW contains the authoritative value. */ + __asm __volatile("mrc p15, 0, %0, c13, c0, 2" : "=r" (tls)); return (tls); } @@ -111,7 +112,15 @@ static inline void set_tls(void *tls) { - __asm __volatile("mcr p15, 0, %0, c13, c0, 3" : : "r" (tls)); + /* + * Update both TPIDRURW and TPIDRURO. TPIDRURW needs to be written + * first to ensure that a context switch between the two writes will + * still give the desired result of updating both. + */ + __asm __volatile( + "mcr p15, 0, %0, c13, c0, 2\n" + "mcr p15, 0, %0, c13, c0, 3\n" + : : "r" (tls)); } #define curthread get_curthread() Modified: stable/11/sys/arm/include/proc.h ============================================================================== --- stable/11/sys/arm/include/proc.h Wed Oct 12 09:16:16 2016 (r307135) +++ stable/11/sys/arm/include/proc.h Wed Oct 12 09:17:41 2016 (r307136) @@ -53,8 +53,8 @@ struct mdthread { int md_ptrace_addr; int md_ptrace_instr_alt; int md_ptrace_addr_alt; - register_t md_tp; #if __ARM_ARCH < 6 + register_t md_tp; void *md_ras_start; void *md_ras_end; #endif From owner-svn-src-all@freebsd.org Wed Oct 12 09:27:41 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 2D521C0EDA9; Wed, 12 Oct 2016 09:27:41 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id E0869981; Wed, 12 Oct 2016 09:27:40 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9C9Re1Z008942; Wed, 12 Oct 2016 09:27:40 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9C9Rd0F008936; Wed, 12 Oct 2016 09:27:39 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610120927.u9C9Rd0F008936@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Wed, 12 Oct 2016 09:27:39 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307137 - in stable/10/sys/dev/hyperv: include netvsc storvsc vmbus X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Oct 2016 09:27:41 -0000 Author: sephe Date: Wed Oct 12 09:27:39 2016 New Revision: 307137 URL: https://svnweb.freebsd.org/changeset/base/307137 Log: MFC 303603-303605,303764 303603 hyperv/vmbus: Remove the artificial entry limit of SG and PRP list. Just make sure that the total channel packet size does not exceed 1/2 data size of the TX bufring. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7359 303604 hyperv/storvsc: Set maxio to 128KB. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7360 303605 hyperv/storvsc: Stringent PRP list assertions Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7361 303764 hyperv/vmbus: Only make sure the TX bufring will not be closed. KVP can write data, whose size is > 1/2 TX bufring size. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7414 Modified: stable/10/sys/dev/hyperv/include/vmbus.h stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c stable/10/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c stable/10/sys/dev/hyperv/vmbus/vmbus_brvar.h stable/10/sys/dev/hyperv/vmbus/vmbus_chan.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/hyperv/include/vmbus.h ============================================================================== --- stable/10/sys/dev/hyperv/include/vmbus.h Wed Oct 12 09:17:41 2016 (r307136) +++ stable/10/sys/dev/hyperv/include/vmbus.h Wed Oct 12 09:27:39 2016 (r307137) @@ -103,9 +103,6 @@ struct vmbus_chanpkt_rxbuf { struct vmbus_rxbuf_desc cp_rxbuf[]; } __packed; -#define VMBUS_CHAN_SGLIST_MAX 32 -#define VMBUS_CHAN_PRPLIST_MAX 32 - struct vmbus_channel; struct hyperv_guid; Modified: stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h Wed Oct 12 09:17:41 2016 (r307136) +++ stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h Wed Oct 12 09:27:39 2016 (r307137) @@ -1088,6 +1088,7 @@ struct vmbus_channel; typedef void (*pfn_on_send_rx_completion)(struct vmbus_channel *, void *); #define NETVSC_DEVICE_RING_BUFFER_SIZE (128 * PAGE_SIZE) +#define NETVSC_PACKET_MAXPAGE 32 #define NETVSC_VLAN_PRIO_MASK 0xe000 #define NETVSC_VLAN_PRIO_SHIFT 13 @@ -1137,7 +1138,7 @@ typedef struct netvsc_packet_ { uint32_t tot_data_buf_len; void *data; uint32_t gpa_cnt; - struct vmbus_gpa gpa[VMBUS_CHAN_SGLIST_MAX]; + struct vmbus_gpa gpa[NETVSC_PACKET_MAXPAGE]; } netvsc_packet; typedef struct { Modified: stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Wed Oct 12 09:17:41 2016 (r307136) +++ stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Wed Oct 12 09:27:39 2016 (r307137) @@ -154,7 +154,7 @@ __FBSDID("$FreeBSD$"); #define HN_TX_DATA_MAXSIZE IP_MAXPACKET #define HN_TX_DATA_SEGSIZE PAGE_SIZE #define HN_TX_DATA_SEGCNT_MAX \ - (VMBUS_CHAN_SGLIST_MAX - HV_RF_NUM_TX_RESERVED_PAGE_BUFS) + (NETVSC_PACKET_MAXPAGE - HV_RF_NUM_TX_RESERVED_PAGE_BUFS) #define HN_DIRECT_TX_SIZE_DEF 128 Modified: stable/10/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c ============================================================================== --- stable/10/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c Wed Oct 12 09:17:41 2016 (r307136) +++ stable/10/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c Wed Oct 12 09:27:39 2016 (r307137) @@ -88,10 +88,25 @@ __FBSDID("$FreeBSD$"); #define VSTOR_PKT_SIZE (sizeof(struct vstor_packet) - vmscsi_size_delta) -#define STORVSC_DATA_SEGCNT_MAX VMBUS_CHAN_PRPLIST_MAX +/* + * 33 segments are needed to allow 128KB maxio, in case the data + * in the first page is _not_ PAGE_SIZE aligned, e.g. + * + * |<----------- 128KB ----------->| + * | | + * 0 2K 4K 8K 16K 124K 128K 130K + * | | | | | | | | + * +--+--+-----+-----+.......+-----+--+--+ + * | | | | | | | | | DATA + * | | | | | | | | | + * +--+--+-----+-----+.......------+--+--+ + * | | | | + * | 1| 31 | 1| ...... # of segments + */ +#define STORVSC_DATA_SEGCNT_MAX 33 #define STORVSC_DATA_SEGSZ_MAX PAGE_SIZE #define STORVSC_DATA_SIZE_MAX \ - (STORVSC_DATA_SEGCNT_MAX * STORVSC_DATA_SEGSZ_MAX) + ((STORVSC_DATA_SEGCNT_MAX - 1) * STORVSC_DATA_SEGSZ_MAX) struct storvsc_softc; @@ -1388,6 +1403,7 @@ storvsc_action(struct cam_sim *sim, unio cpi->hba_misc = PIM_NOBUSRESET; if (hv_storvsc_use_pim_unmapped) cpi->hba_misc |= PIM_UNMAPPED; + cpi->maxio = STORVSC_DATA_SIZE_MAX; cpi->hba_eng_cnt = 0; cpi->max_target = STORVSC_MAX_TARGETS; cpi->max_lun = sc->hs_drv_props->drv_max_luns_per_target; @@ -1761,13 +1777,28 @@ storvsc_xferbuf_prepare(void *arg, bus_d prplist->gpa_range.gpa_ofs = segs[0].ds_addr & PAGE_MASK; for (i = 0; i < nsegs; i++) { - prplist->gpa_page[i] = atop(segs[i].ds_addr); #ifdef INVARIANTS - if (i != 0 && i != nsegs - 1) { - KASSERT((segs[i].ds_addr & PAGE_MASK) == 0 && - segs[i].ds_len == PAGE_SIZE, ("not a full page")); + if (nsegs > 1) { + if (i == 0) { + KASSERT((segs[i].ds_addr & PAGE_MASK) + + segs[i].ds_len == PAGE_SIZE, + ("invalid 1st page, ofs 0x%jx, len %zu", + (uintmax_t)segs[i].ds_addr, + segs[i].ds_len)); + } else if (i == nsegs - 1) { + KASSERT((segs[i].ds_addr & PAGE_MASK) == 0, + ("invalid last page, ofs 0x%jx", + (uintmax_t)segs[i].ds_addr)); + } else { + KASSERT((segs[i].ds_addr & PAGE_MASK) == 0 && + segs[i].ds_len == PAGE_SIZE, + ("not a full page, ofs 0x%jx, len %zu", + (uintmax_t)segs[i].ds_addr, + segs[i].ds_len)); + } } #endif + prplist->gpa_page[i] = atop(segs[i].ds_addr); } reqp->prp_cnt = nsegs; } Modified: stable/10/sys/dev/hyperv/vmbus/vmbus_brvar.h ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/vmbus_brvar.h Wed Oct 12 09:17:41 2016 (r307136) +++ stable/10/sys/dev/hyperv/vmbus/vmbus_brvar.h Wed Oct 12 09:27:39 2016 (r307137) @@ -71,6 +71,17 @@ struct vmbus_txbr { struct sysctl_ctx_list; struct sysctl_oid; +static __inline int +vmbus_txbr_maxpktsz(const struct vmbus_txbr *tbr) +{ + /* + * - 64 bits for the trailing start index (- sizeof(uint64_t)). + * - The rindex and windex can't be same (- 1). See + * the comment near vmbus_bufring.br_{r,w}index. + */ + return (tbr->txbr_dsize - sizeof(uint64_t) - 1); +} + void vmbus_br_sysctl_create(struct sysctl_ctx_list *ctx, struct sysctl_oid *br_tree, struct vmbus_br *br, const char *name); Modified: stable/10/sys/dev/hyperv/vmbus/vmbus_chan.c ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/vmbus_chan.c Wed Oct 12 09:17:41 2016 (r307136) +++ stable/10/sys/dev/hyperv/vmbus/vmbus_chan.c Wed Oct 12 09:27:39 2016 (r307137) @@ -610,6 +610,8 @@ vmbus_chan_send(struct vmbus_channel *ch hlen = sizeof(pkt); pktlen = hlen + dlen; pad_pktlen = VMBUS_CHANPKT_TOTLEN(pktlen); + KASSERT(pad_pktlen <= vmbus_txbr_maxpktsz(&chan->ch_txbr), + ("invalid packet size %d", pad_pktlen)); pkt.cp_hdr.cph_type = type; pkt.cp_hdr.cph_flags = flags; @@ -640,12 +642,11 @@ vmbus_chan_send_sglist(struct vmbus_chan boolean_t send_evt; uint64_t pad = 0; - KASSERT(sglen < VMBUS_CHAN_SGLIST_MAX, - ("invalid sglist len %d", sglen)); - hlen = __offsetof(struct vmbus_chanpkt_sglist, cp_gpa[sglen]); pktlen = hlen + dlen; pad_pktlen = VMBUS_CHANPKT_TOTLEN(pktlen); + KASSERT(pad_pktlen <= vmbus_txbr_maxpktsz(&chan->ch_txbr), + ("invalid packet size %d", pad_pktlen)); pkt.cp_hdr.cph_type = VMBUS_CHANPKT_TYPE_GPA; pkt.cp_hdr.cph_flags = VMBUS_CHANPKT_FLAG_RC; @@ -681,13 +682,12 @@ vmbus_chan_send_prplist(struct vmbus_cha boolean_t send_evt; uint64_t pad = 0; - KASSERT(prp_cnt < VMBUS_CHAN_PRPLIST_MAX, - ("invalid prplist entry count %d", prp_cnt)); - hlen = __offsetof(struct vmbus_chanpkt_prplist, cp_range[0].gpa_page[prp_cnt]); pktlen = hlen + dlen; pad_pktlen = VMBUS_CHANPKT_TOTLEN(pktlen); + KASSERT(pad_pktlen <= vmbus_txbr_maxpktsz(&chan->ch_txbr), + ("invalid packet size %d", pad_pktlen)); pkt.cp_hdr.cph_type = VMBUS_CHANPKT_TYPE_GPA; pkt.cp_hdr.cph_flags = VMBUS_CHANPKT_FLAG_RC; From owner-svn-src-all@freebsd.org Wed Oct 12 09:44:06 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C6F29C0C401; Wed, 12 Oct 2016 09:44:06 +0000 (UTC) (envelope-from slw@zxy.spb.ru) Received: from zxy.spb.ru (zxy.spb.ru [195.70.199.98]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 884CD7B7; Wed, 12 Oct 2016 09:44:06 +0000 (UTC) (envelope-from slw@zxy.spb.ru) Received: from slw by zxy.spb.ru with local (Exim 4.86 (FreeBSD)) (envelope-from ) id 1buG4x-000ISl-DV; Wed, 12 Oct 2016 12:44:03 +0300 Date: Wed, 12 Oct 2016 12:44:03 +0300 From: Slawa Olhovchenkov To: "Jonathan T. Looney" Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r307082 - in head: . sys/amd64/conf sys/arm/conf sys/arm64/conf sys/conf sys/i386/conf sys/mips/conf sys/modules/cc sys/modules/khelp sys/netinet sys/netinet/tcp_stacks sys/pc98/conf sy... Message-ID: <20161012094403.GA57876@zxy.spb.ru> References: <201610120216.u9C2Gga8041814@repo.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <201610120216.u9C2Gga8041814@repo.freebsd.org> User-Agent: Mutt/1.5.24 (2015-08-30) X-SA-Exim-Connect-IP: X-SA-Exim-Mail-From: slw@zxy.spb.ru X-SA-Exim-Scanned: No (on zxy.spb.ru); SAEximRunCond expanded to false X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Oct 2016 09:44:06 -0000 On Wed, Oct 12, 2016 at 02:16:42AM +0000, Jonathan T. Looney wrote: > Author: jtl > Date: Wed Oct 12 02:16:42 2016 > New Revision: 307082 > URL: https://svnweb.freebsd.org/changeset/base/307082 > > Log: > In the TCP stack, the hhook(9) framework provides hooks for kernel modules > to add actions that run when a TCP frame is sent or received on a TCP > session in the ESTABLISHED state. In the base tree, this functionality is > only used for the h_ertt module, which is used by the cc_cdg, cc_chd, cc_hd, > and cc_vegas congestion control modules. > > Presently, we incur overhead to check for hooks each time a TCP frame is > sent or received on an ESTABLISHED TCP session. Do you perform estimate of performane impact of this overhead? From owner-svn-src-all@freebsd.org Wed Oct 12 10:28:25 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B342CC0D8A1; Wed, 12 Oct 2016 10:28:25 +0000 (UTC) (envelope-from mm@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 7F71B3CC; Wed, 12 Oct 2016 10:28:25 +0000 (UTC) (envelope-from mm@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9CASOOp034425; Wed, 12 Oct 2016 10:28:24 GMT (envelope-from mm@FreeBSD.org) Received: (from mm@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9CASMFX034405; Wed, 12 Oct 2016 10:28:22 GMT (envelope-from mm@FreeBSD.org) Message-Id: <201610121028.u9CASMFX034405@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mm set sender to mm@FreeBSD.org using -f From: Martin Matuska Date: Wed, 12 Oct 2016 10:28:22 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307138 - in stable/11: contrib/libarchive/cat/test contrib/libarchive/cpio/test contrib/libarchive/libarchive contrib/libarchive/libarchive/test contrib/libarchive/tar contrib/libarchi... X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Oct 2016 10:28:25 -0000 Author: mm Date: Wed Oct 12 10:28:22 2016 New Revision: 307138 URL: https://svnweb.freebsd.org/changeset/base/307138 Log: MFC r306670: Sync libarchive with vendor including security fixes. Important vendor bugfixes (relevant to FreeBSD): #747: Out of bounds read in mtree parser #761: heap-based buffer overflow in read_Header (7-zip) #794: Invalid file on bsdtar command line results in internal errors (1) PR: 213092 (1) Added: stable/11/contrib/libarchive/libarchive/test/test_read_format_mtree_crash747.c - copied unchanged from r306670, head/contrib/libarchive/libarchive/test/test_read_format_mtree_crash747.c stable/11/contrib/libarchive/libarchive/test/test_read_format_mtree_crash747.mtree.bz2.uu - copied unchanged from r306670, head/contrib/libarchive/libarchive/test/test_read_format_mtree_crash747.mtree.bz2.uu Modified: stable/11/contrib/libarchive/cat/test/main.c stable/11/contrib/libarchive/cat/test/test.h stable/11/contrib/libarchive/cpio/test/main.c stable/11/contrib/libarchive/cpio/test/test.h stable/11/contrib/libarchive/libarchive/archive_read_support_format_7zip.c stable/11/contrib/libarchive/libarchive/archive_read_support_format_mtree.c stable/11/contrib/libarchive/libarchive/test/main.c stable/11/contrib/libarchive/libarchive/test/test_acl_freebsd_nfs4.c stable/11/contrib/libarchive/libarchive/test/test_read_set_format.c stable/11/contrib/libarchive/tar/subst.c stable/11/contrib/libarchive/tar/test/main.c stable/11/contrib/libarchive/tar/test/test.h stable/11/contrib/libarchive/tar/test/test_option_H_upper.c stable/11/contrib/libarchive/tar/test/test_option_L_upper.c stable/11/contrib/libarchive/tar/test/test_option_U_upper.c stable/11/contrib/libarchive/tar/test/test_option_n.c stable/11/contrib/libarchive/tar/write.c stable/11/lib/libarchive/tests/Makefile Directory Properties: stable/11/ (props changed) Modified: stable/11/contrib/libarchive/cat/test/main.c ============================================================================== --- stable/11/contrib/libarchive/cat/test/main.c Wed Oct 12 09:27:39 2016 (r307137) +++ stable/11/contrib/libarchive/cat/test/main.c Wed Oct 12 10:28:22 2016 (r307138) @@ -1360,6 +1360,31 @@ assertion_file_birthtime_recent(const ch return assertion_file_time(file, line, pathname, 0, 0, 'b', 1); } +/* Verify mode of 'pathname'. */ +int +assertion_file_mode(const char *file, int line, const char *pathname, int expected_mode) +{ + int mode; + int r; + + assertion_count(file, line); +#if defined(_WIN32) && !defined(__CYGWIN__) + failure_start(file, line, "assertFileMode not yet implemented for Windows"); +#else + { + struct stat st; + r = lstat(pathname, &st); + mode = (int)(st.st_mode & 0777); + } + if (r == 0 && mode == expected_mode) + return (1); + failure_start(file, line, "File %s has mode %o, expected %o", + pathname, mode, expected_mode); +#endif + failure_finish(NULL); + return (0); +} + /* Verify mtime of 'pathname'. */ int assertion_file_mtime(const char *file, int line, @@ -1578,8 +1603,12 @@ assertion_make_dir(const char *file, int if (0 == _mkdir(dirname)) return (1); #else - if (0 == mkdir(dirname, mode)) - return (1); + if (0 == mkdir(dirname, mode)) { + if (0 == chmod(dirname, mode)) { + assertion_file_mode(file, line, dirname, mode); + return (1); + } + } #endif failure_start(file, line, "Could not create directory %s", dirname); failure_finish(NULL); @@ -1628,6 +1657,11 @@ assertion_make_file(const char *file, in failure_finish(NULL); return (0); } + if (0 != chmod(path, mode)) { + failure_start(file, line, "Could not chmod %s", path); + failure_finish(NULL); + return (0); + } if (contents != NULL) { ssize_t wsize; @@ -1644,6 +1678,7 @@ assertion_make_file(const char *file, in } } close(fd); + assertion_file_mode(file, line, path, mode); return (1); #endif } Modified: stable/11/contrib/libarchive/cat/test/test.h ============================================================================== --- stable/11/contrib/libarchive/cat/test/test.h Wed Oct 12 09:27:39 2016 (r307137) +++ stable/11/contrib/libarchive/cat/test/test.h Wed Oct 12 10:28:22 2016 (r307138) @@ -241,6 +241,7 @@ int assertion_file_birthtime_recent(cons int assertion_file_contains_lines_any_order(const char *, int, const char *, const char **); int assertion_file_contents(const char *, int, const void *, int, const char *); int assertion_file_exists(const char *, int, const char *); +int assertion_file_mode(const char *, int, const char *, int); int assertion_file_mtime(const char *, int, const char *, long, long); int assertion_file_mtime_recent(const char *, int, const char *); int assertion_file_nlinks(const char *, int, const char *, int); Modified: stable/11/contrib/libarchive/cpio/test/main.c ============================================================================== --- stable/11/contrib/libarchive/cpio/test/main.c Wed Oct 12 09:27:39 2016 (r307137) +++ stable/11/contrib/libarchive/cpio/test/main.c Wed Oct 12 10:28:22 2016 (r307138) @@ -1361,6 +1361,31 @@ assertion_file_birthtime_recent(const ch return assertion_file_time(file, line, pathname, 0, 0, 'b', 1); } +/* Verify mode of 'pathname'. */ +int +assertion_file_mode(const char *file, int line, const char *pathname, int expected_mode) +{ + int mode; + int r; + + assertion_count(file, line); +#if defined(_WIN32) && !defined(__CYGWIN__) + failure_start(file, line, "assertFileMode not yet implemented for Windows"); +#else + { + struct stat st; + r = lstat(pathname, &st); + mode = (int)(st.st_mode & 0777); + } + if (r == 0 && mode == expected_mode) + return (1); + failure_start(file, line, "File %s has mode %o, expected %o", + pathname, mode, expected_mode); +#endif + failure_finish(NULL); + return (0); +} + /* Verify mtime of 'pathname'. */ int assertion_file_mtime(const char *file, int line, @@ -1579,8 +1604,12 @@ assertion_make_dir(const char *file, int if (0 == _mkdir(dirname)) return (1); #else - if (0 == mkdir(dirname, mode)) - return (1); + if (0 == mkdir(dirname, mode)) { + if (0 == chmod(dirname, mode)) { + assertion_file_mode(file, line, dirname, mode); + return (1); + } + } #endif failure_start(file, line, "Could not create directory %s", dirname); failure_finish(NULL); @@ -1629,6 +1658,11 @@ assertion_make_file(const char *file, in failure_finish(NULL); return (0); } + if (0 != chmod(path, mode)) { + failure_start(file, line, "Could not chmod %s", path); + failure_finish(NULL); + return (0); + } if (contents != NULL) { ssize_t wsize; @@ -1645,6 +1679,7 @@ assertion_make_file(const char *file, in } } close(fd); + assertion_file_mode(file, line, path, mode); return (1); #endif } Modified: stable/11/contrib/libarchive/cpio/test/test.h ============================================================================== --- stable/11/contrib/libarchive/cpio/test/test.h Wed Oct 12 09:27:39 2016 (r307137) +++ stable/11/contrib/libarchive/cpio/test/test.h Wed Oct 12 10:28:22 2016 (r307138) @@ -241,6 +241,7 @@ int assertion_file_birthtime_recent(cons int assertion_file_contains_lines_any_order(const char *, int, const char *, const char **); int assertion_file_contents(const char *, int, const void *, int, const char *); int assertion_file_exists(const char *, int, const char *); +int assertion_file_mode(const char *, int, const char *, int); int assertion_file_mtime(const char *, int, const char *, long, long); int assertion_file_mtime_recent(const char *, int, const char *); int assertion_file_nlinks(const char *, int, const char *, int); Modified: stable/11/contrib/libarchive/libarchive/archive_read_support_format_7zip.c ============================================================================== --- stable/11/contrib/libarchive/libarchive/archive_read_support_format_7zip.c Wed Oct 12 09:27:39 2016 (r307137) +++ stable/11/contrib/libarchive/libarchive/archive_read_support_format_7zip.c Wed Oct 12 10:28:22 2016 (r307138) @@ -2431,6 +2431,8 @@ read_Header(struct archive_read *a, stru switch (type) { case kEmptyStream: + if (h->emptyStreamBools != NULL) + return (-1); h->emptyStreamBools = calloc((size_t)zip->numFiles, sizeof(*h->emptyStreamBools)); if (h->emptyStreamBools == NULL) @@ -2451,6 +2453,8 @@ read_Header(struct archive_read *a, stru return (-1); break; } + if (h->emptyFileBools != NULL) + return (-1); h->emptyFileBools = calloc(empty_streams, sizeof(*h->emptyFileBools)); if (h->emptyFileBools == NULL) @@ -2465,6 +2469,8 @@ read_Header(struct archive_read *a, stru return (-1); break; } + if (h->antiBools != NULL) + return (-1); h->antiBools = calloc(empty_streams, sizeof(*h->antiBools)); if (h->antiBools == NULL) @@ -2491,6 +2497,8 @@ read_Header(struct archive_read *a, stru if ((ll & 1) || ll < zip->numFiles * 4) return (-1); + if (zip->entry_names != NULL) + return (-1); zip->entry_names = malloc(ll); if (zip->entry_names == NULL) return (-1); @@ -2543,6 +2551,8 @@ read_Header(struct archive_read *a, stru if ((p = header_bytes(a, 2)) == NULL) return (-1); allAreDefined = *p; + if (h->attrBools != NULL) + return (-1); h->attrBools = calloc((size_t)zip->numFiles, sizeof(*h->attrBools)); if (h->attrBools == NULL) Modified: stable/11/contrib/libarchive/libarchive/archive_read_support_format_mtree.c ============================================================================== --- stable/11/contrib/libarchive/libarchive/archive_read_support_format_mtree.c Wed Oct 12 09:27:39 2016 (r307137) +++ stable/11/contrib/libarchive/libarchive/archive_read_support_format_mtree.c Wed Oct 12 10:28:22 2016 (r307138) @@ -301,6 +301,15 @@ get_line_size(const char *b, ssize_t ava return (avail); } +/* + * <---------------- ravail ---------------------> + * <-- diff ------> <--- avail -----------------> + * <---- len -----------> + * | Previous lines | line being parsed nl extra | + * ^ + * b + * + */ static ssize_t next_line(struct archive_read *a, const char **b, ssize_t *avail, ssize_t *ravail, ssize_t *nl) @@ -339,7 +348,7 @@ next_line(struct archive_read *a, *b += diff; *avail -= diff; tested = len;/* Skip some bytes we already determinated. */ - len = get_line_size(*b, *avail, nl); + len = get_line_size(*b + len, *avail - len, nl); if (len >= 0) len += tested; } Modified: stable/11/contrib/libarchive/libarchive/test/main.c ============================================================================== --- stable/11/contrib/libarchive/libarchive/test/main.c Wed Oct 12 09:27:39 2016 (r307137) +++ stable/11/contrib/libarchive/libarchive/test/main.c Wed Oct 12 10:28:22 2016 (r307138) @@ -1607,8 +1607,12 @@ assertion_make_dir(const char *file, int if (0 == _mkdir(dirname)) return (1); #else - if (0 == mkdir(dirname, mode)) - return (1); + if (0 == mkdir(dirname, mode)) { + if (0 == chmod(dirname, mode)) { + assertion_file_mode(file, line, dirname, mode); + return (1); + } + } #endif failure_start(file, line, "Could not create directory %s", dirname); failure_finish(NULL); @@ -1657,6 +1661,11 @@ assertion_make_file(const char *file, in failure_finish(NULL); return (0); } + if (0 != chmod(path, mode)) { + failure_start(file, line, "Could not chmod %s", path); + failure_finish(NULL); + return (0); + } if (contents != NULL) { ssize_t wsize; @@ -1673,6 +1682,7 @@ assertion_make_file(const char *file, in } } close(fd); + assertion_file_mode(file, line, path, mode); return (1); #endif } Modified: stable/11/contrib/libarchive/libarchive/test/test_acl_freebsd_nfs4.c ============================================================================== --- stable/11/contrib/libarchive/libarchive/test/test_acl_freebsd_nfs4.c Wed Oct 12 09:27:39 2016 (r307137) +++ stable/11/contrib/libarchive/libarchive/test/test_acl_freebsd_nfs4.c Wed Oct 12 10:28:22 2016 (r307138) @@ -93,7 +93,7 @@ static struct myacl_t acls_reg[] = { static struct myacl_t acls_dir[] = { /* For this test, we need to be able to read and write the ACL. */ - { ARCHIVE_ENTRY_ACL_TYPE_ALLOW, ARCHIVE_ENTRY_ACL_READ_ACL, + { ARCHIVE_ENTRY_ACL_TYPE_ALLOW, ARCHIVE_ENTRY_ACL_READ_DATA | ARCHIVE_ENTRY_ACL_READ_ACL, ARCHIVE_ENTRY_ACL_USER_OBJ, -1, ""}, /* An entry for each type. */ Copied: stable/11/contrib/libarchive/libarchive/test/test_read_format_mtree_crash747.c (from r306670, head/contrib/libarchive/libarchive/test/test_read_format_mtree_crash747.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/11/contrib/libarchive/libarchive/test/test_read_format_mtree_crash747.c Wed Oct 12 10:28:22 2016 (r307138, copy of r306670, head/contrib/libarchive/libarchive/test/test_read_format_mtree_crash747.c) @@ -0,0 +1,44 @@ +/*- + * Copyright (c) 2003-2016 Tim Kientzle + * 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(S) ``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(S) BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#include "test.h" + + +/* + * Reproduce the crash reported in Github Issue #747. + */ +DEFINE_TEST(test_read_format_mtree_crash747) +{ + const char *reffile = "test_read_format_mtree_crash747.mtree.bz2"; + struct archive *a; + + extract_reference_file(reffile); + + assert((a = archive_read_new()) != NULL); + assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_bzip2(a)); + assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_mtree(a)); + assertEqualIntA(a, ARCHIVE_FATAL, archive_read_open_filename(a, reffile, 10240)); + assertEqualInt(ARCHIVE_OK, archive_read_free(a)); +} + Copied: stable/11/contrib/libarchive/libarchive/test/test_read_format_mtree_crash747.mtree.bz2.uu (from r306670, head/contrib/libarchive/libarchive/test/test_read_format_mtree_crash747.mtree.bz2.uu) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/11/contrib/libarchive/libarchive/test/test_read_format_mtree_crash747.mtree.bz2.uu Wed Oct 12 10:28:22 2016 (r307138, copy of r306670, head/contrib/libarchive/libarchive/test/test_read_format_mtree_crash747.mtree.bz2.uu) @@ -0,0 +1,6 @@ +begin 600 test_read_format_mtree_crash747.mtree.bz2 +M0EIH.3%!62936:OH@(@``'/[@,`0`@!``'^```)A@9\`$`@@`'4)049!IIH! +MM021-0,F@&@6````9%>$(K!GIC*XFR0`$```J0+:$XP```!D-F)H[#SE9+2' +4+E"L=ASXUI%R(I"HD'ZA(5?1`Q`` +` +end Modified: stable/11/contrib/libarchive/libarchive/test/test_read_set_format.c ============================================================================== --- stable/11/contrib/libarchive/libarchive/test/test_read_set_format.c Wed Oct 12 09:27:39 2016 (r307137) +++ stable/11/contrib/libarchive/libarchive/test/test_read_set_format.c Wed Oct 12 10:28:22 2016 (r307138) @@ -204,7 +204,7 @@ DEFINE_TEST(test_read_append_filter_wron /* * If we have "bunzip2 -q", try using that. */ - if (!canRunCommand("bunzip2 -V")) { + if (!canRunCommand("bunzip2 -h")) { skipping("Can't run bunzip2 program on this platform"); return; } Modified: stable/11/contrib/libarchive/tar/subst.c ============================================================================== --- stable/11/contrib/libarchive/tar/subst.c Wed Oct 12 09:27:39 2016 (r307137) +++ stable/11/contrib/libarchive/tar/subst.c Wed Oct 12 10:28:22 2016 (r307138) @@ -84,6 +84,7 @@ add_substitution(struct bsdtar *bsdtar, if (rule == NULL) lafe_errc(1, errno, "Out of memory"); rule->next = NULL; + rule->result = NULL; if (subst->last_rule == NULL) subst->first_rule = rule; Modified: stable/11/contrib/libarchive/tar/test/main.c ============================================================================== --- stable/11/contrib/libarchive/tar/test/main.c Wed Oct 12 09:27:39 2016 (r307137) +++ stable/11/contrib/libarchive/tar/test/main.c Wed Oct 12 10:28:22 2016 (r307138) @@ -130,6 +130,13 @@ __FBSDID("$FreeBSD$"); # include #endif +mode_t umasked(mode_t expected_mode) +{ + mode_t mode = umask(0); + umask(mode); + return expected_mode & ~mode; +} + /* Path to working directory for current test */ const char *testworkdir; #ifdef PROGRAM @@ -1361,6 +1368,31 @@ assertion_file_birthtime_recent(const ch return assertion_file_time(file, line, pathname, 0, 0, 'b', 1); } +/* Verify mode of 'pathname'. */ +int +assertion_file_mode(const char *file, int line, const char *pathname, int expected_mode) +{ + int mode; + int r; + + assertion_count(file, line); +#if defined(_WIN32) && !defined(__CYGWIN__) + failure_start(file, line, "assertFileMode not yet implemented for Windows"); +#else + { + struct stat st; + r = lstat(pathname, &st); + mode = (int)(st.st_mode & 0777); + } + if (r == 0 && mode == expected_mode) + return (1); + failure_start(file, line, "File %s has mode %o, expected %o", + pathname, mode, expected_mode); +#endif + failure_finish(NULL); + return (0); +} + /* Verify mtime of 'pathname'. */ int assertion_file_mtime(const char *file, int line, @@ -1579,8 +1611,12 @@ assertion_make_dir(const char *file, int if (0 == _mkdir(dirname)) return (1); #else - if (0 == mkdir(dirname, mode)) - return (1); + if (0 == mkdir(dirname, mode)) { + if (0 == chmod(dirname, mode)) { + assertion_file_mode(file, line, dirname, mode); + return (1); + } + } #endif failure_start(file, line, "Could not create directory %s", dirname); failure_finish(NULL); @@ -1629,6 +1665,11 @@ assertion_make_file(const char *file, in failure_finish(NULL); return (0); } + if (0 != chmod(path, mode)) { + failure_start(file, line, "Could not chmod %s", path); + failure_finish(NULL); + return (0); + } if (contents != NULL) { ssize_t wsize; @@ -1645,6 +1686,7 @@ assertion_make_file(const char *file, in } } close(fd); + assertion_file_mode(file, line, path, mode); return (1); #endif } Modified: stable/11/contrib/libarchive/tar/test/test.h ============================================================================== --- stable/11/contrib/libarchive/tar/test/test.h Wed Oct 12 09:27:39 2016 (r307137) +++ stable/11/contrib/libarchive/tar/test/test.h Wed Oct 12 10:28:22 2016 (r307138) @@ -241,6 +241,7 @@ int assertion_file_birthtime_recent(cons int assertion_file_contains_lines_any_order(const char *, int, const char *, const char **); int assertion_file_contents(const char *, int, const void *, int, const char *); int assertion_file_exists(const char *, int, const char *); +int assertion_file_mode(const char *, int, const char *, int); int assertion_file_mtime(const char *, int, const char *, long, long); int assertion_file_mtime_recent(const char *, int, const char *); int assertion_file_nlinks(const char *, int, const char *, int); @@ -326,6 +327,9 @@ void copy_reference_file(const char *); */ void extract_reference_files(const char **); +/* Subtract umask from mode */ +mode_t umasked(mode_t expected_mode); + /* Path to working directory for current test */ extern const char *testworkdir; Modified: stable/11/contrib/libarchive/tar/test/test_option_H_upper.c ============================================================================== --- stable/11/contrib/libarchive/tar/test/test_option_H_upper.c Wed Oct 12 09:27:39 2016 (r307137) +++ stable/11/contrib/libarchive/tar/test/test_option_H_upper.c Wed Oct 12 10:28:22 2016 (r307138) @@ -83,10 +83,10 @@ DEFINE_TEST(test_option_H_upper) assertChdir("test3"); assertEqualInt(0, systemf("%s -xf archive.tar >c.out 2>c.err", testprog)); - assertIsDir("ld1", 0755); + assertIsDir("ld1", umasked(0755)); assertIsSymlink("d1/linkX", "fileX"); assertIsSymlink("d1/link1", "file1"); - assertIsReg("link2", 0644); + assertIsReg("link2", umasked(0644)); assertIsSymlink("linkY", "d1/fileY"); assertChdir(".."); } Modified: stable/11/contrib/libarchive/tar/test/test_option_L_upper.c ============================================================================== --- stable/11/contrib/libarchive/tar/test/test_option_L_upper.c Wed Oct 12 09:27:39 2016 (r307137) +++ stable/11/contrib/libarchive/tar/test/test_option_L_upper.c Wed Oct 12 10:28:22 2016 (r307138) @@ -69,10 +69,10 @@ DEFINE_TEST(test_option_L_upper) assertChdir("test2"); assertEqualInt(0, systemf("%s -xf archive.tar >c.out 2>c.err", testprog)); - assertIsDir("ld1", 0755); - assertIsReg("d1/link1", 0644); + assertIsDir("ld1", umasked(0755)); + assertIsReg("d1/link1", umasked(0644)); assertIsSymlink("d1/linkX", "fileX"); - assertIsReg("link2", 0644); + assertIsReg("link2", umasked(0644)); assertIsSymlink("linkY", "d1/fileY"); assertChdir(".."); @@ -83,10 +83,10 @@ DEFINE_TEST(test_option_L_upper) assertChdir("test3"); assertEqualInt(0, systemf("%s -xf archive.tar >c.out 2>c.err", testprog)); - assertIsDir("ld1", 0755); - assertIsReg("d1/link1", 0644); + assertIsDir("ld1", umasked(0755)); + assertIsReg("d1/link1", umasked(0644)); assertIsSymlink("d1/linkX", "fileX"); - assertIsReg("link2", 0644); + assertIsReg("link2", umasked(0644)); assertIsSymlink("linkY", "d1/fileY"); assertChdir(".."); } Modified: stable/11/contrib/libarchive/tar/test/test_option_U_upper.c ============================================================================== --- stable/11/contrib/libarchive/tar/test/test_option_U_upper.c Wed Oct 12 09:27:39 2016 (r307137) +++ stable/11/contrib/libarchive/tar/test/test_option_U_upper.c Wed Oct 12 10:28:22 2016 (r307138) @@ -135,7 +135,7 @@ DEFINE_TEST(test_option_U_upper) assertMakeSymlink("d1/file1", "d1/realfile1"); assertEqualInt(0, systemf("%s -xf ../archive.tar d1/file1 >test.out 2>test.err", testprog)); - assertIsReg("d1/file1", 0644); + assertIsReg("d1/file1", umasked(0644)); assertFileContents("d1/file1", 8, "d1/file1"); assertFileContents("realfile1", 9, "d1/realfile1"); assertEmptyFile("test.out"); @@ -150,7 +150,7 @@ DEFINE_TEST(test_option_U_upper) assertMakeSymlink("d1/file1", "d1/realfile1"); assertEqualInt(0, systemf("%s -xPUf ../archive.tar d1/file1 >test.out 2>test.err", testprog)); - assertIsReg("d1/file1", 0644); + assertIsReg("d1/file1", umasked(0644)); assertFileContents("d1/file1", 8, "d1/file1"); assertFileContents("realfile1", 9, "d1/realfile1"); assertEmptyFile("test.out"); Modified: stable/11/contrib/libarchive/tar/test/test_option_n.c ============================================================================== --- stable/11/contrib/libarchive/tar/test/test_option_n.c Wed Oct 12 09:27:39 2016 (r307137) +++ stable/11/contrib/libarchive/tar/test/test_option_n.c Wed Oct 12 10:28:22 2016 (r307138) @@ -55,7 +55,7 @@ DEFINE_TEST(test_option_n) systemf("%s -xf archive.tar >x.out 2>x.err", testprog)); assertEmptyFile("x.out"); assertEmptyFile("x.err"); - assertIsDir("d1", 0755); + assertIsDir("d1", umasked(0755)); assertFileNotExists("d1/file1"); assertChdir(".."); } Modified: stable/11/contrib/libarchive/tar/write.c ============================================================================== --- stable/11/contrib/libarchive/tar/write.c Wed Oct 12 09:27:39 2016 (r307137) +++ stable/11/contrib/libarchive/tar/write.c Wed Oct 12 10:28:22 2016 (r307138) @@ -886,6 +886,8 @@ write_hierarchy(struct bsdtar *bsdtar, s "%s", archive_error_string(disk)); if (r == ARCHIVE_FATAL || r == ARCHIVE_FAILED) { bsdtar->return_value = 1; + archive_entry_free(entry); + archive_read_close(disk); return; } else if (r < ARCHIVE_WARN) continue; Modified: stable/11/lib/libarchive/tests/Makefile ============================================================================== --- stable/11/lib/libarchive/tests/Makefile Wed Oct 12 09:27:39 2016 (r307137) +++ stable/11/lib/libarchive/tests/Makefile Wed Oct 12 10:28:22 2016 (r307138) @@ -149,6 +149,7 @@ TESTS_SRCS= \ test_read_format_lha_bugfix_0.c \ test_read_format_lha_filename.c \ test_read_format_mtree.c \ + test_read_format_mtree_crash747.c \ test_read_format_pax_bz2.c \ test_read_format_rar.c \ test_read_format_rar_encryption_data.c \ @@ -464,6 +465,7 @@ ${PACKAGE}FILES+= test_read_format_lha_l ${PACKAGE}FILES+= test_read_format_lha_lh7.lzh.uu ${PACKAGE}FILES+= test_read_format_lha_withjunk.lzh.uu ${PACKAGE}FILES+= test_read_format_mtree.mtree.uu +${PACKAGE}FILES+= test_read_format_mtree_crash747.mtree.bz2.uu ${PACKAGE}FILES+= test_read_format_mtree_nomagic.mtree.uu ${PACKAGE}FILES+= test_read_format_mtree_nomagic2.mtree.uu ${PACKAGE}FILES+= test_read_format_mtree_nomagic3.mtree.uu From owner-svn-src-all@freebsd.org Wed Oct 12 10:28:58 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 2291EC0D92A; Wed, 12 Oct 2016 10:28:58 +0000 (UTC) (envelope-from mm@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id E2ADC7AC; Wed, 12 Oct 2016 10:28:57 +0000 (UTC) (envelope-from mm@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9CASvw0034541; Wed, 12 Oct 2016 10:28:57 GMT (envelope-from mm@FreeBSD.org) Received: (from mm@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9CAStPB034520; Wed, 12 Oct 2016 10:28:55 GMT (envelope-from mm@FreeBSD.org) Message-Id: <201610121028.u9CAStPB034520@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mm set sender to mm@FreeBSD.org using -f From: Martin Matuska Date: Wed, 12 Oct 2016 10:28:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307139 - in stable/10: contrib/libarchive/cat/test contrib/libarchive/cpio/test contrib/libarchive/libarchive contrib/libarchive/libarchive/test contrib/libarchive/tar contrib/libarchi... X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Oct 2016 10:28:58 -0000 Author: mm Date: Wed Oct 12 10:28:54 2016 New Revision: 307139 URL: https://svnweb.freebsd.org/changeset/base/307139 Log: MFC r306670: Sync libarchive with vendor including security fixes. Important vendor bugfixes (relevant to FreeBSD): #747: Out of bounds read in mtree parser #761: heap-based buffer overflow in read_Header (7-zip) #794: Invalid file on bsdtar command line results in internal errors (1) PR: 213092 (1) Added: stable/10/contrib/libarchive/libarchive/test/test_read_format_mtree_crash747.c - copied unchanged from r306670, head/contrib/libarchive/libarchive/test/test_read_format_mtree_crash747.c stable/10/contrib/libarchive/libarchive/test/test_read_format_mtree_crash747.mtree.bz2.uu - copied unchanged from r306670, head/contrib/libarchive/libarchive/test/test_read_format_mtree_crash747.mtree.bz2.uu Modified: stable/10/contrib/libarchive/cat/test/main.c stable/10/contrib/libarchive/cat/test/test.h stable/10/contrib/libarchive/cpio/test/main.c stable/10/contrib/libarchive/cpio/test/test.h stable/10/contrib/libarchive/libarchive/archive_read_support_format_7zip.c stable/10/contrib/libarchive/libarchive/archive_read_support_format_mtree.c stable/10/contrib/libarchive/libarchive/test/main.c stable/10/contrib/libarchive/libarchive/test/test_acl_freebsd_nfs4.c stable/10/contrib/libarchive/libarchive/test/test_read_set_format.c stable/10/contrib/libarchive/tar/subst.c stable/10/contrib/libarchive/tar/test/main.c stable/10/contrib/libarchive/tar/test/test.h stable/10/contrib/libarchive/tar/test/test_option_H_upper.c stable/10/contrib/libarchive/tar/test/test_option_L_upper.c stable/10/contrib/libarchive/tar/test/test_option_U_upper.c stable/10/contrib/libarchive/tar/test/test_option_n.c stable/10/contrib/libarchive/tar/write.c stable/10/lib/libarchive/tests/Makefile Directory Properties: stable/10/ (props changed) Modified: stable/10/contrib/libarchive/cat/test/main.c ============================================================================== --- stable/10/contrib/libarchive/cat/test/main.c Wed Oct 12 10:28:22 2016 (r307138) +++ stable/10/contrib/libarchive/cat/test/main.c Wed Oct 12 10:28:54 2016 (r307139) @@ -1360,6 +1360,31 @@ assertion_file_birthtime_recent(const ch return assertion_file_time(file, line, pathname, 0, 0, 'b', 1); } +/* Verify mode of 'pathname'. */ +int +assertion_file_mode(const char *file, int line, const char *pathname, int expected_mode) +{ + int mode; + int r; + + assertion_count(file, line); +#if defined(_WIN32) && !defined(__CYGWIN__) + failure_start(file, line, "assertFileMode not yet implemented for Windows"); +#else + { + struct stat st; + r = lstat(pathname, &st); + mode = (int)(st.st_mode & 0777); + } + if (r == 0 && mode == expected_mode) + return (1); + failure_start(file, line, "File %s has mode %o, expected %o", + pathname, mode, expected_mode); +#endif + failure_finish(NULL); + return (0); +} + /* Verify mtime of 'pathname'. */ int assertion_file_mtime(const char *file, int line, @@ -1578,8 +1603,12 @@ assertion_make_dir(const char *file, int if (0 == _mkdir(dirname)) return (1); #else - if (0 == mkdir(dirname, mode)) - return (1); + if (0 == mkdir(dirname, mode)) { + if (0 == chmod(dirname, mode)) { + assertion_file_mode(file, line, dirname, mode); + return (1); + } + } #endif failure_start(file, line, "Could not create directory %s", dirname); failure_finish(NULL); @@ -1628,6 +1657,11 @@ assertion_make_file(const char *file, in failure_finish(NULL); return (0); } + if (0 != chmod(path, mode)) { + failure_start(file, line, "Could not chmod %s", path); + failure_finish(NULL); + return (0); + } if (contents != NULL) { ssize_t wsize; @@ -1644,6 +1678,7 @@ assertion_make_file(const char *file, in } } close(fd); + assertion_file_mode(file, line, path, mode); return (1); #endif } Modified: stable/10/contrib/libarchive/cat/test/test.h ============================================================================== --- stable/10/contrib/libarchive/cat/test/test.h Wed Oct 12 10:28:22 2016 (r307138) +++ stable/10/contrib/libarchive/cat/test/test.h Wed Oct 12 10:28:54 2016 (r307139) @@ -241,6 +241,7 @@ int assertion_file_birthtime_recent(cons int assertion_file_contains_lines_any_order(const char *, int, const char *, const char **); int assertion_file_contents(const char *, int, const void *, int, const char *); int assertion_file_exists(const char *, int, const char *); +int assertion_file_mode(const char *, int, const char *, int); int assertion_file_mtime(const char *, int, const char *, long, long); int assertion_file_mtime_recent(const char *, int, const char *); int assertion_file_nlinks(const char *, int, const char *, int); Modified: stable/10/contrib/libarchive/cpio/test/main.c ============================================================================== --- stable/10/contrib/libarchive/cpio/test/main.c Wed Oct 12 10:28:22 2016 (r307138) +++ stable/10/contrib/libarchive/cpio/test/main.c Wed Oct 12 10:28:54 2016 (r307139) @@ -1361,6 +1361,31 @@ assertion_file_birthtime_recent(const ch return assertion_file_time(file, line, pathname, 0, 0, 'b', 1); } +/* Verify mode of 'pathname'. */ +int +assertion_file_mode(const char *file, int line, const char *pathname, int expected_mode) +{ + int mode; + int r; + + assertion_count(file, line); +#if defined(_WIN32) && !defined(__CYGWIN__) + failure_start(file, line, "assertFileMode not yet implemented for Windows"); +#else + { + struct stat st; + r = lstat(pathname, &st); + mode = (int)(st.st_mode & 0777); + } + if (r == 0 && mode == expected_mode) + return (1); + failure_start(file, line, "File %s has mode %o, expected %o", + pathname, mode, expected_mode); +#endif + failure_finish(NULL); + return (0); +} + /* Verify mtime of 'pathname'. */ int assertion_file_mtime(const char *file, int line, @@ -1579,8 +1604,12 @@ assertion_make_dir(const char *file, int if (0 == _mkdir(dirname)) return (1); #else - if (0 == mkdir(dirname, mode)) - return (1); + if (0 == mkdir(dirname, mode)) { + if (0 == chmod(dirname, mode)) { + assertion_file_mode(file, line, dirname, mode); + return (1); + } + } #endif failure_start(file, line, "Could not create directory %s", dirname); failure_finish(NULL); @@ -1629,6 +1658,11 @@ assertion_make_file(const char *file, in failure_finish(NULL); return (0); } + if (0 != chmod(path, mode)) { + failure_start(file, line, "Could not chmod %s", path); + failure_finish(NULL); + return (0); + } if (contents != NULL) { ssize_t wsize; @@ -1645,6 +1679,7 @@ assertion_make_file(const char *file, in } } close(fd); + assertion_file_mode(file, line, path, mode); return (1); #endif } Modified: stable/10/contrib/libarchive/cpio/test/test.h ============================================================================== --- stable/10/contrib/libarchive/cpio/test/test.h Wed Oct 12 10:28:22 2016 (r307138) +++ stable/10/contrib/libarchive/cpio/test/test.h Wed Oct 12 10:28:54 2016 (r307139) @@ -241,6 +241,7 @@ int assertion_file_birthtime_recent(cons int assertion_file_contains_lines_any_order(const char *, int, const char *, const char **); int assertion_file_contents(const char *, int, const void *, int, const char *); int assertion_file_exists(const char *, int, const char *); +int assertion_file_mode(const char *, int, const char *, int); int assertion_file_mtime(const char *, int, const char *, long, long); int assertion_file_mtime_recent(const char *, int, const char *); int assertion_file_nlinks(const char *, int, const char *, int); Modified: stable/10/contrib/libarchive/libarchive/archive_read_support_format_7zip.c ============================================================================== --- stable/10/contrib/libarchive/libarchive/archive_read_support_format_7zip.c Wed Oct 12 10:28:22 2016 (r307138) +++ stable/10/contrib/libarchive/libarchive/archive_read_support_format_7zip.c Wed Oct 12 10:28:54 2016 (r307139) @@ -2431,6 +2431,8 @@ read_Header(struct archive_read *a, stru switch (type) { case kEmptyStream: + if (h->emptyStreamBools != NULL) + return (-1); h->emptyStreamBools = calloc((size_t)zip->numFiles, sizeof(*h->emptyStreamBools)); if (h->emptyStreamBools == NULL) @@ -2451,6 +2453,8 @@ read_Header(struct archive_read *a, stru return (-1); break; } + if (h->emptyFileBools != NULL) + return (-1); h->emptyFileBools = calloc(empty_streams, sizeof(*h->emptyFileBools)); if (h->emptyFileBools == NULL) @@ -2465,6 +2469,8 @@ read_Header(struct archive_read *a, stru return (-1); break; } + if (h->antiBools != NULL) + return (-1); h->antiBools = calloc(empty_streams, sizeof(*h->antiBools)); if (h->antiBools == NULL) @@ -2491,6 +2497,8 @@ read_Header(struct archive_read *a, stru if ((ll & 1) || ll < zip->numFiles * 4) return (-1); + if (zip->entry_names != NULL) + return (-1); zip->entry_names = malloc(ll); if (zip->entry_names == NULL) return (-1); @@ -2543,6 +2551,8 @@ read_Header(struct archive_read *a, stru if ((p = header_bytes(a, 2)) == NULL) return (-1); allAreDefined = *p; + if (h->attrBools != NULL) + return (-1); h->attrBools = calloc((size_t)zip->numFiles, sizeof(*h->attrBools)); if (h->attrBools == NULL) Modified: stable/10/contrib/libarchive/libarchive/archive_read_support_format_mtree.c ============================================================================== --- stable/10/contrib/libarchive/libarchive/archive_read_support_format_mtree.c Wed Oct 12 10:28:22 2016 (r307138) +++ stable/10/contrib/libarchive/libarchive/archive_read_support_format_mtree.c Wed Oct 12 10:28:54 2016 (r307139) @@ -301,6 +301,15 @@ get_line_size(const char *b, ssize_t ava return (avail); } +/* + * <---------------- ravail ---------------------> + * <-- diff ------> <--- avail -----------------> + * <---- len -----------> + * | Previous lines | line being parsed nl extra | + * ^ + * b + * + */ static ssize_t next_line(struct archive_read *a, const char **b, ssize_t *avail, ssize_t *ravail, ssize_t *nl) @@ -339,7 +348,7 @@ next_line(struct archive_read *a, *b += diff; *avail -= diff; tested = len;/* Skip some bytes we already determinated. */ - len = get_line_size(*b, *avail, nl); + len = get_line_size(*b + len, *avail - len, nl); if (len >= 0) len += tested; } Modified: stable/10/contrib/libarchive/libarchive/test/main.c ============================================================================== --- stable/10/contrib/libarchive/libarchive/test/main.c Wed Oct 12 10:28:22 2016 (r307138) +++ stable/10/contrib/libarchive/libarchive/test/main.c Wed Oct 12 10:28:54 2016 (r307139) @@ -1607,8 +1607,12 @@ assertion_make_dir(const char *file, int if (0 == _mkdir(dirname)) return (1); #else - if (0 == mkdir(dirname, mode)) - return (1); + if (0 == mkdir(dirname, mode)) { + if (0 == chmod(dirname, mode)) { + assertion_file_mode(file, line, dirname, mode); + return (1); + } + } #endif failure_start(file, line, "Could not create directory %s", dirname); failure_finish(NULL); @@ -1657,6 +1661,11 @@ assertion_make_file(const char *file, in failure_finish(NULL); return (0); } + if (0 != chmod(path, mode)) { + failure_start(file, line, "Could not chmod %s", path); + failure_finish(NULL); + return (0); + } if (contents != NULL) { ssize_t wsize; @@ -1673,6 +1682,7 @@ assertion_make_file(const char *file, in } } close(fd); + assertion_file_mode(file, line, path, mode); return (1); #endif } Modified: stable/10/contrib/libarchive/libarchive/test/test_acl_freebsd_nfs4.c ============================================================================== --- stable/10/contrib/libarchive/libarchive/test/test_acl_freebsd_nfs4.c Wed Oct 12 10:28:22 2016 (r307138) +++ stable/10/contrib/libarchive/libarchive/test/test_acl_freebsd_nfs4.c Wed Oct 12 10:28:54 2016 (r307139) @@ -93,7 +93,7 @@ static struct myacl_t acls_reg[] = { static struct myacl_t acls_dir[] = { /* For this test, we need to be able to read and write the ACL. */ - { ARCHIVE_ENTRY_ACL_TYPE_ALLOW, ARCHIVE_ENTRY_ACL_READ_ACL, + { ARCHIVE_ENTRY_ACL_TYPE_ALLOW, ARCHIVE_ENTRY_ACL_READ_DATA | ARCHIVE_ENTRY_ACL_READ_ACL, ARCHIVE_ENTRY_ACL_USER_OBJ, -1, ""}, /* An entry for each type. */ Copied: stable/10/contrib/libarchive/libarchive/test/test_read_format_mtree_crash747.c (from r306670, head/contrib/libarchive/libarchive/test/test_read_format_mtree_crash747.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/10/contrib/libarchive/libarchive/test/test_read_format_mtree_crash747.c Wed Oct 12 10:28:54 2016 (r307139, copy of r306670, head/contrib/libarchive/libarchive/test/test_read_format_mtree_crash747.c) @@ -0,0 +1,44 @@ +/*- + * Copyright (c) 2003-2016 Tim Kientzle + * 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(S) ``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(S) BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#include "test.h" + + +/* + * Reproduce the crash reported in Github Issue #747. + */ +DEFINE_TEST(test_read_format_mtree_crash747) +{ + const char *reffile = "test_read_format_mtree_crash747.mtree.bz2"; + struct archive *a; + + extract_reference_file(reffile); + + assert((a = archive_read_new()) != NULL); + assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_bzip2(a)); + assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_mtree(a)); + assertEqualIntA(a, ARCHIVE_FATAL, archive_read_open_filename(a, reffile, 10240)); + assertEqualInt(ARCHIVE_OK, archive_read_free(a)); +} + Copied: stable/10/contrib/libarchive/libarchive/test/test_read_format_mtree_crash747.mtree.bz2.uu (from r306670, head/contrib/libarchive/libarchive/test/test_read_format_mtree_crash747.mtree.bz2.uu) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/10/contrib/libarchive/libarchive/test/test_read_format_mtree_crash747.mtree.bz2.uu Wed Oct 12 10:28:54 2016 (r307139, copy of r306670, head/contrib/libarchive/libarchive/test/test_read_format_mtree_crash747.mtree.bz2.uu) @@ -0,0 +1,6 @@ +begin 600 test_read_format_mtree_crash747.mtree.bz2 +M0EIH.3%!62936:OH@(@``'/[@,`0`@!``'^```)A@9\`$`@@`'4)049!IIH! +MM021-0,F@&@6````9%>$(K!GIC*XFR0`$```J0+:$XP```!D-F)H[#SE9+2' +4+E"L=ASXUI%R(I"HD'ZA(5?1`Q`` +` +end Modified: stable/10/contrib/libarchive/libarchive/test/test_read_set_format.c ============================================================================== --- stable/10/contrib/libarchive/libarchive/test/test_read_set_format.c Wed Oct 12 10:28:22 2016 (r307138) +++ stable/10/contrib/libarchive/libarchive/test/test_read_set_format.c Wed Oct 12 10:28:54 2016 (r307139) @@ -204,7 +204,7 @@ DEFINE_TEST(test_read_append_filter_wron /* * If we have "bunzip2 -q", try using that. */ - if (!canRunCommand("bunzip2 -V")) { + if (!canRunCommand("bunzip2 -h")) { skipping("Can't run bunzip2 program on this platform"); return; } Modified: stable/10/contrib/libarchive/tar/subst.c ============================================================================== --- stable/10/contrib/libarchive/tar/subst.c Wed Oct 12 10:28:22 2016 (r307138) +++ stable/10/contrib/libarchive/tar/subst.c Wed Oct 12 10:28:54 2016 (r307139) @@ -84,6 +84,7 @@ add_substitution(struct bsdtar *bsdtar, if (rule == NULL) lafe_errc(1, errno, "Out of memory"); rule->next = NULL; + rule->result = NULL; if (subst->last_rule == NULL) subst->first_rule = rule; Modified: stable/10/contrib/libarchive/tar/test/main.c ============================================================================== --- stable/10/contrib/libarchive/tar/test/main.c Wed Oct 12 10:28:22 2016 (r307138) +++ stable/10/contrib/libarchive/tar/test/main.c Wed Oct 12 10:28:54 2016 (r307139) @@ -130,6 +130,13 @@ __FBSDID("$FreeBSD$"); # include #endif +mode_t umasked(mode_t expected_mode) +{ + mode_t mode = umask(0); + umask(mode); + return expected_mode & ~mode; +} + /* Path to working directory for current test */ const char *testworkdir; #ifdef PROGRAM @@ -1361,6 +1368,31 @@ assertion_file_birthtime_recent(const ch return assertion_file_time(file, line, pathname, 0, 0, 'b', 1); } +/* Verify mode of 'pathname'. */ +int +assertion_file_mode(const char *file, int line, const char *pathname, int expected_mode) +{ + int mode; + int r; + + assertion_count(file, line); +#if defined(_WIN32) && !defined(__CYGWIN__) + failure_start(file, line, "assertFileMode not yet implemented for Windows"); +#else + { + struct stat st; + r = lstat(pathname, &st); + mode = (int)(st.st_mode & 0777); + } + if (r == 0 && mode == expected_mode) + return (1); + failure_start(file, line, "File %s has mode %o, expected %o", + pathname, mode, expected_mode); +#endif + failure_finish(NULL); + return (0); +} + /* Verify mtime of 'pathname'. */ int assertion_file_mtime(const char *file, int line, @@ -1579,8 +1611,12 @@ assertion_make_dir(const char *file, int if (0 == _mkdir(dirname)) return (1); #else - if (0 == mkdir(dirname, mode)) - return (1); + if (0 == mkdir(dirname, mode)) { + if (0 == chmod(dirname, mode)) { + assertion_file_mode(file, line, dirname, mode); + return (1); + } + } #endif failure_start(file, line, "Could not create directory %s", dirname); failure_finish(NULL); @@ -1629,6 +1665,11 @@ assertion_make_file(const char *file, in failure_finish(NULL); return (0); } + if (0 != chmod(path, mode)) { + failure_start(file, line, "Could not chmod %s", path); + failure_finish(NULL); + return (0); + } if (contents != NULL) { ssize_t wsize; @@ -1645,6 +1686,7 @@ assertion_make_file(const char *file, in } } close(fd); + assertion_file_mode(file, line, path, mode); return (1); #endif } Modified: stable/10/contrib/libarchive/tar/test/test.h ============================================================================== --- stable/10/contrib/libarchive/tar/test/test.h Wed Oct 12 10:28:22 2016 (r307138) +++ stable/10/contrib/libarchive/tar/test/test.h Wed Oct 12 10:28:54 2016 (r307139) @@ -241,6 +241,7 @@ int assertion_file_birthtime_recent(cons int assertion_file_contains_lines_any_order(const char *, int, const char *, const char **); int assertion_file_contents(const char *, int, const void *, int, const char *); int assertion_file_exists(const char *, int, const char *); +int assertion_file_mode(const char *, int, const char *, int); int assertion_file_mtime(const char *, int, const char *, long, long); int assertion_file_mtime_recent(const char *, int, const char *); int assertion_file_nlinks(const char *, int, const char *, int); @@ -326,6 +327,9 @@ void copy_reference_file(const char *); */ void extract_reference_files(const char **); +/* Subtract umask from mode */ +mode_t umasked(mode_t expected_mode); + /* Path to working directory for current test */ extern const char *testworkdir; Modified: stable/10/contrib/libarchive/tar/test/test_option_H_upper.c ============================================================================== --- stable/10/contrib/libarchive/tar/test/test_option_H_upper.c Wed Oct 12 10:28:22 2016 (r307138) +++ stable/10/contrib/libarchive/tar/test/test_option_H_upper.c Wed Oct 12 10:28:54 2016 (r307139) @@ -83,10 +83,10 @@ DEFINE_TEST(test_option_H_upper) assertChdir("test3"); assertEqualInt(0, systemf("%s -xf archive.tar >c.out 2>c.err", testprog)); - assertIsDir("ld1", 0755); + assertIsDir("ld1", umasked(0755)); assertIsSymlink("d1/linkX", "fileX"); assertIsSymlink("d1/link1", "file1"); - assertIsReg("link2", 0644); + assertIsReg("link2", umasked(0644)); assertIsSymlink("linkY", "d1/fileY"); assertChdir(".."); } Modified: stable/10/contrib/libarchive/tar/test/test_option_L_upper.c ============================================================================== --- stable/10/contrib/libarchive/tar/test/test_option_L_upper.c Wed Oct 12 10:28:22 2016 (r307138) +++ stable/10/contrib/libarchive/tar/test/test_option_L_upper.c Wed Oct 12 10:28:54 2016 (r307139) @@ -69,10 +69,10 @@ DEFINE_TEST(test_option_L_upper) assertChdir("test2"); assertEqualInt(0, systemf("%s -xf archive.tar >c.out 2>c.err", testprog)); - assertIsDir("ld1", 0755); - assertIsReg("d1/link1", 0644); + assertIsDir("ld1", umasked(0755)); + assertIsReg("d1/link1", umasked(0644)); assertIsSymlink("d1/linkX", "fileX"); - assertIsReg("link2", 0644); + assertIsReg("link2", umasked(0644)); assertIsSymlink("linkY", "d1/fileY"); assertChdir(".."); @@ -83,10 +83,10 @@ DEFINE_TEST(test_option_L_upper) assertChdir("test3"); assertEqualInt(0, systemf("%s -xf archive.tar >c.out 2>c.err", testprog)); - assertIsDir("ld1", 0755); - assertIsReg("d1/link1", 0644); + assertIsDir("ld1", umasked(0755)); + assertIsReg("d1/link1", umasked(0644)); assertIsSymlink("d1/linkX", "fileX"); - assertIsReg("link2", 0644); + assertIsReg("link2", umasked(0644)); assertIsSymlink("linkY", "d1/fileY"); assertChdir(".."); } Modified: stable/10/contrib/libarchive/tar/test/test_option_U_upper.c ============================================================================== --- stable/10/contrib/libarchive/tar/test/test_option_U_upper.c Wed Oct 12 10:28:22 2016 (r307138) +++ stable/10/contrib/libarchive/tar/test/test_option_U_upper.c Wed Oct 12 10:28:54 2016 (r307139) @@ -135,7 +135,7 @@ DEFINE_TEST(test_option_U_upper) assertMakeSymlink("d1/file1", "d1/realfile1"); assertEqualInt(0, systemf("%s -xf ../archive.tar d1/file1 >test.out 2>test.err", testprog)); - assertIsReg("d1/file1", 0644); + assertIsReg("d1/file1", umasked(0644)); assertFileContents("d1/file1", 8, "d1/file1"); assertFileContents("realfile1", 9, "d1/realfile1"); assertEmptyFile("test.out"); @@ -150,7 +150,7 @@ DEFINE_TEST(test_option_U_upper) assertMakeSymlink("d1/file1", "d1/realfile1"); assertEqualInt(0, systemf("%s -xPUf ../archive.tar d1/file1 >test.out 2>test.err", testprog)); - assertIsReg("d1/file1", 0644); + assertIsReg("d1/file1", umasked(0644)); assertFileContents("d1/file1", 8, "d1/file1"); assertFileContents("realfile1", 9, "d1/realfile1"); assertEmptyFile("test.out"); Modified: stable/10/contrib/libarchive/tar/test/test_option_n.c ============================================================================== --- stable/10/contrib/libarchive/tar/test/test_option_n.c Wed Oct 12 10:28:22 2016 (r307138) +++ stable/10/contrib/libarchive/tar/test/test_option_n.c Wed Oct 12 10:28:54 2016 (r307139) @@ -55,7 +55,7 @@ DEFINE_TEST(test_option_n) systemf("%s -xf archive.tar >x.out 2>x.err", testprog)); assertEmptyFile("x.out"); assertEmptyFile("x.err"); - assertIsDir("d1", 0755); + assertIsDir("d1", umasked(0755)); assertFileNotExists("d1/file1"); assertChdir(".."); } Modified: stable/10/contrib/libarchive/tar/write.c ============================================================================== --- stable/10/contrib/libarchive/tar/write.c Wed Oct 12 10:28:22 2016 (r307138) +++ stable/10/contrib/libarchive/tar/write.c Wed Oct 12 10:28:54 2016 (r307139) @@ -886,6 +886,8 @@ write_hierarchy(struct bsdtar *bsdtar, s "%s", archive_error_string(disk)); if (r == ARCHIVE_FATAL || r == ARCHIVE_FAILED) { bsdtar->return_value = 1; + archive_entry_free(entry); + archive_read_close(disk); return; } else if (r < ARCHIVE_WARN) continue; Modified: stable/10/lib/libarchive/tests/Makefile ============================================================================== --- stable/10/lib/libarchive/tests/Makefile Wed Oct 12 10:28:22 2016 (r307138) +++ stable/10/lib/libarchive/tests/Makefile Wed Oct 12 10:28:54 2016 (r307139) @@ -150,6 +150,7 @@ TESTS_SRCS= \ test_read_format_lha_bugfix_0.c \ test_read_format_lha_filename.c \ test_read_format_mtree.c \ + test_read_format_mtree_crash747.c \ test_read_format_pax_bz2.c \ test_read_format_rar.c \ test_read_format_rar_encryption_data.c \ @@ -466,6 +467,7 @@ FILES+= test_read_format_lha_lh6.lzh.uu FILES+= test_read_format_lha_lh7.lzh.uu FILES+= test_read_format_lha_withjunk.lzh.uu FILES+= test_read_format_mtree.mtree.uu +FILES+= test_read_format_mtree_crash747.mtree.bz2.uu FILES+= test_read_format_mtree_nomagic.mtree.uu FILES+= test_read_format_mtree_nomagic2.mtree.uu FILES+= test_read_format_mtree_nomagic3.mtree.uu From owner-svn-src-all@freebsd.org Wed Oct 12 11:12:32 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 9CCCAC0E782; Wed, 12 Oct 2016 11:12:32 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 6C563FC3; Wed, 12 Oct 2016 11:12:32 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9CBCVOK053128; Wed, 12 Oct 2016 11:12:31 GMT (envelope-from avg@FreeBSD.org) Received: (from avg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9CBCVex053127; Wed, 12 Oct 2016 11:12:31 GMT (envelope-from avg@FreeBSD.org) Message-Id: <201610121112.u9CBCVex053127@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avg set sender to avg@FreeBSD.org using -f From: Andriy Gapon Date: Wed, 12 Oct 2016 11:12:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307140 - head/sys/sys X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Oct 2016 11:12:32 -0000 Author: avg Date: Wed Oct 12 11:12:31 2016 New Revision: 307140 URL: https://svnweb.freebsd.org/changeset/base/307140 Log: bump __FreeBSD_version for libzfs_core.h Modified: head/sys/sys/param.h Modified: head/sys/sys/param.h ============================================================================== --- head/sys/sys/param.h Wed Oct 12 10:28:54 2016 (r307139) +++ head/sys/sys/param.h Wed Oct 12 11:12:31 2016 (r307140) @@ -58,7 +58,7 @@ * in the range 5 to 9. */ #undef __FreeBSD_version -#define __FreeBSD_version 1200012 /* Master, propagated to newvers */ +#define __FreeBSD_version 1200013 /* Master, propagated to newvers */ /* * __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD, From owner-svn-src-all@freebsd.org Wed Oct 12 11:17:11 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A6A2BC0E87A; Wed, 12 Oct 2016 11:17:11 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 783CE302; Wed, 12 Oct 2016 11:17:11 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9CBHAY7053323; Wed, 12 Oct 2016 11:17:10 GMT (envelope-from avg@FreeBSD.org) Received: (from avg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9CBHAUm053322; Wed, 12 Oct 2016 11:17:10 GMT (envelope-from avg@FreeBSD.org) Message-Id: <201610121117.u9CBHAUm053322@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avg set sender to avg@FreeBSD.org using -f From: Andriy Gapon Date: Wed, 12 Oct 2016 11:17:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307141 - head/sys/sys X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Oct 2016 11:17:11 -0000 Author: avg Date: Wed Oct 12 11:17:10 2016 New Revision: 307141 URL: https://svnweb.freebsd.org/changeset/base/307141 Log: remove a few stray spaces from sys/param.h Modified: head/sys/sys/param.h Modified: head/sys/sys/param.h ============================================================================== --- head/sys/sys/param.h Wed Oct 12 11:12:31 2016 (r307140) +++ head/sys/sys/param.h Wed Oct 12 11:17:10 2016 (r307141) @@ -44,7 +44,7 @@ #define BSD4_3 1 #define BSD4_4 1 -/* +/* * __FreeBSD_version numbers are documented in the Porter's Handbook. * If you bump the version for any reason, you should update the documentation * there. @@ -241,7 +241,7 @@ * * BKVASIZE - Nominal buffer space per buffer, in bytes. BKVASIZE is the * minimum KVM memory reservation the kernel is willing to make. - * Filesystems can of course request smaller chunks. Actual + * Filesystems can of course request smaller chunks. Actual * backing memory uses a chunk size of a page (PAGE_SIZE). * The default value here can be overridden on a per-architecture * basis by defining it in . This should @@ -250,8 +250,8 @@ * * If you make BKVASIZE too small you risk seriously fragmenting * the buffer KVM map which may slow things down a bit. If you - * make it too big the kernel will not be able to optimally use - * the KVM memory reserved for the buffer cache and will wind + * make it too big the kernel will not be able to optimally use + * the KVM memory reserved for the buffer cache and will wind * up with too-few buffers. * * The default is 16384, roughly 2x the block size used by a @@ -344,7 +344,7 @@ __END_DECLS #define dbtoc(db) /* calculates devblks to pages */ \ ((db + (ctodb(1) - 1)) >> (PAGE_SHIFT - DEV_BSHIFT)) - + #define ctodb(db) /* calculates pages to devblks */ \ ((db) << (PAGE_SHIFT - DEV_BSHIFT)) From owner-svn-src-all@freebsd.org Wed Oct 12 11:48:16 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 0CA3CC0EDF8; Wed, 12 Oct 2016 11:48:16 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id C2141229; Wed, 12 Oct 2016 11:48:15 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9CBmErf064448; Wed, 12 Oct 2016 11:48:14 GMT (envelope-from avg@FreeBSD.org) Received: (from avg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9CBmEpo064447; Wed, 12 Oct 2016 11:48:14 GMT (envelope-from avg@FreeBSD.org) Message-Id: <201610121148.u9CBmEpo064447@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avg set sender to avg@FreeBSD.org using -f From: Andriy Gapon Date: Wed, 12 Oct 2016 11:48:14 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307142 - stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Oct 2016 11:48:16 -0000 Author: avg Date: Wed Oct 12 11:48:14 2016 New Revision: 307142 URL: https://svnweb.freebsd.org/changeset/base/307142 Log: MFC r306665: zfs: fix a wrong assertion for extended attributes PR: 213112 Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c ============================================================================== --- stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c Wed Oct 12 11:17:10 2016 (r307141) +++ stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c Wed Oct 12 11:48:14 2016 (r307142) @@ -1454,7 +1454,8 @@ zfs_lookup_lock(vnode_t *dvp, vnode_t *v ASSERT_VOP_LOCKED(dvp, __func__); #ifdef DIAGNOSTIC - ASSERT(!RRM_LOCK_HELD(&zfsvfs->z_teardown_lock)); + if ((zdp->z_pflags & ZFS_XATTR) == 0) + VERIFY(!RRM_LOCK_HELD(&zfsvfs->z_teardown_lock)); #endif if (name[0] == 0 || (name[0] == '.' && name[1] == 0)) { @@ -5973,13 +5974,15 @@ zfs_lock(ap) vp = ap->a_vp; flags = ap->a_flags; if ((flags & LK_INTERLOCK) == 0 && (flags & LK_NOWAIT) == 0 && - (vp->v_iflag & VI_DOOMED) == 0 && (zp = vp->v_data) != NULL) { + (vp->v_iflag & VI_DOOMED) == 0 && (zp = vp->v_data) != NULL && + (zp->z_pflags & ZFS_XATTR) == 0) { zfsvfs = zp->z_zfsvfs; VERIFY(!RRM_LOCK_HELD(&zfsvfs->z_teardown_lock)); } err = vop_stdlock(ap); if ((flags & LK_INTERLOCK) != 0 && (flags & LK_NOWAIT) == 0 && - (vp->v_iflag & VI_DOOMED) == 0 && (zp = vp->v_data) != NULL) { + (vp->v_iflag & VI_DOOMED) == 0 && (zp = vp->v_data) != NULL && + (zp->z_pflags & ZFS_XATTR) == 0) { zfsvfs = zp->z_zfsvfs; VERIFY(!RRM_LOCK_HELD(&zfsvfs->z_teardown_lock)); } From owner-svn-src-all@freebsd.org Wed Oct 12 11:48:49 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 4A8C7C0EE88; Wed, 12 Oct 2016 11:48:49 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 16E543D8; Wed, 12 Oct 2016 11:48:49 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9CBmmm9064520; Wed, 12 Oct 2016 11:48:48 GMT (envelope-from avg@FreeBSD.org) Received: (from avg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9CBmm8M064519; Wed, 12 Oct 2016 11:48:48 GMT (envelope-from avg@FreeBSD.org) Message-Id: <201610121148.u9CBmm8M064519@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avg set sender to avg@FreeBSD.org using -f From: Andriy Gapon Date: Wed, 12 Oct 2016 11:48:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307143 - stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Oct 2016 11:48:49 -0000 Author: avg Date: Wed Oct 12 11:48:47 2016 New Revision: 307143 URL: https://svnweb.freebsd.org/changeset/base/307143 Log: MFC r306665: zfs: fix a wrong assertion for extended attributes PR: 213112 Modified: stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c ============================================================================== --- stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c Wed Oct 12 11:48:14 2016 (r307142) +++ stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c Wed Oct 12 11:48:47 2016 (r307143) @@ -1454,7 +1454,8 @@ zfs_lookup_lock(vnode_t *dvp, vnode_t *v ASSERT_VOP_LOCKED(dvp, __func__); #ifdef DIAGNOSTIC - ASSERT(!RRM_LOCK_HELD(&zfsvfs->z_teardown_lock)); + if ((zdp->z_pflags & ZFS_XATTR) == 0) + VERIFY(!RRM_LOCK_HELD(&zfsvfs->z_teardown_lock)); #endif if (name[0] == 0 || (name[0] == '.' && name[1] == 0)) { @@ -6017,13 +6018,15 @@ zfs_lock(ap) vp = ap->a_vp; flags = ap->a_flags; if ((flags & LK_INTERLOCK) == 0 && (flags & LK_NOWAIT) == 0 && - (vp->v_iflag & VI_DOOMED) == 0 && (zp = vp->v_data) != NULL) { + (vp->v_iflag & VI_DOOMED) == 0 && (zp = vp->v_data) != NULL && + (zp->z_pflags & ZFS_XATTR) == 0) { zfsvfs = zp->z_zfsvfs; VERIFY(!RRM_LOCK_HELD(&zfsvfs->z_teardown_lock)); } err = vop_stdlock(ap); if ((flags & LK_INTERLOCK) != 0 && (flags & LK_NOWAIT) == 0 && - (vp->v_iflag & VI_DOOMED) == 0 && (zp = vp->v_data) != NULL) { + (vp->v_iflag & VI_DOOMED) == 0 && (zp = vp->v_data) != NULL && + (zp->z_pflags & ZFS_XATTR) == 0) { zfsvfs = zp->z_zfsvfs; VERIFY(!RRM_LOCK_HELD(&zfsvfs->z_teardown_lock)); } From owner-svn-src-all@freebsd.org Wed Oct 12 11:49:29 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id AC7D3C0EEEA; Wed, 12 Oct 2016 11:49:29 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 35A137BD; Wed, 12 Oct 2016 11:49:29 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from tom.home (kib@localhost [127.0.0.1]) by kib.kiev.ua (8.15.2/8.15.2) with ESMTPS id u9CBnLKT031669 (version=TLSv1 cipher=DHE-RSA-CAMELLIA256-SHA bits=256 verify=NO); Wed, 12 Oct 2016 14:49:21 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua u9CBnLKT031669 Received: (from kostik@localhost) by tom.home (8.15.2/8.15.2/Submit) id u9CBnKKI031668; Wed, 12 Oct 2016 14:49:20 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Wed, 12 Oct 2016 14:49:20 +0300 From: Konstantin Belousov To: Warner Losh Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r307070 - in head/sys: amd64/amd64 conf dev/efidev i386/include modules/efirt sys Message-ID: <20161012114920.GU68202@kib.kiev.ua> References: <201610112224.u9BMOUlp053188@repo.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <201610112224.u9BMOUlp053188@repo.freebsd.org> User-Agent: Mutt/1.7.0 (2016-08-17) X-Spam-Status: No, score=-2.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on tom.home X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Oct 2016 11:49:29 -0000 On Tue, Oct 11, 2016 at 10:24:30PM +0000, Warner Losh wrote: > Added: head/sys/dev/efidev/efidev.c > ============================================================================== > --- /dev/null 00:00:00 1970 (empty, because file is newly added) > +++ head/sys/dev/efidev/efidev.c Tue Oct 11 22:24:30 2016 (r307070) > @@ -0,0 +1,199 @@ > +/*- > + * Copyright (c) 2016 Netflix, Inc. > + * All rights reserved. > + * > + * Redistribution and use in source and binary forms, with or without > + * modification, are permitted provided that the following conditions > + * are met: > + * 1. Redistributions of source code must retain the above copyright > + * notice, this list of conditions and the following disclaimer > + * in this position and unchanged. > + * 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 ``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 BE LIABLE FOR ANY DIRECT, INDIRECT, > + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT > + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, > + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY > + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT > + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF > + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. > + */ > + > +#include > +__FBSDID("$FreeBSD$"); > + > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > +#include As I asked in review, please use , not > +#include > + > +static d_ioctl_t efidev_ioctl; > + > +static struct cdevsw efi_cdevsw = { > + .d_name = "efi", > + .d_version = D_VERSION, > + .d_ioctl = efidev_ioctl, > +}; > + > +/* ARGSUSED */ > +static int > +efidev_ioctl(struct cdev *dev __unused, u_long cmd, caddr_t addr, > + int flags __unused, struct thread *td __unused) > +{ > + int error; > + > + switch (cmd) { > + case EFIIOC_GET_TABLE: > + { > + struct efi_get_table_ioc *egtioc = > + (struct efi_get_table_ioc *)addr; > + > + error = efi_get_table(&egtioc->uuid, &egtioc->ptr); > + break; > + } > + case EFIIOC_GET_TIME: > + { > + struct efi_tm *tm = (struct efi_tm *)addr; > + > + error = efi_get_time(tm); > + break; > + } > + case EFIIOC_SET_TIME: > + { > + struct efi_tm *tm = (struct efi_tm *)addr; > + > + error = efi_set_time(tm); > + break; > + } > + case EFIIOC_VAR_GET: > + { > + struct efi_var_ioc *ev = (struct efi_var_ioc *)addr; > + void *data; > + efi_char *name; > + > + data = malloc(ev->datasize, M_TEMP, M_WAITOK); > + name = malloc(ev->namesize, M_TEMP, M_WAITOK); > + error = copyin(ev->name, name, ev->namesize); > + if (error) > + goto vg_out; > + if (name[ev->namesize / sizeof(efi_char) - 1] != 0) { > + error = EINVAL; > + goto vg_out; > + } > + > + error = efi_var_get(name, &ev->vendor, &ev->attrib, > + &ev->datasize, data); > + > + if (error == 0) { > + error = copyout(data, ev->data, ev->datasize); > + } else if (error == EOVERFLOW) { > + /* > + * Pass back the size we really need, but > + * convert the error to 0 so the copyout > + * happens. datasize was updated in the > + * efi_var_get call. > + */ > + ev->data = NULL; > + error = 0; > + } > +vg_out: > + free(data, M_TEMP); > + free(name, M_TEMP); > + break; > + } > + case EFIIOC_VAR_NEXT: > + { > + struct efi_var_ioc *ev = (struct efi_var_ioc *)addr; > + efi_char *name; > + > + name = malloc(ev->namesize, M_TEMP, M_WAITOK); > + if (name == NULL) { The check is for impossible condition. > + error = ENOMEM; > + goto vn_out; > + } > + error = copyin(ev->name, name, ev->namesize); > + if (error) > + goto vn_out; > + /* Note: namesize is the buffer size, not the string lenght */ > + > + error = efi_var_nextname(&ev->namesize, name, &ev->vendor); > + if (error == 0) { > + error = copyout(name, ev->name, ev->namesize); > + } else if (error == EOVERFLOW) { > + ev->name = NULL; > + error = 0; > + } > + vn_out: > + if (name != NULL) The check is redundand. > + free(name, M_TEMP); > + break; > + } > + case EFIIOC_VAR_SET: > + { > + struct efi_var_ioc *ev = (struct efi_var_ioc *)addr; > + void *data = NULL; > + efi_char *name; > + > + /* datasize == 0 -> delete (more or less) */ > + if (ev->datasize > 0) > + data = malloc(ev->datasize, M_TEMP, M_WAITOK); > + name = malloc(ev->namesize, M_TEMP, M_WAITOK); > + if (ev->datasize) { > + error = copyin(ev->data, data, ev->datasize); > + if (error) > + goto vs_out; > + } > + error = copyin(ev->name, name, ev->namesize); > + if (error) > + goto vs_out; > + if (name[ev->namesize / sizeof(efi_char) - 1] != 0) { > + error = EINVAL; > + goto vs_out; > + } > + > + error = efi_var_set(name, &ev->vendor, ev->attrib, ev->datasize, > + data); > +vs_out: > + if (data != NULL) The check is redundand. > + free(data, M_TEMP); > + free(name, M_TEMP); > + break; > + } > + default: > + error = ENOTTY; > + break; > + } > + > + return (error); > +} > + > +int > +efidev_init(struct cdev **cdev) > +{ > + > + *cdev = make_dev(&efi_cdevsw, 0, UID_ROOT, GID_WHEEL, 0700, > + "efidev"); It is still "/dev/efidev". Please rename as discussed. > + > + return (0); > +} > + > +int > +efidev_uninit(struct cdev *cdev) > +{ > + > + destroy_dev(cdev); > + > + return (0); > +} > > Added: head/sys/i386/include/efi.h > ============================================================================== > --- /dev/null 00:00:00 1970 (empty, because file is newly added) > +++ head/sys/i386/include/efi.h Tue Oct 11 22:24:30 2016 (r307070) > @@ -0,0 +1,39 @@ > +/*- > + * Copyright (c) 2016 The FreeBSD Foundation > + * All rights reserved. > + * > + * This software was developed by Konstantin Belousov > + * under sponsorship from the FreeBSD Foundation. It was not. > + * > + * Redistribution and use in source and binary forms, with or without > + * modification, are permitted provided that the following conditions > + * are met: > + * 1. Redistributions of source code must retain the above copyright > + * notice, this list of conditions and the following disclaimer. > + * 2. Redistributions in binary form must reproduce the above copyright > + * notice, this list of conditions and the following disclaimer in the > + * documentation and/or other materials provided with the distribution. > + * > + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND > + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE > + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > + * SUCH DAMAGE. > + * > + * $FreeBSD$ > + */ > + > +#ifndef __I386_INCLUDE_EFI_H_ > +#define __I386_INCLUDE_EFI_H_ > + > +#define EFIABI_ATTR /* __attribute__((ms_abi)) */ /* clang fails with this */ > + > +/* Note: we don't actually support this on i386 yet */ > + > +#endif /* __I386_INCLUDE_EFI_H_ */ From owner-svn-src-all@freebsd.org Wed Oct 12 12:17:44 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id BA546C0D0B5; Wed, 12 Oct 2016 12:17:44 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 5E1A0D8C; Wed, 12 Oct 2016 12:17:44 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9CCHhvr075618; Wed, 12 Oct 2016 12:17:43 GMT (envelope-from ed@FreeBSD.org) Received: (from ed@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9CCHgdP075603; Wed, 12 Oct 2016 12:17:42 GMT (envelope-from ed@FreeBSD.org) Message-Id: <201610121217.u9CCHgdP075603@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ed set sender to ed@FreeBSD.org using -f From: Ed Schouten Date: Wed, 12 Oct 2016 12:17:42 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307144 - in stable/11: share/man/man4 sys/amd64/cloudabi32 sys/amd64/cloudabi64 sys/amd64/conf sys/arm/cloudabi32 sys/arm64/cloudabi64 sys/compat/cloudabi sys/compat/cloudabi32 sys/com... X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Oct 2016 12:17:44 -0000 Author: ed Date: Wed Oct 12 12:17:41 2016 New Revision: 307144 URL: https://svnweb.freebsd.org/changeset/base/307144 Log: MFC r303818, r303833, r303941, r304478, r304481, r304483, r304484, r304554, r304555, r304556, r304557, r304558, r304559, r304561, r304563, r304564, r304565, r304615, r304742, r304743, r304744, r304745, r304748, r304886, r304991, r305928, r305938, r305987, r306185: Bring CloudABI support back in sync with HEAD. - Add support for running 32-bit executables on amd64, armv6 and i386. - As these new architectures require the use of the vDSO, merge back vDSO support for 64-bit executables running on amd64 and arm64 as well. This has the advantage that support for vDSO-less execution can be phased out when 11.0 becomes unsupported, as opposed to 11.x. This change has been tested by running the cloudlibc unit tests on all supported architectures, which seems to work fine. Added: stable/11/sys/amd64/cloudabi32/ - copied from r304744, head/sys/amd64/cloudabi32/ stable/11/sys/arm/cloudabi32/ - copied from r305928, head/sys/arm/cloudabi32/ stable/11/sys/compat/cloudabi/cloudabi_vdso.c - copied unchanged from r303941, head/sys/compat/cloudabi/cloudabi_vdso.c stable/11/sys/compat/cloudabi/cloudabi_vdso.lds - copied unchanged from r304557, head/sys/compat/cloudabi/cloudabi_vdso.lds stable/11/sys/compat/cloudabi32/ - copied from r304564, head/sys/compat/cloudabi32/ stable/11/sys/compat/cloudabi32/cloudabi32_proto.h - copied unchanged from r304565, head/sys/compat/cloudabi32/cloudabi32_proto.h stable/11/sys/compat/cloudabi32/cloudabi32_syscall.h - copied unchanged from r304565, head/sys/compat/cloudabi32/cloudabi32_syscall.h stable/11/sys/compat/cloudabi32/cloudabi32_syscalls.c - copied unchanged from r304565, head/sys/compat/cloudabi32/cloudabi32_syscalls.c stable/11/sys/compat/cloudabi32/cloudabi32_sysent.c - copied unchanged from r304565, head/sys/compat/cloudabi32/cloudabi32_sysent.c stable/11/sys/compat/cloudabi32/cloudabi32_systrace_args.c - copied unchanged from r304565, head/sys/compat/cloudabi32/cloudabi32_systrace_args.c stable/11/sys/contrib/cloudabi/cloudabi32_types.h - copied unchanged from r304561, head/sys/contrib/cloudabi/cloudabi32_types.h stable/11/sys/contrib/cloudabi/cloudabi_vdso_aarch64.S - copied unchanged from r304554, head/sys/contrib/cloudabi/cloudabi_vdso_aarch64.S stable/11/sys/contrib/cloudabi/cloudabi_vdso_armv6.S - copied, changed from r305928, head/sys/contrib/cloudabi/cloudabi_vdso_armv6.S stable/11/sys/contrib/cloudabi/cloudabi_vdso_i686.S - copied, changed from r304615, head/sys/contrib/cloudabi/cloudabi_vdso_i686.S stable/11/sys/contrib/cloudabi/cloudabi_vdso_i686_on_64bit.S - copied unchanged from r304744, head/sys/contrib/cloudabi/cloudabi_vdso_i686_on_64bit.S stable/11/sys/contrib/cloudabi/cloudabi_vdso_x86_64.S - copied unchanged from r304554, head/sys/contrib/cloudabi/cloudabi_vdso_x86_64.S stable/11/sys/contrib/cloudabi/syscalls32.master - copied, changed from r304561, head/sys/contrib/cloudabi/syscalls32.master - copied unchanged from r304478, head/sys/contrib/cloudabi/syscalls64.master stable/11/sys/i386/cloudabi32/ - copied from r304615, head/sys/i386/cloudabi32/ stable/11/sys/modules/cloudabi32/ - copied from r304745, head/sys/modules/cloudabi32/ Directory Properties: stable/11/sys/contrib/cloudabi/syscalls64.master (props changed) Deleted: stable/11/sys/contrib/cloudabi/syscalls.master Modified: stable/11/share/man/man4/cloudabi.4 stable/11/sys/amd64/cloudabi64/cloudabi64_sysvec.c stable/11/sys/amd64/conf/NOTES stable/11/sys/arm64/cloudabi64/cloudabi64_sysvec.c stable/11/sys/compat/cloudabi/cloudabi_clock.c stable/11/sys/compat/cloudabi/cloudabi_thread.c stable/11/sys/compat/cloudabi/cloudabi_util.h stable/11/sys/compat/cloudabi64/Makefile stable/11/sys/compat/cloudabi64/cloudabi64_fd.c stable/11/sys/compat/cloudabi64/cloudabi64_module.c stable/11/sys/compat/cloudabi64/cloudabi64_poll.c stable/11/sys/compat/cloudabi64/cloudabi64_proto.h stable/11/sys/compat/cloudabi64/cloudabi64_sock.c stable/11/sys/compat/cloudabi64/cloudabi64_syscall.h stable/11/sys/compat/cloudabi64/cloudabi64_syscalls.c stable/11/sys/compat/cloudabi64/cloudabi64_sysent.c stable/11/sys/compat/cloudabi64/cloudabi64_systrace_args.c stable/11/sys/compat/cloudabi64/cloudabi64_util.h stable/11/sys/conf/files stable/11/sys/conf/files.amd64 stable/11/sys/conf/files.arm stable/11/sys/conf/files.arm64 stable/11/sys/conf/files.i386 stable/11/sys/conf/options stable/11/sys/contrib/cloudabi/cloudabi64_types.h stable/11/sys/contrib/cloudabi/cloudabi_types_common.h stable/11/sys/i386/cloudabi32/cloudabi32_sysvec.c stable/11/sys/i386/conf/NOTES stable/11/sys/modules/Makefile stable/11/sys/modules/cloudabi/Makefile stable/11/sys/modules/cloudabi32/Makefile stable/11/sys/modules/cloudabi64/Makefile stable/11/usr.bin/truss/syscalls.c Directory Properties: stable/11/ (props changed) Modified: stable/11/share/man/man4/cloudabi.4 ============================================================================== --- stable/11/share/man/man4/cloudabi.4 Wed Oct 12 11:48:47 2016 (r307143) +++ stable/11/share/man/man4/cloudabi.4 Wed Oct 12 12:17:41 2016 (r307144) @@ -1,4 +1,4 @@ -.\" Copyright (c) 2015 Nuxi, https://nuxi.nl/ +.\" Copyright (c) 2015-2016 Nuxi, https://nuxi.nl/ .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions @@ -22,17 +22,25 @@ .\" SUCH DAMAGE. .\" .\" $FreeBSD$ -.Dd October 22, 2015 +.Dd September 22, 2016 .Dt CLOUDABI 4 .Os .Sh NAME .Nm cloudabi , +.Nm cloudabi32 , .Nm cloudabi64 .Nd CloudABI support .Sh SYNOPSIS -Support for 64-bit CloudABI executables can be compiled into the kernel +Support for 32-bit CloudABI executables can be compiled into the kernel by adding this line to the kernel configuration file: .Bd -ragged -offset indent +.Cd "options COMPAT_CLOUDABI32" +.Ed +.Pp +Similarly, +support for 64-bit CloudABI executables can be enabled by adding this +line: +.Bd -ragged -offset indent .Cd "options COMPAT_CLOUDABI64" .Ed .Pp @@ -40,6 +48,7 @@ CloudABI support can also be loaded at b .Xr loader.conf 5 : .Bd -literal -offset indent cloudabi_load="YES" +cloudabi32_load="YES" cloudabi64_load="YES" .Ed .Sh DESCRIPTION @@ -52,19 +61,21 @@ and hardened against security exploits. .Pp Support for CloudABI on .Fx -consists of two separate kernel modules. +consists of three separate kernel modules. The .Nm cloudabi kernel module implements all of the system calls that do not depend on -data structures that differ between architectures. +data structures that differ between hardware architectures. .Pp The +.Nm cloudabi32 +and .Nm cloudabi64 -kernel module provides implementations of all of the machine-dependent -system calls. -It assumes that pointers stored in data structures provided as system -call arguments are 64 bits in size. -It also provides the image activator that loads and starts 64-bit ELF +kernel modules provide implementations of all of the machine-dependent +system calls, +assuming that pointers stored in data structures are either 32 bits or +64 bits in size. +These modules also provide the image activators that load and start ELF executables. .Pp Though the @@ -72,8 +83,12 @@ Though the module can be loaded on any architecture supported by .Fx , the +.Nm cloudabi32 +module is only available on amd64, armv6 and i386. +The same holds for the .Nm cloudabi64 -module is only available for amd64 and arm64. +module, +which is only available for amd64 and arm64. .Pp A full cross compilation toolchain for CloudABI is available in the .Pa devel/cloudabi-toolchain @@ -93,6 +108,9 @@ restricted set of resources. .Xr linux 4 , .Xr elf 5 .Pp +CloudABI for FreeBSD: +.Pa https://nuxi.nl/cloudabi/freebsd/ . +.Pp cloudlibc on GitHub: .Pa https://github.com/NuxiNL/cloudlibc . .Pp Modified: stable/11/sys/amd64/cloudabi64/cloudabi64_sysvec.c ============================================================================== --- stable/11/sys/amd64/cloudabi64/cloudabi64_sysvec.c Wed Oct 12 11:48:47 2016 (r307143) +++ stable/11/sys/amd64/cloudabi64/cloudabi64_sysvec.c Wed Oct 12 12:17:41 2016 (r307144) @@ -171,9 +171,9 @@ cloudabi64_thread_setregs(struct thread return (error); /* Perform standard register initialization. */ - stack.ss_sp = (void *)attr->stack; + stack.ss_sp = TO_PTR(attr->stack); stack.ss_size = tcbptr - attr->stack; - cpu_set_upcall(td, (void *)attr->entry_point, NULL, &stack); + cpu_set_upcall(td, TO_PTR(attr->entry_point), NULL, &stack); /* * Pass in the thread ID of the new thread and the argument @@ -196,7 +196,6 @@ static struct sysentvec cloudabi64_elf_s .sv_pagesize = PAGE_SIZE, .sv_minuser = VM_MIN_ADDRESS, .sv_maxuser = VM_MAXUSER_ADDRESS, - .sv_usrstack = USRSTACK, .sv_stackprot = VM_PROT_READ | VM_PROT_WRITE, .sv_copyout_strings = cloudabi64_copyout_strings, .sv_setregs = cloudabi64_proc_setregs, Modified: stable/11/sys/amd64/conf/NOTES ============================================================================== --- stable/11/sys/amd64/conf/NOTES Wed Oct 12 11:48:47 2016 (r307143) +++ stable/11/sys/amd64/conf/NOTES Wed Oct 12 12:17:41 2016 (r307144) @@ -618,6 +618,9 @@ options COMPAT_FREEBSD32 # Emulate spx device for client side of SVR3 local X interface #XXX#options SPX_HACK +# Enable 32-bit runtime support for CloudABI binaries. +options COMPAT_CLOUDABI32 + # Enable 64-bit runtime support for CloudABI binaries. options COMPAT_CLOUDABI64 Modified: stable/11/sys/arm64/cloudabi64/cloudabi64_sysvec.c ============================================================================== --- stable/11/sys/arm64/cloudabi64/cloudabi64_sysvec.c Wed Oct 12 11:48:47 2016 (r307143) +++ stable/11/sys/arm64/cloudabi64/cloudabi64_sysvec.c Wed Oct 12 12:17:41 2016 (r307144) @@ -139,9 +139,9 @@ cloudabi64_thread_setregs(struct thread stack_t stack; /* Perform standard register initialization. */ - stack.ss_sp = (void *)attr->stack; + stack.ss_sp = TO_PTR(attr->stack); stack.ss_size = attr->stack_size; - cpu_set_upcall(td, (void *)attr->entry_point, NULL, &stack); + cpu_set_upcall(td, TO_PTR(attr->entry_point), NULL, &stack); /* * Pass in the thread ID of the new thread and the argument @@ -165,7 +165,6 @@ static struct sysentvec cloudabi64_elf_s .sv_pagesize = PAGE_SIZE, .sv_minuser = VM_MIN_ADDRESS, .sv_maxuser = VM_MAXUSER_ADDRESS, - .sv_usrstack = USRSTACK, .sv_stackprot = VM_PROT_READ | VM_PROT_WRITE, .sv_copyout_strings = cloudabi64_copyout_strings, .sv_setregs = cloudabi64_proc_setregs, Modified: stable/11/sys/compat/cloudabi/cloudabi_clock.c ============================================================================== --- stable/11/sys/compat/cloudabi/cloudabi_clock.c Wed Oct 12 11:48:47 2016 (r307143) +++ stable/11/sys/compat/cloudabi/cloudabi_clock.c Wed Oct 12 12:17:41 2016 (r307144) @@ -117,7 +117,7 @@ cloudabi_sys_clock_res_get(struct thread error = cloudabi_convert_timespec(&ts, &cts); if (error != 0) return (error); - td->td_retval[0] = cts; + memcpy(td->td_retval, &cts, sizeof(cts)); return (0); } @@ -129,6 +129,6 @@ cloudabi_sys_clock_time_get(struct threa int error; error = cloudabi_clock_time_get(td, uap->clock_id, &ts); - td->td_retval[0] = ts; + memcpy(td->td_retval, &ts, sizeof(ts)); return (error); } Modified: stable/11/sys/compat/cloudabi/cloudabi_thread.c ============================================================================== --- stable/11/sys/compat/cloudabi/cloudabi_thread.c Wed Oct 12 11:48:47 2016 (r307143) +++ stable/11/sys/compat/cloudabi/cloudabi_thread.c Wed Oct 12 12:17:41 2016 (r307144) @@ -60,14 +60,6 @@ cloudabi_sys_thread_exit(struct thread * } int -cloudabi_sys_thread_tcb_set(struct thread *td, - struct cloudabi_sys_thread_tcb_set_args *uap) -{ - - return (cpu_set_user_tls(td, uap->tcb)); -} - -int cloudabi_sys_thread_yield(struct thread *td, struct cloudabi_sys_thread_yield_args *uap) { Modified: stable/11/sys/compat/cloudabi/cloudabi_util.h ============================================================================== --- stable/11/sys/compat/cloudabi/cloudabi_util.h Wed Oct 12 11:48:47 2016 (r307143) +++ stable/11/sys/compat/cloudabi/cloudabi_util.h Wed Oct 12 12:17:41 2016 (r307144) @@ -33,6 +33,7 @@ #include struct file; +struct sysentvec; struct thread; struct timespec; @@ -76,4 +77,8 @@ int cloudabi_futex_lock_wrlock(struct th cloudabi_scope_t, cloudabi_clockid_t, cloudabi_timestamp_t, cloudabi_timestamp_t); +/* vDSO setup and teardown. */ +void cloudabi_vdso_init(struct sysentvec *, char *, char *); +void cloudabi_vdso_destroy(struct sysentvec *); + #endif Copied: stable/11/sys/compat/cloudabi/cloudabi_vdso.c (from r303941, head/sys/compat/cloudabi/cloudabi_vdso.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/11/sys/compat/cloudabi/cloudabi_vdso.c Wed Oct 12 12:17:41 2016 (r307144, copy of r303941, head/sys/compat/cloudabi/cloudabi_vdso.c) @@ -0,0 +1,88 @@ +/*- + * Copyright (c) 2016 Nuxi, https://nuxi.nl/ + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include + +void +cloudabi_vdso_init(struct sysentvec *sv, char *begin, char *end) +{ + vm_page_t m; + vm_object_t obj; + vm_offset_t addr; + size_t i, pages, pages_length, vdso_length; + + /* Determine the number of pages needed to store the vDSO. */ + vdso_length = end - begin; + pages = howmany(vdso_length, PAGE_SIZE); + pages_length = pages * PAGE_SIZE; + + /* Allocate a VM object and fill it with the vDSO. */ + obj = vm_pager_allocate(OBJT_PHYS, 0, pages_length, + VM_PROT_DEFAULT, 0, NULL); + addr = kva_alloc(PAGE_SIZE); + for (i = 0; i < pages; ++i) { + VM_OBJECT_WLOCK(obj); + m = vm_page_grab(obj, i, VM_ALLOC_NOBUSY | VM_ALLOC_ZERO); + m->valid = VM_PAGE_BITS_ALL; + VM_OBJECT_WUNLOCK(obj); + + pmap_qenter(addr, &m, 1); + memcpy((void *)addr, begin + i * PAGE_SIZE, + MIN(vdso_length - i * PAGE_SIZE, PAGE_SIZE)); + pmap_qremove(addr, 1); + } + kva_free(addr, PAGE_SIZE); + + /* + * Place the vDSO at the top of the address space. The user + * stack can start right below it. + */ + sv->sv_shared_page_base = sv->sv_maxuser - pages_length; + sv->sv_shared_page_len = pages_length; + sv->sv_shared_page_obj = obj; + sv->sv_usrstack = sv->sv_shared_page_base; +} + +void +cloudabi_vdso_destroy(struct sysentvec *sv) +{ + + vm_object_deallocate(sv->sv_shared_page_obj); +} Copied: stable/11/sys/compat/cloudabi/cloudabi_vdso.lds (from r304557, head/sys/compat/cloudabi/cloudabi_vdso.lds) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/11/sys/compat/cloudabi/cloudabi_vdso.lds Wed Oct 12 12:17:41 2016 (r307144, copy of r304557, head/sys/compat/cloudabi/cloudabi_vdso.lds) @@ -0,0 +1,51 @@ +/* + * Linker script for the vDSO for CloudABI. + * Based on sys/amd64/linux/linux_vdso.lds.s + * + * $FreeBSD$ + */ + +SECTIONS +{ + . = . + SIZEOF_HEADERS; + + .hash : { *(.hash) } :text + .gnu.hash : { *(.gnu.hash) } + .dynsym : { *(.dynsym) } + .dynstr : { *(.dynstr) } + .gnu.version : { *(.gnu.version) } + .gnu.version_d : { *(.gnu.version_d) } + .gnu.version_r : { *(.gnu.version_r) } + + .note : { *(.note.*) } :text :note + + .eh_frame_hdr : { *(.eh_frame_hdr) } :text :eh_frame_hdr + .eh_frame : { KEEP (*(.eh_frame)) } :text + + .dynamic : { *(.dynamic) } :text :dynamic + + .rodata : { *(.rodata*) } :text + .data : { + *(.data*) + *(.sdata*) + *(.got.plt) *(.got) + *(.gnu.linkonce.d.*) + *(.bss*) + *(.dynbss*) + *(.gnu.linkonce.b.*) + } + + .altinstructions : { *(.altinstructions) } + .altinstr_replacement : { *(.altinstr_replacement) } + + . = ALIGN(0x100); + .text : { *(.test .text*) } :text =0x90909090 +} + +PHDRS +{ + text PT_LOAD FLAGS(5) FILEHDR PHDRS; /* PF_R|PF_X */ + dynamic PT_DYNAMIC FLAGS(4); /* PF_R */ + note PT_NOTE FLAGS(4); /* PF_R */ + eh_frame_hdr PT_GNU_EH_FRAME; +} Copied: stable/11/sys/compat/cloudabi32/cloudabi32_proto.h (from r304565, head/sys/compat/cloudabi32/cloudabi32_proto.h) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/11/sys/compat/cloudabi32/cloudabi32_proto.h Wed Oct 12 12:17:41 2016 (r307144, copy of r304565, head/sys/compat/cloudabi32/cloudabi32_proto.h) @@ -0,0 +1,465 @@ +/* + * System call prototypes. + * + * DO NOT EDIT-- this file is automatically generated. + * $FreeBSD$ + * created from FreeBSD: head/sys/contrib/cloudabi/syscalls32.master 304563 2016-08-21 15:56:19Z ed + */ + +#ifndef _CLOUDABI32_SYSPROTO_H_ +#define _CLOUDABI32_SYSPROTO_H_ + +#include +#include +#include +#include +#include +#include +#include + +#include + +struct proc; + +struct thread; + +#define PAD_(t) (sizeof(register_t) <= sizeof(t) ? \ + 0 : sizeof(register_t) - sizeof(t)) + +#if BYTE_ORDER == LITTLE_ENDIAN +#define PADL_(t) 0 +#define PADR_(t) PAD_(t) +#else +#define PADL_(t) PAD_(t) +#define PADR_(t) 0 +#endif + +struct cloudabi_sys_clock_res_get_args { + char clock_id_l_[PADL_(cloudabi_clockid_t)]; cloudabi_clockid_t clock_id; char clock_id_r_[PADR_(cloudabi_clockid_t)]; +}; +struct cloudabi_sys_clock_time_get_args { + char clock_id_l_[PADL_(cloudabi_clockid_t)]; cloudabi_clockid_t clock_id; char clock_id_r_[PADR_(cloudabi_clockid_t)]; + char precision_l_[PADL_(cloudabi_timestamp_t)]; cloudabi_timestamp_t precision; char precision_r_[PADR_(cloudabi_timestamp_t)]; +}; +struct cloudabi_sys_condvar_signal_args { + char condvar_l_[PADL_(cloudabi_condvar_t *)]; cloudabi_condvar_t * condvar; char condvar_r_[PADR_(cloudabi_condvar_t *)]; + char scope_l_[PADL_(cloudabi_scope_t)]; cloudabi_scope_t scope; char scope_r_[PADR_(cloudabi_scope_t)]; + char nwaiters_l_[PADL_(cloudabi_nthreads_t)]; cloudabi_nthreads_t nwaiters; char nwaiters_r_[PADR_(cloudabi_nthreads_t)]; +}; +struct cloudabi_sys_fd_close_args { + char fd_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t fd; char fd_r_[PADR_(cloudabi_fd_t)]; +}; +struct cloudabi_sys_fd_create1_args { + char type_l_[PADL_(cloudabi_filetype_t)]; cloudabi_filetype_t type; char type_r_[PADR_(cloudabi_filetype_t)]; +}; +struct cloudabi_sys_fd_create2_args { + char type_l_[PADL_(cloudabi_filetype_t)]; cloudabi_filetype_t type; char type_r_[PADR_(cloudabi_filetype_t)]; +}; +struct cloudabi_sys_fd_datasync_args { + char fd_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t fd; char fd_r_[PADR_(cloudabi_fd_t)]; +}; +struct cloudabi_sys_fd_dup_args { + char from_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t from; char from_r_[PADR_(cloudabi_fd_t)]; +}; +struct cloudabi32_sys_fd_pread_args { + char fd_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t fd; char fd_r_[PADR_(cloudabi_fd_t)]; + char iov_l_[PADL_(const cloudabi32_iovec_t *)]; const cloudabi32_iovec_t * iov; char iov_r_[PADR_(const cloudabi32_iovec_t *)]; + char iovcnt_l_[PADL_(size_t)]; size_t iovcnt; char iovcnt_r_[PADR_(size_t)]; + char offset_l_[PADL_(cloudabi_filesize_t)]; cloudabi_filesize_t offset; char offset_r_[PADR_(cloudabi_filesize_t)]; +}; +struct cloudabi32_sys_fd_pwrite_args { + char fd_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t fd; char fd_r_[PADR_(cloudabi_fd_t)]; + char iov_l_[PADL_(const cloudabi32_ciovec_t *)]; const cloudabi32_ciovec_t * iov; char iov_r_[PADR_(const cloudabi32_ciovec_t *)]; + char iovcnt_l_[PADL_(size_t)]; size_t iovcnt; char iovcnt_r_[PADR_(size_t)]; + char offset_l_[PADL_(cloudabi_filesize_t)]; cloudabi_filesize_t offset; char offset_r_[PADR_(cloudabi_filesize_t)]; +}; +struct cloudabi32_sys_fd_read_args { + char fd_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t fd; char fd_r_[PADR_(cloudabi_fd_t)]; + char iov_l_[PADL_(const cloudabi32_iovec_t *)]; const cloudabi32_iovec_t * iov; char iov_r_[PADR_(const cloudabi32_iovec_t *)]; + char iovcnt_l_[PADL_(size_t)]; size_t iovcnt; char iovcnt_r_[PADR_(size_t)]; +}; +struct cloudabi_sys_fd_replace_args { + char from_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t from; char from_r_[PADR_(cloudabi_fd_t)]; + char to_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t to; char to_r_[PADR_(cloudabi_fd_t)]; +}; +struct cloudabi_sys_fd_seek_args { + char fd_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t fd; char fd_r_[PADR_(cloudabi_fd_t)]; + char offset_l_[PADL_(cloudabi_filedelta_t)]; cloudabi_filedelta_t offset; char offset_r_[PADR_(cloudabi_filedelta_t)]; + char whence_l_[PADL_(cloudabi_whence_t)]; cloudabi_whence_t whence; char whence_r_[PADR_(cloudabi_whence_t)]; +}; +struct cloudabi_sys_fd_stat_get_args { + char fd_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t fd; char fd_r_[PADR_(cloudabi_fd_t)]; + char buf_l_[PADL_(cloudabi_fdstat_t *)]; cloudabi_fdstat_t * buf; char buf_r_[PADR_(cloudabi_fdstat_t *)]; +}; +struct cloudabi_sys_fd_stat_put_args { + char fd_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t fd; char fd_r_[PADR_(cloudabi_fd_t)]; + char buf_l_[PADL_(const cloudabi_fdstat_t *)]; const cloudabi_fdstat_t * buf; char buf_r_[PADR_(const cloudabi_fdstat_t *)]; + char flags_l_[PADL_(cloudabi_fdsflags_t)]; cloudabi_fdsflags_t flags; char flags_r_[PADR_(cloudabi_fdsflags_t)]; +}; +struct cloudabi_sys_fd_sync_args { + char fd_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t fd; char fd_r_[PADR_(cloudabi_fd_t)]; +}; +struct cloudabi32_sys_fd_write_args { + char fd_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t fd; char fd_r_[PADR_(cloudabi_fd_t)]; + char iov_l_[PADL_(const cloudabi32_ciovec_t *)]; const cloudabi32_ciovec_t * iov; char iov_r_[PADR_(const cloudabi32_ciovec_t *)]; + char iovcnt_l_[PADL_(size_t)]; size_t iovcnt; char iovcnt_r_[PADR_(size_t)]; +}; +struct cloudabi_sys_file_advise_args { + char fd_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t fd; char fd_r_[PADR_(cloudabi_fd_t)]; + char offset_l_[PADL_(cloudabi_filesize_t)]; cloudabi_filesize_t offset; char offset_r_[PADR_(cloudabi_filesize_t)]; + char len_l_[PADL_(cloudabi_filesize_t)]; cloudabi_filesize_t len; char len_r_[PADR_(cloudabi_filesize_t)]; + char advice_l_[PADL_(cloudabi_advice_t)]; cloudabi_advice_t advice; char advice_r_[PADR_(cloudabi_advice_t)]; +}; +struct cloudabi_sys_file_allocate_args { + char fd_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t fd; char fd_r_[PADR_(cloudabi_fd_t)]; + char offset_l_[PADL_(cloudabi_filesize_t)]; cloudabi_filesize_t offset; char offset_r_[PADR_(cloudabi_filesize_t)]; + char len_l_[PADL_(cloudabi_filesize_t)]; cloudabi_filesize_t len; char len_r_[PADR_(cloudabi_filesize_t)]; +}; +struct cloudabi_sys_file_create_args { + char fd_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t fd; char fd_r_[PADR_(cloudabi_fd_t)]; + char path_l_[PADL_(const char *)]; const char * path; char path_r_[PADR_(const char *)]; + char pathlen_l_[PADL_(size_t)]; size_t pathlen; char pathlen_r_[PADR_(size_t)]; + char type_l_[PADL_(cloudabi_filetype_t)]; cloudabi_filetype_t type; char type_r_[PADR_(cloudabi_filetype_t)]; +}; +struct cloudabi_sys_file_link_args { + char fd1_l_[PADL_(cloudabi_lookup_t)]; cloudabi_lookup_t fd1; char fd1_r_[PADR_(cloudabi_lookup_t)]; + char path1_l_[PADL_(const char *)]; const char * path1; char path1_r_[PADR_(const char *)]; + char path1len_l_[PADL_(size_t)]; size_t path1len; char path1len_r_[PADR_(size_t)]; + char fd2_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t fd2; char fd2_r_[PADR_(cloudabi_fd_t)]; + char path2_l_[PADL_(const char *)]; const char * path2; char path2_r_[PADR_(const char *)]; + char path2len_l_[PADL_(size_t)]; size_t path2len; char path2len_r_[PADR_(size_t)]; +}; +struct cloudabi_sys_file_open_args { + char dirfd_l_[PADL_(cloudabi_lookup_t)]; cloudabi_lookup_t dirfd; char dirfd_r_[PADR_(cloudabi_lookup_t)]; + char path_l_[PADL_(const char *)]; const char * path; char path_r_[PADR_(const char *)]; + char pathlen_l_[PADL_(size_t)]; size_t pathlen; char pathlen_r_[PADR_(size_t)]; + char oflags_l_[PADL_(cloudabi_oflags_t)]; cloudabi_oflags_t oflags; char oflags_r_[PADR_(cloudabi_oflags_t)]; + char fds_l_[PADL_(const cloudabi_fdstat_t *)]; const cloudabi_fdstat_t * fds; char fds_r_[PADR_(const cloudabi_fdstat_t *)]; +}; +struct cloudabi_sys_file_readdir_args { + char fd_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t fd; char fd_r_[PADR_(cloudabi_fd_t)]; + char buf_l_[PADL_(void *)]; void * buf; char buf_r_[PADR_(void *)]; + char nbyte_l_[PADL_(size_t)]; size_t nbyte; char nbyte_r_[PADR_(size_t)]; + char cookie_l_[PADL_(cloudabi_dircookie_t)]; cloudabi_dircookie_t cookie; char cookie_r_[PADR_(cloudabi_dircookie_t)]; +}; +struct cloudabi_sys_file_readlink_args { + char fd_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t fd; char fd_r_[PADR_(cloudabi_fd_t)]; + char path_l_[PADL_(const char *)]; const char * path; char path_r_[PADR_(const char *)]; + char pathlen_l_[PADL_(size_t)]; size_t pathlen; char pathlen_r_[PADR_(size_t)]; + char buf_l_[PADL_(char *)]; char * buf; char buf_r_[PADR_(char *)]; + char bufsize_l_[PADL_(size_t)]; size_t bufsize; char bufsize_r_[PADR_(size_t)]; +}; +struct cloudabi_sys_file_rename_args { + char oldfd_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t oldfd; char oldfd_r_[PADR_(cloudabi_fd_t)]; + char old_l_[PADL_(const char *)]; const char * old; char old_r_[PADR_(const char *)]; + char oldlen_l_[PADL_(size_t)]; size_t oldlen; char oldlen_r_[PADR_(size_t)]; + char newfd_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t newfd; char newfd_r_[PADR_(cloudabi_fd_t)]; + char new_l_[PADL_(const char *)]; const char * new; char new_r_[PADR_(const char *)]; + char newlen_l_[PADL_(size_t)]; size_t newlen; char newlen_r_[PADR_(size_t)]; +}; +struct cloudabi_sys_file_stat_fget_args { + char fd_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t fd; char fd_r_[PADR_(cloudabi_fd_t)]; + char buf_l_[PADL_(cloudabi_filestat_t *)]; cloudabi_filestat_t * buf; char buf_r_[PADR_(cloudabi_filestat_t *)]; +}; +struct cloudabi_sys_file_stat_fput_args { + char fd_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t fd; char fd_r_[PADR_(cloudabi_fd_t)]; + char buf_l_[PADL_(const cloudabi_filestat_t *)]; const cloudabi_filestat_t * buf; char buf_r_[PADR_(const cloudabi_filestat_t *)]; + char flags_l_[PADL_(cloudabi_fsflags_t)]; cloudabi_fsflags_t flags; char flags_r_[PADR_(cloudabi_fsflags_t)]; +}; +struct cloudabi_sys_file_stat_get_args { + char fd_l_[PADL_(cloudabi_lookup_t)]; cloudabi_lookup_t fd; char fd_r_[PADR_(cloudabi_lookup_t)]; + char path_l_[PADL_(const char *)]; const char * path; char path_r_[PADR_(const char *)]; + char pathlen_l_[PADL_(size_t)]; size_t pathlen; char pathlen_r_[PADR_(size_t)]; + char buf_l_[PADL_(cloudabi_filestat_t *)]; cloudabi_filestat_t * buf; char buf_r_[PADR_(cloudabi_filestat_t *)]; +}; +struct cloudabi_sys_file_stat_put_args { + char fd_l_[PADL_(cloudabi_lookup_t)]; cloudabi_lookup_t fd; char fd_r_[PADR_(cloudabi_lookup_t)]; + char path_l_[PADL_(const char *)]; const char * path; char path_r_[PADR_(const char *)]; + char pathlen_l_[PADL_(size_t)]; size_t pathlen; char pathlen_r_[PADR_(size_t)]; + char buf_l_[PADL_(const cloudabi_filestat_t *)]; const cloudabi_filestat_t * buf; char buf_r_[PADR_(const cloudabi_filestat_t *)]; + char flags_l_[PADL_(cloudabi_fsflags_t)]; cloudabi_fsflags_t flags; char flags_r_[PADR_(cloudabi_fsflags_t)]; +}; +struct cloudabi_sys_file_symlink_args { + char path1_l_[PADL_(const char *)]; const char * path1; char path1_r_[PADR_(const char *)]; + char path1len_l_[PADL_(size_t)]; size_t path1len; char path1len_r_[PADR_(size_t)]; + char fd_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t fd; char fd_r_[PADR_(cloudabi_fd_t)]; + char path2_l_[PADL_(const char *)]; const char * path2; char path2_r_[PADR_(const char *)]; + char path2len_l_[PADL_(size_t)]; size_t path2len; char path2len_r_[PADR_(size_t)]; +}; +struct cloudabi_sys_file_unlink_args { + char fd_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t fd; char fd_r_[PADR_(cloudabi_fd_t)]; + char path_l_[PADL_(const char *)]; const char * path; char path_r_[PADR_(const char *)]; + char pathlen_l_[PADL_(size_t)]; size_t pathlen; char pathlen_r_[PADR_(size_t)]; + char flags_l_[PADL_(cloudabi_ulflags_t)]; cloudabi_ulflags_t flags; char flags_r_[PADR_(cloudabi_ulflags_t)]; +}; +struct cloudabi_sys_lock_unlock_args { + char lock_l_[PADL_(cloudabi_lock_t *)]; cloudabi_lock_t * lock; char lock_r_[PADR_(cloudabi_lock_t *)]; + char scope_l_[PADL_(cloudabi_scope_t)]; cloudabi_scope_t scope; char scope_r_[PADR_(cloudabi_scope_t)]; +}; +struct cloudabi_sys_mem_advise_args { + char addr_l_[PADL_(void *)]; void * addr; char addr_r_[PADR_(void *)]; + char len_l_[PADL_(size_t)]; size_t len; char len_r_[PADR_(size_t)]; + char advice_l_[PADL_(cloudabi_advice_t)]; cloudabi_advice_t advice; char advice_r_[PADR_(cloudabi_advice_t)]; +}; +struct cloudabi_sys_mem_lock_args { + char addr_l_[PADL_(const void *)]; const void * addr; char addr_r_[PADR_(const void *)]; + char len_l_[PADL_(size_t)]; size_t len; char len_r_[PADR_(size_t)]; +}; +struct cloudabi_sys_mem_map_args { + char addr_l_[PADL_(void *)]; void * addr; char addr_r_[PADR_(void *)]; + char len_l_[PADL_(size_t)]; size_t len; char len_r_[PADR_(size_t)]; + char prot_l_[PADL_(cloudabi_mprot_t)]; cloudabi_mprot_t prot; char prot_r_[PADR_(cloudabi_mprot_t)]; + char flags_l_[PADL_(cloudabi_mflags_t)]; cloudabi_mflags_t flags; char flags_r_[PADR_(cloudabi_mflags_t)]; + char fd_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t fd; char fd_r_[PADR_(cloudabi_fd_t)]; + char off_l_[PADL_(cloudabi_filesize_t)]; cloudabi_filesize_t off; char off_r_[PADR_(cloudabi_filesize_t)]; +}; +struct cloudabi_sys_mem_protect_args { + char addr_l_[PADL_(void *)]; void * addr; char addr_r_[PADR_(void *)]; + char len_l_[PADL_(size_t)]; size_t len; char len_r_[PADR_(size_t)]; + char prot_l_[PADL_(cloudabi_mprot_t)]; cloudabi_mprot_t prot; char prot_r_[PADR_(cloudabi_mprot_t)]; +}; +struct cloudabi_sys_mem_sync_args { + char addr_l_[PADL_(void *)]; void * addr; char addr_r_[PADR_(void *)]; + char len_l_[PADL_(size_t)]; size_t len; char len_r_[PADR_(size_t)]; + char flags_l_[PADL_(cloudabi_msflags_t)]; cloudabi_msflags_t flags; char flags_r_[PADR_(cloudabi_msflags_t)]; +}; +struct cloudabi_sys_mem_unlock_args { + char addr_l_[PADL_(const void *)]; const void * addr; char addr_r_[PADR_(const void *)]; + char len_l_[PADL_(size_t)]; size_t len; char len_r_[PADR_(size_t)]; +}; +struct cloudabi_sys_mem_unmap_args { + char addr_l_[PADL_(void *)]; void * addr; char addr_r_[PADR_(void *)]; + char len_l_[PADL_(size_t)]; size_t len; char len_r_[PADR_(size_t)]; +}; +struct cloudabi32_sys_poll_args { + char in_l_[PADL_(const cloudabi32_subscription_t *)]; const cloudabi32_subscription_t * in; char in_r_[PADR_(const cloudabi32_subscription_t *)]; + char out_l_[PADL_(cloudabi32_event_t *)]; cloudabi32_event_t * out; char out_r_[PADR_(cloudabi32_event_t *)]; + char nsubscriptions_l_[PADL_(size_t)]; size_t nsubscriptions; char nsubscriptions_r_[PADR_(size_t)]; +}; +struct cloudabi32_sys_poll_fd_args { + char fd_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t fd; char fd_r_[PADR_(cloudabi_fd_t)]; + char in_l_[PADL_(const cloudabi32_subscription_t *)]; const cloudabi32_subscription_t * in; char in_r_[PADR_(const cloudabi32_subscription_t *)]; + char nin_l_[PADL_(size_t)]; size_t nin; char nin_r_[PADR_(size_t)]; + char out_l_[PADL_(cloudabi32_event_t *)]; cloudabi32_event_t * out; char out_r_[PADR_(cloudabi32_event_t *)]; + char nout_l_[PADL_(size_t)]; size_t nout; char nout_r_[PADR_(size_t)]; + char timeout_l_[PADL_(const cloudabi32_subscription_t *)]; const cloudabi32_subscription_t * timeout; char timeout_r_[PADR_(const cloudabi32_subscription_t *)]; +}; +struct cloudabi_sys_proc_exec_args { + char fd_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t fd; char fd_r_[PADR_(cloudabi_fd_t)]; + char data_l_[PADL_(const void *)]; const void * data; char data_r_[PADR_(const void *)]; + char datalen_l_[PADL_(size_t)]; size_t datalen; char datalen_r_[PADR_(size_t)]; + char fds_l_[PADL_(const cloudabi_fd_t *)]; const cloudabi_fd_t * fds; char fds_r_[PADR_(const cloudabi_fd_t *)]; + char fdslen_l_[PADL_(size_t)]; size_t fdslen; char fdslen_r_[PADR_(size_t)]; +}; +struct cloudabi_sys_proc_exit_args { + char rval_l_[PADL_(cloudabi_exitcode_t)]; cloudabi_exitcode_t rval; char rval_r_[PADR_(cloudabi_exitcode_t)]; +}; +struct cloudabi_sys_proc_fork_args { + register_t dummy; +}; +struct cloudabi_sys_proc_raise_args { + char sig_l_[PADL_(cloudabi_signal_t)]; cloudabi_signal_t sig; char sig_r_[PADR_(cloudabi_signal_t)]; +}; +struct cloudabi_sys_random_get_args { + char buf_l_[PADL_(void *)]; void * buf; char buf_r_[PADR_(void *)]; + char nbyte_l_[PADL_(size_t)]; size_t nbyte; char nbyte_r_[PADR_(size_t)]; +}; +struct cloudabi_sys_sock_accept_args { + char sock_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t sock; char sock_r_[PADR_(cloudabi_fd_t)]; + char buf_l_[PADL_(cloudabi_sockstat_t *)]; cloudabi_sockstat_t * buf; char buf_r_[PADR_(cloudabi_sockstat_t *)]; +}; +struct cloudabi_sys_sock_bind_args { + char sock_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t sock; char sock_r_[PADR_(cloudabi_fd_t)]; + char fd_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t fd; char fd_r_[PADR_(cloudabi_fd_t)]; + char path_l_[PADL_(const char *)]; const char * path; char path_r_[PADR_(const char *)]; + char pathlen_l_[PADL_(size_t)]; size_t pathlen; char pathlen_r_[PADR_(size_t)]; +}; +struct cloudabi_sys_sock_connect_args { + char sock_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t sock; char sock_r_[PADR_(cloudabi_fd_t)]; + char fd_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t fd; char fd_r_[PADR_(cloudabi_fd_t)]; + char path_l_[PADL_(const char *)]; const char * path; char path_r_[PADR_(const char *)]; + char pathlen_l_[PADL_(size_t)]; size_t pathlen; char pathlen_r_[PADR_(size_t)]; +}; +struct cloudabi_sys_sock_listen_args { + char sock_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t sock; char sock_r_[PADR_(cloudabi_fd_t)]; + char backlog_l_[PADL_(cloudabi_backlog_t)]; cloudabi_backlog_t backlog; char backlog_r_[PADR_(cloudabi_backlog_t)]; +}; +struct cloudabi32_sys_sock_recv_args { + char sock_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t sock; char sock_r_[PADR_(cloudabi_fd_t)]; + char in_l_[PADL_(const cloudabi32_recv_in_t *)]; const cloudabi32_recv_in_t * in; char in_r_[PADR_(const cloudabi32_recv_in_t *)]; + char out_l_[PADL_(cloudabi32_recv_out_t *)]; cloudabi32_recv_out_t * out; char out_r_[PADR_(cloudabi32_recv_out_t *)]; +}; +struct cloudabi32_sys_sock_send_args { + char sock_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t sock; char sock_r_[PADR_(cloudabi_fd_t)]; + char in_l_[PADL_(const cloudabi32_send_in_t *)]; const cloudabi32_send_in_t * in; char in_r_[PADR_(const cloudabi32_send_in_t *)]; + char out_l_[PADL_(cloudabi32_send_out_t *)]; cloudabi32_send_out_t * out; char out_r_[PADR_(cloudabi32_send_out_t *)]; +}; +struct cloudabi_sys_sock_shutdown_args { + char sock_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t sock; char sock_r_[PADR_(cloudabi_fd_t)]; + char how_l_[PADL_(cloudabi_sdflags_t)]; cloudabi_sdflags_t how; char how_r_[PADR_(cloudabi_sdflags_t)]; +}; +struct cloudabi_sys_sock_stat_get_args { + char sock_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t sock; char sock_r_[PADR_(cloudabi_fd_t)]; + char buf_l_[PADL_(cloudabi_sockstat_t *)]; cloudabi_sockstat_t * buf; char buf_r_[PADR_(cloudabi_sockstat_t *)]; + char flags_l_[PADL_(cloudabi_ssflags_t)]; cloudabi_ssflags_t flags; char flags_r_[PADR_(cloudabi_ssflags_t)]; +}; +struct cloudabi32_sys_thread_create_args { + char attr_l_[PADL_(cloudabi32_threadattr_t *)]; cloudabi32_threadattr_t * attr; char attr_r_[PADR_(cloudabi32_threadattr_t *)]; +}; +struct cloudabi_sys_thread_exit_args { + char lock_l_[PADL_(cloudabi_lock_t *)]; cloudabi_lock_t * lock; char lock_r_[PADR_(cloudabi_lock_t *)]; + char scope_l_[PADL_(cloudabi_scope_t)]; cloudabi_scope_t scope; char scope_r_[PADR_(cloudabi_scope_t)]; +}; +struct cloudabi_sys_thread_yield_args { + register_t dummy; +}; +int cloudabi_sys_clock_res_get(struct thread *, struct cloudabi_sys_clock_res_get_args *); +int cloudabi_sys_clock_time_get(struct thread *, struct cloudabi_sys_clock_time_get_args *); +int cloudabi_sys_condvar_signal(struct thread *, struct cloudabi_sys_condvar_signal_args *); +int cloudabi_sys_fd_close(struct thread *, struct cloudabi_sys_fd_close_args *); +int cloudabi_sys_fd_create1(struct thread *, struct cloudabi_sys_fd_create1_args *); +int cloudabi_sys_fd_create2(struct thread *, struct cloudabi_sys_fd_create2_args *); +int cloudabi_sys_fd_datasync(struct thread *, struct cloudabi_sys_fd_datasync_args *); +int cloudabi_sys_fd_dup(struct thread *, struct cloudabi_sys_fd_dup_args *); +int cloudabi32_sys_fd_pread(struct thread *, struct cloudabi32_sys_fd_pread_args *); +int cloudabi32_sys_fd_pwrite(struct thread *, struct cloudabi32_sys_fd_pwrite_args *); +int cloudabi32_sys_fd_read(struct thread *, struct cloudabi32_sys_fd_read_args *); +int cloudabi_sys_fd_replace(struct thread *, struct cloudabi_sys_fd_replace_args *); +int cloudabi_sys_fd_seek(struct thread *, struct cloudabi_sys_fd_seek_args *); +int cloudabi_sys_fd_stat_get(struct thread *, struct cloudabi_sys_fd_stat_get_args *); +int cloudabi_sys_fd_stat_put(struct thread *, struct cloudabi_sys_fd_stat_put_args *); +int cloudabi_sys_fd_sync(struct thread *, struct cloudabi_sys_fd_sync_args *); +int cloudabi32_sys_fd_write(struct thread *, struct cloudabi32_sys_fd_write_args *); +int cloudabi_sys_file_advise(struct thread *, struct cloudabi_sys_file_advise_args *); +int cloudabi_sys_file_allocate(struct thread *, struct cloudabi_sys_file_allocate_args *); +int cloudabi_sys_file_create(struct thread *, struct cloudabi_sys_file_create_args *); +int cloudabi_sys_file_link(struct thread *, struct cloudabi_sys_file_link_args *); +int cloudabi_sys_file_open(struct thread *, struct cloudabi_sys_file_open_args *); +int cloudabi_sys_file_readdir(struct thread *, struct cloudabi_sys_file_readdir_args *); +int cloudabi_sys_file_readlink(struct thread *, struct cloudabi_sys_file_readlink_args *); +int cloudabi_sys_file_rename(struct thread *, struct cloudabi_sys_file_rename_args *); +int cloudabi_sys_file_stat_fget(struct thread *, struct cloudabi_sys_file_stat_fget_args *); +int cloudabi_sys_file_stat_fput(struct thread *, struct cloudabi_sys_file_stat_fput_args *); +int cloudabi_sys_file_stat_get(struct thread *, struct cloudabi_sys_file_stat_get_args *); +int cloudabi_sys_file_stat_put(struct thread *, struct cloudabi_sys_file_stat_put_args *); +int cloudabi_sys_file_symlink(struct thread *, struct cloudabi_sys_file_symlink_args *); +int cloudabi_sys_file_unlink(struct thread *, struct cloudabi_sys_file_unlink_args *); +int cloudabi_sys_lock_unlock(struct thread *, struct cloudabi_sys_lock_unlock_args *); +int cloudabi_sys_mem_advise(struct thread *, struct cloudabi_sys_mem_advise_args *); +int cloudabi_sys_mem_lock(struct thread *, struct cloudabi_sys_mem_lock_args *); +int cloudabi_sys_mem_map(struct thread *, struct cloudabi_sys_mem_map_args *); +int cloudabi_sys_mem_protect(struct thread *, struct cloudabi_sys_mem_protect_args *); +int cloudabi_sys_mem_sync(struct thread *, struct cloudabi_sys_mem_sync_args *); +int cloudabi_sys_mem_unlock(struct thread *, struct cloudabi_sys_mem_unlock_args *); +int cloudabi_sys_mem_unmap(struct thread *, struct cloudabi_sys_mem_unmap_args *); +int cloudabi32_sys_poll(struct thread *, struct cloudabi32_sys_poll_args *); +int cloudabi32_sys_poll_fd(struct thread *, struct cloudabi32_sys_poll_fd_args *); +int cloudabi_sys_proc_exec(struct thread *, struct cloudabi_sys_proc_exec_args *); +int cloudabi_sys_proc_exit(struct thread *, struct cloudabi_sys_proc_exit_args *); +int cloudabi_sys_proc_fork(struct thread *, struct cloudabi_sys_proc_fork_args *); +int cloudabi_sys_proc_raise(struct thread *, struct cloudabi_sys_proc_raise_args *); +int cloudabi_sys_random_get(struct thread *, struct cloudabi_sys_random_get_args *); +int cloudabi_sys_sock_accept(struct thread *, struct cloudabi_sys_sock_accept_args *); +int cloudabi_sys_sock_bind(struct thread *, struct cloudabi_sys_sock_bind_args *); +int cloudabi_sys_sock_connect(struct thread *, struct cloudabi_sys_sock_connect_args *); +int cloudabi_sys_sock_listen(struct thread *, struct cloudabi_sys_sock_listen_args *); +int cloudabi32_sys_sock_recv(struct thread *, struct cloudabi32_sys_sock_recv_args *); +int cloudabi32_sys_sock_send(struct thread *, struct cloudabi32_sys_sock_send_args *); +int cloudabi_sys_sock_shutdown(struct thread *, struct cloudabi_sys_sock_shutdown_args *); +int cloudabi_sys_sock_stat_get(struct thread *, struct cloudabi_sys_sock_stat_get_args *); +int cloudabi32_sys_thread_create(struct thread *, struct cloudabi32_sys_thread_create_args *); +int cloudabi_sys_thread_exit(struct thread *, struct cloudabi_sys_thread_exit_args *); +int cloudabi_sys_thread_yield(struct thread *, struct cloudabi_sys_thread_yield_args *); + +#ifdef COMPAT_43 + + +#endif /* COMPAT_43 */ + + +#ifdef COMPAT_FREEBSD4 + + +#endif /* COMPAT_FREEBSD4 */ + + +#ifdef COMPAT_FREEBSD6 + + +#endif /* COMPAT_FREEBSD6 */ + + +#ifdef COMPAT_FREEBSD7 + + +#endif /* COMPAT_FREEBSD7 */ + + +#ifdef COMPAT_FREEBSD10 + + +#endif /* COMPAT_FREEBSD10 */ + +#define CLOUDABI32_SYS_AUE_cloudabi_sys_clock_res_get AUE_NULL +#define CLOUDABI32_SYS_AUE_cloudabi_sys_clock_time_get AUE_NULL +#define CLOUDABI32_SYS_AUE_cloudabi_sys_condvar_signal AUE_NULL +#define CLOUDABI32_SYS_AUE_cloudabi_sys_fd_close AUE_NULL +#define CLOUDABI32_SYS_AUE_cloudabi_sys_fd_create1 AUE_NULL +#define CLOUDABI32_SYS_AUE_cloudabi_sys_fd_create2 AUE_NULL +#define CLOUDABI32_SYS_AUE_cloudabi_sys_fd_datasync AUE_NULL +#define CLOUDABI32_SYS_AUE_cloudabi_sys_fd_dup AUE_NULL +#define CLOUDABI32_SYS_AUE_cloudabi32_sys_fd_pread AUE_NULL +#define CLOUDABI32_SYS_AUE_cloudabi32_sys_fd_pwrite AUE_NULL +#define CLOUDABI32_SYS_AUE_cloudabi32_sys_fd_read AUE_NULL +#define CLOUDABI32_SYS_AUE_cloudabi_sys_fd_replace AUE_NULL +#define CLOUDABI32_SYS_AUE_cloudabi_sys_fd_seek AUE_NULL +#define CLOUDABI32_SYS_AUE_cloudabi_sys_fd_stat_get AUE_NULL +#define CLOUDABI32_SYS_AUE_cloudabi_sys_fd_stat_put AUE_NULL +#define CLOUDABI32_SYS_AUE_cloudabi_sys_fd_sync AUE_NULL +#define CLOUDABI32_SYS_AUE_cloudabi32_sys_fd_write AUE_NULL +#define CLOUDABI32_SYS_AUE_cloudabi_sys_file_advise AUE_NULL +#define CLOUDABI32_SYS_AUE_cloudabi_sys_file_allocate AUE_NULL +#define CLOUDABI32_SYS_AUE_cloudabi_sys_file_create AUE_NULL +#define CLOUDABI32_SYS_AUE_cloudabi_sys_file_link AUE_NULL +#define CLOUDABI32_SYS_AUE_cloudabi_sys_file_open AUE_NULL +#define CLOUDABI32_SYS_AUE_cloudabi_sys_file_readdir AUE_NULL +#define CLOUDABI32_SYS_AUE_cloudabi_sys_file_readlink AUE_NULL +#define CLOUDABI32_SYS_AUE_cloudabi_sys_file_rename AUE_NULL +#define CLOUDABI32_SYS_AUE_cloudabi_sys_file_stat_fget AUE_NULL +#define CLOUDABI32_SYS_AUE_cloudabi_sys_file_stat_fput AUE_NULL +#define CLOUDABI32_SYS_AUE_cloudabi_sys_file_stat_get AUE_NULL +#define CLOUDABI32_SYS_AUE_cloudabi_sys_file_stat_put AUE_NULL +#define CLOUDABI32_SYS_AUE_cloudabi_sys_file_symlink AUE_NULL +#define CLOUDABI32_SYS_AUE_cloudabi_sys_file_unlink AUE_NULL +#define CLOUDABI32_SYS_AUE_cloudabi_sys_lock_unlock AUE_NULL +#define CLOUDABI32_SYS_AUE_cloudabi_sys_mem_advise AUE_NULL +#define CLOUDABI32_SYS_AUE_cloudabi_sys_mem_lock AUE_NULL +#define CLOUDABI32_SYS_AUE_cloudabi_sys_mem_map AUE_NULL +#define CLOUDABI32_SYS_AUE_cloudabi_sys_mem_protect AUE_NULL +#define CLOUDABI32_SYS_AUE_cloudabi_sys_mem_sync AUE_NULL +#define CLOUDABI32_SYS_AUE_cloudabi_sys_mem_unlock AUE_NULL +#define CLOUDABI32_SYS_AUE_cloudabi_sys_mem_unmap AUE_NULL +#define CLOUDABI32_SYS_AUE_cloudabi32_sys_poll AUE_NULL +#define CLOUDABI32_SYS_AUE_cloudabi32_sys_poll_fd AUE_NULL +#define CLOUDABI32_SYS_AUE_cloudabi_sys_proc_exec AUE_NULL +#define CLOUDABI32_SYS_AUE_cloudabi_sys_proc_exit AUE_NULL +#define CLOUDABI32_SYS_AUE_cloudabi_sys_proc_fork AUE_NULL +#define CLOUDABI32_SYS_AUE_cloudabi_sys_proc_raise AUE_NULL +#define CLOUDABI32_SYS_AUE_cloudabi_sys_random_get AUE_NULL +#define CLOUDABI32_SYS_AUE_cloudabi_sys_sock_accept AUE_NULL +#define CLOUDABI32_SYS_AUE_cloudabi_sys_sock_bind AUE_NULL +#define CLOUDABI32_SYS_AUE_cloudabi_sys_sock_connect AUE_NULL +#define CLOUDABI32_SYS_AUE_cloudabi_sys_sock_listen AUE_NULL +#define CLOUDABI32_SYS_AUE_cloudabi32_sys_sock_recv AUE_NULL +#define CLOUDABI32_SYS_AUE_cloudabi32_sys_sock_send AUE_NULL +#define CLOUDABI32_SYS_AUE_cloudabi_sys_sock_shutdown AUE_NULL +#define CLOUDABI32_SYS_AUE_cloudabi_sys_sock_stat_get AUE_NULL +#define CLOUDABI32_SYS_AUE_cloudabi32_sys_thread_create AUE_NULL +#define CLOUDABI32_SYS_AUE_cloudabi_sys_thread_exit AUE_NULL +#define CLOUDABI32_SYS_AUE_cloudabi_sys_thread_yield AUE_NULL + +#undef PAD_ +#undef PADL_ +#undef PADR_ + +#endif /* !_CLOUDABI32_SYSPROTO_H_ */ Copied: stable/11/sys/compat/cloudabi32/cloudabi32_syscall.h (from r304565, head/sys/compat/cloudabi32/cloudabi32_syscall.h) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/11/sys/compat/cloudabi32/cloudabi32_syscall.h Wed Oct 12 12:17:41 2016 (r307144, copy of r304565, head/sys/compat/cloudabi32/cloudabi32_syscall.h) @@ -0,0 +1,66 @@ +/* + * System call numbers. + * + * DO NOT EDIT-- this file is automatically generated. + * $FreeBSD$ + * created from FreeBSD: head/sys/contrib/cloudabi/syscalls32.master 304563 2016-08-21 15:56:19Z ed + */ + +#define CLOUDABI32_SYS_cloudabi_sys_clock_res_get 0 +#define CLOUDABI32_SYS_cloudabi_sys_clock_time_get 1 +#define CLOUDABI32_SYS_cloudabi_sys_condvar_signal 2 +#define CLOUDABI32_SYS_cloudabi_sys_fd_close 3 +#define CLOUDABI32_SYS_cloudabi_sys_fd_create1 4 +#define CLOUDABI32_SYS_cloudabi_sys_fd_create2 5 +#define CLOUDABI32_SYS_cloudabi_sys_fd_datasync 6 +#define CLOUDABI32_SYS_cloudabi_sys_fd_dup 7 +#define CLOUDABI32_SYS_cloudabi32_sys_fd_pread 8 +#define CLOUDABI32_SYS_cloudabi32_sys_fd_pwrite 9 +#define CLOUDABI32_SYS_cloudabi32_sys_fd_read 10 +#define CLOUDABI32_SYS_cloudabi_sys_fd_replace 11 +#define CLOUDABI32_SYS_cloudabi_sys_fd_seek 12 +#define CLOUDABI32_SYS_cloudabi_sys_fd_stat_get 13 +#define CLOUDABI32_SYS_cloudabi_sys_fd_stat_put 14 +#define CLOUDABI32_SYS_cloudabi_sys_fd_sync 15 +#define CLOUDABI32_SYS_cloudabi32_sys_fd_write 16 +#define CLOUDABI32_SYS_cloudabi_sys_file_advise 17 +#define CLOUDABI32_SYS_cloudabi_sys_file_allocate 18 +#define CLOUDABI32_SYS_cloudabi_sys_file_create 19 +#define CLOUDABI32_SYS_cloudabi_sys_file_link 20 +#define CLOUDABI32_SYS_cloudabi_sys_file_open 21 +#define CLOUDABI32_SYS_cloudabi_sys_file_readdir 22 +#define CLOUDABI32_SYS_cloudabi_sys_file_readlink 23 +#define CLOUDABI32_SYS_cloudabi_sys_file_rename 24 +#define CLOUDABI32_SYS_cloudabi_sys_file_stat_fget 25 +#define CLOUDABI32_SYS_cloudabi_sys_file_stat_fput 26 +#define CLOUDABI32_SYS_cloudabi_sys_file_stat_get 27 +#define CLOUDABI32_SYS_cloudabi_sys_file_stat_put 28 +#define CLOUDABI32_SYS_cloudabi_sys_file_symlink 29 +#define CLOUDABI32_SYS_cloudabi_sys_file_unlink 30 +#define CLOUDABI32_SYS_cloudabi_sys_lock_unlock 31 +#define CLOUDABI32_SYS_cloudabi_sys_mem_advise 32 +#define CLOUDABI32_SYS_cloudabi_sys_mem_lock 33 +#define CLOUDABI32_SYS_cloudabi_sys_mem_map 34 +#define CLOUDABI32_SYS_cloudabi_sys_mem_protect 35 +#define CLOUDABI32_SYS_cloudabi_sys_mem_sync 36 +#define CLOUDABI32_SYS_cloudabi_sys_mem_unlock 37 +#define CLOUDABI32_SYS_cloudabi_sys_mem_unmap 38 +#define CLOUDABI32_SYS_cloudabi32_sys_poll 39 +#define CLOUDABI32_SYS_cloudabi32_sys_poll_fd 40 +#define CLOUDABI32_SYS_cloudabi_sys_proc_exec 41 +#define CLOUDABI32_SYS_cloudabi_sys_proc_exit 42 +#define CLOUDABI32_SYS_cloudabi_sys_proc_fork 43 +#define CLOUDABI32_SYS_cloudabi_sys_proc_raise 44 +#define CLOUDABI32_SYS_cloudabi_sys_random_get 45 +#define CLOUDABI32_SYS_cloudabi_sys_sock_accept 46 +#define CLOUDABI32_SYS_cloudabi_sys_sock_bind 47 +#define CLOUDABI32_SYS_cloudabi_sys_sock_connect 48 +#define CLOUDABI32_SYS_cloudabi_sys_sock_listen 49 +#define CLOUDABI32_SYS_cloudabi32_sys_sock_recv 50 +#define CLOUDABI32_SYS_cloudabi32_sys_sock_send 51 +#define CLOUDABI32_SYS_cloudabi_sys_sock_shutdown 52 +#define CLOUDABI32_SYS_cloudabi_sys_sock_stat_get 53 +#define CLOUDABI32_SYS_cloudabi32_sys_thread_create 54 +#define CLOUDABI32_SYS_cloudabi_sys_thread_exit 55 +#define CLOUDABI32_SYS_cloudabi_sys_thread_yield 56 +#define CLOUDABI32_SYS_MAXSYSCALL 57 Copied: stable/11/sys/compat/cloudabi32/cloudabi32_syscalls.c (from r304565, head/sys/compat/cloudabi32/cloudabi32_syscalls.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/11/sys/compat/cloudabi32/cloudabi32_syscalls.c Wed Oct 12 12:17:41 2016 (r307144, copy of r304565, head/sys/compat/cloudabi32/cloudabi32_syscalls.c) @@ -0,0 +1,67 @@ +/* + * System call names. + * + * DO NOT EDIT-- this file is automatically generated. + * $FreeBSD$ + * created from FreeBSD: head/sys/contrib/cloudabi/syscalls32.master 304563 2016-08-21 15:56:19Z ed + */ + +const char *cloudabi32_syscallnames[] = { + "cloudabi_sys_clock_res_get", /* 0 = cloudabi_sys_clock_res_get */ + "cloudabi_sys_clock_time_get", /* 1 = cloudabi_sys_clock_time_get */ + "cloudabi_sys_condvar_signal", /* 2 = cloudabi_sys_condvar_signal */ + "cloudabi_sys_fd_close", /* 3 = cloudabi_sys_fd_close */ + "cloudabi_sys_fd_create1", /* 4 = cloudabi_sys_fd_create1 */ + "cloudabi_sys_fd_create2", /* 5 = cloudabi_sys_fd_create2 */ + "cloudabi_sys_fd_datasync", /* 6 = cloudabi_sys_fd_datasync */ + "cloudabi_sys_fd_dup", /* 7 = cloudabi_sys_fd_dup */ + "cloudabi32_sys_fd_pread", /* 8 = cloudabi32_sys_fd_pread */ + "cloudabi32_sys_fd_pwrite", /* 9 = cloudabi32_sys_fd_pwrite */ + "cloudabi32_sys_fd_read", /* 10 = cloudabi32_sys_fd_read */ + "cloudabi_sys_fd_replace", /* 11 = cloudabi_sys_fd_replace */ + "cloudabi_sys_fd_seek", /* 12 = cloudabi_sys_fd_seek */ + "cloudabi_sys_fd_stat_get", /* 13 = cloudabi_sys_fd_stat_get */ + "cloudabi_sys_fd_stat_put", /* 14 = cloudabi_sys_fd_stat_put */ + "cloudabi_sys_fd_sync", /* 15 = cloudabi_sys_fd_sync */ + "cloudabi32_sys_fd_write", /* 16 = cloudabi32_sys_fd_write */ + "cloudabi_sys_file_advise", /* 17 = cloudabi_sys_file_advise */ + "cloudabi_sys_file_allocate", /* 18 = cloudabi_sys_file_allocate */ + "cloudabi_sys_file_create", /* 19 = cloudabi_sys_file_create */ + "cloudabi_sys_file_link", /* 20 = cloudabi_sys_file_link */ + "cloudabi_sys_file_open", /* 21 = cloudabi_sys_file_open */ + "cloudabi_sys_file_readdir", /* 22 = cloudabi_sys_file_readdir */ + "cloudabi_sys_file_readlink", /* 23 = cloudabi_sys_file_readlink */ + "cloudabi_sys_file_rename", /* 24 = cloudabi_sys_file_rename */ + "cloudabi_sys_file_stat_fget", /* 25 = cloudabi_sys_file_stat_fget */ + "cloudabi_sys_file_stat_fput", /* 26 = cloudabi_sys_file_stat_fput */ + "cloudabi_sys_file_stat_get", /* 27 = cloudabi_sys_file_stat_get */ + "cloudabi_sys_file_stat_put", /* 28 = cloudabi_sys_file_stat_put */ + "cloudabi_sys_file_symlink", /* 29 = cloudabi_sys_file_symlink */ + "cloudabi_sys_file_unlink", /* 30 = cloudabi_sys_file_unlink */ + "cloudabi_sys_lock_unlock", /* 31 = cloudabi_sys_lock_unlock */ + "cloudabi_sys_mem_advise", /* 32 = cloudabi_sys_mem_advise */ + "cloudabi_sys_mem_lock", /* 33 = cloudabi_sys_mem_lock */ + "cloudabi_sys_mem_map", /* 34 = cloudabi_sys_mem_map */ + "cloudabi_sys_mem_protect", /* 35 = cloudabi_sys_mem_protect */ + "cloudabi_sys_mem_sync", /* 36 = cloudabi_sys_mem_sync */ + "cloudabi_sys_mem_unlock", /* 37 = cloudabi_sys_mem_unlock */ + "cloudabi_sys_mem_unmap", /* 38 = cloudabi_sys_mem_unmap */ + "cloudabi32_sys_poll", /* 39 = cloudabi32_sys_poll */ + "cloudabi32_sys_poll_fd", /* 40 = cloudabi32_sys_poll_fd */ + "cloudabi_sys_proc_exec", /* 41 = cloudabi_sys_proc_exec */ + "cloudabi_sys_proc_exit", /* 42 = cloudabi_sys_proc_exit */ + "cloudabi_sys_proc_fork", /* 43 = cloudabi_sys_proc_fork */ + "cloudabi_sys_proc_raise", /* 44 = cloudabi_sys_proc_raise */ + "cloudabi_sys_random_get", /* 45 = cloudabi_sys_random_get */ + "cloudabi_sys_sock_accept", /* 46 = cloudabi_sys_sock_accept */ + "cloudabi_sys_sock_bind", /* 47 = cloudabi_sys_sock_bind */ + "cloudabi_sys_sock_connect", /* 48 = cloudabi_sys_sock_connect */ + "cloudabi_sys_sock_listen", /* 49 = cloudabi_sys_sock_listen */ + "cloudabi32_sys_sock_recv", /* 50 = cloudabi32_sys_sock_recv */ + "cloudabi32_sys_sock_send", /* 51 = cloudabi32_sys_sock_send */ + "cloudabi_sys_sock_shutdown", /* 52 = cloudabi_sys_sock_shutdown */ + "cloudabi_sys_sock_stat_get", /* 53 = cloudabi_sys_sock_stat_get */ + "cloudabi32_sys_thread_create", /* 54 = cloudabi32_sys_thread_create */ + "cloudabi_sys_thread_exit", /* 55 = cloudabi_sys_thread_exit */ + "cloudabi_sys_thread_yield", /* 56 = cloudabi_sys_thread_yield */ +}; Copied: stable/11/sys/compat/cloudabi32/cloudabi32_sysent.c (from r304565, head/sys/compat/cloudabi32/cloudabi32_sysent.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/11/sys/compat/cloudabi32/cloudabi32_sysent.c Wed Oct 12 12:17:41 2016 (r307144, copy of r304565, head/sys/compat/cloudabi32/cloudabi32_sysent.c) @@ -0,0 +1,75 @@ +/* + * System call switch table. + * + * DO NOT EDIT-- this file is automatically generated. + * $FreeBSD$ + * created from FreeBSD: head/sys/contrib/cloudabi/syscalls32.master 304563 2016-08-21 15:56:19Z ed + */ + +#include +#include +#include +#include + +#define AS(name) (sizeof(struct name) / sizeof(register_t)) + +/* The casts are bogus but will do for now. */ +struct sysent cloudabi32_sysent[] = { + { AS(cloudabi_sys_clock_res_get_args), (sy_call_t *)cloudabi_sys_clock_res_get, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 0 = cloudabi_sys_clock_res_get */ + { AS(cloudabi_sys_clock_time_get_args), (sy_call_t *)cloudabi_sys_clock_time_get, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 1 = cloudabi_sys_clock_time_get */ + { AS(cloudabi_sys_condvar_signal_args), (sy_call_t *)cloudabi_sys_condvar_signal, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 2 = cloudabi_sys_condvar_signal */ + { AS(cloudabi_sys_fd_close_args), (sy_call_t *)cloudabi_sys_fd_close, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 3 = cloudabi_sys_fd_close */ + { AS(cloudabi_sys_fd_create1_args), (sy_call_t *)cloudabi_sys_fd_create1, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 4 = cloudabi_sys_fd_create1 */ + { AS(cloudabi_sys_fd_create2_args), (sy_call_t *)cloudabi_sys_fd_create2, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 5 = cloudabi_sys_fd_create2 */ + { AS(cloudabi_sys_fd_datasync_args), (sy_call_t *)cloudabi_sys_fd_datasync, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 6 = cloudabi_sys_fd_datasync */ + { AS(cloudabi_sys_fd_dup_args), (sy_call_t *)cloudabi_sys_fd_dup, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 7 = cloudabi_sys_fd_dup */ + { AS(cloudabi32_sys_fd_pread_args), (sy_call_t *)cloudabi32_sys_fd_pread, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 8 = cloudabi32_sys_fd_pread */ + { AS(cloudabi32_sys_fd_pwrite_args), (sy_call_t *)cloudabi32_sys_fd_pwrite, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 9 = cloudabi32_sys_fd_pwrite */ + { AS(cloudabi32_sys_fd_read_args), (sy_call_t *)cloudabi32_sys_fd_read, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 10 = cloudabi32_sys_fd_read */ + { AS(cloudabi_sys_fd_replace_args), (sy_call_t *)cloudabi_sys_fd_replace, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 11 = cloudabi_sys_fd_replace */ + { AS(cloudabi_sys_fd_seek_args), (sy_call_t *)cloudabi_sys_fd_seek, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 12 = cloudabi_sys_fd_seek */ + { AS(cloudabi_sys_fd_stat_get_args), (sy_call_t *)cloudabi_sys_fd_stat_get, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 13 = cloudabi_sys_fd_stat_get */ + { AS(cloudabi_sys_fd_stat_put_args), (sy_call_t *)cloudabi_sys_fd_stat_put, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 14 = cloudabi_sys_fd_stat_put */ + { AS(cloudabi_sys_fd_sync_args), (sy_call_t *)cloudabi_sys_fd_sync, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 15 = cloudabi_sys_fd_sync */ + { AS(cloudabi32_sys_fd_write_args), (sy_call_t *)cloudabi32_sys_fd_write, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 16 = cloudabi32_sys_fd_write */ + { AS(cloudabi_sys_file_advise_args), (sy_call_t *)cloudabi_sys_file_advise, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 17 = cloudabi_sys_file_advise */ + { AS(cloudabi_sys_file_allocate_args), (sy_call_t *)cloudabi_sys_file_allocate, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 18 = cloudabi_sys_file_allocate */ + { AS(cloudabi_sys_file_create_args), (sy_call_t *)cloudabi_sys_file_create, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 19 = cloudabi_sys_file_create */ *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-all@freebsd.org Wed Oct 12 12:56:19 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 88F14C0DFC0; Wed, 12 Oct 2016 12:56:19 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 584849FB; Wed, 12 Oct 2016 12:56:19 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9CCuINC090463; Wed, 12 Oct 2016 12:56:18 GMT (envelope-from emaste@FreeBSD.org) Received: (from emaste@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9CCuITP090462; Wed, 12 Oct 2016 12:56:18 GMT (envelope-from emaste@FreeBSD.org) Message-Id: <201610121256.u9CCuITP090462@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: emaste set sender to emaste@FreeBSD.org using -f From: Ed Maste Date: Wed, 12 Oct 2016 12:56:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307145 - head/sys/dev/kbd X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Oct 2016 12:56:19 -0000 Author: emaste Date: Wed Oct 12 12:56:18 2016 New Revision: 307145 URL: https://svnweb.freebsd.org/changeset/base/307145 Log: Use M_WAITOK in PIO_KEYMAP ioctl The malloc return value is not checked. Submitted by: CTurt MFC after: 1 week Modified: head/sys/dev/kbd/kbd.c Modified: head/sys/dev/kbd/kbd.c ============================================================================== --- head/sys/dev/kbd/kbd.c Wed Oct 12 12:17:41 2016 (r307144) +++ head/sys/dev/kbd/kbd.c Wed Oct 12 12:56:18 2016 (r307145) @@ -888,7 +888,7 @@ genkbd_commonioctl(keyboard_t *kbd, u_lo case PIO_KEYMAP: /* set keyboard translation table */ case OPIO_KEYMAP: /* set keyboard translation table (compat) */ #ifndef KBD_DISABLE_KEYMAP_LOAD - mapp = malloc(sizeof *mapp, M_TEMP, M_NOWAIT); + mapp = malloc(sizeof *mapp, M_TEMP, M_WAITOK); if (cmd == OPIO_KEYMAP) { omapp = (okeymap_t *)arg; mapp->n_keys = omapp->n_keys; From owner-svn-src-all@freebsd.org Wed Oct 12 13:19:22 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id DBE02C0E89B; Wed, 12 Oct 2016 13:19:22 +0000 (UTC) (envelope-from br@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id A91B3EE1; Wed, 12 Oct 2016 13:19:22 +0000 (UTC) (envelope-from br@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9CDJL5X098702; Wed, 12 Oct 2016 13:19:21 GMT (envelope-from br@FreeBSD.org) Received: (from br@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9CDJLju098700; Wed, 12 Oct 2016 13:19:21 GMT (envelope-from br@FreeBSD.org) Message-Id: <201610121319.u9CDJLju098700@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: br set sender to br@FreeBSD.org using -f From: Ruslan Bukin Date: Wed, 12 Oct 2016 13:19:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307146 - head/lib/libc X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Oct 2016 13:19:23 -0000 Author: br Date: Wed Oct 12 13:19:21 2016 New Revision: 307146 URL: https://svnweb.freebsd.org/changeset/base/307146 Log: Add different libc ldscript: the one without libssp -- we don't have it when MK_SSP==no. This fixes compilation on MIPS. Reviewed by: imp Sponsored by: DARPA, AFRL Sponsored by: HEIF5 Differential Revision: https://reviews.freebsd.org/D8212 Added: head/lib/libc/libc_nossp.ldscript (contents, props changed) Modified: head/lib/libc/Makefile Modified: head/lib/libc/Makefile ============================================================================== --- head/lib/libc/Makefile Wed Oct 12 12:56:18 2016 (r307145) +++ head/lib/libc/Makefile Wed Oct 12 13:19:21 2016 (r307146) @@ -29,7 +29,11 @@ LIBC_ARCH=${MACHINE_CPUARCH} # to CFLAGS below. -DSYSLIBC_SCCS affects just the system call stubs. LIB=c SHLIB_MAJOR= 7 +.if ${MK_SSP} != "no" SHLIB_LDSCRIPT=libc.ldscript +.else +SHLIB_LDSCRIPT=libc_nossp.ldscript +.endif SHLIB_LDSCRIPT_LINKS=libxnet.so WARNS?= 2 CFLAGS+=-I${LIBC_SRCTOP}/include -I${LIBC_SRCTOP}/../../include Added: head/lib/libc/libc_nossp.ldscript ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/lib/libc/libc_nossp.ldscript Wed Oct 12 13:19:21 2016 (r307146) @@ -0,0 +1,2 @@ +/* $FreeBSD$ */ +GROUP ( @@SHLIB@@ @@LIBDIR@@/libc_nonshared.a ) From owner-svn-src-all@freebsd.org Wed Oct 12 13:25:46 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id BDB1BC0EA41; Wed, 12 Oct 2016 13:25:46 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from citapm.icyb.net.ua (citapm.icyb.net.ua [212.40.38.140]) by mx1.freebsd.org (Postfix) with ESMTP id 7BA36651; Wed, 12 Oct 2016 13:25:45 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from porto.starpoint.kiev.ua (porto-e.starpoint.kiev.ua [212.40.38.100]) by citapm.icyb.net.ua (8.8.8p3/ICyb-2.3exp) with ESMTP id QAA01302; Wed, 12 Oct 2016 16:25:37 +0300 (EEST) (envelope-from avg@FreeBSD.org) Received: from localhost ([127.0.0.1]) by porto.starpoint.kiev.ua with esmtp (Exim 4.34 (FreeBSD)) id 1buJXN-000I8s-4V; Wed, 12 Oct 2016 16:25:37 +0300 Subject: Re: svn commit: r306680 - in head/sys: amd64/amd64 amd64/include i386/include x86/include x86/x86 To: Konstantin Belousov , src-committers@FreeBSD.org, svn-src-all@FreeBSD.org, svn-src-head@FreeBSD.org References: <201610041701.u94H1OK3061119@repo.freebsd.org> From: Andriy Gapon Message-ID: <425655dd-ba13-8944-0f31-b1ad6666d90a@FreeBSD.org> Date: Wed, 12 Oct 2016 16:25:00 +0300 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <201610041701.u94H1OK3061119@repo.freebsd.org> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Oct 2016 13:25:46 -0000 On 04/10/2016 20:01, Konstantin Belousov wrote: > Author: kib > Date: Tue Oct 4 17:01:24 2016 > New Revision: 306680 > URL: https://svnweb.freebsd.org/changeset/base/306680 > > Log: > Re-apply r306516 (by cem): > > Reduce the cost of TLB invalidation on x86 by using per-CPU completion flags > > Reduce contention during TLB invalidation operations by using a per-CPU > completion flag, rather than a single atomically-updated variable. Kostik, could this commit cause a problem reported in the below links? https://bz-attachments.freebsd.org/attachment.cgi?id=175614 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=213371 > On a Westmere system (2 sockets x 4 cores x 1 threads), dtrace measurements > show that smp_tlb_shootdown is about 50% faster with this patch; observations > with VTune show that the percentage of time spent in invlrng_single_page on an > interrupt (actually doing invalidation, rather than synchronization) increases > from 31% with the old mechanism to 71% with the new one. (Running a basic file > server workload.) > > Submitted by: Anton Rang > Reviewed by: cem (earlier version) > Sponsored by: Dell EMC Isilon > Differential Revision: https://reviews.freebsd.org/D8041 -- Andriy Gapon From owner-svn-src-all@freebsd.org Wed Oct 12 13:45:57 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B8B28C0EFBE; Wed, 12 Oct 2016 13:45:57 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 319DE14C; Wed, 12 Oct 2016 13:45:57 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from tom.home (kib@localhost [127.0.0.1]) by kib.kiev.ua (8.15.2/8.15.2) with ESMTPS id u9CDjoVp067507 (version=TLSv1 cipher=DHE-RSA-CAMELLIA256-SHA bits=256 verify=NO); Wed, 12 Oct 2016 16:45:51 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua u9CDjoVp067507 Received: (from kostik@localhost) by tom.home (8.15.2/8.15.2/Submit) id u9CDjo22067506; Wed, 12 Oct 2016 16:45:50 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Wed, 12 Oct 2016 16:45:50 +0300 From: Konstantin Belousov To: Andriy Gapon Cc: src-committers@FreeBSD.org, svn-src-all@FreeBSD.org, svn-src-head@FreeBSD.org Subject: Re: svn commit: r306680 - in head/sys: amd64/amd64 amd64/include i386/include x86/include x86/x86 Message-ID: <20161012134550.GX68202@kib.kiev.ua> References: <201610041701.u94H1OK3061119@repo.freebsd.org> <425655dd-ba13-8944-0f31-b1ad6666d90a@FreeBSD.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <425655dd-ba13-8944-0f31-b1ad6666d90a@FreeBSD.org> User-Agent: Mutt/1.7.0 (2016-08-17) X-Spam-Status: No, score=-2.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on tom.home X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Oct 2016 13:45:57 -0000 On Wed, Oct 12, 2016 at 04:25:00PM +0300, Andriy Gapon wrote: > On 04/10/2016 20:01, Konstantin Belousov wrote: > > Author: kib > > Date: Tue Oct 4 17:01:24 2016 > > New Revision: 306680 > > URL: https://svnweb.freebsd.org/changeset/base/306680 > > > > Log: > > Re-apply r306516 (by cem): > > > > Reduce the cost of TLB invalidation on x86 by using per-CPU completion flags > > > > Reduce contention during TLB invalidation operations by using a per-CPU > > completion flag, rather than a single atomically-updated variable. > > Kostik, > > could this commit cause a problem reported in the below links? > https://bz-attachments.freebsd.org/attachment.cgi?id=175614 > https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=213371 If I am reading the report right, the problem appears on the 11.0-RELEASE system. The patch you reference was only applied to HEAD a week ago and was not merged even to stable/11. The examination must start with backtracing the thread which owns the smp_ipi_mtx (shown on the screenshot). From owner-svn-src-all@freebsd.org Wed Oct 12 13:51:42 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D72A5C0E189; Wed, 12 Oct 2016 13:51:42 +0000 (UTC) (envelope-from br@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id A92547E0; Wed, 12 Oct 2016 13:51:42 +0000 (UTC) (envelope-from br@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9CDpfsA012067; Wed, 12 Oct 2016 13:51:41 GMT (envelope-from br@FreeBSD.org) Received: (from br@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9CDpfuF012066; Wed, 12 Oct 2016 13:51:41 GMT (envelope-from br@FreeBSD.org) Message-Id: <201610121351.u9CDpfuF012066@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: br set sender to br@FreeBSD.org using -f From: Ruslan Bukin Date: Wed, 12 Oct 2016 13:51:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307147 - head/sys/conf X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Oct 2016 13:51:42 -0000 Author: br Date: Wed Oct 12 13:51:41 2016 New Revision: 307147 URL: https://svnweb.freebsd.org/changeset/base/307147 Log: Keep in-sync MK_SSP=no option both with kernel and userspace. Pointed out by: emaste Sponsored by: DARPA, AFRL Sponsored by: HEIF5 Modified: head/sys/conf/kern.opts.mk Modified: head/sys/conf/kern.opts.mk ============================================================================== --- head/sys/conf/kern.opts.mk Wed Oct 12 13:19:21 2016 (r307146) +++ head/sys/conf/kern.opts.mk Wed Oct 12 13:51:41 2016 (r307147) @@ -65,7 +65,7 @@ BROKEN_OPTIONS+= CDDL ZFS .endif .if ${MACHINE_CPUARCH} == "mips" -BROKEN_OPTIONS+= CDDL ZFS +BROKEN_OPTIONS+= CDDL ZFS SSP .endif .if ${MACHINE_CPUARCH} == "powerpc" && ${MACHINE_ARCH} == "powerpc" From owner-svn-src-all@freebsd.org Wed Oct 12 13:56:16 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 3758EC0E31B; Wed, 12 Oct 2016 13:56:16 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 06F0BBFF; Wed, 12 Oct 2016 13:56:15 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9CDuFFN013533; Wed, 12 Oct 2016 13:56:15 GMT (envelope-from emaste@FreeBSD.org) Received: (from emaste@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9CDuF1q013531; Wed, 12 Oct 2016 13:56:15 GMT (envelope-from emaste@FreeBSD.org) Message-Id: <201610121356.u9CDuF1q013531@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: emaste set sender to emaste@FreeBSD.org using -f From: Ed Maste Date: Wed, 12 Oct 2016 13:56:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307148 - in head/lib/libc: gen stdlib X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Oct 2016 13:56:16 -0000 Author: emaste Date: Wed Oct 12 13:56:14 2016 New Revision: 307148 URL: https://svnweb.freebsd.org/changeset/base/307148 Log: Add comment on use of abort() in libc Suggested by: jonathan (in review D8133) Modified: head/lib/libc/gen/arc4random.c head/lib/libc/stdlib/random.c Modified: head/lib/libc/gen/arc4random.c ============================================================================== --- head/lib/libc/gen/arc4random.c Wed Oct 12 13:51:41 2016 (r307147) +++ head/lib/libc/gen/arc4random.c Wed Oct 12 13:56:14 2016 (r307148) @@ -144,8 +144,15 @@ arc4_stir(void) arc4_init(); rs_initialized = 1; } - if (arc4_sysctl(rdat, KEYSIZE) != KEYSIZE) - abort(); /* Random sysctl cannot fail. */ + if (arc4_sysctl(rdat, KEYSIZE) != KEYSIZE) { + /* + * The sysctl cannot fail. If it does fail on some FreeBSD + * derivative or after some future change, just abort so that + * the problem will be found and fixed. abort is not normally + * suitable for a library but makes sense here. + */ + abort(); + } arc4_addrandom(rdat, KEYSIZE); Modified: head/lib/libc/stdlib/random.c ============================================================================== --- head/lib/libc/stdlib/random.c Wed Oct 12 13:51:41 2016 (r307147) +++ head/lib/libc/stdlib/random.c Wed Oct 12 13:56:14 2016 (r307148) @@ -279,8 +279,15 @@ srandomdev(void) mib[0] = CTL_KERN; mib[1] = KERN_ARND; - if (sysctl(mib, 2, state, &len, NULL, 0) == -1 || len != expected) + if (sysctl(mib, 2, state, &len, NULL, 0) == -1 || len != expected) { + /* + * The sysctl cannot fail. If it does fail on some FreeBSD + * derivative or after some future change, just abort so that + * the problem will be found and fixed. abort is not normally + * suitable for a library but makes sense here. + */ abort(); + } if (rand_type != TYPE_0) { fptr = &state[rand_sep]; From owner-svn-src-all@freebsd.org Wed Oct 12 13:57:05 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A4236C0E3CE; Wed, 12 Oct 2016 13:57:05 +0000 (UTC) (envelope-from rb743@hermes.cam.ac.uk) Received: from ppsw-41.csi.cam.ac.uk (ppsw-41.csi.cam.ac.uk [131.111.8.141]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 6AC35D79; Wed, 12 Oct 2016 13:57:05 +0000 (UTC) (envelope-from rb743@hermes.cam.ac.uk) X-Cam-AntiVirus: no malware found X-Cam-ScannerInfo: http://www.cam.ac.uk/cs/email/scanner/ Received: from sc1.bsdpad.com ([163.172.212.18]:62006) by ppsw-41.csi.cam.ac.uk (smtp.hermes.cam.ac.uk [131.111.8.159]:587) with esmtpsa (LOGIN:rb743) (TLSv1:ECDHE-RSA-AES256-SHA:256) id 1buK1m-0001Ns-QG (Exim 4.86_36-e07b163) (return-path ); Wed, 12 Oct 2016 14:57:02 +0100 Date: Wed, 12 Oct 2016 13:56:46 +0000 From: Ruslan Bukin To: Ed Maste Cc: Ruslan Bukin , "src-committers@freebsd.org" , "svn-src-all@freebsd.org" , "svn-src-head@freebsd.org" Subject: Re: svn commit: r306364 - in head: lib/libc/tests share/mk Message-ID: <20161012135646.GA63534@bsdpad.com> References: <201609270944.u8R9iUqi035006@repo.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.6.1 (2016-04-27) Sender: "R. Bukin" X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Oct 2016 13:57:05 -0000 On Wed, Oct 05, 2016 at 08:44:39PM +0000, Ed Maste wrote: > On 27 September 2016 at 09:44, Ruslan Bukin wrote: > > Author: br > > Date: Tue Sep 27 09:44:30 2016 > > New Revision: 306364 > > URL: https://svnweb.freebsd.org/changeset/base/306364 > > > > Log: > > Mark SSP broken on MIPS. > > This needs an adjustment in sys/conf/kern.opts.mk as well it seems; > 'make showconfig' (as used by makeman to generate src.conf.5) now > reports SSP is both 'no' and 'yes' on mips: > > % make TARGET=mips TARGET_ARCH=mips showconfig | grep SSP > MK_SSP = no > MK_SSP = yes > I made a change, but for some reason it works from buildenv only: make TARGET=mips TARGET_ARCH=mips buildenv % make showconfig |grep SSP MK_SSP = no It looks like MACHINE_CPUARCH is not exported by showconfig. Ruslan From owner-svn-src-all@freebsd.org Wed Oct 12 14:46:01 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 06FC0C0F2AD; Wed, 12 Oct 2016 14:46:01 +0000 (UTC) (envelope-from jonlooney@gmail.com) Received: from mail-qt0-f178.google.com (mail-qt0-f178.google.com [209.85.216.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id C1F5ECEC; Wed, 12 Oct 2016 14:46:00 +0000 (UTC) (envelope-from jonlooney@gmail.com) Received: by mail-qt0-f178.google.com with SMTP id q7so18108693qtq.1; Wed, 12 Oct 2016 07:46:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=OY/35HCrP0/bGZwm5v3OtK0BvJsvrvLla9zhJu8QLc8=; b=dtttkcI2Ra3Uq2AeO/+SeVv03qJ8/W+9JDNfjtqPo4v9Bqo/AP+0Z7UnZAisHJFxx/ QwJFL6Ir9IfLXbHuJ7apDZKMRsESH4ysViz7gxs0cTwfQvK0jj06A9AXsWKqbffxaZp1 O2sfS317zGtK88GZuCd/xotIlqodZcBXSqifKu/aHzDLpgVAX2YM9pIpCdpv00TJZUHm o7zlmzVx3mOJCny29xe7cv1/BHj1b2WiXMrVR7mQdY54C++ixRcYI1S5Fo8lial9gJ3W CoW7NRx30RsPbzHLB/t2geZftd0xxUGfmzUm3BFO2Lo9oPsKuLEoOIzTXekgXJPECpO+ I0Lw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=OY/35HCrP0/bGZwm5v3OtK0BvJsvrvLla9zhJu8QLc8=; b=hUK5BCRtBbLZYvNiyRW6yFhtBgYr5jsJeoMqvUlZXvKW/5QCjaNp3P93eIXTcOHLtr O4WP5C3dMnSOAW4QY4Tr9Q0PCOqbftpC1CwaYyLjQ7IjM/umDXYD984mgRyTtMVAkBfS fLEWRE463uloiZ4r3rWBMk+hLOp6AO4ZJV0MW+yOf+fBEJxmnmPaXqdJ7JcGxRZ6pLUc SRyjbi9P9+LTFjyP3gcfcisa3jJCnbBbcTGxljq5X2PB3secmkCMFFjNk5MQ50H4ocsk 4Lkc1hamv/I3sQaap66RsLwkP55S4L3wBMeb3bsC2YwRZJoEd2Hx3uQADItFMLO3FSoE gdpg== X-Gm-Message-State: AA6/9RmCQCh3KKmPXmIf6c2s5DIB75MdHJggwH9oiH2sC4CaX6KF8EkSuC9Cu7JIxr39dKOICWTbQpN3oVIPKg== X-Received: by 10.237.41.39 with SMTP id s36mr1524139qtd.156.1476283493414; Wed, 12 Oct 2016 07:44:53 -0700 (PDT) MIME-Version: 1.0 Received: by 10.200.53.208 with HTTP; Wed, 12 Oct 2016 07:44:52 -0700 (PDT) In-Reply-To: <20161012094403.GA57876@zxy.spb.ru> References: <201610120216.u9C2Gga8041814@repo.freebsd.org> <20161012094403.GA57876@zxy.spb.ru> From: Jonathan Looney Date: Wed, 12 Oct 2016 10:44:52 -0400 Message-ID: Subject: Re: svn commit: r307082 - in head: . sys/amd64/conf sys/arm/conf sys/arm64/conf sys/conf sys/i386/conf sys/mips/conf sys/modules/cc sys/modules/khelp sys/netinet sys/netinet/tcp_stacks sys/pc98/conf sy... To: Slawa Olhovchenkov Cc: "Jonathan T. Looney" , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Content-Type: text/plain; charset=UTF-8 X-Content-Filtered-By: Mailman/MimeDel 2.1.23 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Oct 2016 14:46:01 -0000 On Wed, Oct 12, 2016 at 5:44 AM, Slawa Olhovchenkov wrote: > Do you perform estimate of performane impact of this overhead? > > Somewhat, but not precisely. It will depend on (at least) a few factors: a. The hardware * How fast is your CPU? Your L1/L2/L3 cache? * How many CPUs? * How smart is the hardware prefetching? * How fast is the memory bus? * etc. b. Whether VNET is enabled * If VNET is enabled, the hook lookup will require more instructions to find the correct list c. Which TCP stack you are using * The hook lookup is implemented as an external function in the non-default stacks, so that requires the overhead of a function call d. The probability that the number of hooks is in your CPU cache * This is a combination of the hardware and the exact workload on the device On a test system running a fairly heavy load of TCP traffic using the default TCP stack, without VNET, and without any TCP hooks installed, the input/output hhook functions accounted for approximately .075% of the "busy" CPU cycles during one of my measurements. That certainly is not a large number, but it is large enough to be measurable. And, I think the hardware I used for the measurement is tuned for high-performance, so this may be close to the "best case" measurement. I suspect that systems with a large number of short-lived sessions will see a larger improvement from the deletion of khelp_init_osd() from the session setup path. (I didn't measure this.) I also suspect that systems with VNET will see a larger improvement. I also suspect that systems with slower memory busses, smaller caches, etc. will see a larger improvement. But, this is very hard to measure precisely in a generic sense. The one concrete thing we *can* measure is that the functions add some number of instructions to the session setup, session teardown, input, and output code paths. If you need those instructions to achieve the desired functionality (in this case, probably a congestion-control algorithm), then you probably want those instructions. If not, then you may want to delete them. This was the impetus to add a kernel option to give you the ability to decide whether you want to include the functionality. I hope this answer helps explain some more about the change. Jonathan From owner-svn-src-all@freebsd.org Wed Oct 12 15:29:24 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 65356C0FB9B; Wed, 12 Oct 2016 15:29:24 +0000 (UTC) (envelope-from andrew@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 1DE09376; Wed, 12 Oct 2016 15:29:24 +0000 (UTC) (envelope-from andrew@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9CFTNIj047009; Wed, 12 Oct 2016 15:29:23 GMT (envelope-from andrew@FreeBSD.org) Received: (from andrew@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9CFTN8Y047006; Wed, 12 Oct 2016 15:29:23 GMT (envelope-from andrew@FreeBSD.org) Message-Id: <201610121529.u9CFTN8Y047006@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: andrew set sender to andrew@FreeBSD.org using -f From: Andrew Turner Date: Wed, 12 Oct 2016 15:29:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307149 - head/release/arm X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Oct 2016 15:29:24 -0000 Author: andrew Date: Wed Oct 12 15:29:22 2016 New Revision: 307149 URL: https://svnweb.freebsd.org/changeset/base/307149 Log: Use the armv6 GENERIC kernel in the release images on hardware this kernel config supports. Approved by: gjb Sponsored by: ABT Systems Ltd Differential Revision: https://reviews.freebsd.org/D8147 Modified: head/release/arm/BANANAPI.conf head/release/arm/CUBIEBOARD2.conf head/release/arm/RPI2.conf Modified: head/release/arm/BANANAPI.conf ============================================================================== --- head/release/arm/BANANAPI.conf Wed Oct 12 13:56:14 2016 (r307148) +++ head/release/arm/BANANAPI.conf Wed Oct 12 15:29:22 2016 (r307149) @@ -7,7 +7,7 @@ EMBEDDEDBUILD=1 EMBEDDED_TARGET="arm" EMBEDDED_TARGET_ARCH="armv6" EMBEDDEDPORTS="sysutils/u-boot-bananapi" -KERNEL="ALLWINNER" +KERNEL="GENERIC" WORLD_FLAGS="${WORLD_FLAGS} UBLDR_LOADADDR=0x42000000" IMAGE_SIZE="1G" PART_SCHEME="MBR" Modified: head/release/arm/CUBIEBOARD2.conf ============================================================================== --- head/release/arm/CUBIEBOARD2.conf Wed Oct 12 13:56:14 2016 (r307148) +++ head/release/arm/CUBIEBOARD2.conf Wed Oct 12 15:29:22 2016 (r307149) @@ -7,7 +7,7 @@ EMBEDDEDBUILD=1 EMBEDDED_TARGET="arm" EMBEDDED_TARGET_ARCH="armv6" EMBEDDEDPORTS="sysutils/u-boot-cubieboard2" -KERNEL="ALLWINNER" +KERNEL="GENERIC" WORLD_FLAGS="${WORLD_FLAGS} UBLDR_LOADADDR=0x42000000" IMAGE_SIZE="1G" PART_SCHEME="MBR" Modified: head/release/arm/RPI2.conf ============================================================================== --- head/release/arm/RPI2.conf Wed Oct 12 13:56:14 2016 (r307148) +++ head/release/arm/RPI2.conf Wed Oct 12 15:29:22 2016 (r307149) @@ -7,7 +7,7 @@ EMBEDDEDBUILD=1 EMBEDDED_TARGET="arm" EMBEDDED_TARGET_ARCH="armv6" EMBEDDEDPORTS="sysutils/u-boot-rpi2" -KERNEL="RPI2" +KERNEL="GENERIC" WORLD_FLAGS="${WORLD_FLAGS} UBLDR_LOADADDR=0x2000000" IMAGE_SIZE="1G" PART_SCHEME="MBR" From owner-svn-src-all@freebsd.org Wed Oct 12 15:30:48 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id BEF12C0FCC4; Wed, 12 Oct 2016 15:30:48 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from citapm.icyb.net.ua (citapm.icyb.net.ua [212.40.38.140]) by mx1.freebsd.org (Postfix) with ESMTP id B69887A3; Wed, 12 Oct 2016 15:30:47 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from porto.starpoint.kiev.ua (porto-e.starpoint.kiev.ua [212.40.38.100]) by citapm.icyb.net.ua (8.8.8p3/ICyb-2.3exp) with ESMTP id SAA01556; Wed, 12 Oct 2016 18:30:45 +0300 (EEST) (envelope-from avg@FreeBSD.org) Received: from localhost ([127.0.0.1]) by porto.starpoint.kiev.ua with esmtp (Exim 4.34 (FreeBSD)) id 1buLUT-000IFW-F2; Wed, 12 Oct 2016 18:30:45 +0300 Subject: Re: svn commit: r306680 - in head/sys: amd64/amd64 amd64/include i386/include x86/include x86/x86 To: Konstantin Belousov References: <201610041701.u94H1OK3061119@repo.freebsd.org> <425655dd-ba13-8944-0f31-b1ad6666d90a@FreeBSD.org> <20161012134550.GX68202@kib.kiev.ua> Cc: src-committers@FreeBSD.org, svn-src-all@FreeBSD.org, svn-src-head@FreeBSD.org From: Andriy Gapon Message-ID: Date: Wed, 12 Oct 2016 18:30:09 +0300 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <20161012134550.GX68202@kib.kiev.ua> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Oct 2016 15:30:48 -0000 On 12/10/2016 16:45, Konstantin Belousov wrote: > On Wed, Oct 12, 2016 at 04:25:00PM +0300, Andriy Gapon wrote: >> On 04/10/2016 20:01, Konstantin Belousov wrote: >>> Author: kib >>> Date: Tue Oct 4 17:01:24 2016 >>> New Revision: 306680 >>> URL: https://svnweb.freebsd.org/changeset/base/306680 >>> >>> Log: >>> Re-apply r306516 (by cem): >>> >>> Reduce the cost of TLB invalidation on x86 by using per-CPU completion flags >>> >>> Reduce contention during TLB invalidation operations by using a per-CPU >>> completion flag, rather than a single atomically-updated variable. >> >> Kostik, >> >> could this commit cause a problem reported in the below links? >> https://bz-attachments.freebsd.org/attachment.cgi?id=175614 >> https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=213371 > > If I am reading the report right, the problem appears on the > 11.0-RELEASE system. The patch you reference was only applied to HEAD a > week ago and was not merged even to stable/11. Sorry for the noise, then. Somehow I thought that this went into the release branch, but obviously there was too little time for that. > The examination must start with backtracing the thread which owns the > smp_ipi_mtx (shown on the screenshot). It looks like DDB is not in GENERIC in 11.0? Not sure if the reporter would be able to configure a dump device and then save the dump given that the panic happens in the installer. If anyone could provide them with instructions that would be great. -- Andriy Gapon From owner-svn-src-all@freebsd.org Wed Oct 12 15:49:22 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 2DF78C0E332; Wed, 12 Oct 2016 15:49:22 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id F1F9B7B9; Wed, 12 Oct 2016 15:49:21 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9CFnLXB054946; Wed, 12 Oct 2016 15:49:21 GMT (envelope-from emaste@FreeBSD.org) Received: (from emaste@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9CFnL2n054945; Wed, 12 Oct 2016 15:49:21 GMT (envelope-from emaste@FreeBSD.org) Message-Id: <201610121549.u9CFnL2n054945@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: emaste set sender to emaste@FreeBSD.org using -f From: Ed Maste Date: Wed, 12 Oct 2016 15:49:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307150 - head/gnu/usr.bin/groff X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Oct 2016 15:49:22 -0000 Author: emaste Date: Wed Oct 12 15:49:20 2016 New Revision: 307150 URL: https://svnweb.freebsd.org/changeset/base/307150 Log: Avoid using 'head' in generating groff doc date It may not be available in certain cross build cases. Note that this is a slight change in functionality, in that now only the first line of the source ChangeLog file is processed. This is acceptable as groff will be retired and we won't encounter a possibly-different ChangeLog format. Reported by: jhibbits Tested by: jhibbits Modified: head/gnu/usr.bin/groff/mdate.sh Modified: head/gnu/usr.bin/groff/mdate.sh ============================================================================== --- head/gnu/usr.bin/groff/mdate.sh Wed Oct 12 15:29:22 2016 (r307149) +++ head/gnu/usr.bin/groff/mdate.sh Wed Oct 12 15:49:20 2016 (r307150) @@ -4,6 +4,5 @@ set -e test -r "$1" export LC_ALL=C -changelog_date=$(sed -E -n 's/^([0-9]{4}-[0-9]{2}-[0-9]{2}).*$/\1/p' "$1" |\ - head -n 1) +changelog_date=$(sed -E -n '1s/^([0-9]{4}-[0-9]{2}-[0-9]{2}).*$/\1/p' "$1") echo $(date -j -f %Y-%m-%d +"%e %B %Y" $changelog_date) From owner-svn-src-all@freebsd.org Wed Oct 12 16:03:47 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 13976C0EA9E; Wed, 12 Oct 2016 16:03:47 +0000 (UTC) (envelope-from slw@zxy.spb.ru) Received: from zxy.spb.ru (zxy.spb.ru [195.70.199.98]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id BEA68204; Wed, 12 Oct 2016 16:03:46 +0000 (UTC) (envelope-from slw@zxy.spb.ru) Received: from slw by zxy.spb.ru with local (Exim 4.86 (FreeBSD)) (envelope-from ) id 1buM0O-0002bE-FC; Wed, 12 Oct 2016 19:03:44 +0300 Date: Wed, 12 Oct 2016 19:03:44 +0300 From: Slawa Olhovchenkov To: Andriy Gapon Cc: Konstantin Belousov , svn-src-head@FreeBSD.org, svn-src-all@FreeBSD.org, src-committers@FreeBSD.org Subject: Re: svn commit: r306680 - in head/sys: amd64/amd64 amd64/include i386/include x86/include x86/x86 Message-ID: <20161012160344.GD57876@zxy.spb.ru> References: <201610041701.u94H1OK3061119@repo.freebsd.org> <425655dd-ba13-8944-0f31-b1ad6666d90a@FreeBSD.org> <20161012134550.GX68202@kib.kiev.ua> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) X-SA-Exim-Connect-IP: X-SA-Exim-Mail-From: slw@zxy.spb.ru X-SA-Exim-Scanned: No (on zxy.spb.ru); SAEximRunCond expanded to false X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Oct 2016 16:03:47 -0000 On Wed, Oct 12, 2016 at 06:30:09PM +0300, Andriy Gapon wrote: > On 12/10/2016 16:45, Konstantin Belousov wrote: > > On Wed, Oct 12, 2016 at 04:25:00PM +0300, Andriy Gapon wrote: > >> On 04/10/2016 20:01, Konstantin Belousov wrote: > >>> Author: kib > >>> Date: Tue Oct 4 17:01:24 2016 > >>> New Revision: 306680 > >>> URL: https://svnweb.freebsd.org/changeset/base/306680 > >>> > >>> Log: > >>> Re-apply r306516 (by cem): > >>> > >>> Reduce the cost of TLB invalidation on x86 by using per-CPU completion flags > >>> > >>> Reduce contention during TLB invalidation operations by using a per-CPU > >>> completion flag, rather than a single atomically-updated variable. > >> > >> Kostik, > >> > >> could this commit cause a problem reported in the below links? > >> https://bz-attachments.freebsd.org/attachment.cgi?id=175614 > >> https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=213371 > > > > If I am reading the report right, the problem appears on the > > 11.0-RELEASE system. The patch you reference was only applied to HEAD a > > week ago and was not merged even to stable/11. > > Sorry for the noise, then. Somehow I thought that this went into the release > branch, but obviously there was too little time for that. > > > The examination must start with backtracing the thread which owns the > > smp_ipi_mtx (shown on the screenshot). > > It looks like DDB is not in GENERIC in 11.0? Yes, DDB is absent in GENERIC 11.0 > Not sure if the reporter would be able to configure a dump device and then save > the dump given that the panic happens in the installer. > If anyone could provide them with instructions that would be great. > > -- > Andriy Gapon > _______________________________________________ > svn-src-all@freebsd.org mailing list > https://lists.freebsd.org/mailman/listinfo/svn-src-all > To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org" From owner-svn-src-all@freebsd.org Wed Oct 12 16:56:21 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B3CA3C0F883 for ; Wed, 12 Oct 2016 16:56:21 +0000 (UTC) (envelope-from zbb@semihalf.com) Received: from mail-lf0-x22b.google.com (mail-lf0-x22b.google.com [IPv6:2a00:1450:4010:c07::22b]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id E47AA2D9 for ; Wed, 12 Oct 2016 16:56:20 +0000 (UTC) (envelope-from zbb@semihalf.com) Received: by mail-lf0-x22b.google.com with SMTP id b81so83718016lfe.1 for ; Wed, 12 Oct 2016 09:56:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf-com.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=oYfLO1RHIN1LxwvoTwHbIjFchTXthduZORBX/Fr1DLY=; b=RZvECUQjgFdR9kJKvJPYfJ21Q9/dX/g+WaFpNIdY3pm58xOi/3IPlRfR0Fe+ooZPHQ Mg6vi8a1D6BTc7Tl3bIdL/F0JqEFBARLwzb35bHReMtUs4Yp2Gu1BrAMqaIj9+cGm0yj sJPUnEXGro+SDSAcjXzM4nrjfv+PwThEFVGRoCcdA+4mqepLlJ3WlO0HQdPCoZF2BK+x 279ioNivT/Hx81KZDol/OS54Dfp7LH91D0yetdKoXBZYl0m+KGXBqiIawyCPvuFUv+VX /EJDGdXkCUkKspWyOGwQdnM4qGlEaGDcROhAWxLvDrv37BgiCVeLVtTzbq/Yvqe5LKtu OZkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=oYfLO1RHIN1LxwvoTwHbIjFchTXthduZORBX/Fr1DLY=; b=OhbOAElhHVJnx9ZUlpDtIjx2B+iRFsExVKTOUfiP0GTzIYoT0aXKnwvTv2oZxncMYH Jol7P0b4zmvqPq0hrZVFWGi0sL9c4+2afDcwLTpAPdWTHYs/ohkSLrAkG4VJypEpzqhv s/oy4WsOY3xnb2b+iM2Y2HDvrm8Uq6n2vgsAKOoN4c2ByJxN1PJAlW4IJSfrSuLMy0gn Z4DYb2I49IMaQ4zpKsC+nclSrpjzUJEeFUkr1fdYZ2gt2aC1n6XDXhpanQXt5GRisoIT Uef05gtmOSG+pg4CXFGTkC7ru8mSnFm7QDD+LH0R1iaLjPQ0uvew+bR0h1QwlrWN4Szd yqzQ== X-Gm-Message-State: AA6/9RkOWT39wNOxjMiW50J9X+DLGVV3TPNGEeW8y2FB4cWXPeMDifwwII0oA5H/NJpS/MsXyuuJbQ1nDVdlfQ== X-Received: by 10.25.217.82 with SMTP id q79mr2400623lfg.13.1476291378567; Wed, 12 Oct 2016 09:56:18 -0700 (PDT) MIME-Version: 1.0 Received: by 10.25.3.215 with HTTP; Wed, 12 Oct 2016 09:55:57 -0700 (PDT) In-Reply-To: <201610112231.u9BMVk8K056208@repo.freebsd.org> References: <201610112231.u9BMVk8K056208@repo.freebsd.org> From: Zbigniew Bodek Date: Wed, 12 Oct 2016 18:55:57 +0200 Message-ID: Subject: Re: svn commit: r307072 - in head/usr.sbin: . efivar To: Warner Losh Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Content-Type: text/plain; charset=UTF-8 X-Content-Filtered-By: Mailman/MimeDel 2.1.23 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Oct 2016 16:56:21 -0000 Hello Warner, Did you try to build world for ARMv6 on HEAD? I'm not able to do so and the issues seems to be related to this commit (missing efivar.h file). Kind regards zbb 2016-10-12 0:31 GMT+02:00 Warner Losh : > Author: imp > Date: Tue Oct 11 22:31:45 2016 > New Revision: 307072 > URL: https://svnweb.freebsd.org/changeset/base/307072 > > Log: > Add efivar(1) to manipulate EFI variables. It uses a similar command > line interface to the Linux program, as well as adding a number of > useful features to make using it in shell scripts easier (since we > don't have a filesystem to fall back on interacting with). > > Differential Revision: https://reviews.freebsd.org/D8128 > Reviewed by: kib@, wblock@, Ganael Laplanche > > Added: > head/usr.sbin/efivar/ > head/usr.sbin/efivar/Makefile (contents, props changed) > head/usr.sbin/efivar/efivar.8 (contents, props changed) > head/usr.sbin/efivar/efivar.c (contents, props changed) > Modified: > head/usr.sbin/Makefile > > Modified: head/usr.sbin/Makefile > ============================================================ > ================== > --- head/usr.sbin/Makefile Tue Oct 11 22:30:41 2016 (r307071) > +++ head/usr.sbin/Makefile Tue Oct 11 22:31:45 2016 (r307072) > @@ -123,6 +123,7 @@ SUBDIR.${MK_BSNMP}+= bsnmpd > SUBDIR.${MK_CTM}+= ctm > SUBDIR.${MK_DIALOG}+= tzsetup > SUBDIR.${MK_DIALOG}+= bsdconfig > +SUBDIR.${MK_EFI}+= efivar > SUBDIR.${MK_FLOPPY}+= fdcontrol > SUBDIR.${MK_FLOPPY}+= fdformat > SUBDIR.${MK_FLOPPY}+= fdread > > Added: head/usr.sbin/efivar/Makefile > ============================================================ > ================== > --- /dev/null 00:00:00 1970 (empty, because file is newly added) > +++ head/usr.sbin/efivar/Makefile Tue Oct 11 22:31:45 2016 > (r307072) > @@ -0,0 +1,8 @@ > +# $FreeBSD$ > + > +PROG= efivar > +MAN= efivar.8 > + > +LIBADD= efivar > + > +.include > > Added: head/usr.sbin/efivar/efivar.8 > ============================================================ > ================== > --- /dev/null 00:00:00 1970 (empty, because file is newly added) > +++ head/usr.sbin/efivar/efivar.8 Tue Oct 11 22:31:45 2016 > (r307072) > @@ -0,0 +1,164 @@ > +.\" Copyright (c) 2003 Netflix, Inc > +.\" All rights reserved. > +.\" > +.\" Redistribution and use in source and binary forms, with or without > +.\" modification, are permitted provided that the following conditions > +.\" are met: > +.\" 1. Redistributions of source code must retain the above copyright > +.\" notice, this list of conditions and the following disclaimer. > +.\" 2. Redistributions in binary form must reproduce the above copyright > +.\" notice, this list of conditions and the following disclaimer in the > +.\" documentation and/or other materials provided with the > distribution. > +.\" > +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS OR CONTRIBUTORS BE > LIABLE > +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR > CONSEQUENTIAL > +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE > GOODS > +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, > STRICT > +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY > WAY > +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > +.\" SUCH DAMAGE. > +.\" > +.\" $FreeBSD$ > +.\" > +.Dd September 29, 2016 > +.Dt EFIVAR 8 > +.Os > +.Sh NAME > +.Nm efivar > +.Nd UEFI environemnt variable interaction > +.Sh SYNOPSIS > +.Nm > +.Op Fl abdDHlLNpRtw > +.Op Fl n Ar name > +.Op Fl f Ar file > +.Op Fl -append > +.Op Fl -ascii > +.Op Fl -attributes > +.Op Fl -binary > +.Op Fl -delete > +.Op Fl -fromfile Ar file > +.Op Fl -hex > +.Op Fl -list-guids > +.Op Fl -list > +.Op Fl -name Ar name > +.Op Fl -no-name > +.Op Fl -print > +.Op Fl -print-decimal > +.Op Fl -raw-guid > +.Op Fl -write > +.Ar name Ns Op = Ns Ar value > +.Sh DESCRIPTION > +This program manages > +.Dq Unified Extensible Firmware Interface > +.Pq UEFI > +environment variables. > +UEFI variables have three part: A namespace, a name and a value. > +The namespace is a GUID that's self assigned by the group defining the > +variables. > +The name is a Unicode name for the variable. > +The value is binary data. > +All Unicode data is presented to the user as UTF-8. > +.Pp > +The following options are available: > +.Bl -tag -width 20m > +.It Fl n Ar name Fl -name Ar name > +Specify the name of the variable to operate on. > +The > +.Ar name > +argument is the GUID of variable, followed by a dash, followed by the > +UEFI variable name. > +The GUID may be in numeric format, or may be one of the well known > +symbolic name (see > +.Fl -list-guids > +for a complete list). > +.It Fl f Ar file Fl -fromfile Ar file > +When writing or appending to a variable, take the data for the > +variable's value from > +.Ar file > +instead of from the command line. > +This flag implies > +.Fl -write > +unless the > +.Fl -append > +flag is given. > +This is not well understood and currently unimplemented. > +.It Fl a Fl -append > +Append the specified value to the UEFI variable rather than replacing > +it.p > +.It Fl t Ar attr Fl -attributes Ar attr > +Specify, in user hostile hexidecimal, the attributes for this > +variable. > +See section 7.2 (GetVariable subsection, Related Definitions) of the > +UEFI Specification for hex values to use. > +.It Fl A Fl -ascii > +Display the variable data as modified ascii: All printable characters > +are printed, while unprintable characters are rendered as a two-digit > +hexadecimal number preceeded by a % character. > +.It Fl A Fl -binary > +Display the variable data as binary data. > +Usually will be used with the > +.Fl N > +or > +.Fl -no-name > +flag. > +Useful in scripts. > +.It Fl D Fl -delete > +Delete the specified variable. > +May not be used with either the > +.Fl -write > +or the > +.Fl -append > +flags. > +No > +.Ar value > +may be specified. > +.It Fl H Fl -hex > +List variable data as a hex dump. > +.It Fl L Fl -list-guids > +Lists the well known GUIDs. > +The names listed here may be used in place of the numeric GUID values. > +These names will replace the numeric GUID values unless > +.Fl -raw-guid > +flag is specified. > +.It Fl l Fl -list > +List all the variables. > +If the > +.Fl -print > +flag is also listed, their values will be displayed. > +.It Fl N Fl -no-name > +Do not display the variable name. > +.It Fl p Fl -print > +Print the value of the variable. > +.It Fl d Fl -print-decimal > +Treat the value of the variable as a number and print it as a > +decimal. > +This is currently unimplemented. > +.It Fl R Fl -raw-guid > +Do not substitute well known names for GUID numeric values in output. > +.It Fl w Fl -write > +Write (replace) the variable specified with the value specified. > +.It Ar name > +Display the > +.Ar name > +environment variable. > +.It Ar name Ns = Ns Ar value > +Set the specified > +.Ar name > +to > +.Ar value . > +This is not yet implemented. > +.Sh COMPATIBILITY > +The > +.Nm > +program is intended to be compatible (strict superset) with a progam > +of the same name included in the Red Hat libefivar package. > +.Sh SEE ALSO > +Appendix A of the UEFI specification has the format for GUIDs. > +All GUIDs > +.Dq Globally Unique Identifiers > +have the format described in RFC 4122. > +.El > > Added: head/usr.sbin/efivar/efivar.c > ============================================================ > ================== > --- /dev/null 00:00:00 1970 (empty, because file is newly added) > +++ head/usr.sbin/efivar/efivar.c Tue Oct 11 22:31:45 2016 > (r307072) > @@ -0,0 +1,349 @@ > +/*- > + * Copyright (c) 2016 Netflix, Inc. > + * All rights reserved. > + * > + * Redistribution and use in source and binary forms, with or without > + * modification, are permitted provided that the following conditions > + * are met: > + * 1. Redistributions of source code must retain the above copyright > + * notice, this list of conditions and the following disclaimer. > + * 2. Redistributions in binary form must reproduce the above copyright > + * notice, this list of conditions and the following disclaimer in the > + * documentation and/or other materials provided with the distribution. > + * > + * THIS SOFTWARE IS PROVIDED BY NETAPP, INC ``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 NETAPP, INC OR CONTRIBUTORS BE > LIABLE > + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR > CONSEQUENTIAL > + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, > STRICT > + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY > WAY > + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > + * SUCH DAMAGE. > + */ > + > +#include > +__FBSDID("$FreeBSD$"); > + > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > +/* options descriptor */ > +static struct option longopts[] = { > + { "append", no_argument, NULL, 'a' }, > + { "ascii", no_argument, NULL, 'A' }, > + { "attributes", required_argument, NULL, 't' }, > + { "binary", no_argument, NULL, 'b' }, > + { "delete", no_argument, NULL, 'D' }, > + { "fromfile", required_argument, NULL, 'f' }, > + { "hex", no_argument, NULL, 'H' }, > + { "list-guids", no_argument, NULL, 'L' }, > + { "list", no_argument, NULL, 'l' }, > + { "name", required_argument, NULL, 'n' }, > + { "no-name", no_argument, NULL, 'N' }, > + { "print", no_argument, NULL, 'p' }, > + { "print-decimal", no_argument, NULL, 'd' }, > + { "raw-guid", no_argument, NULL, 'R' }, > + { "write", no_argument, NULL, 'w' }, > + { NULL, 0, NULL, 0 } > +}; > + > + > +static int aflag, Aflag, bflag, dflag, Dflag, Hflag, Nflag, > + lflag, Lflag, Rflag, wflag, pflag; > +static char *varname; > +static u_long attrib = 0x7; > + > +static void > +usage(void) > +{ > + > + errx(1, "efivar [-abdDHlLNpRtw] [-n name] [-f file] [--append] > [--ascii]\n" > + "\t[--attributes] [--binary] [--delete] [--fromfile file] > [--hex]\n" > + "\t[--list-guids] [--list] [--name name] [--no-name] > [--print]\n" > + "\t[--print-decimal] [--raw-guid] [--write] name[=value]"); > +} > + > +static void > +breakdown_name(char *name, efi_guid_t *guid, char **vname) > +{ > + char *cp; > + > + cp = strrchr(name, '-'); > + if (cp == NULL) > + errx(1, "Invalid name: %s", name); > + *vname = cp + 1; > + *cp = '\0'; > + if (efi_str_to_guid(name, guid) < 0) > + errx(1, "Invalid guid %s", name); > +} > + > +static uint8_t * > +get_value(char *val, size_t *datalen) > +{ > + static char buffer[16*1024]; > + > + if (val != NULL) { > + *datalen = strlen(val); > + return ((uint8_t *)val); > + } > + /* Read from stdin */ > + *datalen = sizeof(buffer); > + *datalen = read(0, buffer, *datalen); > + return ((uint8_t *)buffer); > +} > + > +static void > +append_variable(char *name, char *val) > +{ > + char *vname; > + efi_guid_t guid; > + size_t datalen; > + uint8_t *data; > + > + breakdown_name(name, &guid, &vname); > + data = get_value(val, &datalen); > + if (efi_append_variable(guid, vname, data, datalen, attrib) < 0) > + err(1, "efi_append_variable"); > +} > + > +static void > +delete_variable(char *name) > +{ > + char *vname; > + efi_guid_t guid; > + > + breakdown_name(name, &guid, &vname); > + if (efi_del_variable(guid, vname) < 0) > + err(1, "efi_del_variable"); > +} > + > +static void > +write_variable(char *name, char *val) > +{ > + char *vname; > + efi_guid_t guid; > + size_t datalen; > + uint8_t *data; > + > + breakdown_name(name, &guid, &vname); > + data = get_value(val, &datalen); > + if (efi_set_variable(guid, vname, data, datalen, attrib, 0) < 0) > + err(1, "efi_set_variable"); > +} > + > +static void > +asciidump(uint8_t *data, size_t datalen) > +{ > + size_t i; > + int len; > + > + len = 0; > + if (!Nflag) > + printf("\n"); > + for (i = 0; i < datalen; i++) { > + if (isprint(data[i])) { > + len++; > + if (len > 80) { > + len = 0; > + printf("\n"); > + } > + printf("%c", data[i]); > + } else { > + len +=3; > + if (len > 80) { > + len = 0; > + printf("\n"); > + } > + printf("%%%02x", data[i]); > + } > + } > + printf("\n"); > +} > + > +static void > +hexdump(uint8_t *data, size_t datalen) > +{ > + size_t i; > + > + if (!Nflag) > + printf("\n"); > + for (i = 0; i < datalen; i++) { > + if (i % 16 == 0) { > + if (i != 0) > + printf("\n"); > + printf("%04x: ", (int)i); > + } > + printf("%02x ", data[i]); > + } > + printf("\n"); > +} > + > +static void > +bindump(uint8_t *data, size_t datalen) > +{ > + write(1, data, datalen); > +} > + > +static void > +print_var(efi_guid_t *guid, char *name) > +{ > + uint32_t att; > + uint8_t *data; > + size_t datalen; > + char *gname; > + int rv; > + > + efi_guid_to_str(guid, &gname); > + if (!Nflag) > + printf("%s-%s", gname, name); > + if (pflag) { > + rv = efi_get_variable(*guid, name, &data, &datalen, &att); > + > + if (rv < 0) > + printf("\n --- Error getting value --- %d", errno); > + else { > + if (Aflag) > + asciidump(data, datalen); > + else if (bflag) > + bindump(data, datalen); > + else > + hexdump(data, datalen); > + } > + } > + free(gname); > + if (!Nflag) > + printf("\n"); > +} > + > +static void > +print_variable(char *name) > +{ > + char *vname; > + efi_guid_t guid; > + > + breakdown_name(name, &guid, &vname); > + print_var(&guid, vname); > +} > + > +static void > +print_variables(void) > +{ > + int rv; > + char *name = NULL; > + efi_guid_t *guid = NULL; > + > + while ((rv = efi_get_next_variable_name(&guid, &name)) > 0) > + print_var(guid, name); > + > + if (rv < 0) > + err(1, "Error listing names"); > +} > + > +static void > +parse_args(int argc, char **argv) > +{ > + int ch, i; > + > + while ((ch = getopt_long(argc, argv, "aAbdDf:HlLNn:pRt:w", > + longopts, NULL)) != -1) { > + switch (ch) { > + case 'a': > + aflag++; > + break; > + case 'A': > + Aflag++; > + break; > + case 'b': > + bflag++; > + break; > + case 'd': > + dflag++; > + break; > + case 'D': > + Dflag++; > + break; > + case 'H': > + Hflag++; > + break; > + case 'l': > + lflag++; > + break; > + case 'L': > + Lflag++; > + break; > + case 'n': > + varname = optarg; > + break; > + case 'N': > + Nflag++; > + break; > + case 'p': > + pflag++; > + break; > + case 'R': > + Rflag++; > + break; > + case 'w': > + wflag++; > + break; > + case 'f': > + case 't': > + case 0: > + errx(1, "unknown or unimplemented option\n"); > + break; > + default: > + usage(); > + } > + } > + argc -= optind; > + argv += optind; > + > + if (argc == 1) > + varname = argv[0]; > + > + if (aflag + Dflag + wflag > 1) { > + warnx("Can only use one of -a (--append), " > + "-D (--delete) and -w (--write)"); > + usage(); > + } > + > + if (aflag + Dflag + wflag > 0 && varname == NULL) { > + warnx("Must specify a variable for -a (--append), " > + "-D (--delete) or -w (--write)"); > + usage(); > + } > + > + if (aflag) > + append_variable(varname, NULL); > + else if (Dflag) > + delete_variable(varname); > + else if (wflag) > + write_variable(varname, NULL); > + else if (varname) { > + pflag++; > + print_variable(varname); > + } else if (argc > 0) { > + pflag++; > + for (i = 0; i < argc; i++) > + print_variable(argv[i]); > + } else > + print_variables(); > +} > + > +int > +main(int argc, char **argv) > +{ > + > + parse_args(argc, argv); > +} > _______________________________________________ > svn-src-all@freebsd.org mailing list > https://lists.freebsd.org/mailman/listinfo/svn-src-all > To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org" > From owner-svn-src-all@freebsd.org Wed Oct 12 17:11:01 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 5237FC0FDD9; Wed, 12 Oct 2016 17:11:01 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 0A216D72; Wed, 12 Oct 2016 17:11:00 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9CHB0w4087628; Wed, 12 Oct 2016 17:11:00 GMT (envelope-from gonzo@FreeBSD.org) Received: (from gonzo@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9CHAx9c087600; Wed, 12 Oct 2016 17:10:59 GMT (envelope-from gonzo@FreeBSD.org) Message-Id: <201610121710.u9CHAx9c087600@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: gonzo set sender to gonzo@FreeBSD.org using -f From: Oleksandr Tymoshenko Date: Wed, 12 Oct 2016 17:10:59 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307151 - in head/sys: arm/arm arm64/arm64 mips/mips X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Oct 2016 17:11:01 -0000 Author: gonzo Date: Wed Oct 12 17:10:59 2016 New Revision: 307151 URL: https://svnweb.freebsd.org/changeset/base/307151 Log: INTRNG: Propagate IRQ activation error to API consumer Keep resource state consistent with INTRNG state - if intr_activate_irq fails - deactivate resource and propagate error to calling function Reviewed by: mmel Modified: head/sys/arm/arm/nexus.c head/sys/arm64/arm64/nexus.c head/sys/mips/mips/nexus.c Modified: head/sys/arm/arm/nexus.c ============================================================================== --- head/sys/arm/arm/nexus.c Wed Oct 12 15:49:20 2016 (r307150) +++ head/sys/arm/arm/nexus.c Wed Oct 12 17:10:59 2016 (r307151) @@ -383,7 +383,11 @@ nexus_activate_resource(device_t bus, de return (0); } else if (type == SYS_RES_IRQ) { #ifdef INTRNG - intr_activate_irq(child, r); + err = intr_activate_irq(child, r); + if (err != 0) { + rman_deactivate_resource(r); + return (err); + } #endif } return (0); Modified: head/sys/arm64/arm64/nexus.c ============================================================================== --- head/sys/arm64/arm64/nexus.c Wed Oct 12 15:49:20 2016 (r307150) +++ head/sys/arm64/arm64/nexus.c Wed Oct 12 17:10:59 2016 (r307151) @@ -347,7 +347,11 @@ nexus_activate_resource(device_t bus, de rman_set_virtual(r, (void *)vaddr); rman_set_bushandle(r, vaddr); } else if (type == SYS_RES_IRQ) { - intr_activate_irq(child, r); + err = intr_activate_irq(child, r); + if (err != 0) { + rman_deactivate_resource(r); + return (err); + } } return (0); } Modified: head/sys/mips/mips/nexus.c ============================================================================== --- head/sys/mips/mips/nexus.c Wed Oct 12 15:49:20 2016 (r307150) +++ head/sys/mips/mips/nexus.c Wed Oct 12 17:10:59 2016 (r307151) @@ -433,7 +433,11 @@ nexus_activate_resource(device_t bus, de } else if (type == SYS_RES_IRQ) { #ifdef INTRNG #ifdef FDT - intr_activate_irq(child, r); + err = intr_activate_irq(child, r); + if (err != 0) { + rman_deactivate_resource(r); + return (err); + } #else /* * INTRNG without FDT needs to have the interrupt properly From owner-svn-src-all@freebsd.org Wed Oct 12 18:49:32 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 3905CC0F14C; Wed, 12 Oct 2016 18:49:32 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 0B1D41AE; Wed, 12 Oct 2016 18:49:31 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9CInVjS023211; Wed, 12 Oct 2016 18:49:31 GMT (envelope-from emaste@FreeBSD.org) Received: (from emaste@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9CInVpg023210; Wed, 12 Oct 2016 18:49:31 GMT (envelope-from emaste@FreeBSD.org) Message-Id: <201610121849.u9CInVpg023210@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: emaste set sender to emaste@FreeBSD.org using -f From: Ed Maste Date: Wed, 12 Oct 2016 18:49:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307152 - head/sys/mips/conf X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Oct 2016 18:49:32 -0000 Author: emaste Date: Wed Oct 12 18:49:30 2016 New Revision: 307152 URL: https://svnweb.freebsd.org/changeset/base/307152 Log: Add COMPAT_FREEBSD10 to the MIPS ERL kernel config As of r302092, pipe is a wrapper around pipe2 and the pipe syscall is no longer used. It is included only with the COMPAT_FREEBSD10 kernel option. Add the compat option to support upgrades from systems with an earlier userland. MFC after: 1 week Modified: head/sys/mips/conf/ERL Modified: head/sys/mips/conf/ERL ============================================================================== --- head/sys/mips/conf/ERL Wed Oct 12 17:10:59 2016 (r307151) +++ head/sys/mips/conf/ERL Wed Oct 12 18:49:30 2016 (r307152) @@ -74,6 +74,7 @@ options PSEUDOFS # Pseudo-filesystem f options GEOM_PART_GPT # GUID Partition Tables. options GEOM_LABEL # Provides labelization options COMPAT_FREEBSD32 # Compatible with o32 binaries +options COMPAT_FREEBSD10 # Compatible with FreeBSD10 options SCSI_DELAY=5000 # Delay (in ms) before probing SCSI options KTRACE # ktrace(1) support options STACK # stack(9) support From owner-svn-src-all@freebsd.org Wed Oct 12 19:06:52 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 581A3C0F679; Wed, 12 Oct 2016 19:06:52 +0000 (UTC) (envelope-from jtl@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 2FEA7231; Wed, 12 Oct 2016 19:06:52 +0000 (UTC) (envelope-from jtl@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9CJ6pgB031274; Wed, 12 Oct 2016 19:06:51 GMT (envelope-from jtl@FreeBSD.org) Received: (from jtl@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9CJ6oDn031269; Wed, 12 Oct 2016 19:06:50 GMT (envelope-from jtl@FreeBSD.org) Message-Id: <201610121906.u9CJ6oDn031269@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jtl set sender to jtl@FreeBSD.org using -f From: "Jonathan T. Looney" Date: Wed, 12 Oct 2016 19:06:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307153 - head/sys/netinet X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Oct 2016 19:06:52 -0000 Author: jtl Date: Wed Oct 12 19:06:50 2016 New Revision: 307153 URL: https://svnweb.freebsd.org/changeset/base/307153 Log: The TFO server-side code contains some changes that are not conditioned on the TCP_RFC7413 kernel option. This change removes those few instructions from the packet processing path. While not strictly necessary, for the sake of consistency, I applied the new IS_FASTOPEN macro to all places in the packet processing path that used the (t_flags & TF_FASTOPEN) check. Reviewed by: hiren Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D8219 Modified: head/sys/netinet/tcp_input.c head/sys/netinet/tcp_output.c head/sys/netinet/tcp_syncache.c head/sys/netinet/tcp_usrreq.c head/sys/netinet/tcp_var.h Modified: head/sys/netinet/tcp_input.c ============================================================================== --- head/sys/netinet/tcp_input.c Wed Oct 12 18:49:30 2016 (r307152) +++ head/sys/netinet/tcp_input.c Wed Oct 12 19:06:50 2016 (r307153) @@ -1028,7 +1028,7 @@ relocked: #endif if (!((tp->t_state == TCPS_ESTABLISHED && (thflags & TH_SYN) == 0) || (tp->t_state == TCPS_LISTEN && (thflags & TH_SYN) && - !(tp->t_flags & TF_FASTOPEN)))) { + !IS_FASTOPEN(tp->t_flags)))) { if (ti_locked == TI_UNLOCKED) { if (INP_INFO_TRY_RLOCK(&V_tcbinfo) == 0) { in_pcbref(inp); @@ -1506,7 +1506,9 @@ tcp_do_segment(struct mbuf *m, struct tc struct in_conninfo *inc; struct mbuf *mfree; struct tcpopt to; +#ifdef TCP_RFC7413 int tfo_syn; +#endif #ifdef TCPDEBUG /* @@ -1964,7 +1966,7 @@ tcp_do_segment(struct mbuf *m, struct tc goto dropwithreset; } #ifdef TCP_RFC7413 - if (tp->t_flags & TF_FASTOPEN) { + if (IS_FASTOPEN(tp->t_flags)) { /* * When a TFO connection is in SYN_RECEIVED, the * only valid packets are the initial SYN, a @@ -2398,7 +2400,7 @@ tcp_do_segment(struct mbuf *m, struct tc (tp->t_flags & TF_NEEDSYN)) { #ifdef TCP_RFC7413 if (tp->t_state == TCPS_SYN_RECEIVED && - tp->t_flags & TF_FASTOPEN) { + IS_FASTOPEN(tp->t_flags)) { tp->snd_wnd = tiwin; cc_conn_init(tp); } @@ -2461,7 +2463,7 @@ tcp_do_segment(struct mbuf *m, struct tc * snd_cwnd reduction that occurs when a TFO SYN|ACK * is retransmitted. */ - if (!(tp->t_flags & TF_FASTOPEN)) + if (!IS_FASTOPEN(tp->t_flags)) #endif cc_conn_init(tp); tcp_timer_activate(tp, TT_KEEP, TP_KEEPIDLE(tp)); @@ -3028,8 +3030,12 @@ dodata: /* XXX */ * case PRU_RCVD). If a FIN has already been received on this * connection then we just ignore the text. */ +#ifdef TCP_RFC7413 tfo_syn = ((tp->t_state == TCPS_SYN_RECEIVED) && - (tp->t_flags & TF_FASTOPEN)); + IS_FASTOPEN(tp->t_flags)); +#else +#define tfo_syn (false) +#endif if ((tlen || (thflags & TH_FIN) || tfo_syn) && TCPS_HAVERCVDFIN(tp->t_state) == 0) { tcp_seq save_start = th->th_seq; @@ -3253,6 +3259,9 @@ drop: if (tp != NULL) INP_WUNLOCK(tp->t_inpcb); m_freem(m); +#ifndef TCP_RFC7413 +#undef tfo_syn +#endif } /* Modified: head/sys/netinet/tcp_output.c ============================================================================== --- head/sys/netinet/tcp_output.c Wed Oct 12 18:49:30 2016 (r307152) +++ head/sys/netinet/tcp_output.c Wed Oct 12 19:06:50 2016 (r307153) @@ -230,7 +230,7 @@ tcp_output(struct tcpcb *tp) * For TFO connections in SYN_RECEIVED, only allow the initial * SYN|ACK and those sent by the retransmit timer. */ - if ((tp->t_flags & TF_FASTOPEN) && + if (IS_FASTOPEN(tp->t_flags) && (tp->t_state == TCPS_SYN_RECEIVED) && SEQ_GT(tp->snd_max, tp->snd_una) && /* initial SYN|ACK sent */ (tp->snd_nxt != tp->snd_una)) /* not a retransmit */ @@ -426,7 +426,7 @@ after_sack_rexmit: * When sending additional segments following a TFO SYN|ACK, * do not include the SYN bit. */ - if ((tp->t_flags & TF_FASTOPEN) && + if (IS_FASTOPEN(tp->t_flags) && (tp->t_state == TCPS_SYN_RECEIVED)) flags &= ~TH_SYN; #endif @@ -449,7 +449,7 @@ after_sack_rexmit: * don't include data, as the presence of data may have caused the * original SYN|ACK to have been dropped by a middlebox. */ - if ((tp->t_flags & TF_FASTOPEN) && + if (IS_FASTOPEN(tp->t_flags) && (((tp->t_state == TCPS_SYN_RECEIVED) && (tp->t_rxtshift > 0)) || (flags & TH_RST))) len = 0; @@ -786,7 +786,7 @@ send: * the TFO option may have caused the original * SYN|ACK to have been dropped by a middlebox. */ - if ((tp->t_flags & TF_FASTOPEN) && + if (IS_FASTOPEN(tp->t_flags) && (tp->t_state == TCPS_SYN_RECEIVED) && (tp->t_rxtshift == 0)) { to.to_tfo_len = TCP_FASTOPEN_COOKIE_LEN; Modified: head/sys/netinet/tcp_syncache.c ============================================================================== --- head/sys/netinet/tcp_syncache.c Wed Oct 12 18:49:30 2016 (r307152) +++ head/sys/netinet/tcp_syncache.c Wed Oct 12 19:06:50 2016 (r307153) @@ -1209,7 +1209,7 @@ syncache_add(struct in_conninfo *inc, st ltflags = (tp->t_flags & (TF_NOOPT | TF_SIGNATURE)); #ifdef TCP_RFC7413 - if (V_tcp_fastopen_enabled && (tp->t_flags & TF_FASTOPEN) && + if (V_tcp_fastopen_enabled && IS_FASTOPEN(tp->t_flags) && (tp->t_tfo_pending != NULL) && (to->to_flags & TOF_FASTOPEN)) { /* * Limit the number of pending TFO connections to Modified: head/sys/netinet/tcp_usrreq.c ============================================================================== --- head/sys/netinet/tcp_usrreq.c Wed Oct 12 18:49:30 2016 (r307152) +++ head/sys/netinet/tcp_usrreq.c Wed Oct 12 19:06:50 2016 (r307153) @@ -410,7 +410,7 @@ tcp_usr_listen(struct socket *so, int ba SOCK_UNLOCK(so); #ifdef TCP_RFC7413 - if (tp->t_flags & TF_FASTOPEN) + if (IS_FASTOPEN(tp->t_flags)) tp->t_tfo_pending = tcp_fastopen_alloc_counter(); #endif out: @@ -460,7 +460,7 @@ tcp6_usr_listen(struct socket *so, int b SOCK_UNLOCK(so); #ifdef TCP_RFC7413 - if (tp->t_flags & TF_FASTOPEN) + if (IS_FASTOPEN(tp->t_flags)) tp->t_tfo_pending = tcp_fastopen_alloc_counter(); #endif out: @@ -826,7 +826,7 @@ tcp_usr_rcvd(struct socket *so, int flag * application response data, or failing that, when the DELACK timer * expires. */ - if ((tp->t_flags & TF_FASTOPEN) && + if (IS_FASTOPEN(tp->t_flags) && (tp->t_state == TCPS_SYN_RECEIVED)) goto out; #endif Modified: head/sys/netinet/tcp_var.h ============================================================================== --- head/sys/netinet/tcp_var.h Wed Oct 12 18:49:30 2016 (r307152) +++ head/sys/netinet/tcp_var.h Wed Oct 12 19:06:50 2016 (r307153) @@ -349,6 +349,12 @@ struct tcpcb { #define ENTER_RECOVERY(t_flags) t_flags |= (TF_CONGRECOVERY | TF_FASTRECOVERY) #define EXIT_RECOVERY(t_flags) t_flags &= ~(TF_CONGRECOVERY | TF_FASTRECOVERY) +#if defined(_KERNEL) && !defined(TCP_RFC7413) +#define IS_FASTOPEN(t_flags) (false) +#else +#define IS_FASTOPEN(t_flags) (t_flags & TF_FASTOPEN) +#endif + #define BYTES_THIS_ACK(tp, th) (th->th_ack - tp->snd_una) /* From owner-svn-src-all@freebsd.org Wed Oct 12 19:53:12 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 0C386C0F509; Wed, 12 Oct 2016 19:53:12 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id BBBEA85F; Wed, 12 Oct 2016 19:53:11 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9CJrAjt051053; Wed, 12 Oct 2016 19:53:10 GMT (envelope-from gonzo@FreeBSD.org) Received: (from gonzo@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9CJrAXk051052; Wed, 12 Oct 2016 19:53:10 GMT (envelope-from gonzo@FreeBSD.org) Message-Id: <201610121953.u9CJrAXk051052@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: gonzo set sender to gonzo@FreeBSD.org using -f From: Oleksandr Tymoshenko Date: Wed, 12 Oct 2016 19:53:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307154 - head/sys/dev/usb/net X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Oct 2016 19:53:12 -0000 Author: gonzo Date: Wed Oct 12 19:53:10 2016 New Revision: 307154 URL: https://svnweb.freebsd.org/changeset/base/307154 Log: [fdt] Add one more heuristic to determine MAC address of the SMSC device - If check for net,ethernet/usb,device compatible node fails, try to find .../usb/hub/ethernet, where ... is bus path that can depend on actual HW. net,ethernet/usb,device compatibity strings are FreeBSD custom invention that is used only in RPi DTBs and since there is no other way to tie USB device to FDT node we just do our best effort here to work with upstream device tree - Use -1 value to indicate invalid phandle_t, 0 is valid phandle value and shouldn't be used as error signal Modified: head/sys/dev/usb/net/if_smsc.c Modified: head/sys/dev/usb/net/if_smsc.c ============================================================================== --- head/sys/dev/usb/net/if_smsc.c Wed Oct 12 19:06:50 2016 (r307153) +++ head/sys/dev/usb/net/if_smsc.c Wed Oct 12 19:53:10 2016 (r307154) @@ -1556,6 +1556,9 @@ smsc_ioctl(struct ifnet *ifp, u_long cmd } #ifdef FDT +/* + * This is FreeBSD-specific compatibility strings for RPi/RPi2 + */ static phandle_t smsc_fdt_find_eth_node(phandle_t start) { @@ -1567,11 +1570,68 @@ smsc_fdt_find_eth_node(phandle_t start) fdt_is_compatible(node, "usb,device")) return (node); child = smsc_fdt_find_eth_node(node); - if (child != 0) + if (child != -1) return (child); } - return (0); + return (-1); +} + +/* + * Check if node's path is <*>/usb/hub/ethernet + */ +static int +smsc_fdt_is_usb_eth(phandle_t node) +{ + char name[16]; + int len; + + memset(name, 0, sizeof(name)); + len = OF_getprop(node, "name", name, sizeof(name)); + if (len <= 0) + return (0); + + if (strcmp(name, "ethernet")) + return (0); + + node = OF_parent(node); + if (node == -1) + return (0); + len = OF_getprop(node, "name", name, sizeof(name)); + if (len <= 0) + return (0); + + if (strcmp(name, "hub")) + return (0); + + node = OF_parent(node); + if (node == -1) + return (0); + len = OF_getprop(node, "name", name, sizeof(name)); + if (len <= 0) + return (0); + + if (strcmp(name, "usb")) + return (0); + + return (1); +} + +static phandle_t +smsc_fdt_find_eth_node_by_path(phandle_t start) +{ + phandle_t child, node; + + /* Traverse through entire tree to find usb ethernet nodes. */ + for (node = OF_child(start); node != 0; node = OF_peer(node)) { + if (smsc_fdt_is_usb_eth(node)) + return (node); + child = smsc_fdt_find_eth_node_by_path(node); + if (child != -1) + return (child); + } + + return (-1); } /** @@ -1587,8 +1647,14 @@ smsc_fdt_find_mac(unsigned char *mac) root = OF_finddevice("/"); node = smsc_fdt_find_eth_node(root); - if (node != 0) { + /* + * If it's not FreeBSD FDT blob for RPi, try more + * generic .../usb/hub/ethernet + */ + if (node == -1) + node = smsc_fdt_find_eth_node_by_path(root); + if (node != -1) { /* Check if there is property */ if ((len = OF_getproplen(node, "local-mac-address")) > 0) { if (len != ETHER_ADDR_LEN) From owner-svn-src-all@freebsd.org Wed Oct 12 20:19:34 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C7F30C0F9B5; Wed, 12 Oct 2016 20:19:34 +0000 (UTC) (envelope-from jilles@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 7CB1A2B1; Wed, 12 Oct 2016 20:19:34 +0000 (UTC) (envelope-from jilles@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9CKJXvC058681; Wed, 12 Oct 2016 20:19:33 GMT (envelope-from jilles@FreeBSD.org) Received: (from jilles@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9CKJXT9058679; Wed, 12 Oct 2016 20:19:33 GMT (envelope-from jilles@FreeBSD.org) Message-Id: <201610122019.u9CKJXT9058679@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jilles set sender to jilles@FreeBSD.org using -f From: Jilles Tjoelker Date: Wed, 12 Oct 2016 20:19:33 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307155 - stable/10/lib/libc/sys X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Oct 2016 20:19:34 -0000 Author: jilles Date: Wed Oct 12 20:19:33 2016 New Revision: 307155 URL: https://svnweb.freebsd.org/changeset/base/307155 Log: MFC r305628: intro(2),_exit(2): Update for reaper (procctl(PROC_REAP_ACQUIRE)). Modified: stable/10/lib/libc/sys/_exit.2 stable/10/lib/libc/sys/intro.2 Directory Properties: stable/10/ (props changed) Modified: stable/10/lib/libc/sys/_exit.2 ============================================================================== --- stable/10/lib/libc/sys/_exit.2 Wed Oct 12 19:53:10 2016 (r307154) +++ stable/10/lib/libc/sys/_exit.2 Wed Oct 12 20:19:33 2016 (r307155) @@ -28,7 +28,7 @@ .\" @(#)_exit.2 8.1 (Berkeley) 6/4/93 .\" $FreeBSD$ .\" -.Dd June 4, 1993 +.Dd September 8, 2016 .Dt EXIT 2 .Os .Sh NAME @@ -64,9 +64,11 @@ is set as defined by .Xr wait 2 . .It The parent process-ID of all of the calling process's existing child -processes are set to 1; the initialization process +processes are set to the process-ID of the calling process's reaper; +the reaper (normally the initialization process) inherits each of these processes (see +.Xr procctl 2 , .Xr init 8 and the .Sx DEFINITIONS Modified: stable/10/lib/libc/sys/intro.2 ============================================================================== --- stable/10/lib/libc/sys/intro.2 Wed Oct 12 19:53:10 2016 (r307154) +++ stable/10/lib/libc/sys/intro.2 Wed Oct 12 20:19:33 2016 (r307155) @@ -28,7 +28,7 @@ .\" @(#)intro.2 8.5 (Berkeley) 2/27/95 .\" $FreeBSD$ .\" -.Dd May 4, 2013 +.Dd September 8, 2016 .Dt INTRO 2 .Os .Sh NAME @@ -486,7 +486,10 @@ A new process is created by a currently .Xr fork 2 ) . The parent process ID of a process is initially the process ID of its creator. If the creating process exits, -the parent process ID of each child is set to the ID of a system process, +the parent process ID of each child is set to the ID of the calling process's +reaper (see +.Xr procctl 2 ) , +normally .Xr init 8 . .It Process Group Each active process is a member of a process group that is identified by @@ -535,7 +538,7 @@ when none of its members has a parent pr as the group, but is in a different process group. Note that when a process exits, the parent process for its children -is changed to be +is normally changed to be .Xr init 8 , which is in a separate session. Not all members of an orphaned process group are necessarily orphaned From owner-svn-src-all@freebsd.org Wed Oct 12 20:24:34 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id AD579C0FB0A; Wed, 12 Oct 2016 20:24:34 +0000 (UTC) (envelope-from cperciva@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 7415A95D; Wed, 12 Oct 2016 20:24:34 +0000 (UTC) (envelope-from cperciva@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9CKOXpp062212; Wed, 12 Oct 2016 20:24:33 GMT (envelope-from cperciva@FreeBSD.org) Received: (from cperciva@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9CKOXQR062211; Wed, 12 Oct 2016 20:24:33 GMT (envelope-from cperciva@FreeBSD.org) Message-Id: <201610122024.u9CKOXQR062211@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cperciva set sender to cperciva@FreeBSD.org using -f From: Colin Percival Date: Wed, 12 Oct 2016 20:24:33 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307156 - head/usr.sbin/freebsd-update X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Oct 2016 20:24:34 -0000 Author: cperciva Date: Wed Oct 12 20:24:33 2016 New Revision: 307156 URL: https://svnweb.freebsd.org/changeset/base/307156 Log: MFportsnap r264740: Use case insensitive match when parsing host(1) output. Some DNS caches turn "FreeBSD.org" into "freebsd.org", which was causing the printed SRV records to not match our regex. PR: 170503 MFC after: 2 weeks Modified: head/usr.sbin/freebsd-update/freebsd-update.sh Modified: head/usr.sbin/freebsd-update/freebsd-update.sh ============================================================================== --- head/usr.sbin/freebsd-update/freebsd-update.sh Wed Oct 12 20:19:33 2016 (r307155) +++ head/usr.sbin/freebsd-update/freebsd-update.sh Wed Oct 12 20:24:33 2016 (r307156) @@ -953,7 +953,7 @@ fetch_pick_server_init () { # "$name server selection ..."; we allow either format. MLIST="_http._tcp.${SERVERNAME}" host -t srv "${MLIST}" | - sed -nE "s/${MLIST} (has SRV record|server selection) //p" | + sed -nE "s/${MLIST} (has SRV record|server selection) //Ip" | cut -f 1,2,4 -d ' ' | sed -e 's/\.$//' | sort > serverlist_full From owner-svn-src-all@freebsd.org Wed Oct 12 20:25:04 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id DFC1FC0FB5B; Wed, 12 Oct 2016 20:25:04 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id B1A7CAD8; Wed, 12 Oct 2016 20:25:04 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9CKP303062295; Wed, 12 Oct 2016 20:25:03 GMT (envelope-from emaste@FreeBSD.org) Received: (from emaste@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9CKP3s1062294; Wed, 12 Oct 2016 20:25:03 GMT (envelope-from emaste@FreeBSD.org) Message-Id: <201610122025.u9CKP3s1062294@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: emaste set sender to emaste@FreeBSD.org using -f From: Ed Maste Date: Wed, 12 Oct 2016 20:25:03 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307157 - head/usr.sbin X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Oct 2016 20:25:05 -0000 Author: emaste Date: Wed Oct 12 20:25:03 2016 New Revision: 307157 URL: https://svnweb.freebsd.org/changeset/base/307157 Log: Temporarily disconnect efivar to fix arm and i386 builds Modified: head/usr.sbin/Makefile Modified: head/usr.sbin/Makefile ============================================================================== --- head/usr.sbin/Makefile Wed Oct 12 20:24:33 2016 (r307156) +++ head/usr.sbin/Makefile Wed Oct 12 20:25:03 2016 (r307157) @@ -123,7 +123,7 @@ SUBDIR.${MK_BSNMP}+= bsnmpd SUBDIR.${MK_CTM}+= ctm SUBDIR.${MK_DIALOG}+= tzsetup SUBDIR.${MK_DIALOG}+= bsdconfig -SUBDIR.${MK_EFI}+= efivar +#SUBDIR.${MK_EFI}+= efivar SUBDIR.${MK_FLOPPY}+= fdcontrol SUBDIR.${MK_FLOPPY}+= fdformat SUBDIR.${MK_FLOPPY}+= fdread From owner-svn-src-all@freebsd.org Wed Oct 12 20:27:13 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 8EA12C0FBBD; Wed, 12 Oct 2016 20:27:13 +0000 (UTC) (envelope-from carpeddiem@gmail.com) Received: from mail-it0-x243.google.com (mail-it0-x243.google.com [IPv6:2607:f8b0:4001:c0b::243]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 57566C8F; Wed, 12 Oct 2016 20:27:13 +0000 (UTC) (envelope-from carpeddiem@gmail.com) Received: by mail-it0-x243.google.com with SMTP id o19so4606151ito.3; Wed, 12 Oct 2016 13:27:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=aWQLI+3DSYijs5IeyGuAHXUSPAyMUS0VMwjVb5bwym4=; b=xmn/G8pvXNbjyLP5BjOXMirMYM0hRN9FMNjYEPOvVPFBvrCcGZxuVhpFdidDdy+VDA zp+SeMNLLKcMccpYiJOiNy1iKDyhGJ+iucpUARbCEzkajVncbW4mWQAt5oewv4QNIG9Q 7egMlWRV3zCXaTRE1ziqVIV/PGUc8DuxIQDpuRZNI5g6zUIWiBRVVw4wdWw8SYOYGRBC l5NJBLnlO8jNQwoZjfNSHxvJa1WsC5eJ0D/lmrzvdeWviSiEthNckLdSN404NWF1LYZ1 Z3whLca0xk3LEv0LTa4ZqaYbscJuGXZuQgymPv0AJ0YW2KM+ajRqBBj4lyKQeSS9qE5P KPjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=aWQLI+3DSYijs5IeyGuAHXUSPAyMUS0VMwjVb5bwym4=; b=JhJ8Gv5eBTuwPXwrj9OTltDepkCmMljfTG3XaHVWr70lI6+iI+/ZrJODqBbn49+8Vb G7PTABUMnjD3hVh86OdE/W7EMT7WbcNY4FSYASYLCv4wO12CZx3iSzb6AQKPzLthHdUn csJUKbonQLF60fLxQNwT4zDaN0Xep7jL1zSJ0C0BxSsbcJSxVWx3Sy/iQp2O0QgmyDZX SqrFtps718QkoWQ0BUOQlZV08vK/sDufRsqnojlYKvy0stlj/N+XHEB0iYH7elGRR5ud kb6Tn6w7iLNZ6Rv/JS9bX0fuPTUdlS8GpOv6dZin8DFglz3v1LJlXbpVAWludbNVz8mY IC+g== X-Gm-Message-State: AA6/9RmhKTN7ws9MWcWF1SGnOyVmdxZvOTBegQ9/v4ROQXV/F0Rqxnkz3U8yRp7LCe5CqCFR8y5M+e+qcKM+zQ== X-Received: by 10.36.142.196 with SMTP id h187mr3238042ite.108.1476304032689; Wed, 12 Oct 2016 13:27:12 -0700 (PDT) MIME-Version: 1.0 Sender: carpeddiem@gmail.com Received: by 10.107.180.211 with HTTP; Wed, 12 Oct 2016 13:26:52 -0700 (PDT) In-Reply-To: References: <201610112231.u9BMVk8K056208@repo.freebsd.org> From: Ed Maste Date: Wed, 12 Oct 2016 16:26:52 -0400 X-Google-Sender-Auth: WYPtPLfKUgGzwc7zPOgoM4QSkAg Message-ID: Subject: Re: svn commit: r307072 - in head/usr.sbin: . efivar To: Zbigniew Bodek Cc: Warner Losh , "src-committers@freebsd.org" , "svn-src-all@freebsd.org" , "svn-src-head@freebsd.org" Content-Type: text/plain; charset=UTF-8 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Oct 2016 20:27:13 -0000 On 12 October 2016 at 12:55, Zbigniew Bodek wrote: > Hello Warner, > > Did you try to build world for ARMv6 on HEAD? I'm not able to do so and the > issues seems to be related to this commit (missing efivar.h file). Indeed, my tinderbox build failed for arm.arm, arm.armeb, arm.armv6, arm64.aarch64, pc98.i386, i386.i386 with /scratch/tmp/emaste/freebsd/usr.sbin/efivar/efivar.c:31:10: fatal error: 'efivar.h' file not found #include ^ I temporarily unhooked it from the build in r307157. From owner-svn-src-all@freebsd.org Wed Oct 12 20:50:14 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B6631C0E235; Wed, 12 Oct 2016 20:50:14 +0000 (UTC) (envelope-from avos@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 9133CAAB; Wed, 12 Oct 2016 20:50:14 +0000 (UTC) (envelope-from avos@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9CKoDoo070578; Wed, 12 Oct 2016 20:50:13 GMT (envelope-from avos@FreeBSD.org) Received: (from avos@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9CKoDb5070573; Wed, 12 Oct 2016 20:50:13 GMT (envelope-from avos@FreeBSD.org) Message-Id: <201610122050.u9CKoDb5070573@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avos set sender to avos@FreeBSD.org using -f From: Andriy Voskoboinyk Date: Wed, 12 Oct 2016 20:50:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307158 - in head/sys: dev/iwm dev/otus dev/usb/wlan net80211 X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Oct 2016 20:50:14 -0000 Author: avos Date: Wed Oct 12 20:50:13 2016 New Revision: 307158 URL: https://svnweb.freebsd.org/changeset/base/307158 Log: net80211: convert all ieee80211_input_mimo*() consumers to ieee80211_add_rx_params() + drop last (ieee80211_rx_stats) parameter Note: there is an additional check for ieee80211_get_rx_params() return value (which does not exist in the original diff). Reviewed by: adrian Differential Revision: https://reviews.freebsd.org/D8207 Modified: head/sys/dev/iwm/if_iwm.c head/sys/dev/otus/if_otus.c head/sys/dev/usb/wlan/if_rsu.c head/sys/net80211/ieee80211_input.c head/sys/net80211/ieee80211_proto.h Modified: head/sys/dev/iwm/if_iwm.c ============================================================================== --- head/sys/dev/iwm/if_iwm.c Wed Oct 12 20:25:03 2016 (r307157) +++ head/sys/dev/iwm/if_iwm.c Wed Oct 12 20:50:13 2016 (r307158) @@ -2977,6 +2977,8 @@ iwm_mvm_rx_rx_mpdu(struct iwm_softc *sc, /* rssi is in 1/2db units */ rxs.c_rssi = rssi * 2; rxs.c_nf = sc->sc_noise; + if (ieee80211_add_rx_params(m, &rxs) == 0) + goto fail; if (ieee80211_radiotap_active_vap(vap)) { struct iwm_rx_radiotap_header *tap = &sc->sc_rxtap; @@ -3013,11 +3015,11 @@ iwm_mvm_rx_rx_mpdu(struct iwm_softc *sc, IWM_UNLOCK(sc); if (ni != NULL) { IWM_DPRINTF(sc, IWM_DEBUG_RECV, "input m %p\n", m); - ieee80211_input_mimo(ni, m, &rxs); + ieee80211_input_mimo(ni, m); ieee80211_free_node(ni); } else { IWM_DPRINTF(sc, IWM_DEBUG_RECV, "inputall m %p\n", m); - ieee80211_input_mimo_all(ic, m, &rxs); + ieee80211_input_mimo_all(ic, m); } IWM_LOCK(sc); Modified: head/sys/dev/otus/if_otus.c ============================================================================== --- head/sys/dev/otus/if_otus.c Wed Oct 12 20:25:03 2016 (r307157) +++ head/sys/dev/otus/if_otus.c Wed Oct 12 20:50:13 2016 (r307158) @@ -1713,7 +1713,10 @@ otus_sub_rxeof(struct otus_softc *sc, ui rxs.c_nf = sc->sc_nf[0]; /* XXX chain 0 != combined rssi/nf */ rxs.c_rssi = tail->rssi; /* XXX TODO: add MIMO RSSI/NF as well */ - ieee80211_add_rx_params(m, &rxs); + if (ieee80211_add_rx_params(m, &rxs) == 0) { + counter_u64_add(ic->ic_ierrors, 1); + return; + } /* XXX make a method */ STAILQ_INSERT_TAIL(&rxq->mq_head, m, m_stailqpkt); @@ -1826,10 +1829,10 @@ tr_setup: if (ni != NULL) { if (ni->ni_flags & IEEE80211_NODE_HT) m->m_flags |= M_AMPDU; - (void)ieee80211_input_mimo(ni, m, NULL); + (void)ieee80211_input_mimo(ni, m); ieee80211_free_node(ni); } else - (void)ieee80211_input_mimo_all(ic, m, NULL); + (void)ieee80211_input_mimo_all(ic, m); } #ifdef IEEE80211_SUPPORT_SUPERG ieee80211_ff_age_all(ic, 100); Modified: head/sys/dev/usb/wlan/if_rsu.c ============================================================================== --- head/sys/dev/usb/wlan/if_rsu.c Wed Oct 12 20:25:03 2016 (r307157) +++ head/sys/dev/usb/wlan/if_rsu.c Wed Oct 12 20:50:13 2016 (r307158) @@ -1536,10 +1536,12 @@ rsu_event_survey(struct rsu_softc *sc, u /* This is a number from 0..100; so let's just divide it down a bit */ rxs.c_rssi = le32toh(bss->rssi) / 2; rxs.c_nf = -96; + if (ieee80211_add_rx_params(m, &rxs) == 0) + return; /* XXX avoid a LOR */ RSU_UNLOCK(sc); - ieee80211_input_mimo_all(ic, m, &rxs); + ieee80211_input_mimo_all(ic, m); RSU_LOCK(sc); } Modified: head/sys/net80211/ieee80211_input.c ============================================================================== --- head/sys/net80211/ieee80211_input.c Wed Oct 12 20:25:03 2016 (r307157) +++ head/sys/net80211/ieee80211_input.c Wed Oct 12 20:50:13 2016 (r307158) @@ -83,18 +83,14 @@ ieee80211_process_mimo(struct ieee80211_ } int -ieee80211_input_mimo(struct ieee80211_node *ni, struct mbuf *m, - struct ieee80211_rx_stats *rx) +ieee80211_input_mimo(struct ieee80211_node *ni, struct mbuf *m) { struct ieee80211_rx_stats rxs; - if (rx) { - memcpy(&rxs, rx, sizeof(*rx)); - } else { - /* try to read from mbuf */ - bzero(&rxs, sizeof(rxs)); - ieee80211_get_rx_params(m, &rxs); - } + /* try to read stats from mbuf */ + bzero(&rxs, sizeof(rxs)); + if (ieee80211_get_rx_params(m, &rxs) != 0) + return (-1); /* XXX should assert IEEE80211_R_NF and IEEE80211_R_RSSI are set */ ieee80211_process_mimo(ni, &rxs); @@ -111,27 +107,21 @@ ieee80211_input_all(struct ieee80211com rx.r_flags = IEEE80211_R_NF | IEEE80211_R_RSSI; rx.c_nf = nf; rx.c_rssi = rssi; - return ieee80211_input_mimo_all(ic, m, &rx); + + if (!ieee80211_add_rx_params(m, &rx)) + return (-1); + + return ieee80211_input_mimo_all(ic, m); } int -ieee80211_input_mimo_all(struct ieee80211com *ic, struct mbuf *m, - struct ieee80211_rx_stats *rx) +ieee80211_input_mimo_all(struct ieee80211com *ic, struct mbuf *m) { - struct ieee80211_rx_stats rxs; struct ieee80211vap *vap; int type = -1; m->m_flags |= M_BCAST; /* NB: mark for bpf tap'ing */ - if (rx) { - memcpy(&rxs, rx, sizeof(*rx)); - } else { - /* try to read from mbuf */ - bzero(&rxs, sizeof(rxs)); - ieee80211_get_rx_params(m, &rxs); - } - /* XXX locking */ TAILQ_FOREACH(vap, &ic->ic_vaps, iv_next) { struct ieee80211_node *ni; @@ -152,6 +142,7 @@ ieee80211_input_mimo_all(struct ieee8021 /* * Packet contents are changed by ieee80211_decap * so do a deep copy of the packet. + * NB: tags are copied too. */ mcopy = m_dup(m, M_NOWAIT); if (mcopy == NULL) { @@ -163,7 +154,7 @@ ieee80211_input_mimo_all(struct ieee8021 m = NULL; } ni = ieee80211_ref_node(vap->iv_bss); - type = ieee80211_input_mimo(ni, mcopy, &rxs); + type = ieee80211_input_mimo(ni, mcopy); ieee80211_free_node(ni); } if (m != NULL) /* no vaps, reclaim mbuf */ Modified: head/sys/net80211/ieee80211_proto.h ============================================================================== --- head/sys/net80211/ieee80211_proto.h Wed Oct 12 20:25:03 2016 (r307157) +++ head/sys/net80211/ieee80211_proto.h Wed Oct 12 20:50:13 2016 (r307158) @@ -83,10 +83,8 @@ void ieee80211_syncflag_ext(struct ieee8 ((ni)->ni_vap->iv_input(ni, m, NULL, rssi, nf)) int ieee80211_input_all(struct ieee80211com *, struct mbuf *, int, int); -int ieee80211_input_mimo(struct ieee80211_node *, struct mbuf *, - struct ieee80211_rx_stats *); -int ieee80211_input_mimo_all(struct ieee80211com *, struct mbuf *, - struct ieee80211_rx_stats *); +int ieee80211_input_mimo(struct ieee80211_node *, struct mbuf *); +int ieee80211_input_mimo_all(struct ieee80211com *, struct mbuf *); struct ieee80211_bpf_params; int ieee80211_mgmt_output(struct ieee80211_node *, struct mbuf *, int, From owner-svn-src-all@freebsd.org Wed Oct 12 20:50:19 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 307BEC0E25E; Wed, 12 Oct 2016 20:50:19 +0000 (UTC) (envelope-from dteske@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id D4409AEF; Wed, 12 Oct 2016 20:50:18 +0000 (UTC) (envelope-from dteske@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9CKoHgs070627; Wed, 12 Oct 2016 20:50:17 GMT (envelope-from dteske@FreeBSD.org) Received: (from dteske@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9CKoHSu070624; Wed, 12 Oct 2016 20:50:17 GMT (envelope-from dteske@FreeBSD.org) Message-Id: <201610122050.u9CKoHSu070624@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: dteske set sender to dteske@FreeBSD.org using -f From: Devin Teske Date: Wed, 12 Oct 2016 20:50:17 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307159 - in head/etc: defaults rc.d X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Oct 2016 20:50:19 -0000 Author: dteske Date: Wed Oct 12 20:50:17 2016 New Revision: 307159 URL: https://svnweb.freebsd.org/changeset/base/307159 Log: Many shops still prefer rc.conf(5) based jail configuration(s). In-part because they can use sysrc in conjunction with ssh and xargs to perform en-masse changes in a large distribution with lots of jails spread over many hosts on a LAN/WAN. Provide a mechanism for disabling the warning eschewed by /etc/rc.d/jail in said situation. If jail_confwarn="NO" is in rc.conf(5) (default "YES") skip the warning that per-jail configurations are obsolete and that the user should migrate to jail.conf(5). Reviewed by: jelischer MFC after: 3 days Sponsored by: FIS Global, Inc. Differential Revision: https://reviews.freebsd.org/D7465 Modified: head/etc/defaults/rc.conf head/etc/rc.d/jail Modified: head/etc/defaults/rc.conf ============================================================================== --- head/etc/defaults/rc.conf Wed Oct 12 20:50:13 2016 (r307158) +++ head/etc/defaults/rc.conf Wed Oct 12 20:50:17 2016 (r307159) @@ -695,6 +695,7 @@ iovctl_files="" # Config files for iovc ### Jail Configuration (see rc.conf(5) manual page) ########## ############################################################## jail_enable="NO" # Set to NO to disable starting of any jails +jail_confwarn="YES" # Prevent warning about obsolete per-jail configuration jail_parallel_start="NO" # Start jails in the background jail_list="" # Space separated list of names of jails jail_reverse_stop="NO" # Stop jails in reverse order Modified: head/etc/rc.d/jail ============================================================================== --- head/etc/rc.d/jail Wed Oct 12 20:50:13 2016 (r307158) +++ head/etc/rc.d/jail Wed Oct 12 20:50:17 2016 (r307159) @@ -147,7 +147,8 @@ parse_options() # # To relieve confusion, show a warning message. # - _confwarn=1 + : ${jail_confwarn:=YES} + checkyesno jail_confwarn && _confwarn=1 if [ -r "$jail_conf" -o -r "$_jconf" ]; then if ! checkyesno jail_parallel_start; then warn "$_conf is created and used for jail $_j." From owner-svn-src-all@freebsd.org Wed Oct 12 23:41:31 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 8F617C0FC3E; Wed, 12 Oct 2016 23:41:31 +0000 (UTC) (envelope-from cy.schubert@komquats.com) Received: from smtp-out-no.shaw.ca (smtp-out-no.shaw.ca [64.59.134.9]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "Client", Issuer "CA" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 34FC919B8; Wed, 12 Oct 2016 23:41:30 +0000 (UTC) (envelope-from cy.schubert@komquats.com) Received: from spqr.komquats.com ([96.50.22.10]) by shaw.ca with SMTP id uT9GbeOHGFfiXuT9HbEhFI; Wed, 12 Oct 2016 17:41:24 -0600 X-Authority-Analysis: v=2.2 cv=Qb8khYTv c=1 sm=1 tr=0 a=jvE2nwUzI0ECrNeyr98KWA==:117 a=jvE2nwUzI0ECrNeyr98KWA==:17 a=L9H7d07YOLsA:10 a=9cW_t1CCXrUA:10 a=s5jvgZ67dGcA:10 a=CH0kA5CcgfcA:10 a=oCJs8q-oAAAA:8 a=YxBL1-UpAAAA:8 a=6I5d2MoRAAAA:8 a=5liKsSN3vyoQSZ0aausA:9 a=CjuIK1q_8ugA:10 a=qUF70SbvcHBaGhGVny9j:22 a=Ia-lj3WSrqcvXOmTRaiG:22 a=IjZwj45LgO3ly-622nXo:22 Received: from slippy.cwsent.com (slippy8 [10.2.2.6]) by spqr.komquats.com (Postfix) with ESMTPS id 7607899C; Wed, 12 Oct 2016 16:41:21 -0700 (PDT) Received: from slippy (localhost [127.0.0.1]) by slippy.cwsent.com (8.15.2/8.15.2) with ESMTP id u9CNf2qO056708; Wed, 12 Oct 2016 16:41:02 -0700 (PDT) (envelope-from Cy.Schubert@cschubert.com) Message-Id: <201610122341.u9CNf2qO056708@slippy.cwsent.com> X-Mailer: exmh version 2.8.0 04/21/2012 with nmh-1.6 Reply-to: Cy Schubert From: Cy Schubert X-os: FreeBSD X-Sender: cy@cwsent.com X-URL: http://www.cschubert.com/ To: Ed Maste cc: Zbigniew Bodek , Warner Losh , "src-committers@freebsd.org" , "svn-src-all@freebsd.org" , "svn-src-head@freebsd.org" Subject: Re: svn commit: r307072 - in head/usr.sbin: . efivar In-Reply-To: Message from Ed Maste of "Wed, 12 Oct 2016 16:26:52 -0400." Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Wed, 12 Oct 2016 16:41:02 -0700 X-CMAE-Envelope: MS4wfF7k5Sa/Q8R2DFah8fOstN2nW5FzoHQ9pM2twMe71nTLIc3sizU1C64G2NQ6tW+c/dfjILIAVOsqyyJi39f4x/Zb6yyQFrE+DPbAtiY4x1dI4uwg6dke au6vhfEyv+005ZAytCz/vAVln2OhUx+CXUlwOchsOJ9ibGMa0WlhG+OzcSQWM+ByezZAZ9irqRFYsAtXUhpT2lf9lgyqFykTJO7QRowfWUtHLieN0MA4i3Y0 YPyHg/GzvSgJ/sAN2qWsrNjJK3pFGIWvmYmIuwUAT3C/vFxOkb+1rdPVB2cOZ4IYeOVu29TzeV3/PJSTNhTfwYEnMI1q793svPhejWCngeU= X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Oct 2016 23:41:31 -0000 In message , Ed Maste writes: > On 12 October 2016 at 12:55, Zbigniew Bodek wrote: > > Hello Warner, > > > > Did you try to build world for ARMv6 on HEAD? I'm not able to do so and the > > issues seems to be related to this commit (missing efivar.h file). > > Indeed, my tinderbox build failed for arm.arm, arm.armeb, arm.armv6, > arm64.aarch64, pc98.i386, i386.i386 with > > /scratch/tmp/emaste/freebsd/usr.sbin/efivar/efivar.c:31:10: fatal > error: 'efivar.h' file not found > #include > ^ > > I temporarily unhooked it from the build in r307157. > > I had the same on amd64. -- Cheers, Cy Schubert FreeBSD UNIX: Web: http://www.FreeBSD.org The need of the many outweighs the greed of the few. From owner-svn-src-all@freebsd.org Thu Oct 13 00:22:04 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 333C2C0D78D for ; Thu, 13 Oct 2016 00:22:04 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: from mail-io0-x22e.google.com (mail-io0-x22e.google.com [IPv6:2607:f8b0:4001:c06::22e]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 032B8B26 for ; Thu, 13 Oct 2016 00:22:03 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: by mail-io0-x22e.google.com with SMTP id j37so68220360ioo.3 for ; Wed, 12 Oct 2016 17:22:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20150623.gappssmtp.com; s=20150623; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=7+K+1Y+c4PSyq/8BnSYBiOVRwlLjI5im21eruxVSOW4=; b=JchJRXZQYWkpk3Q4bG3TWuShQxer6ne5U7Ac75V7P79lLnC2lOCwWJ4twjtvWR2Omu PpmDx4JF5EKKdrdEFQQEmV4O5GJ+P6f0tHw5vVRwM/dO/E2R+06EVwMJqYzKKOPNoUlq aqJVAryt7jyARo94euzExNKgpolf4fhWh/O5G/2gA5i3gJgfCms6U/PY0o6LUuPOQ9P0 CWwTKYP5VpPrLFFCblsq7j5Gri7+ZtpkU6f7CpVd4Cna4PZ212JfXLPY14JH+Vgh8CJZ qrQ9EZtoa3LxGh3aS4L9SvuKcWufXEs6Bi1wRZU0FzM2y5pJ7hjy4pqQMKq6EzyHfF+F R3WA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=7+K+1Y+c4PSyq/8BnSYBiOVRwlLjI5im21eruxVSOW4=; b=dIxvUuh3C+NS7JH+PlZXl5exmcRSsP4GrUq6KhJOU8GjxbmK4VVV5IU3DhsdV+D5kR 59f+yHooef9AhV2uiI3ivj14HHQz2ClCZqWP29IvjUQ2UTt1n9aTe2xiCJUIvGiM6XDQ NMhT2NsSpbcoRylczn6eJuj2pbDSIxaPQYWEMz6liFMmfe9A5ezwRtlvGlgwCEIRutWJ WrgzKnS+WHkHgKRQpf16YkYxoMzyr8pl+gmrEhCrQMr43gw+pFnYmt8K6qsGDf5ZLbQn BQGRpAdu5rOBZbGg40AIeAKdxE3yE5xkk3wbwPruy6SeFnYIx6PF+biagubmE1ITrBYA zK0g== X-Gm-Message-State: AA6/9Rl/XCu7cyaxZsXBa8mSnLxQEgXojCVJGYsBCG4ftKrw+NekpIDVeuJfzSgbQ5NZ45M6cT40zIHNCrkVFA== X-Received: by 10.107.142.67 with SMTP id q64mr4227077iod.0.1476318123239; Wed, 12 Oct 2016 17:22:03 -0700 (PDT) MIME-Version: 1.0 Sender: wlosh@bsdimp.com Received: by 10.79.77.85 with HTTP; Wed, 12 Oct 2016 17:22:02 -0700 (PDT) X-Originating-IP: [69.53.245.200] In-Reply-To: <201610122341.u9CNf2qO056708@slippy.cwsent.com> References: <201610122341.u9CNf2qO056708@slippy.cwsent.com> From: Warner Losh Date: Wed, 12 Oct 2016 18:22:02 -0600 X-Google-Sender-Auth: sEM25nBgXkOD4EdYi7u_m_-NSo0 Message-ID: Subject: Re: svn commit: r307072 - in head/usr.sbin: . efivar To: Cy Schubert Cc: Ed Maste , Zbigniew Bodek , Warner Losh , "src-committers@freebsd.org" , "svn-src-all@freebsd.org" , "svn-src-head@freebsd.org" Content-Type: text/plain; charset=UTF-8 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Oct 2016 00:22:04 -0000 I'll look into it. It worked just fine for me for all the builds I did on many different machines. Ugg. Warner On Wed, Oct 12, 2016 at 5:41 PM, Cy Schubert wrote: > In message om> > , Ed Maste writes: >> On 12 October 2016 at 12:55, Zbigniew Bodek wrote: >> > Hello Warner, >> > >> > Did you try to build world for ARMv6 on HEAD? I'm not able to do so and the >> > issues seems to be related to this commit (missing efivar.h file). >> >> Indeed, my tinderbox build failed for arm.arm, arm.armeb, arm.armv6, >> arm64.aarch64, pc98.i386, i386.i386 with >> >> /scratch/tmp/emaste/freebsd/usr.sbin/efivar/efivar.c:31:10: fatal >> error: 'efivar.h' file not found >> #include >> ^ >> >> I temporarily unhooked it from the build in r307157. >> >> > > I had the same on amd64. > > > -- > Cheers, > Cy Schubert > FreeBSD UNIX: Web: http://www.FreeBSD.org > > The need of the many outweighs the greed of the few. > > From owner-svn-src-all@freebsd.org Thu Oct 13 01:43:17 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 429B8C0EA1A; Thu, 13 Oct 2016 01:43:17 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 1D350D21; Thu, 13 Oct 2016 01:43:17 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9D1hG5K084232; Thu, 13 Oct 2016 01:43:16 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9D1hFAb084225; Thu, 13 Oct 2016 01:43:15 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610130143.u9D1hFAb084225@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Thu, 13 Oct 2016 01:43:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307160 - stable/10/sys/dev/hyperv/utilities X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Oct 2016 01:43:17 -0000 Author: sephe Date: Thu Oct 13 01:43:15 2016 New Revision: 307160 URL: https://svnweb.freebsd.org/changeset/base/307160 Log: MFC 303822-303824 303822 hyperv/ic: Remove never used second parameter of hv_negotiate_version() Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7422 303823 hyperv/ic: Expose the receive buffer length for callers to use. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7423 303824 hyperv/ic: Pass the channel callback to hv_util_attach() The saved channel callback in util softc is actually never used. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7424 Modified: stable/10/sys/dev/hyperv/utilities/hv_heartbeat.c stable/10/sys/dev/hyperv/utilities/hv_kvp.c stable/10/sys/dev/hyperv/utilities/hv_shutdown.c stable/10/sys/dev/hyperv/utilities/hv_timesync.c stable/10/sys/dev/hyperv/utilities/hv_util.c stable/10/sys/dev/hyperv/utilities/hv_util.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/hyperv/utilities/hv_heartbeat.c ============================================================================== --- stable/10/sys/dev/hyperv/utilities/hv_heartbeat.c Wed Oct 12 20:50:17 2016 (r307159) +++ stable/10/sys/dev/hyperv/utilities/hv_heartbeat.c Thu Oct 13 01:43:15 2016 (r307160) @@ -64,7 +64,7 @@ hv_heartbeat_cb(struct vmbus_channel *ch softc = (hv_util_sc*)context; buf = softc->receive_buffer;; - recvlen = PAGE_SIZE; + recvlen = softc->ic_buflen; ret = vmbus_chan_recv(channel, buf, &recvlen, &requestid); KASSERT(ret != ENOBUFS, ("hvheartbeat recvbuf is not large enough")); /* XXX check recvlen to make sure that it contains enough data */ @@ -75,8 +75,7 @@ hv_heartbeat_cb(struct vmbus_channel *ch &buf[sizeof(struct hv_vmbus_pipe_hdr)]; if (icmsghdrp->icmsgtype == HV_ICMSGTYPE_NEGOTIATE) { - hv_negotiate_version(icmsghdrp, NULL, buf); - + hv_negotiate_version(icmsghdrp, buf); } else { heartbeat_msg = (struct hv_vmbus_heartbeat_msg_data *) @@ -110,11 +109,7 @@ hv_heartbeat_probe(device_t dev) static int hv_heartbeat_attach(device_t dev) { - hv_util_sc *softc = (hv_util_sc*)device_get_softc(dev); - - softc->callback = hv_heartbeat_cb; - - return hv_util_attach(dev); + return hv_util_attach(dev, hv_heartbeat_cb); } static device_method_t heartbeat_methods[] = { Modified: stable/10/sys/dev/hyperv/utilities/hv_kvp.c ============================================================================== --- stable/10/sys/dev/hyperv/utilities/hv_kvp.c Wed Oct 12 20:50:17 2016 (r307159) +++ stable/10/sys/dev/hyperv/utilities/hv_kvp.c Thu Oct 13 01:43:15 2016 (r307160) @@ -629,7 +629,7 @@ hv_kvp_process_request(void *context, in kvp_buf = sc->util_sc.receive_buffer;; channel = vmbus_get_channel(sc->dev); - recvlen = 2 * PAGE_SIZE; + recvlen = sc->util_sc.ic_buflen; ret = vmbus_chan_recv(channel, kvp_buf, &recvlen, &requestid); KASSERT(ret != ENOBUFS, ("hvkvp recvbuf is not large enough")); /* XXX check recvlen to make sure that it contains enough data */ @@ -696,7 +696,7 @@ hv_kvp_process_request(void *context, in /* * Try reading next buffer */ - recvlen = 2 * PAGE_SIZE; + recvlen = sc->util_sc.ic_buflen; ret = vmbus_chan_recv(channel, kvp_buf, &recvlen, &requestid); KASSERT(ret != ENOBUFS, ("hvkvp recvbuf is not large enough")); /* XXX check recvlen to make sure that it contains enough data */ @@ -892,7 +892,6 @@ hv_kvp_attach(device_t dev) hv_kvp_sc *sc = (hv_kvp_sc*)device_get_softc(dev); - sc->util_sc.callback = hv_kvp_callback; sc->dev = dev; sema_init(&sc->dev_sema, 0, "hv_kvp device semaphore"); mtx_init(&sc->pending_mutex, "hv-kvp pending mutex", @@ -920,7 +919,7 @@ hv_kvp_attach(device_t dev) return (error); sc->hv_kvp_dev->si_drv1 = sc; - return hv_util_attach(dev); + return hv_util_attach(dev, hv_kvp_callback); } static int Modified: stable/10/sys/dev/hyperv/utilities/hv_shutdown.c ============================================================================== --- stable/10/sys/dev/hyperv/utilities/hv_shutdown.c Wed Oct 12 20:50:17 2016 (r307159) +++ stable/10/sys/dev/hyperv/utilities/hv_shutdown.c Thu Oct 13 01:43:15 2016 (r307160) @@ -68,7 +68,7 @@ hv_shutdown_cb(struct vmbus_channel *cha softc = (hv_util_sc*)context; buf = softc->receive_buffer;; - recv_len = PAGE_SIZE; + recv_len = softc->ic_buflen; ret = vmbus_chan_recv(channel, buf, &recv_len, &request_id); KASSERT(ret != ENOBUFS, ("hvshutdown recvbuf is not large enough")); /* XXX check recv_len to make sure that it contains enough data */ @@ -79,8 +79,7 @@ hv_shutdown_cb(struct vmbus_channel *cha &buf[sizeof(struct hv_vmbus_pipe_hdr)]; if (icmsghdrp->icmsgtype == HV_ICMSGTYPE_NEGOTIATE) { - hv_negotiate_version(icmsghdrp, NULL, buf); - + hv_negotiate_version(icmsghdrp, buf); } else { shutdown_msg = (struct hv_vmbus_shutdown_msg_data *) @@ -132,11 +131,7 @@ hv_shutdown_probe(device_t dev) static int hv_shutdown_attach(device_t dev) { - hv_util_sc *softc = (hv_util_sc*)device_get_softc(dev); - - softc->callback = hv_shutdown_cb; - - return hv_util_attach(dev); + return hv_util_attach(dev, hv_shutdown_cb); } static device_method_t shutdown_methods[] = { Modified: stable/10/sys/dev/hyperv/utilities/hv_timesync.c ============================================================================== --- stable/10/sys/dev/hyperv/utilities/hv_timesync.c Wed Oct 12 20:50:17 2016 (r307159) +++ stable/10/sys/dev/hyperv/utilities/hv_timesync.c Thu Oct 13 01:43:15 2016 (r307160) @@ -145,7 +145,7 @@ hv_timesync_cb(struct vmbus_channel *cha softc = (hv_timesync_sc*)context; time_buf = softc->util_sc.receive_buffer; - recvlen = PAGE_SIZE; + recvlen = softc->util_sc.ic_buflen; ret = vmbus_chan_recv(channel, time_buf, &recvlen, &requestId); KASSERT(ret != ENOBUFS, ("hvtimesync recvbuf is not large enough")); /* XXX check recvlen to make sure that it contains enough data */ @@ -155,7 +155,7 @@ hv_timesync_cb(struct vmbus_channel *cha sizeof(struct hv_vmbus_pipe_hdr)]; if (icmsghdrp->icmsgtype == HV_ICMSGTYPE_NEGOTIATE) { - hv_negotiate_version(icmsghdrp, NULL, time_buf); + hv_negotiate_version(icmsghdrp, time_buf); } else { timedatap = (struct hv_ictimesync_data *) &time_buf[ sizeof(struct hv_vmbus_pipe_hdr) + @@ -189,18 +189,16 @@ hv_timesync_attach(device_t dev) { hv_timesync_sc *softc = device_get_softc(dev); - softc->util_sc.callback = hv_timesync_cb; TASK_INIT(&softc->task, 1, hv_set_host_time, softc); - - return hv_util_attach(dev); + return hv_util_attach(dev, hv_timesync_cb); } static int hv_timesync_detach(device_t dev) { hv_timesync_sc *softc = device_get_softc(dev); - taskqueue_drain(taskqueue_thread, &softc->task); + taskqueue_drain(taskqueue_thread, &softc->task); return hv_util_detach(dev); } Modified: stable/10/sys/dev/hyperv/utilities/hv_util.c ============================================================================== --- stable/10/sys/dev/hyperv/utilities/hv_util.c Wed Oct 12 20:50:17 2016 (r307159) +++ stable/10/sys/dev/hyperv/utilities/hv_util.c Thu Oct 13 01:43:15 2016 (r307160) @@ -44,12 +44,13 @@ #include #include "hv_util.h" +#define VMBUS_IC_BRSIZE (4 * PAGE_SIZE) + void -hv_negotiate_version( - struct hv_vmbus_icmsg_hdr* icmsghdrp, - struct hv_vmbus_icmsg_negotiate* negop, - uint8_t* buf) +hv_negotiate_version(struct hv_vmbus_icmsg_hdr *icmsghdrp, uint8_t *buf) { + struct hv_vmbus_icmsg_negotiate *negop; + icmsghdrp->icmsgsize = 0x10; negop = (struct hv_vmbus_icmsg_negotiate *)&buf[ @@ -74,16 +75,15 @@ hv_negotiate_version( } int -hv_util_attach(device_t dev) +hv_util_attach(device_t dev, vmbus_chan_callback_t cb) { - struct hv_util_sc* softc; - struct vmbus_channel *chan; - int ret; - - softc = device_get_softc(dev); - softc->receive_buffer = - malloc(4 * PAGE_SIZE, M_DEVBUF, M_WAITOK | M_ZERO); - chan = vmbus_get_channel(dev); + struct hv_util_sc *sc = device_get_softc(dev); + struct vmbus_channel *chan = vmbus_get_channel(dev); + int error; + + sc->ic_buflen = VMBUS_IC_BRSIZE; + sc->receive_buffer = malloc(VMBUS_IC_BRSIZE, M_DEVBUF, + M_WAITOK | M_ZERO); /* * These services are not performance critical and do not need @@ -94,17 +94,13 @@ hv_util_attach(device_t dev) */ vmbus_chan_set_readbatch(chan, false); - ret = vmbus_chan_open(chan, 4 * PAGE_SIZE, 4 * PAGE_SIZE, NULL, 0, - softc->callback, softc); - - if (ret) - goto error0; - + error = vmbus_chan_open(chan, VMBUS_IC_BRSIZE, VMBUS_IC_BRSIZE, NULL, 0, + cb, sc); + if (error) { + free(sc->receive_buffer, M_DEVBUF); + return (error); + } return (0); - -error0: - free(softc->receive_buffer, M_DEVBUF); - return (ret); } int Modified: stable/10/sys/dev/hyperv/utilities/hv_util.h ============================================================================== --- stable/10/sys/dev/hyperv/utilities/hv_util.h Wed Oct 12 20:50:17 2016 (r307159) +++ stable/10/sys/dev/hyperv/utilities/hv_util.h Thu Oct 13 01:43:15 2016 (r307160) @@ -31,23 +31,20 @@ #ifndef _HVUTIL_H_ #define _HVUTIL_H_ +#include + /** * hv_util related structures * */ typedef struct hv_util_sc { - /* - * function to process Hyper-V messages - */ - void (*callback)(struct vmbus_channel *, void *); uint8_t *receive_buffer; + int ic_buflen; } hv_util_sc; -void hv_negotiate_version( - struct hv_vmbus_icmsg_hdr* icmsghdrp, - struct hv_vmbus_icmsg_negotiate* negop, - uint8_t* buf); +void hv_negotiate_version(struct hv_vmbus_icmsg_hdr *icmsghdrp, uint8_t *buf); -int hv_util_attach(device_t dev); +int hv_util_attach(device_t dev, vmbus_chan_callback_t cb); int hv_util_detach(device_t dev); + #endif From owner-svn-src-all@freebsd.org Thu Oct 13 01:51:51 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 0FF45C0EC27; Thu, 13 Oct 2016 01:51:51 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id D34A3210; Thu, 13 Oct 2016 01:51:50 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9D1po5W086309; Thu, 13 Oct 2016 01:51:50 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9D1pnIG086303; Thu, 13 Oct 2016 01:51:49 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610130151.u9D1pnIG086303@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Thu, 13 Oct 2016 01:51:49 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307161 - stable/10/sys/dev/hyperv/netvsc X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Oct 2016 01:51:51 -0000 Author: sephe Date: Thu Oct 13 01:51:49 2016 New Revision: 307161 URL: https://svnweb.freebsd.org/changeset/base/307161 Log: MFC 303867,303901 303867 hyperv/hn: Move gpa array out of netvsc_packet. Prepare to deprecate the netvsc_packet. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7436 303901 hyperv/hn: Reorganize send done callback. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7450 Added: stable/10/sys/dev/hyperv/netvsc/if_hnvar.h - copied unchanged from r303901, head/sys/dev/hyperv/netvsc/if_hnvar.h Modified: stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.c stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.c stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.c Thu Oct 13 01:43:15 2016 (r307160) +++ stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.c Thu Oct 13 01:51:49 2016 (r307161) @@ -67,6 +67,12 @@ static void hv_nv_on_receive_completion( static void hv_nv_on_receive(netvsc_dev *net_dev, struct hn_rx_ring *rxr, struct vmbus_channel *chan, const struct vmbus_chanpkt_hdr *pkt); +static void hn_nvs_sent_none(struct hn_send_ctx *sndc, + struct netvsc_dev_ *net_dev, struct vmbus_channel *chan, + const struct nvsp_msg_ *msg); + +static struct hn_send_ctx hn_send_ctx_none = + HN_SEND_CTX_INITIALIZER(hn_nvs_sent_none, NULL); /* * @@ -140,6 +146,7 @@ hv_nv_get_next_send_section(netvsc_dev * static int hv_nv_init_rx_buffer_with_net_vsp(struct hn_softc *sc) { + struct hn_send_ctx sndc; netvsc_dev *net_dev; nvsp_msg *init_pkt; int ret = 0; @@ -188,9 +195,10 @@ hv_nv_init_rx_buffer_with_net_vsp(struct /* Send the gpadl notification request */ + hn_send_ctx_init_simple(&sndc, hn_nvs_sent_wakeup, NULL); ret = vmbus_chan_send(sc->hn_prichan, VMBUS_CHANPKT_TYPE_INBAND, VMBUS_CHANPKT_FLAG_RC, - init_pkt, sizeof(nvsp_msg), (uint64_t)(uintptr_t)init_pkt); + init_pkt, sizeof(nvsp_msg), (uint64_t)(uintptr_t)&sndc); if (ret != 0) { goto cleanup; } @@ -239,6 +247,7 @@ exit: static int hv_nv_init_send_buffer_with_net_vsp(struct hn_softc *sc) { + struct hn_send_ctx sndc; netvsc_dev *net_dev; nvsp_msg *init_pkt; int ret = 0; @@ -286,9 +295,10 @@ hv_nv_init_send_buffer_with_net_vsp(stru /* Send the gpadl notification request */ + hn_send_ctx_init_simple(&sndc, hn_nvs_sent_wakeup, NULL); ret = vmbus_chan_send(sc->hn_prichan, VMBUS_CHANPKT_TYPE_INBAND, VMBUS_CHANPKT_FLAG_RC, - init_pkt, sizeof(nvsp_msg), (uint64_t)init_pkt); + init_pkt, sizeof(nvsp_msg), (uint64_t)(uintptr_t)&sndc); if (ret != 0) { goto cleanup; } @@ -347,8 +357,7 @@ hv_nv_destroy_rx_buffer(netvsc_dev *net_ ret = vmbus_chan_send(net_dev->sc->hn_prichan, VMBUS_CHANPKT_TYPE_INBAND, 0, revoke_pkt, sizeof(nvsp_msg), - (uint64_t)(uintptr_t)revoke_pkt); - + (uint64_t)(uintptr_t)&hn_send_ctx_none); /* * If we failed here, we might as well return and have a leak * rather than continue and a bugchk @@ -413,9 +422,8 @@ hv_nv_destroy_send_buffer(netvsc_dev *ne NETVSC_SEND_BUFFER_ID; ret = vmbus_chan_send(net_dev->sc->hn_prichan, - VMBUS_CHANPKT_TYPE_INBAND, 0, - revoke_pkt, sizeof(nvsp_msg), - (uint64_t)(uintptr_t)revoke_pkt); + VMBUS_CHANPKT_TYPE_INBAND, 0, revoke_pkt, sizeof(nvsp_msg), + (uint64_t)(uintptr_t)&hn_send_ctx_none); /* * If we failed here, we might as well return and have a leak * rather than continue and a bugchk @@ -465,6 +473,7 @@ static int hv_nv_negotiate_nvsp_protocol(struct hn_softc *sc, netvsc_dev *net_dev, uint32_t nvsp_ver) { + struct hn_send_ctx sndc; nvsp_msg *init_pkt; int ret; @@ -479,9 +488,10 @@ hv_nv_negotiate_nvsp_protocol(struct hn_ init_pkt->msgs.init_msgs.init.protocol_version_2 = nvsp_ver; /* Send the init request */ + hn_send_ctx_init_simple(&sndc, hn_nvs_sent_wakeup, NULL); ret = vmbus_chan_send(sc->hn_prichan, VMBUS_CHANPKT_TYPE_INBAND, VMBUS_CHANPKT_FLAG_RC, - init_pkt, sizeof(nvsp_msg), (uint64_t)(uintptr_t)init_pkt); + init_pkt, sizeof(nvsp_msg), (uint64_t)(uintptr_t)&sndc); if (ret != 0) return (-1); @@ -523,7 +533,7 @@ hv_nv_send_ndis_config(struct hn_softc * /* Send the configuration packet */ ret = vmbus_chan_send(sc->hn_prichan, VMBUS_CHANPKT_TYPE_INBAND, 0, - init_pkt, sizeof(nvsp_msg), (uint64_t)(uintptr_t)init_pkt); + init_pkt, sizeof(nvsp_msg), (uint64_t)(uintptr_t)&hn_send_ctx_none); if (ret != 0) return (-EINVAL); @@ -601,7 +611,7 @@ hv_nv_connect_to_vsp(struct hn_softc *sc /* Send the init request */ ret = vmbus_chan_send(sc->hn_prichan, VMBUS_CHANPKT_TYPE_INBAND, 0, - init_pkt, sizeof(nvsp_msg), (uint64_t)(uintptr_t)init_pkt); + init_pkt, sizeof(nvsp_msg), (uint64_t)(uintptr_t)&hn_send_ctx_none); if (ret != 0) { goto cleanup; } @@ -730,6 +740,43 @@ hv_nv_on_device_remove(struct hn_softc * return (0); } +void +hn_nvs_sent_wakeup(struct hn_send_ctx *sndc __unused, + struct netvsc_dev_ *net_dev, struct vmbus_channel *chan __unused, + const struct nvsp_msg_ *msg) +{ + /* Copy the response back */ + memcpy(&net_dev->channel_init_packet, msg, sizeof(nvsp_msg)); + sema_post(&net_dev->channel_init_sema); +} + +static void +hn_nvs_sent_none(struct hn_send_ctx *sndc __unused, + struct netvsc_dev_ *net_dev __unused, struct vmbus_channel *chan __unused, + const struct nvsp_msg_ *msg __unused) +{ + /* EMPTY */ +} + +void +hn_chim_free(struct netvsc_dev_ *net_dev, uint32_t chim_idx) +{ + u_long mask; + uint32_t idx; + + idx = chim_idx / BITS_PER_LONG; + KASSERT(idx < net_dev->bitsmap_words, + ("invalid chimney index 0x%x", chim_idx)); + + mask = 1UL << (chim_idx % BITS_PER_LONG); + KASSERT(net_dev->send_section_bitsmap[idx] & mask, + ("index bitmap 0x%lx, chimney index %u, " + "bitmap idx %d, bitmask 0x%lx", + net_dev->send_section_bitsmap[idx], chim_idx, idx, mask)); + + atomic_clear_long(&net_dev->send_section_bitsmap[idx], mask); +} + /* * Net VSC on send completion */ @@ -737,59 +784,15 @@ static void hv_nv_on_send_completion(netvsc_dev *net_dev, struct vmbus_channel *chan, const struct vmbus_chanpkt_hdr *pkt) { - const nvsp_msg *nvsp_msg_pkt; - netvsc_packet *net_vsc_pkt; + struct hn_send_ctx *sndc; - nvsp_msg_pkt = VMBUS_CHANPKT_CONST_DATA(pkt); - - if (nvsp_msg_pkt->hdr.msg_type == nvsp_msg_type_init_complete - || nvsp_msg_pkt->hdr.msg_type - == nvsp_msg_1_type_send_rx_buf_complete - || nvsp_msg_pkt->hdr.msg_type - == nvsp_msg_1_type_send_send_buf_complete - || nvsp_msg_pkt->hdr.msg_type - == nvsp_msg5_type_subchannel) { - /* Copy the response back */ - memcpy(&net_dev->channel_init_packet, nvsp_msg_pkt, - sizeof(nvsp_msg)); - sema_post(&net_dev->channel_init_sema); - } else if (nvsp_msg_pkt->hdr.msg_type == - nvsp_msg_1_type_send_rndis_pkt_complete) { - /* Get the send context */ - net_vsc_pkt = - (netvsc_packet *)(unsigned long)pkt->cph_xactid; - if (NULL != net_vsc_pkt) { - if (net_vsc_pkt->send_buf_section_idx != - NVSP_1_CHIMNEY_SEND_INVALID_SECTION_INDEX) { - u_long mask; - int idx; - - idx = net_vsc_pkt->send_buf_section_idx / - BITS_PER_LONG; - KASSERT(idx < net_dev->bitsmap_words, - ("invalid section index %u", - net_vsc_pkt->send_buf_section_idx)); - mask = 1UL << - (net_vsc_pkt->send_buf_section_idx % - BITS_PER_LONG); - - KASSERT(net_dev->send_section_bitsmap[idx] & - mask, - ("index bitmap 0x%lx, section index %u, " - "bitmap idx %d, bitmask 0x%lx", - net_dev->send_section_bitsmap[idx], - net_vsc_pkt->send_buf_section_idx, - idx, mask)); - atomic_clear_long( - &net_dev->send_section_bitsmap[idx], mask); - } - - /* Notify the layer above us */ - net_vsc_pkt->compl.send.on_send_completion(chan, - net_vsc_pkt->compl.send.send_completion_context); - - } - } + sndc = (struct hn_send_ctx *)(uintptr_t)pkt->cph_xactid; + sndc->hn_cb(sndc, net_dev, chan, VMBUS_CHANPKT_CONST_DATA(pkt)); + /* + * NOTE: + * 'sndc' CAN NOT be accessed anymore, since it can be freed by + * its callback. + */ } /* @@ -798,13 +801,14 @@ hv_nv_on_send_completion(netvsc_dev *net * Returns 0 on success, non-zero on failure. */ int -hv_nv_on_send(struct vmbus_channel *chan, netvsc_packet *pkt) +hv_nv_on_send(struct vmbus_channel *chan, bool is_data_pkt, + struct hn_send_ctx *sndc, struct vmbus_gpa *gpa, int gpa_cnt) { nvsp_msg send_msg; int ret; send_msg.hdr.msg_type = nvsp_msg_1_type_send_rndis_pkt; - if (pkt->is_data_pkt) { + if (is_data_pkt) { /* 0 is RMC_DATA */ send_msg.msgs.vers_1_msgs.send_rndis_pkt.chan_type = 0; } else { @@ -813,17 +817,17 @@ hv_nv_on_send(struct vmbus_channel *chan } send_msg.msgs.vers_1_msgs.send_rndis_pkt.send_buf_section_idx = - pkt->send_buf_section_idx; + sndc->hn_chim_idx; send_msg.msgs.vers_1_msgs.send_rndis_pkt.send_buf_section_size = - pkt->send_buf_section_size; + sndc->hn_chim_sz; - if (pkt->gpa_cnt) { - ret = vmbus_chan_send_sglist(chan, pkt->gpa, pkt->gpa_cnt, - &send_msg, sizeof(nvsp_msg), (uint64_t)(uintptr_t)pkt); + if (gpa_cnt) { + ret = vmbus_chan_send_sglist(chan, gpa, gpa_cnt, + &send_msg, sizeof(nvsp_msg), (uint64_t)(uintptr_t)sndc); } else { ret = vmbus_chan_send(chan, VMBUS_CHANPKT_TYPE_INBAND, VMBUS_CHANPKT_FLAG_RC, - &send_msg, sizeof(nvsp_msg), (uint64_t)(uintptr_t)pkt); + &send_msg, sizeof(nvsp_msg), (uint64_t)(uintptr_t)sndc); } return (ret); Modified: stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h Thu Oct 13 01:43:15 2016 (r307160) +++ stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h Thu Oct 13 01:51:49 2016 (r307161) @@ -1112,33 +1112,10 @@ typedef void (*pfn_on_send_rx_completion #endif typedef struct netvsc_packet_ { - uint8_t is_data_pkt; /* One byte */ - uint16_t vlan_tci; - uint32_t status; - - /* Completion */ - union { - struct { - uint64_t rx_completion_tid; - void *rx_completion_context; - /* This is no longer used */ - pfn_on_send_rx_completion on_rx_completion; - } rx; - struct { - uint64_t send_completion_tid; - void *send_completion_context; - /* Still used in netvsc and filter code */ - pfn_on_send_rx_completion on_send_completion; - } send; - } compl; - uint32_t send_buf_section_idx; - uint32_t send_buf_section_size; - - void *rndis_mesg; + uint16_t vlan_tci; + uint32_t status; uint32_t tot_data_buf_len; void *data; - uint32_t gpa_cnt; - struct vmbus_gpa gpa[NETVSC_PACKET_MAXPAGE]; } netvsc_packet; typedef struct { @@ -1216,6 +1193,9 @@ struct hn_tx_ring { bus_dma_tag_t hn_tx_data_dtag; uint64_t hn_csum_assist; + int hn_gpa_cnt; + struct vmbus_gpa hn_gpa[NETVSC_PACKET_MAXPAGE]; + u_long hn_no_txdescs; u_long hn_send_failed; u_long hn_txdma_failed; @@ -1270,13 +1250,15 @@ typedef struct hn_softc { * Externs */ extern int hv_promisc_mode; +struct hn_send_ctx; void netvsc_linkstatus_callback(struct hn_softc *sc, uint32_t status); netvsc_dev *hv_nv_on_device_add(struct hn_softc *sc, void *additional_info, struct hn_rx_ring *rxr); int hv_nv_on_device_remove(struct hn_softc *sc, boolean_t destroy_channel); -int hv_nv_on_send(struct vmbus_channel *chan, netvsc_packet *pkt); +int hv_nv_on_send(struct vmbus_channel *chan, bool is_data_pkt, + struct hn_send_ctx *sndc, struct vmbus_gpa *gpa, int gpa_cnt); int hv_nv_get_next_send_section(netvsc_dev *net_dev); void hv_nv_subchan_attach(struct vmbus_channel *chan, struct hn_rx_ring *rxr); Modified: stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Thu Oct 13 01:43:15 2016 (r307160) +++ stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Thu Oct 13 01:51:49 2016 (r307161) @@ -168,7 +168,7 @@ struct hn_txdesc { struct hn_tx_ring *txr; int refs; uint32_t flags; /* HN_TXD_FLAG_ */ - netvsc_packet netvsc_pkt; /* XXX to be removed */ + struct hn_send_ctx send_ctx; bus_dmamap_t data_dmap; @@ -793,14 +793,14 @@ hn_txeof(struct hn_tx_ring *txr) } static void -hn_tx_done(struct vmbus_channel *chan, void *xpkt) +hn_tx_done(struct hn_send_ctx *sndc, struct netvsc_dev_ *net_dev, + struct vmbus_channel *chan, const struct nvsp_msg_ *msg __unused) { - netvsc_packet *packet = xpkt; - struct hn_txdesc *txd; + struct hn_txdesc *txd = sndc->hn_cbarg; struct hn_tx_ring *txr; - txd = (struct hn_txdesc *)(uintptr_t) - packet->compl.send.send_completion_tid; + if (sndc->hn_chim_idx != NVSP_1_CHIMNEY_SEND_INVALID_SECTION_INDEX) + hn_chim_free(net_dev, sndc->hn_chim_idx); txr = txd->txr; KASSERT(txr->hn_chan == chan, @@ -853,16 +853,14 @@ hn_encap(struct hn_tx_ring *txr, struct bus_dma_segment_t segs[HN_TX_DATA_SEGCNT_MAX]; int error, nsegs, i; struct mbuf *m_head = *m_head0; - netvsc_packet *packet; rndis_msg *rndis_mesg; rndis_packet *rndis_pkt; rndis_per_packet_info *rppi; struct rndis_hash_value *hash_value; - uint32_t rndis_msg_size; + uint32_t rndis_msg_size, tot_data_buf_len, send_buf_section_idx; + int send_buf_section_size; - packet = &txd->netvsc_pkt; - packet->is_data_pkt = TRUE; - packet->tot_data_buf_len = m_head->m_pkthdr.len; + tot_data_buf_len = m_head->m_pkthdr.len; /* * extension points to the area reserved for the @@ -877,7 +875,7 @@ hn_encap(struct hn_tx_ring *txr, struct rndis_pkt = &rndis_mesg->msg.packet; rndis_pkt->data_offset = sizeof(rndis_packet); - rndis_pkt->data_length = packet->tot_data_buf_len; + rndis_pkt->data_length = tot_data_buf_len; rndis_pkt->per_pkt_info_offset = sizeof(rndis_packet); rndis_msg_size = RNDIS_MESSAGE_SIZE(rndis_packet); @@ -985,15 +983,14 @@ hn_encap(struct hn_tx_ring *txr, struct } } - rndis_mesg->msg_len = packet->tot_data_buf_len + rndis_msg_size; - packet->tot_data_buf_len = rndis_mesg->msg_len; + rndis_mesg->msg_len = tot_data_buf_len + rndis_msg_size; + tot_data_buf_len = rndis_mesg->msg_len; /* * Chimney send, if the packet could fit into one chimney buffer. */ - if (packet->tot_data_buf_len < txr->hn_tx_chimney_size) { + if (tot_data_buf_len < txr->hn_tx_chimney_size) { netvsc_dev *net_dev = txr->hn_sc->net_dev; - uint32_t send_buf_section_idx; txr->hn_tx_chimney_tried++; send_buf_section_idx = @@ -1008,10 +1005,8 @@ hn_encap(struct hn_tx_ring *txr, struct dest += rndis_msg_size; m_copydata(m_head, 0, m_head->m_pkthdr.len, dest); - packet->send_buf_section_idx = send_buf_section_idx; - packet->send_buf_section_size = - packet->tot_data_buf_len; - packet->gpa_cnt = 0; + send_buf_section_size = tot_data_buf_len; + txr->hn_gpa_cnt = 0; txr->hn_tx_chimney++; goto done; } @@ -1037,19 +1032,19 @@ hn_encap(struct hn_tx_ring *txr, struct } *m_head0 = m_head; - packet->gpa_cnt = nsegs + HV_RF_NUM_TX_RESERVED_PAGE_BUFS; + txr->hn_gpa_cnt = nsegs + HV_RF_NUM_TX_RESERVED_PAGE_BUFS; /* send packet with page buffer */ - packet->gpa[0].gpa_page = atop(txd->rndis_msg_paddr); - packet->gpa[0].gpa_ofs = txd->rndis_msg_paddr & PAGE_MASK; - packet->gpa[0].gpa_len = rndis_msg_size; + txr->hn_gpa[0].gpa_page = atop(txd->rndis_msg_paddr); + txr->hn_gpa[0].gpa_ofs = txd->rndis_msg_paddr & PAGE_MASK; + txr->hn_gpa[0].gpa_len = rndis_msg_size; /* * Fill the page buffers with mbuf info starting at index * HV_RF_NUM_TX_RESERVED_PAGE_BUFS. */ for (i = 0; i < nsegs; ++i) { - struct vmbus_gpa *gpa = &packet->gpa[ + struct vmbus_gpa *gpa = &txr->hn_gpa[ i + HV_RF_NUM_TX_RESERVED_PAGE_BUFS]; gpa->gpa_page = atop(segs[i].ds_addr); @@ -1057,16 +1052,14 @@ hn_encap(struct hn_tx_ring *txr, struct gpa->gpa_len = segs[i].ds_len; } - packet->send_buf_section_idx = - NVSP_1_CHIMNEY_SEND_INVALID_SECTION_INDEX; - packet->send_buf_section_size = 0; + send_buf_section_idx = NVSP_1_CHIMNEY_SEND_INVALID_SECTION_INDEX; + send_buf_section_size = 0; done: txd->m = m_head; /* Set the completion routine */ - packet->compl.send.on_send_completion = hn_tx_done; - packet->compl.send.send_completion_context = packet; - packet->compl.send.send_completion_tid = (uint64_t)(uintptr_t)txd; + hn_send_ctx_init(&txd->send_ctx, hn_tx_done, txd, + send_buf_section_idx, send_buf_section_size); return 0; } @@ -1086,7 +1079,8 @@ again: * Make sure that txd is not freed before ETHER_BPF_MTAP. */ hn_txdesc_hold(txd); - error = hv_nv_on_send(txr->hn_chan, &txd->netvsc_pkt); + error = hv_nv_on_send(txr->hn_chan, true, &txd->send_ctx, + txr->hn_gpa, txr->hn_gpa_cnt); if (!error) { ETHER_BPF_MTAP(ifp, txd->m); if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); Modified: stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.c Thu Oct 13 01:43:15 2016 (r307160) +++ stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.c Thu Oct 13 01:51:49 2016 (r307161) @@ -86,11 +86,17 @@ static int hv_rf_set_packet_filter(rndi static int hv_rf_init_device(rndis_device *device); static int hv_rf_open_device(rndis_device *device); static int hv_rf_close_device(rndis_device *device); -static void hv_rf_on_send_request_completion(struct vmbus_channel *, void *context); -static void hv_rf_on_send_request_halt_completion(struct vmbus_channel *, void *context); int hv_rf_send_offload_request(struct hn_softc *sc, rndis_offload_params *offloads); + +static void hn_rndis_sent_halt(struct hn_send_ctx *sndc, + struct netvsc_dev_ *net_dev, struct vmbus_channel *chan, + const struct nvsp_msg_ *msg); +static void hn_rndis_sent_cb(struct hn_send_ctx *sndc, + struct netvsc_dev_ *net_dev, struct vmbus_channel *chan, + const struct nvsp_msg_ *msg); + /* * Set the Per-Packet-Info with the specified type */ @@ -239,45 +245,36 @@ static int hv_rf_send_request(rndis_device *device, rndis_request *request, uint32_t message_type) { - int ret; - netvsc_packet *packet; netvsc_dev *net_dev = device->net_dev; - int send_buf_section_idx; + uint32_t send_buf_section_idx, tot_data_buf_len; + struct vmbus_gpa gpa[2]; + int gpa_cnt, send_buf_section_size; + hn_sent_callback_t cb; /* Set up the packet to send it */ - packet = &request->pkt; - - packet->is_data_pkt = FALSE; - packet->tot_data_buf_len = request->request_msg.msg_len; - packet->gpa_cnt = 1; - - packet->gpa[0].gpa_page = - hv_get_phys_addr(&request->request_msg) >> PAGE_SHIFT; - packet->gpa[0].gpa_len = request->request_msg.msg_len; - packet->gpa[0].gpa_ofs = - (unsigned long)&request->request_msg & (PAGE_SIZE - 1); - - if (packet->gpa[0].gpa_ofs + packet->gpa[0].gpa_len > PAGE_SIZE) { - packet->gpa_cnt = 2; - packet->gpa[0].gpa_len = PAGE_SIZE - packet->gpa[0].gpa_ofs; - packet->gpa[1].gpa_page = - hv_get_phys_addr((char*)&request->request_msg + - packet->gpa[0].gpa_len) >> PAGE_SHIFT; - packet->gpa[1].gpa_ofs = 0; - packet->gpa[1].gpa_len = request->request_msg.msg_len - - packet->gpa[0].gpa_len; - } - - packet->compl.send.send_completion_context = request; /* packet */ - if (message_type != REMOTE_NDIS_HALT_MSG) { - packet->compl.send.on_send_completion = - hv_rf_on_send_request_completion; - } else { - packet->compl.send.on_send_completion = - hv_rf_on_send_request_halt_completion; + tot_data_buf_len = request->request_msg.msg_len; + + gpa_cnt = 1; + gpa[0].gpa_page = hv_get_phys_addr(&request->request_msg) >> PAGE_SHIFT; + gpa[0].gpa_len = request->request_msg.msg_len; + gpa[0].gpa_ofs = (unsigned long)&request->request_msg & (PAGE_SIZE - 1); + + if (gpa[0].gpa_ofs + gpa[0].gpa_len > PAGE_SIZE) { + gpa_cnt = 2; + gpa[0].gpa_len = PAGE_SIZE - gpa[0].gpa_ofs; + gpa[1].gpa_page = + hv_get_phys_addr((char*)&request->request_msg + + gpa[0].gpa_len) >> PAGE_SHIFT; + gpa[1].gpa_ofs = 0; + gpa[1].gpa_len = request->request_msg.msg_len - gpa[0].gpa_len; } - packet->compl.send.send_completion_tid = (unsigned long)device; - if (packet->tot_data_buf_len < net_dev->send_section_size) { + + if (message_type != REMOTE_NDIS_HALT_MSG) + cb = hn_rndis_sent_cb; + else + cb = hn_rndis_sent_halt; + + if (tot_data_buf_len < net_dev->send_section_size) { send_buf_section_idx = hv_nv_get_next_send_section(net_dev); if (send_buf_section_idx != NVSP_1_CHIMNEY_SEND_INVALID_SECTION_INDEX) { @@ -285,20 +282,20 @@ hv_rf_send_request(rndis_device *device, send_buf_section_idx * net_dev->send_section_size); memcpy(dest, &request->request_msg, request->request_msg.msg_len); - packet->send_buf_section_idx = send_buf_section_idx; - packet->send_buf_section_size = packet->tot_data_buf_len; - packet->gpa_cnt = 0; + send_buf_section_size = tot_data_buf_len; + gpa_cnt = 0; goto sendit; } /* Failed to allocate chimney send buffer; move on */ } - packet->send_buf_section_idx = NVSP_1_CHIMNEY_SEND_INVALID_SECTION_INDEX; - packet->send_buf_section_size = 0; + send_buf_section_idx = NVSP_1_CHIMNEY_SEND_INVALID_SECTION_INDEX; + send_buf_section_size = 0; sendit: - ret = hv_nv_on_send(device->net_dev->sc->hn_prichan, packet); - - return (ret); + hn_send_ctx_init(&request->send_ctx, cb, request, + send_buf_section_idx, send_buf_section_size); + return hv_nv_on_send(device->net_dev->sc->hn_prichan, false, + &request->send_ctx, gpa, gpa_cnt); } /* @@ -1060,6 +1057,7 @@ int hv_rf_on_device_add(struct hn_softc *sc, void *additl_info, int nchan, struct hn_rx_ring *rxr) { + struct hn_send_ctx sndc; int ret; netvsc_dev *net_dev; rndis_device *rndis_dev; @@ -1166,9 +1164,10 @@ hv_rf_on_device_add(struct hn_softc *sc, init_pkt->msgs.vers_5_msgs.subchannel_request.num_subchannels = net_dev->num_channel - 1; + hn_send_ctx_init_simple(&sndc, hn_nvs_sent_wakeup, NULL); ret = vmbus_chan_send(sc->hn_prichan, VMBUS_CHANPKT_TYPE_INBAND, VMBUS_CHANPKT_FLAG_RC, - init_pkt, sizeof(nvsp_msg), (uint64_t)(uintptr_t)init_pkt); + init_pkt, sizeof(nvsp_msg), (uint64_t)(uintptr_t)&sndc); if (ret != 0) { device_printf(dev, "Fail to allocate subchannel\n"); goto out; @@ -1239,23 +1238,22 @@ hv_rf_on_close(struct hn_softc *sc) return (hv_rf_close_device((rndis_device *)net_dev->extension)); } -/* - * RNDIS filter on send request completion callback - */ -static void -hv_rf_on_send_request_completion(struct vmbus_channel *chan __unused, - void *context __unused) +static void +hn_rndis_sent_cb(struct hn_send_ctx *sndc, struct netvsc_dev_ *net_dev, + struct vmbus_channel *chan __unused, const struct nvsp_msg_ *msg __unused) { + if (sndc->hn_chim_idx != NVSP_1_CHIMNEY_SEND_INVALID_SECTION_INDEX) + hn_chim_free(net_dev, sndc->hn_chim_idx); } -/* - * RNDIS filter on send request (halt only) completion callback - */ -static void -hv_rf_on_send_request_halt_completion(struct vmbus_channel *chan __unused, - void *context) +static void +hn_rndis_sent_halt(struct hn_send_ctx *sndc, struct netvsc_dev_ *net_dev, + struct vmbus_channel *chan __unused, const struct nvsp_msg_ *msg __unused) { - rndis_request *request = context; + rndis_request *request = sndc->hn_cbarg; + + if (sndc->hn_chim_idx != NVSP_1_CHIMNEY_SEND_INVALID_SECTION_INDEX) + hn_chim_free(net_dev, sndc->hn_chim_idx); /* * Notify hv_rf_halt_device() about halt completion. Modified: stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.h ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.h Thu Oct 13 01:43:15 2016 (r307160) +++ stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.h Thu Oct 13 01:51:49 2016 (r307161) @@ -33,6 +33,7 @@ #include #include +#include /* * Defines @@ -75,7 +76,7 @@ typedef struct rndis_request_ { uint8_t buf_resp[PAGE_SIZE]; /* Simplify allocation by having a netvsc packet inline */ - netvsc_packet pkt; + struct hn_send_ctx send_ctx; /* * The max request size is sizeof(rndis_msg) + PAGE_SIZE. Copied: stable/10/sys/dev/hyperv/netvsc/if_hnvar.h (from r303901, head/sys/dev/hyperv/netvsc/if_hnvar.h) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/10/sys/dev/hyperv/netvsc/if_hnvar.h Thu Oct 13 01:51:49 2016 (r307161, copy of r303901, head/sys/dev/hyperv/netvsc/if_hnvar.h) @@ -0,0 +1,83 @@ +/*- + * Copyright (c) 2016 Microsoft Corp. + * 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 unmodified, 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 ``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 BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#ifndef _IF_HNVAR_H_ +#define _IF_HNVAR_H_ + +#include +#include + +struct netvsc_dev_; +struct nvsp_msg_; + +struct vmbus_channel; +struct hn_send_ctx; + +typedef void (*hn_sent_callback_t) + (struct hn_send_ctx *, struct netvsc_dev_ *, + struct vmbus_channel *, const struct nvsp_msg_ *); + +struct hn_send_ctx { + hn_sent_callback_t hn_cb; + void *hn_cbarg; + uint32_t hn_chim_idx; + int hn_chim_sz; +}; + +#define HN_SEND_CTX_INITIALIZER(cb, cbarg) \ +{ \ + .hn_cb = cb, \ + .hn_cbarg = cbarg, \ + .hn_chim_idx = NVSP_1_CHIMNEY_SEND_INVALID_SECTION_INDEX, \ + .hn_chim_sz = 0 \ +} + +static __inline void +hn_send_ctx_init(struct hn_send_ctx *sndc, hn_sent_callback_t cb, + void *cbarg, uint32_t chim_idx, int chim_sz) +{ + sndc->hn_cb = cb; + sndc->hn_cbarg = cbarg; + sndc->hn_chim_idx = chim_idx; + sndc->hn_chim_sz = chim_sz; +} + +static __inline void +hn_send_ctx_init_simple(struct hn_send_ctx *sndc, hn_sent_callback_t cb, + void *cbarg) +{ + hn_send_ctx_init(sndc, cb, cbarg, + NVSP_1_CHIMNEY_SEND_INVALID_SECTION_INDEX, 0); +} + +void hn_nvs_sent_wakeup(struct hn_send_ctx *sndc, + struct netvsc_dev_ *net_dev, struct vmbus_channel *chan, + const struct nvsp_msg_ *msg); +void hn_chim_free(struct netvsc_dev_ *net_dev, uint32_t chim_idx); + +#endif /* !_IF_HNVAR_H_ */ From owner-svn-src-all@freebsd.org Thu Oct 13 01:58:51 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 4C547C0ECAE; Thu, 13 Oct 2016 01:58:51 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 10BE767E; Thu, 13 Oct 2016 01:58:50 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9D1wovB088692; Thu, 13 Oct 2016 01:58:50 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9D1wo0I088691; Thu, 13 Oct 2016 01:58:50 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610130158.u9D1wo0I088691@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Thu, 13 Oct 2016 01:58:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307162 - stable/10/sys/cam/scsi X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Oct 2016 01:58:51 -0000 Author: sephe Date: Thu Oct 13 01:58:49 2016 New Revision: 307162 URL: https://svnweb.freebsd.org/changeset/base/307162 Log: MFC 303944 cam/da: Add quirk for I-O Data USB Flash Disk PR: 211716 Submitted by: Jun Su Reported by: Jun Su Sponsored by: Microsoft Modified: stable/10/sys/cam/scsi/scsi_da.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/cam/scsi/scsi_da.c ============================================================================== --- stable/10/sys/cam/scsi/scsi_da.c Thu Oct 13 01:51:49 2016 (r307161) +++ stable/10/sys/cam/scsi/scsi_da.c Thu Oct 13 01:58:49 2016 (r307162) @@ -713,6 +713,14 @@ static struct da_quirk_entry da_quirk_ta {T_DIRECT, SIP_MEDIA_REMOVABLE, "JetFlash", "Transcend*", "*"}, /*quirks*/ DA_Q_NO_RC16 }, + { + /* + * I-O Data USB Flash Disk + * PR: usb/211716 + */ + {T_DIRECT, SIP_MEDIA_REMOVABLE, "I-O DATA", "USB Flash Disk*", + "*"}, /*quirks*/ DA_Q_NO_RC16 + }, /* ATA/SATA devices over SAS/USB/... */ { /* Hitachi Advanced Format (4k) drives */ From owner-svn-src-all@freebsd.org Thu Oct 13 02:05:28 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id F4161C0EEF3; Thu, 13 Oct 2016 02:05:27 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mail109.syd.optusnet.com.au (mail109.syd.optusnet.com.au [211.29.132.80]) by mx1.freebsd.org (Postfix) with ESMTP id 9526AAF5; Thu, 13 Oct 2016 02:05:27 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from besplex.bde.org (c110-21-100-78.carlnfd1.nsw.optusnet.com.au [110.21.100.78]) by mail109.syd.optusnet.com.au (Postfix) with ESMTPS id 38115D65FB2; Thu, 13 Oct 2016 13:05:17 +1100 (AEDT) Date: Thu, 13 Oct 2016 13:05:17 +1100 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: Ed Maste cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r307148 - in head/lib/libc: gen stdlib In-Reply-To: <201610121356.u9CDuF1q013531@repo.freebsd.org> Message-ID: <20161013110013.W925@besplex.bde.org> References: <201610121356.u9CDuF1q013531@repo.freebsd.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.1 cv=RIxOZNW+ c=1 sm=1 tr=0 a=uGjuzT6u7JdBDS7kH8taPg==:117 a=uGjuzT6u7JdBDS7kH8taPg==:17 a=L9H7d07YOLsA:10 a=9cW_t1CCXrUA:10 a=s5jvgZ67dGcA:10 a=kj9zAlcOel0A:10 a=g0By5FnHFSSzutFJYmsA:9 a=CjuIK1q_8ugA:10 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Oct 2016 02:05:28 -0000 On Wed, 12 Oct 2016, Ed Maste wrote: > Log: > Add comment on use of abort() in libc > > Suggested by: jonathan (in review D8133) It is almost easier to fix the bugs than add the comment. > Modified: head/lib/libc/gen/arc4random.c > ============================================================================== > --- head/lib/libc/gen/arc4random.c Wed Oct 12 13:51:41 2016 (r307147) > +++ head/lib/libc/gen/arc4random.c Wed Oct 12 13:56:14 2016 (r307148) > @@ -144,8 +144,15 @@ arc4_stir(void) > arc4_init(); > rs_initialized = 1; > } > - if (arc4_sysctl(rdat, KEYSIZE) != KEYSIZE) > - abort(); /* Random sysctl cannot fail. */ > + if (arc4_sysctl(rdat, KEYSIZE) != KEYSIZE) { > + /* > + * The sysctl cannot fail. If it does fail on some FreeBSD > + * derivative or after some future change, just abort so that > + * the problem will be found and fixed. abort is not normally > + * suitable for a library but makes sense here. > + */ > + abort(); > + } The comment starts by being just wrong: 1. "The" sysctl is not used here. Instead, a wrapper arc4_sysctl() is used. The wrapper handles some but not all errors. 2. The sysctl can and does fail. It fails on: - all old kernels mixed with new userlands - with new kernels, at boot time, before the random device is seeded. I couldn't get this to happen in practice, but it used to be a large problem ("Dance fandago on keyboard to unblock"), and source code still has large warnings about it. Apparently des's preseeding based on device attach times fixes it for me. I use the new kernels with 3. The sysctl can, or at least used to, return short reads with nonzero counts. The documentation for this is well hidden, but the arc4_sysctl() wrapper exists to support short reads, or perhaps just the special case of short reads of 0, which it handles poorly by possibly spinning forever. I couldn't get this to happen either. I think it takes O_NONBLOCK. With interrupts but without O_NONBLOCK, I just got nice denial of service attacks with simple dd tests like "dd bs=200m silently truncates to 256 bytes. Then the excuse is wrong. abort() never makes sense in library functions. Here it gives very confusing errors for the delicate boot-time fandago case. Style bugs: - sentence breaks are 2 spaces in KNF, and all old code in this file follows that rule. - 'abort' is not marked up > arc4_addrandom(rdat, KEYSIZE); > > > Modified: head/lib/libc/stdlib/random.c > ============================================================================== > --- head/lib/libc/stdlib/random.c Wed Oct 12 13:51:41 2016 (r307147) > +++ head/lib/libc/stdlib/random.c Wed Oct 12 13:56:14 2016 (r307148) > @@ -279,8 +279,15 @@ srandomdev(void) > > mib[0] = CTL_KERN; > mib[1] = KERN_ARND; > - if (sysctl(mib, 2, state, &len, NULL, 0) == -1 || len != expected) > + if (sysctl(mib, 2, state, &len, NULL, 0) == -1 || len != expected) { > + /* > + * The sysctl cannot fail. If it does fail on some FreeBSD This is even more broken, since it doesn't have the wrapper. All the old versions using [_]read() mishandled short reads, but this was less broken when there was a fallback. For some reason the sysctl wrapper in arc4random.c alone handled short reads. > + * derivative or after some future change, just abort so that > + * the problem will be found and fixed. abort is not normally > + * suitable for a library but makes sense here. > + */ > abort(); > + } > > if (rand_type != TYPE_0) { > fptr = &state[rand_sep]; There are also gratuitous namespace differences and bugs. arc4random() is less standard than random(), so it can use sysctl() without being technically broken by namespace pollution. But it uses __sysctl(), and has style bugs to declare this. OTOH, random() is now standard in POSIX, so it has a reason to use __sysctl(), but it just uses sysctl(). Both should use _sysctlbyname(), and this should be declared in namespace.h. Old code used _read() instead of read(), but that seems to be nonsense since read() is more standard than random(). The old code with the fallback to read() was not wrong (except for the missing short read heandling). It gave portability to old kernels. If the sysctl were documented, then I think its documentation would say that it acts like a special case of read (without O_NONBLOCK or EINTR handling), perhaps on a slightly different device than /dev/random, except for some technical differences for error reporting. So the read() is just as secure as the sysctl. But with no documentation, we can't tell what the differences are. Bruce From owner-svn-src-all@freebsd.org Thu Oct 13 02:06:24 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B316AC0EF8E; Thu, 13 Oct 2016 02:06:24 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 76047C7E; Thu, 13 Oct 2016 02:06:24 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9D26Nik092465; Thu, 13 Oct 2016 02:06:23 GMT (envelope-from cem@FreeBSD.org) Received: (from cem@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9D26NV4092463; Thu, 13 Oct 2016 02:06:23 GMT (envelope-from cem@FreeBSD.org) Message-Id: <201610130206.u9D26NV4092463@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cem set sender to cem@FreeBSD.org using -f From: "Conrad E. Meyer" Date: Thu, 13 Oct 2016 02:06:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307163 - in head/sys: kern sys X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Oct 2016 02:06:24 -0000 Author: cem Date: Thu Oct 13 02:06:23 2016 New Revision: 307163 URL: https://svnweb.freebsd.org/changeset/base/307163 Log: kern_linker: Handle module-loading failures in preloaded .ko files The runtime kernel loader, linker_load_file, unloads kernel files that failed to load all of their modules. For consistency, treat preloaded (loader.conf loaded) kernel files in the same way. Reviewed by: kib Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D8200 Modified: head/sys/kern/kern_linker.c head/sys/sys/linker.h Modified: head/sys/kern/kern_linker.c ============================================================================== --- head/sys/kern/kern_linker.c Thu Oct 13 01:58:49 2016 (r307162) +++ head/sys/kern/kern_linker.c Thu Oct 13 02:06:23 2016 (r307163) @@ -1599,7 +1599,6 @@ restart: if (error) panic("cannot add dependency"); } - lf->userrefs++; /* so we can (try to) kldunload it */ error = linker_file_lookup_set(lf, MDT_SETNAME, &start, &stop, NULL); if (!error) { @@ -1637,6 +1636,8 @@ restart: goto fail; } linker_file_register_modules(lf); + if (!TAILQ_EMPTY(&lf->modules)) + lf->flags |= LINKER_FILE_MODULES; if (linker_file_lookup_set(lf, "sysinit_set", &si_start, &si_stop, NULL) == 0) sysinit_add(si_start, si_stop); @@ -1654,6 +1655,41 @@ fail: SYSINIT(preload, SI_SUB_KLD, SI_ORDER_MIDDLE, linker_preload, 0); /* + * Handle preload files that failed to load any modules. + */ +static void +linker_preload_finish(void *arg) +{ + linker_file_t lf, nlf; + + sx_xlock(&kld_sx); + TAILQ_FOREACH_SAFE(lf, &linker_files, link, nlf) { + /* + * If all of the modules in this file failed to load, unload + * the file and return an error of ENOEXEC. (Parity with + * linker_load_file.) + */ + if ((lf->flags & LINKER_FILE_MODULES) != 0 && + TAILQ_EMPTY(&lf->modules)) { + linker_file_unload(lf, LINKER_UNLOAD_FORCE); + continue; + } + + lf->flags &= ~LINKER_FILE_MODULES; + lf->userrefs++; /* so we can (try to) kldunload it */ + } + sx_xunlock(&kld_sx); +} + +/* + * Attempt to run after all DECLARE_MODULE SYSINITs. Unfortunately they can be + * scheduled at any subsystem and order, so run this as late as possible. init + * becomes runnable in SI_SUB_KTHREAD_INIT, so go slightly before that. + */ +SYSINIT(preload_finish, SI_SUB_KTHREAD_INIT - 100, SI_ORDER_MIDDLE, + linker_preload_finish, 0); + +/* * Search for a not-loaded module by name. * * Modules may be found in the following locations: Modified: head/sys/sys/linker.h ============================================================================== --- head/sys/sys/linker.h Thu Oct 13 01:58:49 2016 (r307162) +++ head/sys/sys/linker.h Thu Oct 13 02:06:23 2016 (r307163) @@ -73,6 +73,7 @@ struct linker_file { int userrefs; /* kldload(2) count */ int flags; #define LINKER_FILE_LINKED 0x1 /* file has been fully linked */ +#define LINKER_FILE_MODULES 0x2 /* file has >0 modules at preload */ TAILQ_ENTRY(linker_file) link; /* list of all loaded files */ char* filename; /* file which was loaded */ char* pathname; /* file name with full path */ From owner-svn-src-all@freebsd.org Thu Oct 13 02:28:43 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 1E6CDC0F597; Thu, 13 Oct 2016 02:28:43 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id A8C1E771; Thu, 13 Oct 2016 02:28:42 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9D2SfA4099979; Thu, 13 Oct 2016 02:28:41 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9D2SeiU099968; Thu, 13 Oct 2016 02:28:40 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610130228.u9D2SeiU099968@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Thu, 13 Oct 2016 02:28:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307164 - in stable/10/sys: conf dev/hyperv/include dev/hyperv/netvsc dev/hyperv/vmbus modules/hyperv/vmbus X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Oct 2016 02:28:43 -0000 Author: sephe Date: Thu Oct 13 02:28:40 2016 New Revision: 307164 URL: https://svnweb.freebsd.org/changeset/base/307164 Log: MFC 303945,303947-303949,303989,303992,303998,304001,304002,304109,304111 303945 hyperv/vmbus: Add macro to get channel packet data length. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7455 303947 hyperv/vmbus: Add APIs for various types of transactions. Reviewed by: Jun Su Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7456 303948 hyperv/hn: Switch to vmbus xact APIs for NVS initialization Reviewed by: Jun Su Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7457 303949 hyperv/vmbus: Use xact APIs to implement post message Hypercall APIs Avoid code duplication. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7458 303989 hyperv/hn: Simplify NDIS configuration. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7466 303992 hyperv/hn: Simplify NDIS initialization. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7467 303998 hyperv/hn: Switch to vmbus xact APIs for NVS RXBUF connection. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7469 304001 hyperv/hn: Switch to vmbus xact APIs for NVS chimney buffer connection. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7470 304002 hyperv/hn: Simplify RXBUF disconnection. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7472 304109 hyperv/hn: Simplify chimney sending buffer disconnection. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7479 304111 hyperv/hn: Switch to vmbus xact APIs for sub-channel alloc request. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7480 Added: stable/10/sys/dev/hyperv/include/vmbus_xact.h - copied, changed from r303947, head/sys/dev/hyperv/include/vmbus_xact.h stable/10/sys/dev/hyperv/netvsc/if_hnreg.h - copied, changed from r303948, head/sys/dev/hyperv/netvsc/if_hnreg.h stable/10/sys/dev/hyperv/vmbus/vmbus_xact.c - copied, changed from r303947, head/sys/dev/hyperv/vmbus/vmbus_xact.c Modified: stable/10/sys/conf/files.amd64 stable/10/sys/conf/files.i386 stable/10/sys/dev/hyperv/include/vmbus.h stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.c stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c stable/10/sys/dev/hyperv/netvsc/hv_rndis.h stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.c stable/10/sys/dev/hyperv/netvsc/if_hnvar.h stable/10/sys/dev/hyperv/vmbus/vmbus.c stable/10/sys/dev/hyperv/vmbus/vmbus_var.h stable/10/sys/modules/hyperv/vmbus/Makefile Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/conf/files.amd64 ============================================================================== --- stable/10/sys/conf/files.amd64 Thu Oct 13 02:06:23 2016 (r307163) +++ stable/10/sys/conf/files.amd64 Thu Oct 13 02:28:40 2016 (r307164) @@ -278,6 +278,7 @@ dev/hyperv/vmbus/vmbus_br.c optional dev/hyperv/vmbus/vmbus_chan.c optional hyperv dev/hyperv/vmbus/vmbus_et.c optional hyperv dev/hyperv/vmbus/vmbus_if.m optional hyperv +dev/hyperv/vmbus/vmbus_xact.c optional hyperv dev/hyperv/vmbus/amd64/hyperv_machdep.c optional hyperv dev/hyperv/vmbus/amd64/vmbus_vector.S optional hyperv dev/lindev/full.c optional lindev Modified: stable/10/sys/conf/files.i386 ============================================================================== --- stable/10/sys/conf/files.i386 Thu Oct 13 02:06:23 2016 (r307163) +++ stable/10/sys/conf/files.i386 Thu Oct 13 02:28:40 2016 (r307164) @@ -255,6 +255,7 @@ dev/hyperv/vmbus/vmbus_br.c optional dev/hyperv/vmbus/vmbus_chan.c optional hyperv dev/hyperv/vmbus/vmbus_et.c optional hyperv dev/hyperv/vmbus/vmbus_if.m optional hyperv +dev/hyperv/vmbus/vmbus_xact.c optional hyperv dev/hyperv/vmbus/i386/hyperv_machdep.c optional hyperv dev/hyperv/vmbus/i386/vmbus_vector.S optional hyperv dev/ichwd/ichwd.c optional ichwd Modified: stable/10/sys/dev/hyperv/include/vmbus.h ============================================================================== --- stable/10/sys/dev/hyperv/include/vmbus.h Thu Oct 13 02:06:23 2016 (r307163) +++ stable/10/sys/dev/hyperv/include/vmbus.h Thu Oct 13 02:28:40 2016 (r307164) @@ -90,6 +90,11 @@ struct vmbus_chanpkt_hdr { (const void *)((const uint8_t *)(pkt) + \ VMBUS_CHANPKT_GETLEN((pkt)->cph_hlen)) +/* Include padding */ +#define VMBUS_CHANPKT_DATALEN(pkt) \ + (VMBUS_CHANPKT_GETLEN((pkt)->cph_tlen) -\ + VMBUS_CHANPKT_GETLEN((pkt)->cph_hlen)) + struct vmbus_rxbuf_desc { uint32_t rb_len; uint32_t rb_ofs; Copied and modified: stable/10/sys/dev/hyperv/include/vmbus_xact.h (from r303947, head/sys/dev/hyperv/include/vmbus_xact.h) ============================================================================== --- head/sys/dev/hyperv/include/vmbus_xact.h Thu Aug 11 05:49:49 2016 (r303947, copy source) +++ stable/10/sys/dev/hyperv/include/vmbus_xact.h Thu Oct 13 02:28:40 2016 (r307164) @@ -31,12 +31,14 @@ #include #include +#include struct vmbus_xact; struct vmbus_xact_ctx; struct vmbus_xact_ctx *vmbus_xact_ctx_create(bus_dma_tag_t dtag, - size_t req_size, size_t resp_size); + size_t req_size, size_t resp_size, + size_t priv_size); void vmbus_xact_ctx_destroy(struct vmbus_xact_ctx *ctx); struct vmbus_xact *vmbus_xact_get(struct vmbus_xact_ctx *ctx, size_t req_len); @@ -44,11 +46,15 @@ void vmbus_xact_put(struct vmbus_xact void *vmbus_xact_req_data(const struct vmbus_xact *xact); bus_addr_t vmbus_xact_req_paddr(const struct vmbus_xact *xact); +void *vmbus_xact_priv(const struct vmbus_xact *xact, + size_t priv_len); void vmbus_xact_activate(struct vmbus_xact *xact); void vmbus_xact_deactivate(struct vmbus_xact *xact); const void *vmbus_xact_wait(struct vmbus_xact *xact, size_t *resp_len); void vmbus_xact_wakeup(struct vmbus_xact *xact, const void *data, size_t dlen); +void vmbus_xact_ctx_wakeup(struct vmbus_xact_ctx *ctx, + const void *data, size_t dlen); #endif /* !_VMBUS_XACT_H_ */ Modified: stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.c Thu Oct 13 02:06:23 2016 (r307163) +++ stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.c Thu Oct 13 02:28:40 2016 (r307164) @@ -44,9 +44,11 @@ #include #include -#include "hv_net_vsc.h" -#include "hv_rndis.h" -#include "hv_rndis_filter.h" +#include +#include +#include +#include +#include MALLOC_DEFINE(M_NETVSC, "netvsc", "Hyper-V netvsc driver"); @@ -69,7 +71,7 @@ static void hv_nv_on_receive(netvsc_dev const struct vmbus_chanpkt_hdr *pkt); static void hn_nvs_sent_none(struct hn_send_ctx *sndc, struct netvsc_dev_ *net_dev, struct vmbus_channel *chan, - const struct nvsp_msg_ *msg); + const struct nvsp_msg_ *msg, int); static struct hn_send_ctx hn_send_ctx_none = HN_SEND_CTX_INITIALIZER(hn_nvs_sent_none, NULL); @@ -146,10 +148,14 @@ hv_nv_get_next_send_section(netvsc_dev * static int hv_nv_init_rx_buffer_with_net_vsp(struct hn_softc *sc) { + struct vmbus_xact *xact; + struct hn_nvs_rxbuf_conn *conn; + const struct hn_nvs_rxbuf_connresp *resp; + size_t resp_len; struct hn_send_ctx sndc; netvsc_dev *net_dev; - nvsp_msg *init_pkt; - int ret = 0; + uint32_t status; + int error; net_dev = hv_nv_get_outbound_net_device(sc); if (!net_dev) { @@ -161,7 +167,7 @@ hv_nv_init_rx_buffer_with_net_vsp(struct BUS_DMA_WAITOK | BUS_DMA_ZERO); if (net_dev->rx_buf == NULL) { device_printf(sc->hn_dev, "allocate rxbuf failed\n"); - return ENOMEM; + return (ENOMEM); } /* @@ -171,74 +177,76 @@ hv_nv_init_rx_buffer_with_net_vsp(struct * Only primary channel has RXBUF connected to it. Sub-channels * just share this RXBUF. */ - ret = vmbus_chan_gpadl_connect(sc->hn_prichan, + error = vmbus_chan_gpadl_connect(sc->hn_prichan, net_dev->rxbuf_dma.hv_paddr, net_dev->rx_buf_size, &net_dev->rx_buf_gpadl_handle); - if (ret != 0) { - device_printf(sc->hn_dev, "rxbuf gpadl connect failed: %d\n", - ret); + if (error) { + if_printf(sc->hn_ifp, "rxbuf gpadl connect failed: %d\n", + error); goto cleanup; } - - /* sema_wait(&ext->channel_init_sema); KYS CHECK */ - /* Notify the NetVsp of the gpadl handle */ - init_pkt = &net_dev->channel_init_packet; + /* + * Connect RXBUF to NVS. + */ - memset(init_pkt, 0, sizeof(nvsp_msg)); + xact = vmbus_xact_get(sc->hn_xact, sizeof(*conn)); + if (xact == NULL) { + if_printf(sc->hn_ifp, "no xact for nvs rxbuf conn\n"); + error = ENXIO; + goto cleanup; + } - init_pkt->hdr.msg_type = nvsp_msg_1_type_send_rx_buf; - init_pkt->msgs.vers_1_msgs.send_rx_buf.gpadl_handle = - net_dev->rx_buf_gpadl_handle; - init_pkt->msgs.vers_1_msgs.send_rx_buf.id = - NETVSC_RECEIVE_BUFFER_ID; + conn = vmbus_xact_req_data(xact); + conn->nvs_type = HN_NVS_TYPE_RXBUF_CONN; + conn->nvs_gpadl = net_dev->rx_buf_gpadl_handle; + conn->nvs_sig = HN_NVS_RXBUF_SIG; - /* Send the gpadl notification request */ + hn_send_ctx_init_simple(&sndc, hn_nvs_sent_xact, xact); + vmbus_xact_activate(xact); - hn_send_ctx_init_simple(&sndc, hn_nvs_sent_wakeup, NULL); - ret = vmbus_chan_send(sc->hn_prichan, + error = vmbus_chan_send(sc->hn_prichan, VMBUS_CHANPKT_TYPE_INBAND, VMBUS_CHANPKT_FLAG_RC, - init_pkt, sizeof(nvsp_msg), (uint64_t)(uintptr_t)&sndc); - if (ret != 0) { + conn, sizeof(*conn), (uint64_t)(uintptr_t)&sndc); + if (error != 0) { + if_printf(sc->hn_ifp, "send nvs rxbuf conn failed: %d\n", + error); + vmbus_xact_deactivate(xact); + vmbus_xact_put(xact); goto cleanup; } - sema_wait(&net_dev->channel_init_sema); - - /* Check the response */ - if (init_pkt->msgs.vers_1_msgs.send_rx_buf_complete.status - != nvsp_status_success) { - ret = EINVAL; + resp = vmbus_xact_wait(xact, &resp_len); + if (resp_len < sizeof(*resp)) { + if_printf(sc->hn_ifp, "invalid rxbuf conn resp length %zu\n", + resp_len); + vmbus_xact_put(xact); + error = EINVAL; + goto cleanup; + } + if (resp->nvs_type != HN_NVS_TYPE_RXBUF_CONNRESP) { + if_printf(sc->hn_ifp, "not rxbuf conn resp, type %u\n", + resp->nvs_type); + vmbus_xact_put(xact); + error = EINVAL; goto cleanup; } - net_dev->rx_section_count = - init_pkt->msgs.vers_1_msgs.send_rx_buf_complete.num_sections; - - net_dev->rx_sections = malloc(net_dev->rx_section_count * - sizeof(nvsp_1_rx_buf_section), M_NETVSC, M_WAITOK); - memcpy(net_dev->rx_sections, - init_pkt->msgs.vers_1_msgs.send_rx_buf_complete.sections, - net_dev->rx_section_count * sizeof(nvsp_1_rx_buf_section)); - + status = resp->nvs_status; + vmbus_xact_put(xact); - /* - * For first release, there should only be 1 section that represents - * the entire receive buffer - */ - if (net_dev->rx_section_count != 1 - || net_dev->rx_sections->offset != 0) { - ret = EINVAL; + if (status != HN_NVS_STATUS_OK) { + if_printf(sc->hn_ifp, "rxbuf conn failed: %x\n", status); + error = EIO; goto cleanup; } + net_dev->rx_section_count = 1; - goto exit; + return (0); cleanup: hv_nv_destroy_rx_buffer(net_dev); - -exit: - return (ret); + return (error); } /* @@ -248,9 +256,13 @@ static int hv_nv_init_send_buffer_with_net_vsp(struct hn_softc *sc) { struct hn_send_ctx sndc; + struct vmbus_xact *xact; + struct hn_nvs_chim_conn *chim; + const struct hn_nvs_chim_connresp *resp; + size_t resp_len; + uint32_t status, sectsz; netvsc_dev *net_dev; - nvsp_msg *init_pkt; - int ret = 0; + int error; net_dev = hv_nv_get_outbound_net_device(sc); if (!net_dev) { @@ -262,7 +274,7 @@ hv_nv_init_send_buffer_with_net_vsp(stru BUS_DMA_WAITOK | BUS_DMA_ZERO); if (net_dev->send_buf == NULL) { device_printf(sc->hn_dev, "allocate chimney txbuf failed\n"); - return ENOMEM; + return (ENOMEM); } /* @@ -272,48 +284,77 @@ hv_nv_init_send_buffer_with_net_vsp(stru * Only primary channel has chimney sending buffer connected to it. * Sub-channels just share this chimney sending buffer. */ - ret = vmbus_chan_gpadl_connect(sc->hn_prichan, + error = vmbus_chan_gpadl_connect(sc->hn_prichan, net_dev->txbuf_dma.hv_paddr, net_dev->send_buf_size, &net_dev->send_buf_gpadl_handle); - if (ret != 0) { - device_printf(sc->hn_dev, "chimney sending buffer gpadl " - "connect failed: %d\n", ret); + if (error) { + if_printf(sc->hn_ifp, "chimney sending buffer gpadl " + "connect failed: %d\n", error); goto cleanup; } - /* Notify the NetVsp of the gpadl handle */ - - init_pkt = &net_dev->channel_init_packet; + /* + * Connect chimney sending buffer to NVS + */ - memset(init_pkt, 0, sizeof(nvsp_msg)); + xact = vmbus_xact_get(sc->hn_xact, sizeof(*chim)); + if (xact == NULL) { + if_printf(sc->hn_ifp, "no xact for nvs chim conn\n"); + error = ENXIO; + goto cleanup; + } - init_pkt->hdr.msg_type = nvsp_msg_1_type_send_send_buf; - init_pkt->msgs.vers_1_msgs.send_rx_buf.gpadl_handle = - net_dev->send_buf_gpadl_handle; - init_pkt->msgs.vers_1_msgs.send_rx_buf.id = - NETVSC_SEND_BUFFER_ID; + chim = vmbus_xact_req_data(xact); + chim->nvs_type = HN_NVS_TYPE_CHIM_CONN; + chim->nvs_gpadl = net_dev->send_buf_gpadl_handle; + chim->nvs_sig = HN_NVS_CHIM_SIG; - /* Send the gpadl notification request */ + hn_send_ctx_init_simple(&sndc, hn_nvs_sent_xact, xact); + vmbus_xact_activate(xact); - hn_send_ctx_init_simple(&sndc, hn_nvs_sent_wakeup, NULL); - ret = vmbus_chan_send(sc->hn_prichan, + error = vmbus_chan_send(sc->hn_prichan, VMBUS_CHANPKT_TYPE_INBAND, VMBUS_CHANPKT_FLAG_RC, - init_pkt, sizeof(nvsp_msg), (uint64_t)(uintptr_t)&sndc); - if (ret != 0) { + chim, sizeof(*chim), (uint64_t)(uintptr_t)&sndc); + if (error) { + if_printf(sc->hn_ifp, "send nvs chim conn failed: %d\n", + error); + vmbus_xact_deactivate(xact); + vmbus_xact_put(xact); goto cleanup; } - sema_wait(&net_dev->channel_init_sema); + resp = vmbus_xact_wait(xact, &resp_len); + if (resp_len < sizeof(*resp)) { + if_printf(sc->hn_ifp, "invalid chim conn resp length %zu\n", + resp_len); + vmbus_xact_put(xact); + error = EINVAL; + goto cleanup; + } + if (resp->nvs_type != HN_NVS_TYPE_CHIM_CONNRESP) { + if_printf(sc->hn_ifp, "not chim conn resp, type %u\n", + resp->nvs_type); + vmbus_xact_put(xact); + error = EINVAL; + goto cleanup; + } - /* Check the response */ - if (init_pkt->msgs.vers_1_msgs.send_send_buf_complete.status - != nvsp_status_success) { - ret = EINVAL; + status = resp->nvs_status; + sectsz = resp->nvs_sectsz; + vmbus_xact_put(xact); + + if (status != HN_NVS_STATUS_OK) { + if_printf(sc->hn_ifp, "chim conn failed: %x\n", status); + error = EIO; goto cleanup; } + if (sectsz == 0) { + if_printf(sc->hn_ifp, "zero chimney sending buffer " + "section size\n"); + return 0; + } - net_dev->send_section_size = - init_pkt->msgs.vers_1_msgs.send_send_buf_complete.section_size; + net_dev->send_section_size = sectsz; net_dev->send_section_count = net_dev->send_buf_size / net_dev->send_section_size; net_dev->bitsmap_words = howmany(net_dev->send_section_count, @@ -322,13 +363,15 @@ hv_nv_init_send_buffer_with_net_vsp(stru malloc(net_dev->bitsmap_words * sizeof(long), M_NETVSC, M_WAITOK | M_ZERO); - goto exit; + if (bootverbose) { + if_printf(sc->hn_ifp, "chimney sending buffer %u/%u\n", + net_dev->send_section_size, net_dev->send_section_count); + } + return 0; cleanup: hv_nv_destroy_send_buffer(net_dev); - -exit: - return (ret); + return (error); } /* @@ -337,34 +380,27 @@ exit: static int hv_nv_destroy_rx_buffer(netvsc_dev *net_dev) { - nvsp_msg *revoke_pkt; int ret = 0; - /* - * If we got a section count, it means we received a - * send_rx_buf_complete msg - * (ie sent nvsp_msg_1_type_send_rx_buf msg) therefore, - * we need to send a revoke msg here - */ if (net_dev->rx_section_count) { - /* Send the revoke receive buffer */ - revoke_pkt = &net_dev->revoke_packet; - memset(revoke_pkt, 0, sizeof(nvsp_msg)); - - revoke_pkt->hdr.msg_type = nvsp_msg_1_type_revoke_rx_buf; - revoke_pkt->msgs.vers_1_msgs.revoke_rx_buf.id = - NETVSC_RECEIVE_BUFFER_ID; + struct hn_nvs_rxbuf_disconn disconn; - ret = vmbus_chan_send(net_dev->sc->hn_prichan, - VMBUS_CHANPKT_TYPE_INBAND, 0, revoke_pkt, sizeof(nvsp_msg), - (uint64_t)(uintptr_t)&hn_send_ctx_none); /* - * If we failed here, we might as well return and have a leak - * rather than continue and a bugchk + * Disconnect RXBUF from NVS. */ + memset(&disconn, 0, sizeof(disconn)); + disconn.nvs_type = HN_NVS_TYPE_RXBUF_DISCONN; + disconn.nvs_sig = HN_NVS_RXBUF_SIG; + + ret = vmbus_chan_send(net_dev->sc->hn_prichan, + VMBUS_CHANPKT_TYPE_INBAND, 0, &disconn, sizeof(disconn), + (uint64_t)(uintptr_t)&hn_send_ctx_none); if (ret != 0) { + if_printf(net_dev->sc->hn_ifp, + "send rxbuf disconn failed: %d\n", ret); return (ret); } + net_dev->rx_section_count = 0; } /* Tear down the gpadl on the vsp end */ @@ -387,12 +423,6 @@ hv_nv_destroy_rx_buffer(netvsc_dev *net_ net_dev->rx_buf = NULL; } - if (net_dev->rx_sections) { - free(net_dev->rx_sections, M_NETVSC); - net_dev->rx_sections = NULL; - net_dev->rx_section_count = 0; - } - return (ret); } @@ -402,33 +432,24 @@ hv_nv_destroy_rx_buffer(netvsc_dev *net_ static int hv_nv_destroy_send_buffer(netvsc_dev *net_dev) { - nvsp_msg *revoke_pkt; int ret = 0; - /* - * If we got a section count, it means we received a - * send_rx_buf_complete msg - * (ie sent nvsp_msg_1_type_send_rx_buf msg) therefore, - * we need to send a revoke msg here - */ if (net_dev->send_section_size) { - /* Send the revoke send buffer */ - revoke_pkt = &net_dev->revoke_packet; - memset(revoke_pkt, 0, sizeof(nvsp_msg)); - - revoke_pkt->hdr.msg_type = - nvsp_msg_1_type_revoke_send_buf; - revoke_pkt->msgs.vers_1_msgs.revoke_send_buf.id = - NETVSC_SEND_BUFFER_ID; + struct hn_nvs_chim_disconn disconn; - ret = vmbus_chan_send(net_dev->sc->hn_prichan, - VMBUS_CHANPKT_TYPE_INBAND, 0, revoke_pkt, sizeof(nvsp_msg), - (uint64_t)(uintptr_t)&hn_send_ctx_none); /* - * If we failed here, we might as well return and have a leak - * rather than continue and a bugchk + * Disconnect chimney sending buffer from NVS. */ + memset(&disconn, 0, sizeof(disconn)); + disconn.nvs_type = HN_NVS_TYPE_CHIM_DISCONN; + disconn.nvs_sig = HN_NVS_CHIM_SIG; + + ret = vmbus_chan_send(net_dev->sc->hn_prichan, + VMBUS_CHANPKT_TYPE_INBAND, 0, &disconn, sizeof(disconn), + (uint64_t)(uintptr_t)&hn_send_ctx_none); if (ret != 0) { + if_printf(net_dev->sc->hn_ifp, + "send chim disconn failed: %d\n", ret); return (ret); } } @@ -461,45 +482,64 @@ hv_nv_destroy_send_buffer(netvsc_dev *ne return (ret); } - -/* - * Attempt to negotiate the caller-specified NVSP version - * - * For NVSP v2, Server 2008 R2 does not set - * init_pkt->msgs.init_msgs.init_compl.negotiated_prot_vers - * to the negotiated version, so we cannot rely on that. - */ static int hv_nv_negotiate_nvsp_protocol(struct hn_softc *sc, netvsc_dev *net_dev, - uint32_t nvsp_ver) + uint32_t nvs_ver) { struct hn_send_ctx sndc; - nvsp_msg *init_pkt; - int ret; - - init_pkt = &net_dev->channel_init_packet; - memset(init_pkt, 0, sizeof(nvsp_msg)); - init_pkt->hdr.msg_type = nvsp_msg_type_init; + struct vmbus_xact *xact; + struct hn_nvs_init *init; + const struct hn_nvs_init_resp *resp; + size_t resp_len; + uint32_t status; + int error; + + xact = vmbus_xact_get(sc->hn_xact, sizeof(*init)); + if (xact == NULL) { + if_printf(sc->hn_ifp, "no xact for nvs init\n"); + return (ENXIO); + } + + init = vmbus_xact_req_data(xact); + init->nvs_type = HN_NVS_TYPE_INIT; + init->nvs_ver_min = nvs_ver; + init->nvs_ver_max = nvs_ver; - /* - * Specify parameter as the only acceptable protocol version - */ - init_pkt->msgs.init_msgs.init.p1.protocol_version = nvsp_ver; - init_pkt->msgs.init_msgs.init.protocol_version_2 = nvsp_ver; + vmbus_xact_activate(xact); + hn_send_ctx_init_simple(&sndc, hn_nvs_sent_xact, xact); - /* Send the init request */ - hn_send_ctx_init_simple(&sndc, hn_nvs_sent_wakeup, NULL); - ret = vmbus_chan_send(sc->hn_prichan, + error = vmbus_chan_send(sc->hn_prichan, VMBUS_CHANPKT_TYPE_INBAND, VMBUS_CHANPKT_FLAG_RC, - init_pkt, sizeof(nvsp_msg), (uint64_t)(uintptr_t)&sndc); - if (ret != 0) - return (-1); - - sema_wait(&net_dev->channel_init_sema); + init, sizeof(*init), (uint64_t)(uintptr_t)&sndc); + if (error) { + if_printf(sc->hn_ifp, "send nvs init failed: %d\n", error); + vmbus_xact_deactivate(xact); + vmbus_xact_put(xact); + return (error); + } - if (init_pkt->msgs.init_msgs.init_compl.status != nvsp_status_success) + resp = vmbus_xact_wait(xact, &resp_len); + if (resp_len < sizeof(*resp)) { + if_printf(sc->hn_ifp, "invalid init resp length %zu\n", + resp_len); + vmbus_xact_put(xact); + return (EINVAL); + } + if (resp->nvs_type != HN_NVS_TYPE_INIT_RESP) { + if_printf(sc->hn_ifp, "not init resp, type %u\n", + resp->nvs_type); + vmbus_xact_put(xact); return (EINVAL); + } + + status = resp->nvs_status; + vmbus_xact_put(xact); + if (status != HN_NVS_STATUS_OK) { + if_printf(sc->hn_ifp, "nvs init failed for ver 0x%x\n", + nvs_ver); + return (EINVAL); + } return (0); } @@ -511,33 +551,19 @@ hv_nv_negotiate_nvsp_protocol(struct hn_ static int hv_nv_send_ndis_config(struct hn_softc *sc, uint32_t mtu) { - netvsc_dev *net_dev; - nvsp_msg *init_pkt; - int ret; - - net_dev = hv_nv_get_outbound_net_device(sc); - if (!net_dev) - return (-ENODEV); - - /* - * Set up configuration packet, write MTU - * Indicate we are capable of handling VLAN tags - */ - init_pkt = &net_dev->channel_init_packet; - memset(init_pkt, 0, sizeof(nvsp_msg)); - init_pkt->hdr.msg_type = nvsp_msg_2_type_send_ndis_config; - init_pkt->msgs.vers_2_msgs.send_ndis_config.mtu = mtu; - init_pkt-> - msgs.vers_2_msgs.send_ndis_config.capabilities.u1.u2.ieee8021q - = 1; - - /* Send the configuration packet */ - ret = vmbus_chan_send(sc->hn_prichan, VMBUS_CHANPKT_TYPE_INBAND, 0, - init_pkt, sizeof(nvsp_msg), (uint64_t)(uintptr_t)&hn_send_ctx_none); - if (ret != 0) - return (-EINVAL); + struct hn_nvs_ndis_conf conf; + int error; - return (0); + memset(&conf, 0, sizeof(conf)); + conf.nvs_type = HN_NVS_TYPE_NDIS_CONF; + conf.nvs_mtu = mtu; + conf.nvs_caps = HN_NVS_NDIS_CONF_VLAN; + + error = vmbus_chan_send(sc->hn_prichan, VMBUS_CHANPKT_TYPE_INBAND, 0, + &conf, sizeof(conf), (uint64_t)(uintptr_t)&hn_send_ctx_none); + if (error) + if_printf(sc->hn_ifp, "send nvs ndis conf failed: %d\n", error); + return (error); } /* @@ -547,8 +573,6 @@ static int hv_nv_connect_to_vsp(struct hn_softc *sc) { netvsc_dev *net_dev; - nvsp_msg *init_pkt; - uint32_t ndis_version; uint32_t protocol_list[] = { NVSP_PROTOCOL_VERSION_1, NVSP_PROTOCOL_VERSION_2, NVSP_PROTOCOL_VERSION_4, @@ -558,6 +582,7 @@ hv_nv_connect_to_vsp(struct hn_softc *sc int ret = 0; device_t dev = sc->hn_dev; struct ifnet *ifp = sc->arpcom.ac_ifp; + struct hn_nvs_ndis_init ndis; net_dev = hv_nv_get_outbound_net_device(sc); @@ -590,37 +615,23 @@ hv_nv_connect_to_vsp(struct hn_softc *sc ret = hv_nv_send_ndis_config(sc, ifp->if_mtu); /* - * Send the NDIS version + * Initialize NDIS. */ - init_pkt = &net_dev->channel_init_packet; - - memset(init_pkt, 0, sizeof(nvsp_msg)); - - if (net_dev->nvsp_version <= NVSP_PROTOCOL_VERSION_4) { - ndis_version = NDIS_VERSION_6_1; - } else { - ndis_version = NDIS_VERSION_6_30; - } - - init_pkt->hdr.msg_type = nvsp_msg_1_type_send_ndis_vers; - init_pkt->msgs.vers_1_msgs.send_ndis_vers.ndis_major_vers = - (ndis_version & 0xFFFF0000) >> 16; - init_pkt->msgs.vers_1_msgs.send_ndis_vers.ndis_minor_vers = - ndis_version & 0xFFFF; - /* Send the init request */ + memset(&ndis, 0, sizeof(ndis)); + ndis.nvs_type = HN_NVS_TYPE_NDIS_INIT; + ndis.nvs_ndis_major = NDIS_VERSION_MAJOR_6; + if (net_dev->nvsp_version <= NVSP_PROTOCOL_VERSION_4) + ndis.nvs_ndis_minor = NDIS_VERSION_MINOR_1; + else + ndis.nvs_ndis_minor = NDIS_VERSION_MINOR_30; ret = vmbus_chan_send(sc->hn_prichan, VMBUS_CHANPKT_TYPE_INBAND, 0, - init_pkt, sizeof(nvsp_msg), (uint64_t)(uintptr_t)&hn_send_ctx_none); + &ndis, sizeof(ndis), (uint64_t)(uintptr_t)&hn_send_ctx_none); if (ret != 0) { + if_printf(sc->hn_ifp, "send nvs ndis init failed: %d\n", ret); goto cleanup; } - /* - * TODO: BUGBUG - We have to wait for the above msg since the netvsp - * uses KMCL which acknowledges packet (completion packet) - * since our Vmbus always set the VMBUS_CHANPKT_FLAG_RC flag - */ - /* sema_wait(&NetVscChannel->channel_init_sema); */ /* Post the big receive buffer to NetVSP */ if (net_dev->nvsp_version <= NVSP_PROTOCOL_VERSION_2) @@ -741,19 +752,18 @@ hv_nv_on_device_remove(struct hn_softc * } void -hn_nvs_sent_wakeup(struct hn_send_ctx *sndc __unused, - struct netvsc_dev_ *net_dev, struct vmbus_channel *chan __unused, - const struct nvsp_msg_ *msg) -{ - /* Copy the response back */ - memcpy(&net_dev->channel_init_packet, msg, sizeof(nvsp_msg)); - sema_post(&net_dev->channel_init_sema); +hn_nvs_sent_xact(struct hn_send_ctx *sndc, + struct netvsc_dev_ *net_dev __unused, struct vmbus_channel *chan __unused, + const struct nvsp_msg_ *msg, int dlen) +{ + + vmbus_xact_wakeup(sndc->hn_cbarg, msg, dlen); } static void hn_nvs_sent_none(struct hn_send_ctx *sndc __unused, struct netvsc_dev_ *net_dev __unused, struct vmbus_channel *chan __unused, - const struct nvsp_msg_ *msg __unused) + const struct nvsp_msg_ *msg __unused, int dlen __unused) { /* EMPTY */ } @@ -787,7 +797,8 @@ hv_nv_on_send_completion(netvsc_dev *net struct hn_send_ctx *sndc; sndc = (struct hn_send_ctx *)(uintptr_t)pkt->cph_xactid; - sndc->hn_cb(sndc, net_dev, chan, VMBUS_CHANPKT_CONST_DATA(pkt)); + sndc->hn_cb(sndc, net_dev, chan, VMBUS_CHANPKT_CONST_DATA(pkt), + VMBUS_CHANPKT_DATALEN(pkt)); /* * NOTE: * 'sndc' CAN NOT be accessed anymore, since it can be freed by Modified: stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h Thu Oct 13 02:06:23 2016 (r307163) +++ stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h Thu Oct 13 02:28:40 2016 (r307164) @@ -1060,7 +1060,6 @@ typedef struct netvsc_dev_ { uint32_t rx_buf_size; uint32_t rx_buf_gpadl_handle; uint32_t rx_section_count; - nvsp_1_rx_buf_section *rx_sections; /* Used for NetVSP initialization protocol */ struct sema channel_init_sema; @@ -1244,6 +1243,7 @@ typedef struct hn_softc { struct taskqueue *hn_tx_taskq; struct sysctl_oid *hn_tx_sysctl_tree; struct sysctl_oid *hn_rx_sysctl_tree; + struct vmbus_xact_ctx *hn_xact; } hn_softc_t; /* Modified: stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Thu Oct 13 02:06:23 2016 (r307163) +++ stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Thu Oct 13 02:28:40 2016 (r307164) @@ -117,6 +117,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include "hv_net_vsc.h" #include "hv_rndis.h" @@ -126,6 +127,9 @@ __FBSDID("$FreeBSD$"); /* Short for Hyper-V network interface */ #define NETVSC_DEVNAME "hn" +#define HN_XACT_REQ_SIZE (2 * PAGE_SIZE) +#define HN_XACT_RESP_SIZE (2 * PAGE_SIZE) + /* * It looks like offset 0 of buf is reserved to hold the softc pointer. * The sc pointer evidently not needed, and is not presently populated. @@ -558,6 +562,11 @@ netvsc_attach(device_t dev) IFCAP_LRO; ifp->if_hwassist = sc->hn_tx_ring[0].hn_csum_assist | CSUM_TSO; + sc->hn_xact = vmbus_xact_ctx_create(bus_get_dma_tag(dev), + HN_XACT_REQ_SIZE, HN_XACT_RESP_SIZE, 0); + if (sc->hn_xact == NULL) + goto failed; + error = hv_rf_on_device_add(sc, &device_info, ring_cnt, &sc->hn_rx_ring[0]); if (error) @@ -655,6 +664,7 @@ netvsc_detach(device_t dev) if (sc->hn_tx_taskq != hn_tx_taskq) taskqueue_free(sc->hn_tx_taskq); + vmbus_xact_ctx_destroy(sc->hn_xact); return (0); } @@ -794,7 +804,8 @@ hn_txeof(struct hn_tx_ring *txr) static void hn_tx_done(struct hn_send_ctx *sndc, struct netvsc_dev_ *net_dev, - struct vmbus_channel *chan, const struct nvsp_msg_ *msg __unused) + struct vmbus_channel *chan, const struct nvsp_msg_ *msg __unused, + int dlen __unused) { struct hn_txdesc *txd = sndc->hn_cbarg; struct hn_tx_ring *txr; Modified: stable/10/sys/dev/hyperv/netvsc/hv_rndis.h ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_rndis.h Thu Oct 13 02:06:23 2016 (r307163) +++ stable/10/sys/dev/hyperv/netvsc/hv_rndis.h Thu Oct 13 02:28:40 2016 (r307164) @@ -41,6 +41,10 @@ #define NDIS_VERSION_6_1 0x00060001 #define NDIS_VERSION_6_30 0x0006001e +#define NDIS_VERSION_MAJOR_6 6 +#define NDIS_VERSION_MINOR_1 1 +#define NDIS_VERSION_MINOR_30 30 + #define NDIS_VERSION (NDIS_VERSION_5_1) /* Modified: stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.c Thu Oct 13 02:06:23 2016 (r307163) +++ stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.c Thu Oct 13 02:28:40 2016 (r307164) @@ -47,9 +47,11 @@ __FBSDID("$FreeBSD$"); #include #include -#include "hv_net_vsc.h" -#include "hv_rndis.h" -#include "hv_rndis_filter.h" +#include +#include +#include +#include +#include struct hv_rf_recvinfo { const ndis_8021q_info *vlan_info; @@ -92,10 +94,10 @@ hv_rf_send_offload_request(struct hn_sof static void hn_rndis_sent_halt(struct hn_send_ctx *sndc, struct netvsc_dev_ *net_dev, struct vmbus_channel *chan, - const struct nvsp_msg_ *msg); + const struct nvsp_msg_ *msg, int dlen); static void hn_rndis_sent_cb(struct hn_send_ctx *sndc, struct netvsc_dev_ *net_dev, struct vmbus_channel *chan, - const struct nvsp_msg_ *msg); + const struct nvsp_msg_ *msg, int dlen); /* * Set the Per-Packet-Info with the specified type @@ -1061,12 +1063,16 @@ hv_rf_on_device_add(struct hn_softc *sc, int ret; netvsc_dev *net_dev; rndis_device *rndis_dev; - nvsp_msg *init_pkt; rndis_offload_params offloads; struct rndis_recv_scale_cap rsscaps; uint32_t rsscaps_size = sizeof(struct rndis_recv_scale_cap); netvsc_device_info *dev_info = (netvsc_device_info *)additl_info; device_t dev = sc->hn_dev; + struct hn_nvs_subch_req *req; + const struct hn_nvs_subch_resp *resp; + size_t resp_len; + struct vmbus_xact *xact; + uint32_t status, nsubch; rndis_dev = hv_get_rndis_device(); if (rndis_dev == NULL) { @@ -1154,36 +1160,65 @@ hv_rf_on_device_add(struct hn_softc *sc, goto out; } - /* request host to create sub channels */ - init_pkt = &net_dev->channel_init_packet; - memset(init_pkt, 0, sizeof(nvsp_msg)); - - init_pkt->hdr.msg_type = nvsp_msg5_type_subchannel; - init_pkt->msgs.vers_5_msgs.subchannel_request.op = - NVSP_SUBCHANNE_ALLOCATE; - init_pkt->msgs.vers_5_msgs.subchannel_request.num_subchannels = - net_dev->num_channel - 1; + /* + * Ask NVS to allocate sub-channels. + */ + xact = vmbus_xact_get(sc->hn_xact, sizeof(*req)); + if (xact == NULL) { + if_printf(sc->hn_ifp, "no xact for nvs subch req\n"); + ret = ENXIO; + goto out; + } + + req = vmbus_xact_req_data(xact); + req->nvs_type = HN_NVS_TYPE_SUBCH_REQ; + req->nvs_op = HN_NVS_SUBCH_OP_ALLOC; + req->nvs_nsubch = net_dev->num_channel - 1; + + hn_send_ctx_init_simple(&sndc, hn_nvs_sent_xact, xact); + vmbus_xact_activate(xact); - hn_send_ctx_init_simple(&sndc, hn_nvs_sent_wakeup, NULL); ret = vmbus_chan_send(sc->hn_prichan, VMBUS_CHANPKT_TYPE_INBAND, VMBUS_CHANPKT_FLAG_RC, - init_pkt, sizeof(nvsp_msg), (uint64_t)(uintptr_t)&sndc); + req, sizeof(*req), (uint64_t)(uintptr_t)&sndc); if (ret != 0) { - device_printf(dev, "Fail to allocate subchannel\n"); + if_printf(sc->hn_ifp, "send nvs subch req failed: %d\n", ret); + vmbus_xact_deactivate(xact); + vmbus_xact_put(xact); goto out; } - sema_wait(&net_dev->channel_init_sema); - - if (init_pkt->msgs.vers_5_msgs.subchn_complete.status != - nvsp_status_success) { - ret = ENODEV; - device_printf(dev, "sub channel complete error\n"); + resp = vmbus_xact_wait(xact, &resp_len); + if (resp_len < sizeof(*resp)) { + if_printf(sc->hn_ifp, "invalid subch resp length %zu\n", + resp_len); + vmbus_xact_put(xact); + ret = EINVAL; + goto out; + } + if (resp->nvs_type != HN_NVS_TYPE_SUBCH_RESP) { + if_printf(sc->hn_ifp, "not subch resp, type %u\n", + resp->nvs_type); + vmbus_xact_put(xact); + ret = EINVAL; goto out; } - net_dev->num_channel = 1 + - init_pkt->msgs.vers_5_msgs.subchn_complete.num_subchannels; + status = resp->nvs_status; + nsubch = resp->nvs_nsubch; + vmbus_xact_put(xact); + + if (status != HN_NVS_STATUS_OK) { + if_printf(sc->hn_ifp, "subch req failed: %x\n", status); + ret = EIO; + goto out; + } + if (nsubch > net_dev->num_channel - 1) { + if_printf(sc->hn_ifp, "%u subchans are allocated, requested %u\n", + nsubch, net_dev->num_channel - 1); + nsubch = net_dev->num_channel - 1; + } + net_dev->num_channel = nsubch + 1; ret = hv_rf_set_rss_param(rndis_dev, net_dev->num_channel); @@ -1240,7 +1275,8 @@ hv_rf_on_close(struct hn_softc *sc) static void hn_rndis_sent_cb(struct hn_send_ctx *sndc, struct netvsc_dev_ *net_dev, - struct vmbus_channel *chan __unused, const struct nvsp_msg_ *msg __unused) + struct vmbus_channel *chan __unused, const struct nvsp_msg_ *msg __unused, + int dlen __unused) { if (sndc->hn_chim_idx != NVSP_1_CHIMNEY_SEND_INVALID_SECTION_INDEX) hn_chim_free(net_dev, sndc->hn_chim_idx); @@ -1248,7 +1284,8 @@ hn_rndis_sent_cb(struct hn_send_ctx *snd static void hn_rndis_sent_halt(struct hn_send_ctx *sndc, struct netvsc_dev_ *net_dev, - struct vmbus_channel *chan __unused, const struct nvsp_msg_ *msg __unused) + struct vmbus_channel *chan __unused, const struct nvsp_msg_ *msg __unused, + int dlen __unused) { rndis_request *request = sndc->hn_cbarg; Copied and modified: stable/10/sys/dev/hyperv/netvsc/if_hnreg.h (from r303948, head/sys/dev/hyperv/netvsc/if_hnreg.h) ============================================================================== --- head/sys/dev/hyperv/netvsc/if_hnreg.h Thu Aug 11 06:14:54 2016 (r303948, copy source) +++ stable/10/sys/dev/hyperv/netvsc/if_hnreg.h Thu Oct 13 02:28:40 2016 (r307164) @@ -32,10 +32,23 @@ #include #include +#define HN_NVS_RXBUF_SIG 0xcafe +#define HN_NVS_CHIM_SIG 0xface + #define HN_NVS_STATUS_OK 1 #define HN_NVS_TYPE_INIT 1 #define HN_NVS_TYPE_INIT_RESP 2 +#define HN_NVS_TYPE_NDIS_INIT 100 +#define HN_NVS_TYPE_RXBUF_CONN 101 +#define HN_NVS_TYPE_RXBUF_CONNRESP 102 +#define HN_NVS_TYPE_RXBUF_DISCONN 103 +#define HN_NVS_TYPE_CHIM_CONN 104 +#define HN_NVS_TYPE_CHIM_CONNRESP 105 +#define HN_NVS_TYPE_CHIM_DISCONN 106 +#define HN_NVS_TYPE_NDIS_CONF 125 +#define HN_NVS_TYPE_SUBCH_REQ 133 +#define HN_NVS_TYPE_SUBCH_RESP 133 /* same as SUBCH_REQ */ /* * Any size less than this one will _not_ work, e.g. hn_nvs_init @@ -59,4 +72,94 @@ struct hn_nvs_init_resp { uint32_t nvs_status; /* HN_NVS_STATUS_ */ *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-all@freebsd.org Thu Oct 13 02:31:33 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 9863DC0F725; Thu, 13 Oct 2016 02:31:33 +0000 (UTC) (envelope-from jtl@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 678EBA54; Thu, 13 Oct 2016 02:31:33 +0000 (UTC) (envelope-from jtl@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9D2VW0i000290; Thu, 13 Oct 2016 02:31:32 GMT (envelope-from jtl@FreeBSD.org) Received: (from jtl@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9D2VWF7000289; Thu, 13 Oct 2016 02:31:32 GMT (envelope-from jtl@FreeBSD.org) Message-Id: <201610130231.u9D2VWF7000289@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jtl set sender to jtl@FreeBSD.org using -f From: "Jonathan T. Looney" Date: Thu, 13 Oct 2016 02:31:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307165 - stable/10/sys/netinet X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Oct 2016 02:31:33 -0000 Author: jtl Date: Thu Oct 13 02:31:32 2016 New Revision: 307165 URL: https://svnweb.freebsd.org/changeset/base/307165 Log: MFC r306766: Remove declaration of un-defined function tcp_seq_subtract(). Modified: stable/10/sys/netinet/tcp_var.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/netinet/tcp_var.h ============================================================================== --- stable/10/sys/netinet/tcp_var.h Thu Oct 13 02:28:40 2016 (r307164) +++ stable/10/sys/netinet/tcp_var.h Thu Oct 13 02:31:32 2016 (r307165) @@ -764,7 +764,6 @@ struct sackhole *tcp_sack_output(struct void tcp_sack_partialack(struct tcpcb *, struct tcphdr *); void tcp_free_sackholes(struct tcpcb *tp); int tcp_newreno(struct tcpcb *, struct tcphdr *); -u_long tcp_seq_subtract(u_long, u_long ); int tcp_compute_pipe(struct tcpcb *); void cc_cong_signal(struct tcpcb *tp, struct tcphdr *th, uint32_t type); From owner-svn-src-all@freebsd.org Thu Oct 13 02:32:42 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E4FCEC0F791; Thu, 13 Oct 2016 02:32:42 +0000 (UTC) (envelope-from jtl@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id B14BDC6D; Thu, 13 Oct 2016 02:32:42 +0000 (UTC) (envelope-from jtl@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9D2WfvD003687; Thu, 13 Oct 2016 02:32:41 GMT (envelope-from jtl@FreeBSD.org) Received: (from jtl@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9D2WfTM003686; Thu, 13 Oct 2016 02:32:41 GMT (envelope-from jtl@FreeBSD.org) Message-Id: <201610130232.u9D2WfTM003686@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jtl set sender to jtl@FreeBSD.org using -f From: "Jonathan T. Looney" Date: Thu, 13 Oct 2016 02:32:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307166 - stable/11/sys/netinet X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Oct 2016 02:32:43 -0000 Author: jtl Date: Thu Oct 13 02:32:41 2016 New Revision: 307166 URL: https://svnweb.freebsd.org/changeset/base/307166 Log: MFC r306766: Remove declaration of un-defined function tcp_seq_subtract(). Modified: stable/11/sys/netinet/tcp_var.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/netinet/tcp_var.h ============================================================================== --- stable/11/sys/netinet/tcp_var.h Thu Oct 13 02:31:32 2016 (r307165) +++ stable/11/sys/netinet/tcp_var.h Thu Oct 13 02:32:41 2016 (r307166) @@ -854,7 +854,6 @@ struct sackhole *tcp_sack_output(struct void tcp_sack_partialack(struct tcpcb *, struct tcphdr *); void tcp_free_sackholes(struct tcpcb *tp); int tcp_newreno(struct tcpcb *, struct tcphdr *); -u_long tcp_seq_subtract(u_long, u_long ); int tcp_compute_pipe(struct tcpcb *); static inline void From owner-svn-src-all@freebsd.org Thu Oct 13 02:38:48 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 25CE7C0F899; Thu, 13 Oct 2016 02:38:48 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id BB3B9E3F; Thu, 13 Oct 2016 02:38:47 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9D2clop003988; Thu, 13 Oct 2016 02:38:47 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9D2ckUt003984; Thu, 13 Oct 2016 02:38:46 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610130238.u9D2ckUt003984@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Thu, 13 Oct 2016 02:38:46 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307167 - in stable/10/sys/dev/hyperv: include netvsc X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Oct 2016 02:38:48 -0000 Author: sephe Date: Thu Oct 13 02:38:46 2016 New Revision: 307167 URL: https://svnweb.freebsd.org/changeset/base/307167 Log: MFC 304204-304206,304252-304256 304204 hyperv/hn: Factor out hn_nvs_send/hn_nvs_send_sglist Avoid unnecessary message type setting and centralize the send context to transaction id cast. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7500 304205 hyperv/hn: Simplify RNDIS NVS message sending. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7501 304206 hyperv/hn: Simplify RNDIS message checks on RX path. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7502 304252 hyperv/hn: Ignore the useless TX table. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7514 304253 hyperv/hn: Simplify RNDIS RX packets acknowledgement. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7515 304254 hyperv/hn: Remove reference to nvsp_msg Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7516 304255 hyperv/hn: Remove reference to nvsp_status Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7517 304256 hyperv/hn: Get rid of unused bits Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7518 Modified: stable/10/sys/dev/hyperv/include/vmbus.h stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.c stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.c stable/10/sys/dev/hyperv/netvsc/if_hnreg.h stable/10/sys/dev/hyperv/netvsc/if_hnvar.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/hyperv/include/vmbus.h ============================================================================== --- stable/10/sys/dev/hyperv/include/vmbus.h Thu Oct 13 02:32:41 2016 (r307166) +++ stable/10/sys/dev/hyperv/include/vmbus.h Thu Oct 13 02:38:46 2016 (r307167) @@ -84,6 +84,7 @@ struct vmbus_chanpkt_hdr { #define VMBUS_CHANPKT_TYPE_GPA 0x0009 #define VMBUS_CHANPKT_TYPE_COMP 0x000b +#define VMBUS_CHANPKT_FLAG_NONE 0 #define VMBUS_CHANPKT_FLAG_RC 0x0001 /* report completion */ #define VMBUS_CHANPKT_CONST_DATA(pkt) \ Modified: stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.c Thu Oct 13 02:32:41 2016 (r307166) +++ stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.c Thu Oct 13 02:38:46 2016 (r307167) @@ -71,7 +71,7 @@ static void hv_nv_on_receive(netvsc_dev const struct vmbus_chanpkt_hdr *pkt); static void hn_nvs_sent_none(struct hn_send_ctx *sndc, struct netvsc_dev_ *net_dev, struct vmbus_channel *chan, - const struct nvsp_msg_ *msg, int); + const void *, int); static struct hn_send_ctx hn_send_ctx_none = HN_SEND_CTX_INITIALIZER(hn_nvs_sent_none, NULL); @@ -117,7 +117,7 @@ hv_nv_get_next_send_section(netvsc_dev * unsigned long bitsmap_words = net_dev->bitsmap_words; unsigned long *bitsmap = net_dev->send_section_bitsmap; unsigned long idx; - int ret = NVSP_1_CHIMNEY_SEND_INVALID_SECTION_INDEX; + int ret = HN_NVS_CHIM_IDX_INVALID; int i; for (i = 0; i < bitsmap_words; i++) { @@ -205,9 +205,8 @@ hv_nv_init_rx_buffer_with_net_vsp(struct hn_send_ctx_init_simple(&sndc, hn_nvs_sent_xact, xact); vmbus_xact_activate(xact); - error = vmbus_chan_send(sc->hn_prichan, - VMBUS_CHANPKT_TYPE_INBAND, VMBUS_CHANPKT_FLAG_RC, - conn, sizeof(*conn), (uint64_t)(uintptr_t)&sndc); + error = hn_nvs_send(sc->hn_prichan, VMBUS_CHANPKT_FLAG_RC, + conn, sizeof(*conn), &sndc); if (error != 0) { if_printf(sc->hn_ifp, "send nvs rxbuf conn failed: %d\n", error); @@ -312,9 +311,8 @@ hv_nv_init_send_buffer_with_net_vsp(stru hn_send_ctx_init_simple(&sndc, hn_nvs_sent_xact, xact); vmbus_xact_activate(xact); - error = vmbus_chan_send(sc->hn_prichan, - VMBUS_CHANPKT_TYPE_INBAND, VMBUS_CHANPKT_FLAG_RC, - chim, sizeof(*chim), (uint64_t)(uintptr_t)&sndc); + error = hn_nvs_send(sc->hn_prichan, VMBUS_CHANPKT_FLAG_RC, + chim, sizeof(*chim), &sndc); if (error) { if_printf(sc->hn_ifp, "send nvs chim conn failed: %d\n", error); @@ -392,9 +390,10 @@ hv_nv_destroy_rx_buffer(netvsc_dev *net_ disconn.nvs_type = HN_NVS_TYPE_RXBUF_DISCONN; disconn.nvs_sig = HN_NVS_RXBUF_SIG; - ret = vmbus_chan_send(net_dev->sc->hn_prichan, - VMBUS_CHANPKT_TYPE_INBAND, 0, &disconn, sizeof(disconn), - (uint64_t)(uintptr_t)&hn_send_ctx_none); + /* NOTE: No response. */ + ret = hn_nvs_send(net_dev->sc->hn_prichan, + VMBUS_CHANPKT_FLAG_NONE, &disconn, sizeof(disconn), + &hn_send_ctx_none); if (ret != 0) { if_printf(net_dev->sc->hn_ifp, "send rxbuf disconn failed: %d\n", ret); @@ -444,9 +443,10 @@ hv_nv_destroy_send_buffer(netvsc_dev *ne disconn.nvs_type = HN_NVS_TYPE_CHIM_DISCONN; disconn.nvs_sig = HN_NVS_CHIM_SIG; - ret = vmbus_chan_send(net_dev->sc->hn_prichan, - VMBUS_CHANPKT_TYPE_INBAND, 0, &disconn, sizeof(disconn), - (uint64_t)(uintptr_t)&hn_send_ctx_none); + /* NOTE: No response. */ + ret = hn_nvs_send(net_dev->sc->hn_prichan, + VMBUS_CHANPKT_FLAG_NONE, &disconn, sizeof(disconn), + &hn_send_ctx_none); if (ret != 0) { if_printf(net_dev->sc->hn_ifp, "send chim disconn failed: %d\n", ret); @@ -508,9 +508,8 @@ hv_nv_negotiate_nvsp_protocol(struct hn_ vmbus_xact_activate(xact); hn_send_ctx_init_simple(&sndc, hn_nvs_sent_xact, xact); - error = vmbus_chan_send(sc->hn_prichan, - VMBUS_CHANPKT_TYPE_INBAND, VMBUS_CHANPKT_FLAG_RC, - init, sizeof(*init), (uint64_t)(uintptr_t)&sndc); + error = hn_nvs_send(sc->hn_prichan, VMBUS_CHANPKT_FLAG_RC, + init, sizeof(*init), &sndc); if (error) { if_printf(sc->hn_ifp, "send nvs init failed: %d\n", error); vmbus_xact_deactivate(xact); @@ -559,8 +558,9 @@ hv_nv_send_ndis_config(struct hn_softc * conf.nvs_mtu = mtu; conf.nvs_caps = HN_NVS_NDIS_CONF_VLAN; - error = vmbus_chan_send(sc->hn_prichan, VMBUS_CHANPKT_TYPE_INBAND, 0, - &conf, sizeof(conf), (uint64_t)(uintptr_t)&hn_send_ctx_none); + /* NOTE: No response. */ + error = hn_nvs_send(sc->hn_prichan, VMBUS_CHANPKT_FLAG_NONE, + &conf, sizeof(conf), &hn_send_ctx_none); if (error) if_printf(sc->hn_ifp, "send nvs ndis conf failed: %d\n", error); return (error); @@ -626,8 +626,9 @@ hv_nv_connect_to_vsp(struct hn_softc *sc else ndis.nvs_ndis_minor = NDIS_VERSION_MINOR_30; - ret = vmbus_chan_send(sc->hn_prichan, VMBUS_CHANPKT_TYPE_INBAND, 0, - &ndis, sizeof(ndis), (uint64_t)(uintptr_t)&hn_send_ctx_none); + /* NOTE: No response. */ + ret = hn_nvs_send(sc->hn_prichan, VMBUS_CHANPKT_FLAG_NONE, + &ndis, sizeof(ndis), &hn_send_ctx_none); if (ret != 0) { if_printf(sc->hn_ifp, "send nvs ndis init failed: %d\n", ret); goto cleanup; @@ -688,8 +689,6 @@ hv_nv_on_device_add(struct hn_softc *sc, /* Initialize the NetVSC channel extension */ - sema_init(&net_dev->channel_init_sema, 0, "netdev_sema"); - /* * Open the channel */ @@ -720,7 +719,6 @@ cleanup: * Free the packet buffers on the netvsc device packet queue. * Release other resources. */ - sema_destroy(&net_dev->channel_init_sema); free(net_dev, M_NETVSC); return (NULL); @@ -745,7 +743,6 @@ hv_nv_on_device_remove(struct hn_softc * vmbus_chan_close(sc->hn_prichan); - sema_destroy(&net_dev->channel_init_sema); free(net_dev, M_NETVSC); return (0); @@ -754,16 +751,16 @@ hv_nv_on_device_remove(struct hn_softc * void hn_nvs_sent_xact(struct hn_send_ctx *sndc, struct netvsc_dev_ *net_dev __unused, struct vmbus_channel *chan __unused, - const struct nvsp_msg_ *msg, int dlen) + const void *data, int dlen) { - vmbus_xact_wakeup(sndc->hn_cbarg, msg, dlen); + vmbus_xact_wakeup(sndc->hn_cbarg, data, dlen); } static void hn_nvs_sent_none(struct hn_send_ctx *sndc __unused, struct netvsc_dev_ *net_dev __unused, struct vmbus_channel *chan __unused, - const struct nvsp_msg_ *msg __unused, int dlen __unused) + const void *data __unused, int dlen __unused) { /* EMPTY */ } @@ -812,33 +809,23 @@ hv_nv_on_send_completion(netvsc_dev *net * Returns 0 on success, non-zero on failure. */ int -hv_nv_on_send(struct vmbus_channel *chan, bool is_data_pkt, +hv_nv_on_send(struct vmbus_channel *chan, uint32_t rndis_mtype, struct hn_send_ctx *sndc, struct vmbus_gpa *gpa, int gpa_cnt) { - nvsp_msg send_msg; + struct hn_nvs_rndis rndis; int ret; - send_msg.hdr.msg_type = nvsp_msg_1_type_send_rndis_pkt; - if (is_data_pkt) { - /* 0 is RMC_DATA */ - send_msg.msgs.vers_1_msgs.send_rndis_pkt.chan_type = 0; - } else { - /* 1 is RMC_CONTROL */ - send_msg.msgs.vers_1_msgs.send_rndis_pkt.chan_type = 1; - } - - send_msg.msgs.vers_1_msgs.send_rndis_pkt.send_buf_section_idx = - sndc->hn_chim_idx; - send_msg.msgs.vers_1_msgs.send_rndis_pkt.send_buf_section_size = - sndc->hn_chim_sz; + rndis.nvs_type = HN_NVS_TYPE_RNDIS; + rndis.nvs_rndis_mtype = rndis_mtype; + rndis.nvs_chim_idx = sndc->hn_chim_idx; + rndis.nvs_chim_sz = sndc->hn_chim_sz; if (gpa_cnt) { - ret = vmbus_chan_send_sglist(chan, gpa, gpa_cnt, - &send_msg, sizeof(nvsp_msg), (uint64_t)(uintptr_t)sndc); + ret = hn_nvs_send_sglist(chan, gpa, gpa_cnt, + &rndis, sizeof(rndis), sndc); } else { - ret = vmbus_chan_send(chan, - VMBUS_CHANPKT_TYPE_INBAND, VMBUS_CHANPKT_FLAG_RC, - &send_msg, sizeof(nvsp_msg), (uint64_t)(uintptr_t)sndc); + ret = hn_nvs_send(chan, VMBUS_CHANPKT_FLAG_RC, + &rndis, sizeof(rndis), sndc); } return (ret); @@ -855,19 +842,18 @@ hv_nv_on_receive(netvsc_dev *net_dev, st struct vmbus_channel *chan, const struct vmbus_chanpkt_hdr *pkthdr) { const struct vmbus_chanpkt_rxbuf *pkt; - const nvsp_msg *nvsp_msg_pkt; + const struct hn_nvs_hdr *nvs_hdr; netvsc_packet vsc_pkt; netvsc_packet *net_vsc_pkt = &vsc_pkt; int count = 0; int i = 0; - int status = nvsp_status_success; - - nvsp_msg_pkt = VMBUS_CHANPKT_CONST_DATA(pkthdr); + int status = HN_NVS_STATUS_OK; - /* Make sure this is a valid nvsp packet */ - if (nvsp_msg_pkt->hdr.msg_type != nvsp_msg_1_type_send_rndis_pkt) { - if_printf(rxr->hn_ifp, "packet hdr type %u is invalid!\n", - nvsp_msg_pkt->hdr.msg_type); + /* Make sure that this is a RNDIS message. */ + nvs_hdr = VMBUS_CHANPKT_CONST_DATA(pkthdr); + if (__predict_false(nvs_hdr->nvs_type != HN_NVS_TYPE_RNDIS)) { + if_printf(rxr->hn_ifp, "nvs type %u, not RNDIS\n", + nvs_hdr->nvs_type); return; } @@ -883,15 +869,16 @@ hv_nv_on_receive(netvsc_dev *net_dev, st /* Each range represents 1 RNDIS pkt that contains 1 Ethernet frame */ for (i = 0; i < count; i++) { - net_vsc_pkt->status = nvsp_status_success; + net_vsc_pkt->status = HN_NVS_STATUS_OK; net_vsc_pkt->data = ((uint8_t *)net_dev->rx_buf + pkt->cp_rxbuf[i].rb_ofs); net_vsc_pkt->tot_data_buf_len = pkt->cp_rxbuf[i].rb_len; hv_rf_on_receive(net_dev, rxr, net_vsc_pkt); - if (net_vsc_pkt->status != nvsp_status_success) { - status = nvsp_status_failure; - } + + /* XXX pretty broken; whack it */ + if (net_vsc_pkt->status != HN_NVS_STATUS_OK) + status = HN_NVS_STATUS_FAILED; } /* @@ -911,20 +898,17 @@ static void hv_nv_on_receive_completion(struct vmbus_channel *chan, uint64_t tid, uint32_t status) { - nvsp_msg rx_comp_msg; + struct hn_nvs_rndis_ack ack; int retries = 0; int ret = 0; - rx_comp_msg.hdr.msg_type = nvsp_msg_1_type_send_rndis_pkt_complete; - - /* Pass in the status */ - rx_comp_msg.msgs.vers_1_msgs.send_rndis_pkt_complete.status = - status; + ack.nvs_type = HN_NVS_TYPE_RNDIS_ACK; + ack.nvs_status = status; retry_send_cmplt: /* Send the completion */ - ret = vmbus_chan_send(chan, VMBUS_CHANPKT_TYPE_COMP, 0, - &rx_comp_msg, sizeof(nvsp_msg), tid); + ret = vmbus_chan_send(chan, VMBUS_CHANPKT_TYPE_COMP, + VMBUS_CHANPKT_FLAG_NONE, &ack, sizeof(ack), tid); if (ret == 0) { /* success */ /* no-op */ @@ -939,44 +923,17 @@ retry_send_cmplt: } } -/* - * Net VSC receiving vRSS send table from VSP - */ static void -hv_nv_send_table(struct hn_softc *sc, const struct vmbus_chanpkt_hdr *pkt) +hn_proc_notify(struct hn_softc *sc, const struct vmbus_chanpkt_hdr *pkt) { - netvsc_dev *net_dev; - const nvsp_msg *nvsp_msg_pkt; - int i; - uint32_t count; - const uint32_t *table; - - net_dev = hv_nv_get_inbound_net_device(sc); - if (!net_dev) - return; - - nvsp_msg_pkt = VMBUS_CHANPKT_CONST_DATA(pkt); + const struct hn_nvs_hdr *hdr; - if (nvsp_msg_pkt->hdr.msg_type != - nvsp_msg5_type_send_indirection_table) { - printf("Netvsc: !Warning! receive msg type not " - "send_indirection_table. type = %d\n", - nvsp_msg_pkt->hdr.msg_type); + hdr = VMBUS_CHANPKT_CONST_DATA(pkt); + if (hdr->nvs_type == HN_NVS_TYPE_TXTBL_NOTE) { + /* Useless; ignore */ return; } - - count = nvsp_msg_pkt->msgs.vers_5_msgs.send_table.count; - if (count != VRSS_SEND_TABLE_SIZE) { - printf("Netvsc: Received wrong send table size: %u\n", count); - return; - } - - table = (const uint32_t *) - ((const uint8_t *)&nvsp_msg_pkt->msgs.vers_5_msgs.send_table + - nvsp_msg_pkt->msgs.vers_5_msgs.send_table.offset); - - for (i = 0; i < count; i++) - net_dev->vrss_send_table[i] = table[i]; + if_printf(sc->hn_ifp, "got notify, nvs type %u\n", hdr->nvs_type); } /* @@ -1014,7 +971,7 @@ hv_nv_on_channel_callback(struct vmbus_c hv_nv_on_receive(net_dev, rxr, chan, pkt); break; case VMBUS_CHANPKT_TYPE_INBAND: - hv_nv_send_table(sc, pkt); + hn_proc_notify(sc, pkt); break; default: if_printf(rxr->hn_ifp, Modified: stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h Thu Oct 13 02:32:41 2016 (r307166) +++ stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h Thu Oct 13 02:38:46 2016 (r307167) @@ -177,834 +177,6 @@ typedef struct rndis_recv_scale_param_ { uint32_t processor_masks_entry_size; } rndis_recv_scale_param; -typedef enum nvsp_msg_type_ { - nvsp_msg_type_none = 0, - - /* - * Init Messages - */ - nvsp_msg_type_init = 1, - nvsp_msg_type_init_complete = 2, - - nvsp_version_msg_start = 100, - - /* - * Version 1 Messages - */ - nvsp_msg_1_type_send_ndis_vers = nvsp_version_msg_start, - - nvsp_msg_1_type_send_rx_buf, - nvsp_msg_1_type_send_rx_buf_complete, - nvsp_msg_1_type_revoke_rx_buf, - - nvsp_msg_1_type_send_send_buf, - nvsp_msg_1_type_send_send_buf_complete, - nvsp_msg_1_type_revoke_send_buf, - - nvsp_msg_1_type_send_rndis_pkt, - nvsp_msg_1_type_send_rndis_pkt_complete, - - /* - * Version 2 Messages - */ - nvsp_msg_2_type_send_chimney_delegated_buf, - nvsp_msg_2_type_send_chimney_delegated_buf_complete, - nvsp_msg_2_type_revoke_chimney_delegated_buf, - - nvsp_msg_2_type_resume_chimney_rx_indication, - - nvsp_msg_2_type_terminate_chimney, - nvsp_msg_2_type_terminate_chimney_complete, - - nvsp_msg_2_type_indicate_chimney_event, - - nvsp_msg_2_type_send_chimney_packet, - nvsp_msg_2_type_send_chimney_packet_complete, - - nvsp_msg_2_type_post_chimney_rx_request, - nvsp_msg_2_type_post_chimney_rx_request_complete, - - nvsp_msg_2_type_alloc_rx_buf, - nvsp_msg_2_type_alloc_rx_buf_complete, - - nvsp_msg_2_type_free_rx_buf, - - nvsp_msg_2_send_vmq_rndis_pkt, - nvsp_msg_2_send_vmq_rndis_pkt_complete, - - nvsp_msg_2_type_send_ndis_config, - - nvsp_msg_2_type_alloc_chimney_handle, - nvsp_msg_2_type_alloc_chimney_handle_complete, - - nvsp_msg2_max = nvsp_msg_2_type_alloc_chimney_handle_complete, - - /* - * Version 4 Messages - */ - nvsp_msg4_type_send_vf_association, - nvsp_msg4_type_switch_data_path, - nvsp_msg4_type_uplink_connect_state_deprecated, - - nvsp_msg4_max = nvsp_msg4_type_uplink_connect_state_deprecated, - - /* - * Version 5 Messages - */ - nvsp_msg5_type_oid_query_ex, - nvsp_msg5_type_oid_query_ex_comp, - nvsp_msg5_type_subchannel, - nvsp_msg5_type_send_indirection_table, - - nvsp_msg5_max = nvsp_msg5_type_send_indirection_table, -} nvsp_msg_type; - -typedef enum nvsp_status_ { - nvsp_status_none = 0, - nvsp_status_success, - nvsp_status_failure, - /* Deprecated */ - nvsp_status_prot_vers_range_too_new, - /* Deprecated */ - nvsp_status_prot_vers_range_too_old, - nvsp_status_invalid_rndis_pkt, - nvsp_status_busy, - nvsp_status_max, -} nvsp_status; - -typedef struct nvsp_msg_hdr_ { - uint32_t msg_type; -} __packed nvsp_msg_hdr; - -/* - * Init Messages - */ - -/* - * This message is used by the VSC to initialize the channel - * after the channels has been opened. This message should - * never include anything other then versioning (i.e. this - * message will be the same for ever). - * - * Forever is a long time. The values have been redefined - * in Win7 to indicate major and minor protocol version - * number. - */ -typedef struct nvsp_msg_init_ { - union { - struct { - uint16_t minor_protocol_version; - uint16_t major_protocol_version; - } s; - /* Formerly min_protocol_version */ - uint32_t protocol_version; - } p1; - /* Formerly max_protocol_version */ - uint32_t protocol_version_2; -} __packed nvsp_msg_init; - -/* - * This message is used by the VSP to complete the initialization - * of the channel. This message should never include anything other - * then versioning (i.e. this message will be the same forever). - */ -typedef struct nvsp_msg_init_complete_ { - /* Deprecated */ - uint32_t negotiated_prot_vers; - uint32_t max_mdl_chain_len; - uint32_t status; -} __packed nvsp_msg_init_complete; - -typedef union nvsp_msg_init_uber_ { - nvsp_msg_init init; - nvsp_msg_init_complete init_compl; -} __packed nvsp_msg_init_uber; - -/* - * Version 1 Messages - */ - -/* - * This message is used by the VSC to send the NDIS version - * to the VSP. The VSP can use this information when handling - * OIDs sent by the VSC. - */ -typedef struct nvsp_1_msg_send_ndis_version_ { - uint32_t ndis_major_vers; - /* Deprecated */ - uint32_t ndis_minor_vers; -} __packed nvsp_1_msg_send_ndis_version; - -/* - * This message is used by the VSC to send a receive buffer - * to the VSP. The VSP can then use the receive buffer to - * send data to the VSC. - */ -typedef struct nvsp_1_msg_send_rx_buf_ { - uint32_t gpadl_handle; - uint16_t id; -} __packed nvsp_1_msg_send_rx_buf; - -typedef struct nvsp_1_rx_buf_section_ { - uint32_t offset; - uint32_t sub_allocation_size; - uint32_t num_sub_allocations; - uint32_t end_offset; -} __packed nvsp_1_rx_buf_section; - -/* - * This message is used by the VSP to acknowledge a receive - * buffer send by the VSC. This message must be sent by the - * VSP before the VSP uses the receive buffer. - */ -typedef struct nvsp_1_msg_send_rx_buf_complete_ { - uint32_t status; - uint32_t num_sections; - - /* - * The receive buffer is split into two parts, a large - * suballocation section and a small suballocation - * section. These sections are then suballocated by a - * certain size. - * - * For example, the following break up of the receive - * buffer has 6 large suballocations and 10 small - * suballocations. - * - * | Large Section | | Small Section | - * ------------------------------------------------------------ - * | | | | | | | | | | | | | | | | | | - * | | - * LargeOffset SmallOffset - */ - nvsp_1_rx_buf_section sections[1]; - -} __packed nvsp_1_msg_send_rx_buf_complete; - -/* - * This message is sent by the VSC to revoke the receive buffer. - * After the VSP completes this transaction, the VSP should never - * use the receive buffer again. - */ -typedef struct nvsp_1_msg_revoke_rx_buf_ { - uint16_t id; -} __packed nvsp_1_msg_revoke_rx_buf; - -/* - * This message is used by the VSC to send a send buffer - * to the VSP. The VSC can then use the send buffer to - * send data to the VSP. - */ -typedef struct nvsp_1_msg_send_send_buf_ { - uint32_t gpadl_handle; - uint16_t id; -} __packed nvsp_1_msg_send_send_buf; - -/* - * This message is used by the VSP to acknowledge a send - * buffer sent by the VSC. This message must be sent by the - * VSP before the VSP uses the sent buffer. - */ -typedef struct nvsp_1_msg_send_send_buf_complete_ { - uint32_t status; - - /* - * The VSC gets to choose the size of the send buffer and - * the VSP gets to choose the sections size of the buffer. - * This was done to enable dynamic reconfigurations when - * the cost of GPA-direct buffers decreases. - */ - uint32_t section_size; -} __packed nvsp_1_msg_send_send_buf_complete; - -/* - * This message is sent by the VSC to revoke the send buffer. - * After the VSP completes this transaction, the vsp should never - * use the send buffer again. - */ -typedef struct nvsp_1_msg_revoke_send_buf_ { - uint16_t id; -} __packed nvsp_1_msg_revoke_send_buf; - -/* - * This message is used by both the VSP and the VSC to send - * an RNDIS message to the opposite channel endpoint. - */ -typedef struct nvsp_1_msg_send_rndis_pkt_ { - /* - * This field is specified by RNIDS. They assume there's - * two different channels of communication. However, - * the Network VSP only has one. Therefore, the channel - * travels with the RNDIS packet. - */ - uint32_t chan_type; - - /* - * This field is used to send part or all of the data - * through a send buffer. This values specifies an - * index into the send buffer. If the index is - * 0xFFFFFFFF, then the send buffer is not being used - * and all of the data was sent through other VMBus - * mechanisms. - */ - uint32_t send_buf_section_idx; - uint32_t send_buf_section_size; -} __packed nvsp_1_msg_send_rndis_pkt; - -/* - * This message is used by both the VSP and the VSC to complete - * a RNDIS message to the opposite channel endpoint. At this - * point, the initiator of this message cannot use any resources - * associated with the original RNDIS packet. - */ -typedef struct nvsp_1_msg_send_rndis_pkt_complete_ { - uint32_t status; -} __packed nvsp_1_msg_send_rndis_pkt_complete; - - -/* - * Version 2 Messages - */ - -/* - * This message is used by the VSC to send the NDIS version - * to the VSP. The VSP can use this information when handling - * OIDs sent by the VSC. - */ -typedef struct nvsp_2_netvsc_capabilities_ { - union { - uint64_t as_uint64; - struct { - uint64_t vmq : 1; - uint64_t chimney : 1; - uint64_t sriov : 1; - uint64_t ieee8021q : 1; - uint64_t correlationid : 1; - uint64_t teaming : 1; - } u2; - } u1; -} __packed nvsp_2_netvsc_capabilities; - -typedef struct nvsp_2_msg_send_ndis_config_ { - uint32_t mtu; - uint32_t reserved; - nvsp_2_netvsc_capabilities capabilities; -} __packed nvsp_2_msg_send_ndis_config; - -/* - * NvspMessage2TypeSendChimneyDelegatedBuffer - */ -typedef struct nvsp_2_msg_send_chimney_buf_ -{ - /* - * On WIN7 beta, delegated_obj_max_size is defined as a uint32_t - * Since WIN7 RC, it was split into two uint16_t. To have the same - * struct layout, delegated_obj_max_size shall be the first field. - */ - uint16_t delegated_obj_max_size; - - /* - * The revision # of chimney protocol used between NVSC and NVSP. - * - * This revision is NOT related to the chimney revision between - * NDIS protocol and miniport drivers. - */ - uint16_t revision; - - uint32_t gpadl_handle; -} __packed nvsp_2_msg_send_chimney_buf; - - -/* Unsupported chimney revision 0 (only present in WIN7 beta) */ -#define NVSP_CHIMNEY_REVISION_0 0 - -/* WIN7 Beta Chimney QFE */ -#define NVSP_CHIMNEY_REVISION_1 1 - -/* The chimney revision since WIN7 RC */ -#define NVSP_CHIMNEY_REVISION_2 2 - - -/* - * NvspMessage2TypeSendChimneyDelegatedBufferComplete - */ -typedef struct nvsp_2_msg_send_chimney_buf_complete_ { - uint32_t status; - - /* - * Maximum number outstanding sends and pre-posted receives. - * - * NVSC should not post more than SendQuota/ReceiveQuota packets. - * Otherwise, it can block the non-chimney path for an indefinite - * amount of time. - * (since chimney sends/receives are affected by the remote peer). - * - * Note: NVSP enforces the quota restrictions on a per-VMBCHANNEL - * basis. It doesn't enforce the restriction separately for chimney - * send/receive. If NVSC doesn't voluntarily enforce "SendQuota", - * it may kill its own network connectivity. - */ - uint32_t send_quota; - uint32_t rx_quota; -} __packed nvsp_2_msg_send_chimney_buf_complete; - -/* - * NvspMessage2TypeRevokeChimneyDelegatedBuffer - */ -typedef struct nvsp_2_msg_revoke_chimney_buf_ { - uint32_t gpadl_handle; -} __packed nvsp_2_msg_revoke_chimney_buf; - - -#define NVSP_CHIMNEY_OBJECT_TYPE_NEIGHBOR 0 -#define NVSP_CHIMNEY_OBJECT_TYPE_PATH4 1 -#define NVSP_CHIMNEY_OBJECT_TYPE_PATH6 2 -#define NVSP_CHIMNEY_OBJECT_TYPE_TCP 3 - -/* - * NvspMessage2TypeAllocateChimneyHandle - */ -typedef struct nvsp_2_msg_alloc_chimney_handle_ { - uint64_t vsc_context; - uint32_t object_type; -} __packed nvsp_2_msg_alloc_chimney_handle; - -/* - * NvspMessage2TypeAllocateChimneyHandleComplete - */ -typedef struct nvsp_2_msg_alloc_chimney_handle_complete_ { - uint32_t vsp_handle; -} __packed nvsp_2_msg_alloc_chimney_handle_complete; - - -/* - * NvspMessage2TypeResumeChimneyRXIndication - */ -typedef struct nvsp_2_msg_resume_chimney_rx_indication { - /* - * Handle identifying the offloaded connection - */ - uint32_t vsp_tcp_handle; -} __packed nvsp_2_msg_resume_chimney_rx_indication; - - -#define NVSP_2_MSG_TERMINATE_CHIMNEY_FLAGS_FIRST_STAGE (0x01u) -#define NVSP_2_MSG_TERMINATE_CHIMNEY_FLAGS_RESERVED (~(0x01u)) - -/* - * NvspMessage2TypeTerminateChimney - */ -typedef struct nvsp_2_msg_terminate_chimney_ { - /* - * Handle identifying the offloaded object - */ - uint32_t vsp_handle; - - /* - * Terminate Offload Flags - * Bit 0: - * When set to 0, terminate the offload at the destination NIC - * Bit 1-31: Reserved, shall be zero - */ - uint32_t flags; - - union { - /* - * This field is valid only when bit 0 of flags is clear. - * It specifies the index into the premapped delegated - * object buffer. The buffer was sent through the - * NvspMessage2TypeSendChimneyDelegatedBuffer - * message at initialization time. - * - * NVSP will write the delegated state into the delegated - * buffer upon upload completion. - */ - uint32_t index; - - /* - * This field is valid only when bit 0 of flags is set. - * - * The seqence number of the most recently accepted RX - * indication when VSC sets its TCP context into - * "terminating" state. - * - * This allows NVSP to determines if there are any in-flight - * RX indications for which the acceptance state is still - * undefined. - */ - uint64_t last_accepted_rx_seq_no; - } f0; -} __packed nvsp_2_msg_terminate_chimney; - - -#define NVSP_TERMINATE_CHIMNEY_COMPLETE_FLAG_DATA_CORRUPTED 0x0000001u - -/* - * NvspMessage2TypeTerminateChimneyComplete - */ -typedef struct nvsp_2_msg_terminate_chimney_complete_ { - uint64_t vsc_context; - uint32_t flags; -} __packed nvsp_2_msg_terminate_chimney_complete; - -/* - * NvspMessage2TypeIndicateChimneyEvent - */ -typedef struct nvsp_2_msg_indicate_chimney_event_ { - /* - * When VscTcpContext is 0, event_type is an NDIS_STATUS event code - * Otherwise, EventType is an TCP connection event (defined in - * NdisTcpOffloadEventHandler chimney DDK document). - */ - uint32_t event_type; - - /* - * When VscTcpContext is 0, EventType is an NDIS_STATUS event code - * Otherwise, EventType is an TCP connection event specific information - * (defined in NdisTcpOffloadEventHandler chimney DDK document). - */ - uint32_t event_specific_info; - - /* - * If not 0, the event is per-TCP connection event. This field - * contains the VSC's TCP context. - * If 0, the event indication is global. - */ - uint64_t vsc_tcp_context; -} __packed nvsp_2_msg_indicate_chimney_event; - - -#define NVSP_1_CHIMNEY_SEND_INVALID_OOB_INDEX 0xffffu -#define NVSP_1_CHIMNEY_SEND_INVALID_SECTION_INDEX 0xffffffff - -/* - * NvspMessage2TypeSendChimneyPacket - */ -typedef struct nvsp_2_msg_send_chimney_pkt_ { - /* - * Identify the TCP connection for which this chimney send is - */ - uint32_t vsp_tcp_handle; - - /* - * This field is used to send part or all of the data - * through a send buffer. This values specifies an - * index into the send buffer. If the index is - * 0xFFFF, then the send buffer is not being used - * and all of the data was sent through other VMBus - * mechanisms. - */ - uint16_t send_buf_section_index; - uint16_t send_buf_section_size; - - /* - * OOB Data Index - * This an index to the OOB data buffer. If the index is 0xFFFFFFFF, - * then there is no OOB data. - * - * This field shall be always 0xFFFFFFFF for now. It is reserved for - * the future. - */ - uint16_t oob_data_index; - - /* - * DisconnectFlags = 0 - * Normal chimney send. See MiniportTcpOffloadSend for details. - * - * DisconnectFlags = TCP_DISCONNECT_GRACEFUL_CLOSE (0x01) - * Graceful disconnect. See MiniportTcpOffloadDisconnect for details. - * - * DisconnectFlags = TCP_DISCONNECT_ABORTIVE_CLOSE (0x02) - * Abortive disconnect. See MiniportTcpOffloadDisconnect for details. - */ - uint16_t disconnect_flags; - - uint32_t seq_no; -} __packed nvsp_2_msg_send_chimney_pkt; - -/* - * NvspMessage2TypeSendChimneyPacketComplete - */ -typedef struct nvsp_2_msg_send_chimney_pkt_complete_ { - /* - * The NDIS_STATUS for the chimney send - */ - uint32_t status; - - /* - * Number of bytes that have been sent to the peer (and ACKed by the peer). - */ - uint32_t bytes_transferred; -} __packed nvsp_2_msg_send_chimney_pkt_complete; - - -#define NVSP_1_CHIMNEY_RECV_FLAG_NO_PUSH 0x0001u -#define NVSP_1_CHIMNEY_RECV_INVALID_OOB_INDEX 0xffffu - -/* - * NvspMessage2TypePostChimneyRecvRequest - */ -typedef struct nvsp_2_msg_post_chimney_rx_request_ { - /* - * Identify the TCP connection which this chimney receive request - * is for. - */ - uint32_t vsp_tcp_handle; - - /* - * OOB Data Index - * This an index to the OOB data buffer. If the index is 0xFFFFFFFF, - * then there is no OOB data. - * - * This field shall be always 0xFFFFFFFF for now. It is reserved for - * the future. - */ - uint32_t oob_data_index; - - /* - * Bit 0 - * When it is set, this is a "no-push" receive. - * When it is clear, this is a "push" receive. - * - * Bit 1-15: Reserved and shall be zero - */ - uint16_t flags; - - /* - * For debugging and diagnoses purpose. - * The SeqNo is per TCP connection and starts from 0. - */ - uint32_t seq_no; -} __packed nvsp_2_msg_post_chimney_rx_request; - -/* - * NvspMessage2TypePostChimneyRecvRequestComplete - */ -typedef struct nvsp_2_msg_post_chimney_rx_request_complete_ { - /* - * The NDIS_STATUS for the chimney send - */ - uint32_t status; - - /* - * Number of bytes that have been sent to the peer (and ACKed by - * the peer). - */ - uint32_t bytes_xferred; -} __packed nvsp_2_msg_post_chimney_rx_request_complete; - -/* - * NvspMessage2TypeAllocateReceiveBuffer - */ -typedef struct nvsp_2_msg_alloc_rx_buf_ { - /* - * Allocation ID to match the allocation request and response - */ - uint32_t allocation_id; - - /* - * Length of the VM shared memory receive buffer that needs to - * be allocated - */ - uint32_t length; -} __packed nvsp_2_msg_alloc_rx_buf; - -/* - * NvspMessage2TypeAllocateReceiveBufferComplete - */ -typedef struct nvsp_2_msg_alloc_rx_buf_complete_ { - /* - * The NDIS_STATUS code for buffer allocation - */ - uint32_t status; - - /* - * Allocation ID from NVSP_2_MESSAGE_ALLOCATE_RECEIVE_BUFFER - */ - uint32_t allocation_id; - - /* - * GPADL handle for the allocated receive buffer - */ - uint32_t gpadl_handle; - - /* - * Receive buffer ID that is further used in *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-all@freebsd.org Thu Oct 13 02:45:10 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 964AAC0FA34; Thu, 13 Oct 2016 02:45:10 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 65B4E23F; Thu, 13 Oct 2016 02:45:10 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9D2j9mN007786; Thu, 13 Oct 2016 02:45:09 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9D2j8cS007779; Thu, 13 Oct 2016 02:45:08 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610130245.u9D2j8cS007779@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Thu, 13 Oct 2016 02:45:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307168 - stable/10/sys/dev/hyperv/utilities X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Oct 2016 02:45:10 -0000 Author: sephe Date: Thu Oct 13 02:45:08 2016 New Revision: 307168 URL: https://svnweb.freebsd.org/changeset/base/307168 Log: MFC 304270,304273 304270 hyperv/util: Don't reference hn_softc in KVP hn_softc is private data struct. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7519 304273 hyperv/util: Factor out helper for IC device_probe DEVMETHOD Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7530 Modified: stable/10/sys/dev/hyperv/utilities/hv_heartbeat.c stable/10/sys/dev/hyperv/utilities/hv_kvp.c stable/10/sys/dev/hyperv/utilities/hv_shutdown.c stable/10/sys/dev/hyperv/utilities/hv_timesync.c stable/10/sys/dev/hyperv/utilities/hv_util.c stable/10/sys/dev/hyperv/utilities/hv_util.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/hyperv/utilities/hv_heartbeat.c ============================================================================== --- stable/10/sys/dev/hyperv/utilities/hv_heartbeat.c Thu Oct 13 02:38:46 2016 (r307167) +++ stable/10/sys/dev/hyperv/utilities/hv_heartbeat.c Thu Oct 13 02:45:08 2016 (r307168) @@ -41,10 +41,15 @@ #include "hv_util.h" #include "vmbus_if.h" -/* Heartbeat Service */ -static const struct hyperv_guid service_guid = { .hv_guid = - {0x39, 0x4f, 0x16, 0x57, 0x15, 0x91, 0x78, 0x4e, - 0xab, 0x55, 0x38, 0x2f, 0x3b, 0xd5, 0x42, 0x2d} }; +static const struct vmbus_ic_desc vmbus_heartbeat_descs[] = { + { + .ic_guid = { .hv_guid = { + 0x39, 0x4f, 0x16, 0x57, 0x15, 0x91, 0x78, 0x4e, + 0xab, 0x55, 0x38, 0x2f, 0x3b, 0xd5, 0x42, 0x2d} }, + .ic_desc = "Hyper-V Heartbeat" + }, + VMBUS_IC_DESC_END +}; /** * Process heartbeat message @@ -96,14 +101,8 @@ hv_heartbeat_cb(struct vmbus_channel *ch static int hv_heartbeat_probe(device_t dev) { - if (resource_disabled("hvheartbeat", 0)) - return ENXIO; - if (VMBUS_PROBE_GUID(device_get_parent(dev), dev, &service_guid) == 0) { - device_set_desc(dev, "Hyper-V Heartbeat Service"); - return BUS_PROBE_DEFAULT; - } - return ENXIO; + return (vmbus_ic_probe(dev, vmbus_heartbeat_descs)); } static int Modified: stable/10/sys/dev/hyperv/utilities/hv_kvp.c ============================================================================== --- stable/10/sys/dev/hyperv/utilities/hv_kvp.c Thu Oct 13 02:38:46 2016 (r307167) +++ stable/10/sys/dev/hyperv/utilities/hv_kvp.c Thu Oct 13 02:45:08 2016 (r307168) @@ -54,17 +54,13 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include #include -#include -#include -#include - #include -#include #include #include "hv_util.h" @@ -91,9 +87,15 @@ static int hv_kvp_log = 0; log(LOG_INFO, "hv_kvp: " __VA_ARGS__); \ } while (0) -static const struct hyperv_guid service_guid = { .hv_guid = - {0xe7, 0xf4, 0xa0, 0xa9, 0x45, 0x5a, 0x96, 0x4d, - 0xb8, 0x27, 0x8a, 0x84, 0x1e, 0x8c, 0x3, 0xe6} }; +static const struct vmbus_ic_desc vmbus_kvp_descs[] = { + { + .ic_guid = { .hv_guid = { + 0xe7, 0xf4, 0xa0, 0xa9, 0x45, 0x5a, 0x96, 0x4d, + 0xb8, 0x27, 0x8a, 0x84, 0x1e, 0x8c, 0x3, 0xe6 } }, + .ic_desc = "Hyper-V KVP" + }, + VMBUS_IC_DESC_END +}; /* character device prototypes */ static d_open_t hv_kvp_dev_open; @@ -333,13 +335,11 @@ hv_kvp_convert_utf16_ipinfo_to_utf8(stru for (devcnt = devcnt - 1; devcnt >= 0; devcnt--) { /* XXX access other driver's softc? are you kidding? */ device_t dev = devs[devcnt]; - struct hn_softc *sc = device_get_softc(dev); struct vmbus_channel *chan; char buf[HYPERV_GUID_STRLEN]; /* * Trying to find GUID of Network Device - * TODO: need vmbus interface. */ chan = vmbus_get_channel(dev); hyperv_guid2str(vmbus_chan_guid_inst(chan), @@ -348,7 +348,7 @@ hv_kvp_convert_utf16_ipinfo_to_utf8(stru if (strncmp(buf, (char *)umsg->body.kvp_ip_val.adapter_id, HYPERV_GUID_STRLEN - 1) == 0) { strlcpy((char *)umsg->body.kvp_ip_val.adapter_id, - sc->hn_ifp->if_xname, MAX_ADAPTER_ID_SIZE); + device_get_nameunit(dev), MAX_ADAPTER_ID_SIZE); break; } } @@ -873,14 +873,8 @@ hv_kvp_dev_daemon_poll(struct cdev *dev, static int hv_kvp_probe(device_t dev) { - if (resource_disabled("hvkvp", 0)) - return ENXIO; - if (VMBUS_PROBE_GUID(device_get_parent(dev), dev, &service_guid) == 0) { - device_set_desc(dev, "Hyper-V KVP Service"); - return BUS_PROBE_DEFAULT; - } - return ENXIO; + return (vmbus_ic_probe(dev, vmbus_kvp_descs)); } static int Modified: stable/10/sys/dev/hyperv/utilities/hv_shutdown.c ============================================================================== --- stable/10/sys/dev/hyperv/utilities/hv_shutdown.c Thu Oct 13 02:38:46 2016 (r307167) +++ stable/10/sys/dev/hyperv/utilities/hv_shutdown.c Thu Oct 13 02:45:08 2016 (r307168) @@ -46,9 +46,15 @@ #include "hv_util.h" #include "vmbus_if.h" -static const struct hyperv_guid service_guid = { .hv_guid = - {0x31, 0x60, 0x0B, 0X0E, 0x13, 0x52, 0x34, 0x49, - 0x81, 0x8B, 0x38, 0XD9, 0x0C, 0xED, 0x39, 0xDB} }; +static const struct vmbus_ic_desc vmbus_shutdown_descs[] = { + { + .ic_guid = { .hv_guid = { + 0x31, 0x60, 0x0b, 0x0e, 0x13, 0x52, 0x34, 0x49, + 0x81, 0x8b, 0x38, 0xd9, 0x0c, 0xed, 0x39, 0xdb } }, + .ic_desc = "Hyper-V Shutdown" + }, + VMBUS_IC_DESC_END +}; /** * Shutdown @@ -118,14 +124,8 @@ hv_shutdown_cb(struct vmbus_channel *cha static int hv_shutdown_probe(device_t dev) { - if (resource_disabled("hvshutdown", 0)) - return ENXIO; - if (VMBUS_PROBE_GUID(device_get_parent(dev), dev, &service_guid) == 0) { - device_set_desc(dev, "Hyper-V Shutdown Service"); - return BUS_PROBE_DEFAULT; - } - return ENXIO; + return (vmbus_ic_probe(dev, vmbus_shutdown_descs)); } static int Modified: stable/10/sys/dev/hyperv/utilities/hv_timesync.c ============================================================================== --- stable/10/sys/dev/hyperv/utilities/hv_timesync.c Thu Oct 13 02:38:46 2016 (r307167) +++ stable/10/sys/dev/hyperv/utilities/hv_timesync.c Thu Oct 13 02:45:08 2016 (r307168) @@ -58,10 +58,15 @@ typedef struct { uint64_t data; } time_sync_data; - /* Time Synch Service */ -static const struct hyperv_guid service_guid = {.hv_guid = - {0x30, 0xe6, 0x27, 0x95, 0xae, 0xd0, 0x7b, 0x49, - 0xad, 0xce, 0xe8, 0x0a, 0xb0, 0x17, 0x5c, 0xaf } }; +static const struct vmbus_ic_desc vmbus_timesync_descs[] = { + { + .ic_guid = { .hv_guid = { + 0x30, 0xe6, 0x27, 0x95, 0xae, 0xd0, 0x7b, 0x49, + 0xad, 0xce, 0xe8, 0x0a, 0xb0, 0x17, 0x5c, 0xaf } }, + .ic_desc = "Hyper-V Timesync" + }, + VMBUS_IC_DESC_END +}; struct hv_ictimesync_data { uint64_t parenttime; @@ -174,14 +179,8 @@ hv_timesync_cb(struct vmbus_channel *cha static int hv_timesync_probe(device_t dev) { - if (resource_disabled("hvtimesync", 0)) - return ENXIO; - if (VMBUS_PROBE_GUID(device_get_parent(dev), dev, &service_guid) == 0) { - device_set_desc(dev, "Hyper-V Time Synch Service"); - return BUS_PROBE_DEFAULT; - } - return ENXIO; + return (vmbus_ic_probe(dev, vmbus_timesync_descs)); } static int Modified: stable/10/sys/dev/hyperv/utilities/hv_util.c ============================================================================== --- stable/10/sys/dev/hyperv/utilities/hv_util.c Thu Oct 13 02:38:46 2016 (r307167) +++ stable/10/sys/dev/hyperv/utilities/hv_util.c Thu Oct 13 02:45:08 2016 (r307168) @@ -42,7 +42,9 @@ #include #include #include -#include "hv_util.h" +#include + +#include "vmbus_if.h" #define VMBUS_IC_BRSIZE (4 * PAGE_SIZE) @@ -75,6 +77,24 @@ hv_negotiate_version(struct hv_vmbus_icm } int +vmbus_ic_probe(device_t dev, const struct vmbus_ic_desc descs[]) +{ + device_t bus = device_get_parent(dev); + const struct vmbus_ic_desc *d; + + if (resource_disabled(device_get_name(dev), 0)) + return (ENXIO); + + for (d = descs; d->ic_desc != NULL; ++d) { + if (VMBUS_PROBE_GUID(bus, dev, &d->ic_guid) == 0) { + device_set_desc(dev, d->ic_desc); + return (BUS_PROBE_DEFAULT); + } + } + return (ENXIO); +} + +int hv_util_attach(device_t dev, vmbus_chan_callback_t cb) { struct hv_util_sc *sc = device_get_softc(dev); Modified: stable/10/sys/dev/hyperv/utilities/hv_util.h ============================================================================== --- stable/10/sys/dev/hyperv/utilities/hv_util.h Thu Oct 13 02:38:46 2016 (r307167) +++ stable/10/sys/dev/hyperv/utilities/hv_util.h Thu Oct 13 02:45:08 2016 (r307168) @@ -31,6 +31,7 @@ #ifndef _HVUTIL_H_ #define _HVUTIL_H_ +#include #include /** @@ -42,9 +43,17 @@ typedef struct hv_util_sc { int ic_buflen; } hv_util_sc; +struct vmbus_ic_desc { + const struct hyperv_guid ic_guid; + const char *ic_desc; +}; + +#define VMBUS_IC_DESC_END { .ic_desc = NULL } + void hv_negotiate_version(struct hv_vmbus_icmsg_hdr *icmsghdrp, uint8_t *buf); -int hv_util_attach(device_t dev, vmbus_chan_callback_t cb); -int hv_util_detach(device_t dev); +int hv_util_attach(device_t dev, vmbus_chan_callback_t cb); +int hv_util_detach(device_t dev); +int vmbus_ic_probe(device_t dev, const struct vmbus_ic_desc descs[]); #endif From owner-svn-src-all@freebsd.org Thu Oct 13 02:58:55 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 63976C0FDEA; Thu, 13 Oct 2016 02:58:55 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 1F61FAF7; Thu, 13 Oct 2016 02:58:55 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9D2wsp9011679; Thu, 13 Oct 2016 02:58:54 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9D2wrZw011671; Thu, 13 Oct 2016 02:58:53 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610130258.u9D2wrZw011671@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Thu, 13 Oct 2016 02:58:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307169 - stable/10/sys/dev/hyperv/netvsc X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Oct 2016 02:58:55 -0000 Author: sephe Date: Thu Oct 13 02:58:53 2016 New Revision: 307169 URL: https://svnweb.freebsd.org/changeset/base/307169 Log: MFC 304327,304329,304330 304327 hyperv/hn: Pass RX packet info to netvsc_recv. This paves to nuke netvsc_packet, which does not serves much purpose now. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7541 304329 hyperv/hn: Constify RNDIS messages on RX path. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7542 304330 hyperv/hn: Get rid of the useless netvsc_packet Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7544 Modified: stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.c stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c stable/10/sys/dev/hyperv/netvsc/hv_rndis.h stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.c stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.h stable/10/sys/dev/hyperv/netvsc/if_hnvar.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.c Thu Oct 13 02:45:08 2016 (r307168) +++ stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.c Thu Oct 13 02:58:53 2016 (r307169) @@ -65,7 +65,7 @@ static int hv_nv_connect_to_vsp(struct static void hv_nv_on_send_completion(netvsc_dev *net_dev, struct vmbus_channel *, const struct vmbus_chanpkt_hdr *pkt); static void hv_nv_on_receive_completion(struct vmbus_channel *chan, - uint64_t tid, uint32_t status); + uint64_t tid); static void hv_nv_on_receive(netvsc_dev *net_dev, struct hn_rx_ring *rxr, struct vmbus_channel *chan, const struct vmbus_chanpkt_hdr *pkt); @@ -843,11 +843,8 @@ hv_nv_on_receive(netvsc_dev *net_dev, st { const struct vmbus_chanpkt_rxbuf *pkt; const struct hn_nvs_hdr *nvs_hdr; - netvsc_packet vsc_pkt; - netvsc_packet *net_vsc_pkt = &vsc_pkt; int count = 0; int i = 0; - int status = HN_NVS_STATUS_OK; /* Make sure that this is a RNDIS message. */ nvs_hdr = VMBUS_CHANPKT_CONST_DATA(pkthdr); @@ -869,16 +866,9 @@ hv_nv_on_receive(netvsc_dev *net_dev, st /* Each range represents 1 RNDIS pkt that contains 1 Ethernet frame */ for (i = 0; i < count; i++) { - net_vsc_pkt->status = HN_NVS_STATUS_OK; - net_vsc_pkt->data = ((uint8_t *)net_dev->rx_buf + - pkt->cp_rxbuf[i].rb_ofs); - net_vsc_pkt->tot_data_buf_len = pkt->cp_rxbuf[i].rb_len; - - hv_rf_on_receive(net_dev, rxr, net_vsc_pkt); - - /* XXX pretty broken; whack it */ - if (net_vsc_pkt->status != HN_NVS_STATUS_OK) - status = HN_NVS_STATUS_FAILED; + hv_rf_on_receive(net_dev, rxr, + (const uint8_t *)net_dev->rx_buf + pkt->cp_rxbuf[i].rb_ofs, + pkt->cp_rxbuf[i].rb_len); } /* @@ -886,7 +876,7 @@ hv_nv_on_receive(netvsc_dev *net_dev, st * messages (not just data messages) will trigger a response * message back to the host. */ - hv_nv_on_receive_completion(chan, pkt->cp_hdr.cph_xactid, status); + hv_nv_on_receive_completion(chan, pkt->cp_hdr.cph_xactid); } /* @@ -895,15 +885,14 @@ hv_nv_on_receive(netvsc_dev *net_dev, st * Send a receive completion packet to RNDIS device (ie NetVsp) */ static void -hv_nv_on_receive_completion(struct vmbus_channel *chan, uint64_t tid, - uint32_t status) +hv_nv_on_receive_completion(struct vmbus_channel *chan, uint64_t tid) { struct hn_nvs_rndis_ack ack; int retries = 0; int ret = 0; ack.nvs_type = HN_NVS_TYPE_RNDIS_ACK; - ack.nvs_status = status; + ack.nvs_status = HN_NVS_STATUS_OK; retry_send_cmplt: /* Send the completion */ Modified: stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h Thu Oct 13 02:45:08 2016 (r307168) +++ stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h Thu Oct 13 02:58:53 2016 (r307169) @@ -274,13 +274,6 @@ typedef void (*pfn_on_send_rx_completion #define BITS_PER_LONG 32 #endif -typedef struct netvsc_packet_ { - uint16_t vlan_tci; - uint32_t status; - uint32_t tot_data_buf_len; - void *data; -} netvsc_packet; - typedef struct { uint8_t mac_addr[6]; /* Assumption unsigned long */ uint8_t link_state; Modified: stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Thu Oct 13 02:45:08 2016 (r307168) +++ stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Thu Oct 13 02:58:53 2016 (r307169) @@ -1295,10 +1295,8 @@ hn_lro_rx(struct lro_ctrl *lc, struct mb * Note: This is no longer used as a callback */ int -netvsc_recv(struct hn_rx_ring *rxr, netvsc_packet *packet, - const rndis_tcp_ip_csum_info *csum_info, - const struct rndis_hash_info *hash_info, - const struct rndis_hash_value *hash_value) +netvsc_recv(struct hn_rx_ring *rxr, const void *data, int dlen, + const struct hn_recvinfo *info) { struct ifnet *ifp = rxr->hn_ifp; struct mbuf *m_new; @@ -1310,17 +1308,16 @@ netvsc_recv(struct hn_rx_ring *rxr, netv /* * Bail out if packet contains more data than configured MTU. */ - if (packet->tot_data_buf_len > (ifp->if_mtu + ETHER_HDR_LEN)) { + if (dlen > (ifp->if_mtu + ETHER_HDR_LEN)) { return (0); - } else if (packet->tot_data_buf_len <= MHLEN) { + } else if (dlen <= MHLEN) { m_new = m_gethdr(M_NOWAIT, MT_DATA); if (m_new == NULL) { if_inc_counter(ifp, IFCOUNTER_IQDROPS, 1); return (0); } - memcpy(mtod(m_new, void *), packet->data, - packet->tot_data_buf_len); - m_new->m_pkthdr.len = m_new->m_len = packet->tot_data_buf_len; + memcpy(mtod(m_new, void *), data, dlen); + m_new->m_pkthdr.len = m_new->m_len = dlen; rxr->hn_small_pkts++; } else { /* @@ -1330,7 +1327,7 @@ netvsc_recv(struct hn_rx_ring *rxr, netv * if looped around to the Hyper-V TX channel, so avoid them. */ size = MCLBYTES; - if (packet->tot_data_buf_len > MCLBYTES) { + if (dlen > MCLBYTES) { /* 4096 */ size = MJUMPAGESIZE; } @@ -1341,7 +1338,7 @@ netvsc_recv(struct hn_rx_ring *rxr, netv return (0); } - hv_m_append(m_new, packet->tot_data_buf_len, packet->data); + hv_m_append(m_new, dlen, data); } m_new->m_pkthdr.rcvif = ifp; @@ -1349,28 +1346,28 @@ netvsc_recv(struct hn_rx_ring *rxr, netv do_csum = 0; /* receive side checksum offload */ - if (csum_info != NULL) { + if (info->csum_info != NULL) { /* IP csum offload */ - if (csum_info->receive.ip_csum_succeeded && do_csum) { + if (info->csum_info->receive.ip_csum_succeeded && do_csum) { m_new->m_pkthdr.csum_flags |= (CSUM_IP_CHECKED | CSUM_IP_VALID); rxr->hn_csum_ip++; } /* TCP/UDP csum offload */ - if ((csum_info->receive.tcp_csum_succeeded || - csum_info->receive.udp_csum_succeeded) && do_csum) { + if ((info->csum_info->receive.tcp_csum_succeeded || + info->csum_info->receive.udp_csum_succeeded) && do_csum) { m_new->m_pkthdr.csum_flags |= (CSUM_DATA_VALID | CSUM_PSEUDO_HDR); m_new->m_pkthdr.csum_data = 0xffff; - if (csum_info->receive.tcp_csum_succeeded) + if (info->csum_info->receive.tcp_csum_succeeded) rxr->hn_csum_tcp++; else rxr->hn_csum_udp++; } - if (csum_info->receive.ip_csum_succeeded && - csum_info->receive.tcp_csum_succeeded) + if (info->csum_info->receive.ip_csum_succeeded && + info->csum_info->receive.tcp_csum_succeeded) do_lro = 1; } else { const struct ether_header *eh; @@ -1426,21 +1423,20 @@ netvsc_recv(struct hn_rx_ring *rxr, netv } } skip: - if ((packet->vlan_tci != 0) && - (ifp->if_capenable & IFCAP_VLAN_HWTAGGING) != 0) { - m_new->m_pkthdr.ether_vtag = packet->vlan_tci; + if (info->vlan_info != NULL) { + m_new->m_pkthdr.ether_vtag = info->vlan_info->u1.s1.vlan_id; m_new->m_flags |= M_VLANTAG; } - if (hash_info != NULL && hash_value != NULL) { + if (info->hash_info != NULL && info->hash_value != NULL) { int hash_type = M_HASHTYPE_OPAQUE; rxr->hn_rss_pkts++; - m_new->m_pkthdr.flowid = hash_value->hash_value; - if ((hash_info->hash_info & NDIS_HASH_FUNCTION_MASK) == + m_new->m_pkthdr.flowid = info->hash_value->hash_value; + if ((info->hash_info->hash_info & NDIS_HASH_FUNCTION_MASK) == NDIS_HASH_FUNCTION_TOEPLITZ) { uint32_t type = - (hash_info->hash_info & NDIS_HASH_TYPE_MASK); + (info->hash_info->hash_info & NDIS_HASH_TYPE_MASK); switch (type) { case NDIS_HASH_IPV4: @@ -1470,8 +1466,8 @@ skip: } M_HASHTYPE_SET(m_new, hash_type); } else { - if (hash_value != NULL) - m_new->m_pkthdr.flowid = hash_value->hash_value; + if (info->hash_value != NULL) + m_new->m_pkthdr.flowid = info->hash_value->hash_value; else m_new->m_pkthdr.flowid = rxr->hn_rx_idx; M_HASHTYPE_SET(m_new, M_HASHTYPE_OPAQUE); Modified: stable/10/sys/dev/hyperv/netvsc/hv_rndis.h ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_rndis.h Thu Oct 13 02:45:08 2016 (r307168) +++ stable/10/sys/dev/hyperv/netvsc/hv_rndis.h Thu Oct 13 02:58:53 2016 (r307169) @@ -1088,11 +1088,10 @@ typedef struct rndismp_rx_bufs_info_ { */ struct hn_rx_ring; struct hn_tx_ring; +struct hn_recvinfo; -int netvsc_recv(struct hn_rx_ring *rxr, - netvsc_packet *packet, const rndis_tcp_ip_csum_info *csum_info, - const struct rndis_hash_info *hash_info, - const struct rndis_hash_value *hash_value); +int netvsc_recv(struct hn_rx_ring *rxr, const void *data, int dlen, + const struct hn_recvinfo *info); void netvsc_channel_rollup(struct hn_rx_ring *rxr, struct hn_tx_ring *txr); void* hv_set_rppi_data(rndis_msg *rndis_mesg, Modified: stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.c Thu Oct 13 02:45:08 2016 (r307168) +++ stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.c Thu Oct 13 02:58:53 2016 (r307169) @@ -53,13 +53,6 @@ __FBSDID("$FreeBSD$"); #include #include -struct hv_rf_recvinfo { - const ndis_8021q_info *vlan_info; - const rndis_tcp_ip_csum_info *csum_info; - const struct rndis_hash_info *hash_info; - const struct rndis_hash_value *hash_value; -}; - #define HV_RF_RECVINFO_VLAN 0x1 #define HV_RF_RECVINFO_CSUM 0x2 #define HV_RF_RECVINFO_HASHINF 0x4 @@ -75,11 +68,12 @@ struct hv_rf_recvinfo { */ static int hv_rf_send_request(rndis_device *device, rndis_request *request, uint32_t message_type); -static void hv_rf_receive_response(rndis_device *device, rndis_msg *response); +static void hv_rf_receive_response(rndis_device *device, + const rndis_msg *response); static void hv_rf_receive_indicate_status(rndis_device *device, - rndis_msg *response); -static void hv_rf_receive_data(struct hn_rx_ring *rxr, rndis_msg *message, - netvsc_packet *pkt); + const rndis_msg *response); +static void hv_rf_receive_data(struct hn_rx_ring *rxr, + const void *data, int dlen); static int hv_rf_query_device(rndis_device *device, uint32_t oid, void *result, uint32_t *result_size); static inline int hv_rf_query_device_mac(rndis_device *device); @@ -303,7 +297,7 @@ sendit: * RNDIS filter receive response */ static void -hv_rf_receive_response(rndis_device *device, rndis_msg *response) +hv_rf_receive_response(rndis_device *device, const rndis_msg *response) { rndis_request *request = NULL; rndis_request *next_request; @@ -425,9 +419,9 @@ cleanup: * RNDIS filter receive indicate status */ static void -hv_rf_receive_indicate_status(rndis_device *device, rndis_msg *response) +hv_rf_receive_indicate_status(rndis_device *device, const rndis_msg *response) { - rndis_indicate_status *indicate = &response->msg.indicate_status; + const rndis_indicate_status *indicate = &response->msg.indicate_status; switch(indicate->status) { case RNDIS_STATUS_MEDIA_CONNECT: @@ -445,7 +439,7 @@ hv_rf_receive_indicate_status(rndis_devi } static int -hv_rf_find_recvinfo(const rndis_packet *rpkt, struct hv_rf_recvinfo *info) +hv_rf_find_recvinfo(const rndis_packet *rpkt, struct hn_recvinfo *info) { const rndis_per_packet_info *ppi; uint32_t mask, len; @@ -526,12 +520,12 @@ skip: * RNDIS filter receive data */ static void -hv_rf_receive_data(struct hn_rx_ring *rxr, rndis_msg *message, - netvsc_packet *pkt) +hv_rf_receive_data(struct hn_rx_ring *rxr, const void *data, int dlen) { - rndis_packet *rndis_pkt; + const rndis_msg *message = data; + const rndis_packet *rndis_pkt; uint32_t data_offset; - struct hv_rf_recvinfo info; + struct hn_recvinfo info; rndis_pkt = &message->msg.packet; @@ -543,30 +537,22 @@ hv_rf_receive_data(struct hn_rx_ring *rx /* Remove rndis header, then pass data packet up the stack */ data_offset = RNDIS_HEADER_SIZE + rndis_pkt->data_offset; - pkt->tot_data_buf_len -= data_offset; - if (pkt->tot_data_buf_len < rndis_pkt->data_length) { - pkt->status = HN_NVS_STATUS_FAILED; + dlen -= data_offset; + if (dlen < rndis_pkt->data_length) { if_printf(rxr->hn_ifp, "total length %u is less than data length %u\n", - pkt->tot_data_buf_len, rndis_pkt->data_length); + dlen, rndis_pkt->data_length); return; } - pkt->tot_data_buf_len = rndis_pkt->data_length; - pkt->data = (void *)((unsigned long)pkt->data + data_offset); + dlen = rndis_pkt->data_length; + data = (const uint8_t *)data + data_offset; if (hv_rf_find_recvinfo(rndis_pkt, &info)) { - pkt->status = HN_NVS_STATUS_FAILED; if_printf(rxr->hn_ifp, "recvinfo parsing failed\n"); return; } - - if (info.vlan_info != NULL) - pkt->vlan_tci = info.vlan_info->u1.s1.vlan_id; - else - pkt->vlan_tci = 0; - - netvsc_recv(rxr, pkt, info.csum_info, info.hash_info, info.hash_value); + netvsc_recv(rxr, data, dlen, &info); } /* @@ -574,30 +560,25 @@ hv_rf_receive_data(struct hn_rx_ring *rx */ int hv_rf_on_receive(netvsc_dev *net_dev, - struct hn_rx_ring *rxr, netvsc_packet *pkt) + struct hn_rx_ring *rxr, const void *data, int dlen) { rndis_device *rndis_dev; - rndis_msg *rndis_hdr; + const rndis_msg *rndis_hdr; /* Make sure the rndis device state is initialized */ - if (net_dev->extension == NULL) { - pkt->status = HN_NVS_STATUS_FAILED; + if (net_dev->extension == NULL) return (ENODEV); - } rndis_dev = (rndis_device *)net_dev->extension; - if (rndis_dev->state == RNDIS_DEV_UNINITIALIZED) { - pkt->status = HN_NVS_STATUS_FAILED; + if (rndis_dev->state == RNDIS_DEV_UNINITIALIZED) return (EINVAL); - } - - rndis_hdr = pkt->data; + rndis_hdr = data; switch (rndis_hdr->ndis_msg_type) { /* data message */ case REMOTE_NDIS_PACKET_MSG: - hv_rf_receive_data(rxr, rndis_hdr, pkt); + hv_rf_receive_data(rxr, data, dlen); break; /* completion messages */ case REMOTE_NDIS_INITIALIZE_CMPLT: Modified: stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.h ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.h Thu Oct 13 02:45:08 2016 (r307168) +++ stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.h Thu Oct 13 02:58:53 2016 (r307169) @@ -115,8 +115,8 @@ typedef struct rndis_device_ { struct hn_softc; struct hn_rx_ring; -int hv_rf_on_receive(netvsc_dev *net_dev, - struct hn_rx_ring *rxr, netvsc_packet *pkt); +int hv_rf_on_receive(netvsc_dev *net_dev, struct hn_rx_ring *rxr, + const void *data, int dlen); void hv_rf_receive_rollup(netvsc_dev *net_dev); void hv_rf_channel_rollup(struct hn_rx_ring *rxr, struct hn_tx_ring *txr); int hv_rf_on_device_add(struct hn_softc *sc, void *additl_info, int nchan, Modified: stable/10/sys/dev/hyperv/netvsc/if_hnvar.h ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/if_hnvar.h Thu Oct 13 02:45:08 2016 (r307168) +++ stable/10/sys/dev/hyperv/netvsc/if_hnvar.h Thu Oct 13 02:58:53 2016 (r307169) @@ -35,7 +35,6 @@ #include struct netvsc_dev_; -struct nvsp_msg_; struct vmbus_channel; struct hn_send_ctx; @@ -51,6 +50,18 @@ struct hn_send_ctx { int hn_chim_sz; }; +struct rndis_hash_info; +struct rndix_hash_value; +struct ndis_8021q_info_; +struct rndis_tcp_ip_csum_info_; + +struct hn_recvinfo { + const struct ndis_8021q_info_ *vlan_info; + const struct rndis_tcp_ip_csum_info_ *csum_info; + const struct rndis_hash_info *hash_info; + const struct rndis_hash_value *hash_value; +}; + #define HN_SEND_CTX_INITIALIZER(cb, cbarg) \ { \ .hn_cb = cb, \ From owner-svn-src-all@freebsd.org Thu Oct 13 03:00:57 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A93C6C0FECB; Thu, 13 Oct 2016 03:00:57 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 7843BD36; Thu, 13 Oct 2016 03:00:57 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9D30uJv011856; Thu, 13 Oct 2016 03:00:56 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9D30uEG011855; Thu, 13 Oct 2016 03:00:56 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610130300.u9D30uEG011855@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Thu, 13 Oct 2016 03:00:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307170 - stable/10/sys/dev/hyperv/utilities X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Oct 2016 03:00:57 -0000 Author: sephe Date: Thu Oct 13 03:00:56 2016 New Revision: 307170 URL: https://svnweb.freebsd.org/changeset/base/307170 Log: MFC 304331 hyperv/kvp: Remove unnecessary function parameter. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7550 Modified: stable/10/sys/dev/hyperv/utilities/hv_kvp.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/hyperv/utilities/hv_kvp.c ============================================================================== --- stable/10/sys/dev/hyperv/utilities/hv_kvp.c Thu Oct 13 02:58:53 2016 (r307169) +++ stable/10/sys/dev/hyperv/utilities/hv_kvp.c Thu Oct 13 03:00:56 2016 (r307170) @@ -217,10 +217,9 @@ hv_kvp_transaction_init(hv_kvp_sc *sc, u * hv_kvp - version neogtiation function */ static void -hv_kvp_negotiate_version(struct hv_vmbus_icmsg_hdr *icmsghdrp, - struct hv_vmbus_icmsg_negotiate *negop, - uint8_t *buf) +hv_kvp_negotiate_version(struct hv_vmbus_icmsg_hdr *icmsghdrp, uint8_t *buf) { + struct hv_vmbus_icmsg_negotiate *negop; int icframe_vercnt; int icmsg_vercnt; @@ -641,7 +640,7 @@ hv_kvp_process_request(void *context, in hv_kvp_transaction_init(sc, recvlen, requestid, kvp_buf); if (icmsghdrp->icmsgtype == HV_ICMSGTYPE_NEGOTIATE) { - hv_kvp_negotiate_version(icmsghdrp, NULL, kvp_buf); + hv_kvp_negotiate_version(icmsghdrp, kvp_buf); hv_kvp_respond_host(sc, ret); /* From owner-svn-src-all@freebsd.org Thu Oct 13 03:06:25 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 27155C0E415; Thu, 13 Oct 2016 03:06:25 +0000 (UTC) (envelope-from lidl@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 019111578; Thu, 13 Oct 2016 03:06:24 +0000 (UTC) (envelope-from lidl@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9D36OOZ016142; Thu, 13 Oct 2016 03:06:24 GMT (envelope-from lidl@FreeBSD.org) Received: (from lidl@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9D36OoK016141; Thu, 13 Oct 2016 03:06:24 GMT (envelope-from lidl@FreeBSD.org) Message-Id: <201610130306.u9D36OoK016141@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: lidl set sender to lidl@FreeBSD.org using -f From: Kurt Lidl Date: Thu, 13 Oct 2016 03:06:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307171 - stable/11/contrib/blacklist/libexec X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Oct 2016 03:06:25 -0000 Author: lidl Date: Thu Oct 13 03:06:23 2016 New Revision: 307171 URL: https://svnweb.freebsd.org/changeset/base/307171 Log: MFC r306695: Make blacklist-helper commands emit a message when successful The blacklistd daemon expects to see a message on stdout, instead of just relying on the exit value from any invoked programs. Change the pf filtering to create multiple filters, attached under a the "blacklist/*" anchor point. This prevents the filtering for each port's filtering rule from overwriting the previously installed filtering rule. Check for an existing filtering rule for each port, so the installation of a given filtering rule only happens once. Reinstalling the same rule resets the counters for the pf rule, and we don't want that. Sponsored by: The FreeBSD Foundation Modified: stable/11/contrib/blacklist/libexec/blacklistd-helper Directory Properties: stable/11/ (props changed) Modified: stable/11/contrib/blacklist/libexec/blacklistd-helper ============================================================================== --- stable/11/contrib/blacklist/libexec/blacklistd-helper Thu Oct 13 03:00:56 2016 (r307170) +++ stable/11/contrib/blacklist/libexec/blacklistd-helper Thu Oct 13 03:06:23 2016 (r307171) @@ -19,8 +19,8 @@ fi if [ -z "$pf" ]; then for f in npf pf ipf; do if [ -f "/etc/$f.conf" ]; then - pf="$f" - break + pf="$f" + break fi done fi @@ -54,8 +54,8 @@ add) ipf) /sbin/ipfstat -io | /sbin/ipf -I -f - >/dev/null 2>&1 echo block in quick $proto from $addr/$mask to \ - any port=$6 head port$6 | \ - /sbin/ipf -I -f - -s >/dev/null 2>&1 + any port=$6 head port$6 | \ + /sbin/ipf -I -f - -s >/dev/null 2>&1 && echo OK ;; ipfw) # use $ipfw_offset+$port for rule number @@ -64,17 +64,21 @@ add) /sbin/ipfw table $tname create type addr 2>/dev/null /sbin/ipfw -q table $tname add "$addr/$mask" /sbin/ipfw -q add $rule drop $3 from "table("$tname")" to \ - any dst-port $6 + any dst-port $6 && echo OK ;; npf) /sbin/npfctl rule "$2" add block in final $proto from \ "$addr/$mask" to any $port ;; pf) - # insert $ip/$mask into per-protocol anchored table - /sbin/pfctl -a "$2" -t "port$6" -T add "$addr/$mask" - echo "block in quick $proto from to any $port" | \ - /sbin/pfctl -a "$2" -f - + # if the filtering rule does not exist, create it + /sbin/pfctl -a "$2/$6" -sr 2>/dev/null | \ + grep -q "" || \ + echo "block in quick $proto from to any $port" | \ + /sbin/pfctl -a "$2/$6" -f - + # insert $ip/$mask into per-protocol/port anchored table + /sbin/pfctl -a "$2/$6" -t "port$6" -T add "$addr/$mask" && \ + echo OK ;; esac ;; @@ -83,33 +87,35 @@ rem) ipf) /sbin/ipfstat -io | /sbin/ipf -I -f - >/dev/null 2>&1 echo block in quick $proto from $addr/$mask to \ - any port=$6 head port$6 | \ - /sbin/ipf -I -r -f - -s >/dev/null 2>&1 + any port=$6 head port$6 | \ + /sbin/ipf -I -r -f - -s >/dev/null 2>&1 && echo OK ;; ipfw) - /sbin/ipfw table "port$6" delete "$addr/$mask" 2>/dev/null + /sbin/ipfw table "port$6" delete "$addr/$mask" 2>/dev/null && \ + echo OK ;; npf) /sbin/npfctl rule "$2" rem-id "$7" ;; pf) - /sbin/pfctl -a "$2" -t "port$6" -T delete "$addr/$mask" + /sbin/pfctl -a "$2/$6" -t "port$6" -T delete "$addr/$mask" && \ + echo OK ;; esac ;; flush) case "$pf" in ipf) - /sbin/ipf -Z -I -Fi -s > /dev/null + /sbin/ipf -Z -I -Fi -s > /dev/null && echo OK ;; ipfw) - /sbin/ipfw table "port$6" flush 2>/dev/null + /sbin/ipfw table "port$6" flush 2>/dev/null && echo OK ;; npf) /sbin/npfctl rule "$2" flush ;; pf) - /sbin/pfctl -a "$2" -t "port$6" -T flush + /sbin/pfctl -a "$2/$6" -t "port$6" -T flush && echo OK ;; esac ;; From owner-svn-src-all@freebsd.org Thu Oct 13 03:08:33 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 68B96C0E4D1; Thu, 13 Oct 2016 03:08:33 +0000 (UTC) (envelope-from lidl@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 36C4F170C; Thu, 13 Oct 2016 03:08:33 +0000 (UTC) (envelope-from lidl@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9D38WPn016269; Thu, 13 Oct 2016 03:08:32 GMT (envelope-from lidl@FreeBSD.org) Received: (from lidl@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9D38W38016268; Thu, 13 Oct 2016 03:08:32 GMT (envelope-from lidl@FreeBSD.org) Message-Id: <201610130308.u9D38W38016268@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: lidl set sender to lidl@FreeBSD.org using -f From: Kurt Lidl Date: Thu, 13 Oct 2016 03:08:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307172 - stable/11/etc/periodic/security X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Oct 2016 03:08:33 -0000 Author: lidl Date: Thu Oct 13 03:08:32 2016 New Revision: 307172 URL: https://svnweb.freebsd.org/changeset/base/307172 Log: MFC r306696: Make 502.pfdenied find blacklistd/* filter names dynamically This change is needed to make the 520.pfdenied script find the new blacklistd/* anchor points for reporting blocked traffic. Sponsored by: The FreeBSD Foundation Modified: stable/11/etc/periodic/security/520.pfdenied Directory Properties: stable/11/ (props changed) Modified: stable/11/etc/periodic/security/520.pfdenied ============================================================================== --- stable/11/etc/periodic/security/520.pfdenied Thu Oct 13 03:06:23 2016 (r307171) +++ stable/11/etc/periodic/security/520.pfdenied Thu Oct 13 03:08:32 2016 (r307172) @@ -44,8 +44,7 @@ rc=0 if check_yesno_period security_status_pfdenied_enable then TMP=`mktemp -t security` - touch ${TMP} - for _a in "" blacklistd + for _a in "" $(pfctl -a "blacklistd" -sA 2>/dev/null) do pfctl -a ${_a} -sr -v -z 2>/dev/null | \ nawk '{if (/^block/) {buf=$0; getline; gsub(" +"," ",$0); if ($5 > 0) print buf$0;} }' >> ${TMP} From owner-svn-src-all@freebsd.org Thu Oct 13 03:10:05 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 87217C0E586; Thu, 13 Oct 2016 03:10:05 +0000 (UTC) (envelope-from lidl@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 40802189F; Thu, 13 Oct 2016 03:10:05 +0000 (UTC) (envelope-from lidl@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9D3A46J016401; Thu, 13 Oct 2016 03:10:04 GMT (envelope-from lidl@FreeBSD.org) Received: (from lidl@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9D3A4jd016400; Thu, 13 Oct 2016 03:10:04 GMT (envelope-from lidl@FreeBSD.org) Message-Id: <201610130310.u9D3A4jd016400@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: lidl set sender to lidl@FreeBSD.org using -f From: Kurt Lidl Date: Thu, 13 Oct 2016 03:10:04 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307173 - stable/11/sys/netinet X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Oct 2016 03:10:05 -0000 Author: lidl Date: Thu Oct 13 03:10:04 2016 New Revision: 307173 URL: https://svnweb.freebsd.org/changeset/base/307173 Log: MFC r306458: Properly preserve ip_tos bits for IPv4 packets Restructure code slightly to save ip_tos bits earlier. Fix the bug where the ip_tos field is zeroed out before assigning to the iptos variable. Restore the ip_tos and ip_ver fields only if they have been zeroed during the pseudo-header checksum calculation. Modified: stable/11/sys/netinet/tcp_input.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/netinet/tcp_input.c ============================================================================== --- stable/11/sys/netinet/tcp_input.c Thu Oct 13 03:08:32 2016 (r307172) +++ stable/11/sys/netinet/tcp_input.c Thu Oct 13 03:10:04 2016 (r307173) @@ -601,7 +601,7 @@ tcp_input(struct mbuf **mp, int *offp, i #ifdef TCP_SIGNATURE uint8_t sig_checked = 0; #endif - uint8_t iptos = 0; + uint8_t iptos; struct m_tag *fwd_tag = NULL; #ifdef INET6 struct ip6_hdr *ip6 = NULL; @@ -673,6 +673,7 @@ tcp_input(struct mbuf **mp, int *offp, i /* XXX stat */ goto drop; } + iptos = (ntohl(ip6->ip6_flow) >> 20) & 0xff; } #endif #if defined(INET) && defined(INET6) @@ -699,6 +700,7 @@ tcp_input(struct mbuf **mp, int *offp, i th = (struct tcphdr *)((caddr_t)ip + off0); tlen = ntohs(ip->ip_len) - off0; + iptos = ip->ip_tos; if (m->m_pkthdr.csum_flags & CSUM_DATA_VALID) { if (m->m_pkthdr.csum_flags & CSUM_PSEUDO_HDR) th->th_sum = m->m_pkthdr.csum_data; @@ -719,29 +721,20 @@ tcp_input(struct mbuf **mp, int *offp, i ipov->ih_len = htons(tlen); th->th_sum = in_cksum(m, len); /* Reset length for SDT probes. */ - ip->ip_len = htons(tlen + off0); + ip->ip_len = htons(len); + /* Reset TOS bits */ + ip->ip_tos = iptos; + /* Re-initialization for later version check */ + ip->ip_v = IPVERSION; } if (th->th_sum) { TCPSTAT_INC(tcps_rcvbadsum); goto drop; } - /* Re-initialization for later version check */ - ip->ip_v = IPVERSION; } #endif /* INET */ -#ifdef INET6 - if (isipv6) - iptos = (ntohl(ip6->ip6_flow) >> 20) & 0xff; -#endif -#if defined(INET) && defined(INET6) - else -#endif -#ifdef INET - iptos = ip->ip_tos; -#endif - /* * Check that TCP offset makes sense, * pull out TCP options and adjust length. XXX From owner-svn-src-all@freebsd.org Thu Oct 13 03:16:17 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 22FDEC0E6F3; Thu, 13 Oct 2016 03:16:17 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id DF5EE1C68; Thu, 13 Oct 2016 03:16:16 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9D3GGM8020061; Thu, 13 Oct 2016 03:16:16 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9D3GFQ0020057; Thu, 13 Oct 2016 03:16:15 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610130316.u9D3GFQ0020057@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Thu, 13 Oct 2016 03:16:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307174 - stable/10/sys/dev/hyperv/netvsc X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Oct 2016 03:16:17 -0000 Author: sephe Date: Thu Oct 13 03:16:15 2016 New Revision: 307174 URL: https://svnweb.freebsd.org/changeset/base/307174 Log: MFC 304441,304444,304446,304447,304591,304593-304595 304441 hyperv/hn: Move NVS version to softc Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7553 304444 hyperv/hn: Remove assign-only struct field Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7554 304446 hyperv/hn: Remove the useless num_channel Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7555 304447 hyperv/hn: Move RXBUF to hn_softc And don't recreate RXBUF for each primary channel open, it is now created in device_attach DEVMETHOD and destroyed in device_detach DEVMETHOD. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7556 304591 hyperv/hn: Move chimney sending buffer to hn_softc And don't recreate chimney sending buffer for each primary channel open, it is now created in device_attach DEVMETHOD and destroyed in device_detach DEVMETHOD. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7574 304593 hyperv/hn: Get rid of netvsc_dev Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7575 304594 hyperv/hn: Factor out function to execute NVS transactions. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7577 304595 hyperv/hn: Factor out function to simplify NVS request sending Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7578 Modified: stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.c stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.c stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.h stable/10/sys/dev/hyperv/netvsc/if_hnvar.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.c Thu Oct 13 03:10:04 2016 (r307173) +++ stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.c Thu Oct 13 03:16:15 2016 (r307174) @@ -37,6 +37,7 @@ #include #include #include +#include #include #include #include @@ -58,85 +59,78 @@ MALLOC_DEFINE(M_NETVSC, "netvsc", "Hyper static void hv_nv_on_channel_callback(struct vmbus_channel *chan, void *xrxr); static int hv_nv_init_send_buffer_with_net_vsp(struct hn_softc *sc); -static int hv_nv_init_rx_buffer_with_net_vsp(struct hn_softc *); -static int hv_nv_destroy_send_buffer(netvsc_dev *net_dev); -static int hv_nv_destroy_rx_buffer(netvsc_dev *net_dev); +static int hv_nv_init_rx_buffer_with_net_vsp(struct hn_softc *, int); +static int hv_nv_destroy_send_buffer(struct hn_softc *sc); +static int hv_nv_destroy_rx_buffer(struct hn_softc *sc); static int hv_nv_connect_to_vsp(struct hn_softc *sc); -static void hv_nv_on_send_completion(netvsc_dev *net_dev, +static void hv_nv_on_send_completion(struct hn_softc *sc, struct vmbus_channel *, const struct vmbus_chanpkt_hdr *pkt); static void hv_nv_on_receive_completion(struct vmbus_channel *chan, uint64_t tid); -static void hv_nv_on_receive(netvsc_dev *net_dev, +static void hv_nv_on_receive(struct hn_softc *sc, struct hn_rx_ring *rxr, struct vmbus_channel *chan, const struct vmbus_chanpkt_hdr *pkt); static void hn_nvs_sent_none(struct hn_send_ctx *sndc, - struct netvsc_dev_ *net_dev, struct vmbus_channel *chan, + struct hn_softc *, struct vmbus_channel *chan, const void *, int); +static void hn_nvs_sent_xact(struct hn_send_ctx *, struct hn_softc *sc, + struct vmbus_channel *, const void *, int); static struct hn_send_ctx hn_send_ctx_none = HN_SEND_CTX_INITIALIZER(hn_nvs_sent_none, NULL); -/* - * - */ -static inline netvsc_dev * -hv_nv_alloc_net_device(struct hn_softc *sc) +uint32_t +hn_chim_alloc(struct hn_softc *sc) { - netvsc_dev *net_dev; + int i, bmap_cnt = sc->hn_chim_bmap_cnt; + u_long *bmap = sc->hn_chim_bmap; + uint32_t ret = HN_NVS_CHIM_IDX_INVALID; - net_dev = malloc(sizeof(netvsc_dev), M_NETVSC, M_WAITOK | M_ZERO); + for (i = 0; i < bmap_cnt; ++i) { + int idx; - net_dev->sc = sc; - net_dev->destroy = FALSE; - sc->net_dev = net_dev; + idx = ffsl(~bmap[i]); + if (idx == 0) + continue; - return (net_dev); -} + --idx; /* ffsl is 1-based */ + KASSERT(i * LONG_BIT + idx < sc->hn_chim_cnt, + ("invalid i %d and idx %d", i, idx)); -/* - * XXX unnecessary; nuke it. - */ -static inline netvsc_dev * -hv_nv_get_outbound_net_device(struct hn_softc *sc) -{ - return sc->net_dev; -} + if (atomic_testandset_long(&bmap[i], idx)) + continue; -/* - * XXX unnecessary; nuke it. - */ -static inline netvsc_dev * -hv_nv_get_inbound_net_device(struct hn_softc *sc) -{ - return sc->net_dev; + ret = i * LONG_BIT + idx; + break; + } + return (ret); } -int -hv_nv_get_next_send_section(netvsc_dev *net_dev) +const void * +hn_nvs_xact_execute(struct hn_softc *sc, struct vmbus_xact *xact, + void *req, int reqlen, size_t *resp_len) { - unsigned long bitsmap_words = net_dev->bitsmap_words; - unsigned long *bitsmap = net_dev->send_section_bitsmap; - unsigned long idx; - int ret = HN_NVS_CHIM_IDX_INVALID; - int i; - - for (i = 0; i < bitsmap_words; i++) { - idx = ffsl(~bitsmap[i]); - if (0 == idx) - continue; - - idx--; - KASSERT(i * BITS_PER_LONG + idx < net_dev->send_section_count, - ("invalid i %d and idx %lu", i, idx)); + struct hn_send_ctx sndc; + int error; - if (atomic_testandset_long(&bitsmap[i], idx)) - continue; + hn_send_ctx_init_simple(&sndc, hn_nvs_sent_xact, xact); + vmbus_xact_activate(xact); - ret = i * BITS_PER_LONG + idx; - break; + error = hn_nvs_send(sc->hn_prichan, VMBUS_CHANPKT_FLAG_RC, + req, reqlen, &sndc); + if (error) { + vmbus_xact_deactivate(xact); + return NULL; } + return (vmbus_xact_wait(xact, resp_len)); +} - return (ret); +static __inline int +hn_nvs_req_send(struct hn_softc *sc, void *req, int reqlen) +{ + + return (hn_nvs_send(sc->hn_prichan, VMBUS_CHANPKT_FLAG_NONE, + req, reqlen, &hn_send_ctx_none)); } /* @@ -146,29 +140,17 @@ hv_nv_get_next_send_section(netvsc_dev * * Hyper-V extensible switch and the synthetic data path. */ static int -hv_nv_init_rx_buffer_with_net_vsp(struct hn_softc *sc) +hv_nv_init_rx_buffer_with_net_vsp(struct hn_softc *sc, int rxbuf_size) { - struct vmbus_xact *xact; + struct vmbus_xact *xact = NULL; struct hn_nvs_rxbuf_conn *conn; const struct hn_nvs_rxbuf_connresp *resp; size_t resp_len; - struct hn_send_ctx sndc; - netvsc_dev *net_dev; uint32_t status; int error; - net_dev = hv_nv_get_outbound_net_device(sc); - if (!net_dev) { - return (ENODEV); - } - - net_dev->rx_buf = hyperv_dmamem_alloc(bus_get_dma_tag(sc->hn_dev), - PAGE_SIZE, 0, net_dev->rx_buf_size, &net_dev->rxbuf_dma, - BUS_DMA_WAITOK | BUS_DMA_ZERO); - if (net_dev->rx_buf == NULL) { - device_printf(sc->hn_dev, "allocate rxbuf failed\n"); - return (ENOMEM); - } + KASSERT(rxbuf_size <= NETVSC_RECEIVE_BUFFER_SIZE, + ("invalid rxbuf size %d", rxbuf_size)); /* * Connect the RXBUF GPADL to the primary channel. @@ -178,8 +160,7 @@ hv_nv_init_rx_buffer_with_net_vsp(struct * just share this RXBUF. */ error = vmbus_chan_gpadl_connect(sc->hn_prichan, - net_dev->rxbuf_dma.hv_paddr, net_dev->rx_buf_size, - &net_dev->rx_buf_gpadl_handle); + sc->hn_rxbuf_dma.hv_paddr, rxbuf_size, &sc->hn_rxbuf_gpadl); if (error) { if_printf(sc->hn_ifp, "rxbuf gpadl connect failed: %d\n", error); @@ -196,55 +177,47 @@ hv_nv_init_rx_buffer_with_net_vsp(struct error = ENXIO; goto cleanup; } - conn = vmbus_xact_req_data(xact); conn->nvs_type = HN_NVS_TYPE_RXBUF_CONN; - conn->nvs_gpadl = net_dev->rx_buf_gpadl_handle; + conn->nvs_gpadl = sc->hn_rxbuf_gpadl; conn->nvs_sig = HN_NVS_RXBUF_SIG; - hn_send_ctx_init_simple(&sndc, hn_nvs_sent_xact, xact); - vmbus_xact_activate(xact); - - error = hn_nvs_send(sc->hn_prichan, VMBUS_CHANPKT_FLAG_RC, - conn, sizeof(*conn), &sndc); - if (error != 0) { - if_printf(sc->hn_ifp, "send nvs rxbuf conn failed: %d\n", - error); - vmbus_xact_deactivate(xact); - vmbus_xact_put(xact); + resp = hn_nvs_xact_execute(sc, xact, conn, sizeof(*conn), &resp_len); + if (resp == NULL) { + if_printf(sc->hn_ifp, "exec rxbuf conn failed\n"); + error = EIO; goto cleanup; } - - resp = vmbus_xact_wait(xact, &resp_len); if (resp_len < sizeof(*resp)) { if_printf(sc->hn_ifp, "invalid rxbuf conn resp length %zu\n", resp_len); - vmbus_xact_put(xact); error = EINVAL; goto cleanup; } if (resp->nvs_type != HN_NVS_TYPE_RXBUF_CONNRESP) { if_printf(sc->hn_ifp, "not rxbuf conn resp, type %u\n", resp->nvs_type); - vmbus_xact_put(xact); error = EINVAL; goto cleanup; } status = resp->nvs_status; vmbus_xact_put(xact); + xact = NULL; if (status != HN_NVS_STATUS_OK) { if_printf(sc->hn_ifp, "rxbuf conn failed: %x\n", status); error = EIO; goto cleanup; } - net_dev->rx_section_count = 1; + sc->hn_flags |= HN_FLAG_RXBUF_CONNECTED; return (0); cleanup: - hv_nv_destroy_rx_buffer(net_dev); + if (xact != NULL) + vmbus_xact_put(xact); + hv_nv_destroy_rx_buffer(sc); return (error); } @@ -254,28 +227,13 @@ cleanup: static int hv_nv_init_send_buffer_with_net_vsp(struct hn_softc *sc) { - struct hn_send_ctx sndc; - struct vmbus_xact *xact; + struct vmbus_xact *xact = NULL; struct hn_nvs_chim_conn *chim; const struct hn_nvs_chim_connresp *resp; size_t resp_len; uint32_t status, sectsz; - netvsc_dev *net_dev; int error; - net_dev = hv_nv_get_outbound_net_device(sc); - if (!net_dev) { - return (ENODEV); - } - - net_dev->send_buf = hyperv_dmamem_alloc(bus_get_dma_tag(sc->hn_dev), - PAGE_SIZE, 0, net_dev->send_buf_size, &net_dev->txbuf_dma, - BUS_DMA_WAITOK | BUS_DMA_ZERO); - if (net_dev->send_buf == NULL) { - device_printf(sc->hn_dev, "allocate chimney txbuf failed\n"); - return (ENOMEM); - } - /* * Connect chimney sending buffer GPADL to the primary channel. * @@ -284,8 +242,8 @@ hv_nv_init_send_buffer_with_net_vsp(stru * Sub-channels just share this chimney sending buffer. */ error = vmbus_chan_gpadl_connect(sc->hn_prichan, - net_dev->txbuf_dma.hv_paddr, net_dev->send_buf_size, - &net_dev->send_buf_gpadl_handle); + sc->hn_chim_dma.hv_paddr, NETVSC_SEND_BUFFER_SIZE, + &sc->hn_chim_gpadl); if (error) { if_printf(sc->hn_ifp, "chimney sending buffer gpadl " "connect failed: %d\n", error); @@ -302,37 +260,26 @@ hv_nv_init_send_buffer_with_net_vsp(stru error = ENXIO; goto cleanup; } - chim = vmbus_xact_req_data(xact); chim->nvs_type = HN_NVS_TYPE_CHIM_CONN; - chim->nvs_gpadl = net_dev->send_buf_gpadl_handle; + chim->nvs_gpadl = sc->hn_chim_gpadl; chim->nvs_sig = HN_NVS_CHIM_SIG; - hn_send_ctx_init_simple(&sndc, hn_nvs_sent_xact, xact); - vmbus_xact_activate(xact); - - error = hn_nvs_send(sc->hn_prichan, VMBUS_CHANPKT_FLAG_RC, - chim, sizeof(*chim), &sndc); - if (error) { - if_printf(sc->hn_ifp, "send nvs chim conn failed: %d\n", - error); - vmbus_xact_deactivate(xact); - vmbus_xact_put(xact); + resp = hn_nvs_xact_execute(sc, xact, chim, sizeof(*chim), &resp_len); + if (resp == NULL) { + if_printf(sc->hn_ifp, "exec chim conn failed\n"); + error = EIO; goto cleanup; } - - resp = vmbus_xact_wait(xact, &resp_len); if (resp_len < sizeof(*resp)) { if_printf(sc->hn_ifp, "invalid chim conn resp length %zu\n", resp_len); - vmbus_xact_put(xact); error = EINVAL; goto cleanup; } if (resp->nvs_type != HN_NVS_TYPE_CHIM_CONNRESP) { if_printf(sc->hn_ifp, "not chim conn resp, type %u\n", resp->nvs_type); - vmbus_xact_put(xact); error = EINVAL; goto cleanup; } @@ -340,6 +287,7 @@ hv_nv_init_send_buffer_with_net_vsp(stru status = resp->nvs_status; sectsz = resp->nvs_sectsz; vmbus_xact_put(xact); + xact = NULL; if (status != HN_NVS_STATUS_OK) { if_printf(sc->hn_ifp, "chim conn failed: %x\n", status); @@ -352,23 +300,33 @@ hv_nv_init_send_buffer_with_net_vsp(stru return 0; } - net_dev->send_section_size = sectsz; - net_dev->send_section_count = - net_dev->send_buf_size / net_dev->send_section_size; - net_dev->bitsmap_words = howmany(net_dev->send_section_count, - BITS_PER_LONG); - net_dev->send_section_bitsmap = - malloc(net_dev->bitsmap_words * sizeof(long), M_NETVSC, - M_WAITOK | M_ZERO); + sc->hn_chim_szmax = sectsz; + sc->hn_chim_cnt = NETVSC_SEND_BUFFER_SIZE / sc->hn_chim_szmax; + if (NETVSC_SEND_BUFFER_SIZE % sc->hn_chim_szmax != 0) { + if_printf(sc->hn_ifp, "chimney sending sections are " + "not properly aligned\n"); + } + if (sc->hn_chim_cnt % LONG_BIT != 0) { + if_printf(sc->hn_ifp, "discard %d chimney sending sections\n", + sc->hn_chim_cnt % LONG_BIT); + } + + sc->hn_chim_bmap_cnt = sc->hn_chim_cnt / LONG_BIT; + sc->hn_chim_bmap = malloc(sc->hn_chim_bmap_cnt * sizeof(u_long), + M_NETVSC, M_WAITOK | M_ZERO); + /* Done! */ + sc->hn_flags |= HN_FLAG_CHIM_CONNECTED; if (bootverbose) { - if_printf(sc->hn_ifp, "chimney sending buffer %u/%u\n", - net_dev->send_section_size, net_dev->send_section_count); + if_printf(sc->hn_ifp, "chimney sending buffer %d/%d\n", + sc->hn_chim_szmax, sc->hn_chim_cnt); } return 0; cleanup: - hv_nv_destroy_send_buffer(net_dev); + if (xact != NULL) + vmbus_xact_put(xact); + hv_nv_destroy_send_buffer(sc); return (error); } @@ -376,11 +334,11 @@ cleanup: * Net VSC destroy receive buffer */ static int -hv_nv_destroy_rx_buffer(netvsc_dev *net_dev) +hv_nv_destroy_rx_buffer(struct hn_softc *sc) { int ret = 0; - if (net_dev->rx_section_count) { + if (sc->hn_flags & HN_FLAG_RXBUF_CONNECTED) { struct hn_nvs_rxbuf_disconn disconn; /* @@ -391,37 +349,28 @@ hv_nv_destroy_rx_buffer(netvsc_dev *net_ disconn.nvs_sig = HN_NVS_RXBUF_SIG; /* NOTE: No response. */ - ret = hn_nvs_send(net_dev->sc->hn_prichan, - VMBUS_CHANPKT_FLAG_NONE, &disconn, sizeof(disconn), - &hn_send_ctx_none); + ret = hn_nvs_req_send(sc, &disconn, sizeof(disconn)); if (ret != 0) { - if_printf(net_dev->sc->hn_ifp, + if_printf(sc->hn_ifp, "send rxbuf disconn failed: %d\n", ret); return (ret); } - net_dev->rx_section_count = 0; + sc->hn_flags &= ~HN_FLAG_RXBUF_CONNECTED; } - /* Tear down the gpadl on the vsp end */ - if (net_dev->rx_buf_gpadl_handle) { - ret = vmbus_chan_gpadl_disconnect(net_dev->sc->hn_prichan, - net_dev->rx_buf_gpadl_handle); + if (sc->hn_rxbuf_gpadl != 0) { /* - * If we failed here, we might as well return and have a leak - * rather than continue and a bugchk + * Disconnect RXBUF from primary channel. */ + ret = vmbus_chan_gpadl_disconnect(sc->hn_prichan, + sc->hn_rxbuf_gpadl); if (ret != 0) { + if_printf(sc->hn_ifp, + "rxbuf disconn failed: %d\n", ret); return (ret); } - net_dev->rx_buf_gpadl_handle = 0; - } - - if (net_dev->rx_buf) { - /* Free up the receive buffer */ - hyperv_dmamem_free(&net_dev->rxbuf_dma, net_dev->rx_buf); - net_dev->rx_buf = NULL; + sc->hn_rxbuf_gpadl = 0; } - return (ret); } @@ -429,11 +378,11 @@ hv_nv_destroy_rx_buffer(netvsc_dev *net_ * Net VSC destroy send buffer */ static int -hv_nv_destroy_send_buffer(netvsc_dev *net_dev) +hv_nv_destroy_send_buffer(struct hn_softc *sc) { int ret = 0; - if (net_dev->send_section_size) { + if (sc->hn_flags & HN_FLAG_CHIM_CONNECTED) { struct hn_nvs_chim_disconn disconn; /* @@ -444,80 +393,62 @@ hv_nv_destroy_send_buffer(netvsc_dev *ne disconn.nvs_sig = HN_NVS_CHIM_SIG; /* NOTE: No response. */ - ret = hn_nvs_send(net_dev->sc->hn_prichan, - VMBUS_CHANPKT_FLAG_NONE, &disconn, sizeof(disconn), - &hn_send_ctx_none); + ret = hn_nvs_req_send(sc, &disconn, sizeof(disconn)); if (ret != 0) { - if_printf(net_dev->sc->hn_ifp, + if_printf(sc->hn_ifp, "send chim disconn failed: %d\n", ret); return (ret); } + sc->hn_flags &= ~HN_FLAG_CHIM_CONNECTED; } - /* Tear down the gpadl on the vsp end */ - if (net_dev->send_buf_gpadl_handle) { - ret = vmbus_chan_gpadl_disconnect(net_dev->sc->hn_prichan, - net_dev->send_buf_gpadl_handle); - + if (sc->hn_chim_gpadl != 0) { /* - * If we failed here, we might as well return and have a leak - * rather than continue and a bugchk + * Disconnect chimney sending buffer from primary channel. */ + ret = vmbus_chan_gpadl_disconnect(sc->hn_prichan, + sc->hn_chim_gpadl); if (ret != 0) { + if_printf(sc->hn_ifp, + "chim disconn failed: %d\n", ret); return (ret); } - net_dev->send_buf_gpadl_handle = 0; - } - - if (net_dev->send_buf) { - /* Free up the receive buffer */ - hyperv_dmamem_free(&net_dev->txbuf_dma, net_dev->send_buf); - net_dev->send_buf = NULL; + sc->hn_chim_gpadl = 0; } - if (net_dev->send_section_bitsmap) { - free(net_dev->send_section_bitsmap, M_NETVSC); + if (sc->hn_chim_bmap != NULL) { + free(sc->hn_chim_bmap, M_NETVSC); + sc->hn_chim_bmap = NULL; } return (ret); } static int -hv_nv_negotiate_nvsp_protocol(struct hn_softc *sc, netvsc_dev *net_dev, - uint32_t nvs_ver) +hv_nv_negotiate_nvsp_protocol(struct hn_softc *sc, uint32_t nvs_ver) { - struct hn_send_ctx sndc; struct vmbus_xact *xact; struct hn_nvs_init *init; const struct hn_nvs_init_resp *resp; size_t resp_len; uint32_t status; - int error; xact = vmbus_xact_get(sc->hn_xact, sizeof(*init)); if (xact == NULL) { if_printf(sc->hn_ifp, "no xact for nvs init\n"); return (ENXIO); } - init = vmbus_xact_req_data(xact); init->nvs_type = HN_NVS_TYPE_INIT; init->nvs_ver_min = nvs_ver; init->nvs_ver_max = nvs_ver; - vmbus_xact_activate(xact); - hn_send_ctx_init_simple(&sndc, hn_nvs_sent_xact, xact); - - error = hn_nvs_send(sc->hn_prichan, VMBUS_CHANPKT_FLAG_RC, - init, sizeof(*init), &sndc); - if (error) { - if_printf(sc->hn_ifp, "send nvs init failed: %d\n", error); - vmbus_xact_deactivate(xact); + resp = hn_nvs_xact_execute(sc, xact, init, sizeof(*init), &resp_len); + if (resp == NULL) { + if_printf(sc->hn_ifp, "exec init failed\n"); vmbus_xact_put(xact); - return (error); + return (EIO); } - - resp = vmbus_xact_wait(xact, &resp_len); if (resp_len < sizeof(*resp)) { if_printf(sc->hn_ifp, "invalid init resp length %zu\n", resp_len); @@ -559,8 +490,7 @@ hv_nv_send_ndis_config(struct hn_softc * conf.nvs_caps = HN_NVS_NDIS_CONF_VLAN; /* NOTE: No response. */ - error = hn_nvs_send(sc->hn_prichan, VMBUS_CHANPKT_FLAG_NONE, - &conf, sizeof(conf), &hn_send_ctx_none); + error = hn_nvs_req_send(sc, &conf, sizeof(conf)); if (error) if_printf(sc->hn_ifp, "send nvs ndis conf failed: %d\n", error); return (error); @@ -572,7 +502,6 @@ hv_nv_send_ndis_config(struct hn_softc * static int hv_nv_connect_to_vsp(struct hn_softc *sc) { - netvsc_dev *net_dev; uint32_t protocol_list[] = { NVSP_PROTOCOL_VERSION_1, NVSP_PROTOCOL_VERSION_2, NVSP_PROTOCOL_VERSION_4, @@ -583,19 +512,18 @@ hv_nv_connect_to_vsp(struct hn_softc *sc device_t dev = sc->hn_dev; struct ifnet *ifp = sc->arpcom.ac_ifp; struct hn_nvs_ndis_init ndis; - - net_dev = hv_nv_get_outbound_net_device(sc); + int rxbuf_size; /* * Negotiate the NVSP version. Try the latest NVSP first. */ for (i = protocol_number - 1; i >= 0; i--) { - if (hv_nv_negotiate_nvsp_protocol(sc, net_dev, - protocol_list[i]) == 0) { - net_dev->nvsp_version = protocol_list[i]; - if (bootverbose) - device_printf(dev, "Netvsc: got version 0x%x\n", - net_dev->nvsp_version); + if (hv_nv_negotiate_nvsp_protocol(sc, protocol_list[i]) == 0) { + sc->hn_nvs_ver = protocol_list[i]; + if (bootverbose) { + device_printf(dev, "NVS version 0x%x\n", + sc->hn_nvs_ver); + } break; } } @@ -611,7 +539,7 @@ hv_nv_connect_to_vsp(struct hn_softc *sc * Set the MTU if supported by this NVSP protocol version * This needs to be right after the NVSP init message per Haiyang */ - if (net_dev->nvsp_version >= NVSP_PROTOCOL_VERSION_2) + if (sc->hn_nvs_ver >= NVSP_PROTOCOL_VERSION_2) ret = hv_nv_send_ndis_config(sc, ifp->if_mtu); /* @@ -621,27 +549,25 @@ hv_nv_connect_to_vsp(struct hn_softc *sc memset(&ndis, 0, sizeof(ndis)); ndis.nvs_type = HN_NVS_TYPE_NDIS_INIT; ndis.nvs_ndis_major = NDIS_VERSION_MAJOR_6; - if (net_dev->nvsp_version <= NVSP_PROTOCOL_VERSION_4) + if (sc->hn_nvs_ver <= NVSP_PROTOCOL_VERSION_4) ndis.nvs_ndis_minor = NDIS_VERSION_MINOR_1; else ndis.nvs_ndis_minor = NDIS_VERSION_MINOR_30; /* NOTE: No response. */ - ret = hn_nvs_send(sc->hn_prichan, VMBUS_CHANPKT_FLAG_NONE, - &ndis, sizeof(ndis), &hn_send_ctx_none); + ret = hn_nvs_req_send(sc, &ndis, sizeof(ndis)); if (ret != 0) { if_printf(sc->hn_ifp, "send nvs ndis init failed: %d\n", ret); goto cleanup; } /* Post the big receive buffer to NetVSP */ - if (net_dev->nvsp_version <= NVSP_PROTOCOL_VERSION_2) - net_dev->rx_buf_size = NETVSC_RECEIVE_BUFFER_SIZE_LEGACY; + if (sc->hn_nvs_ver <= NVSP_PROTOCOL_VERSION_2) + rxbuf_size = NETVSC_RECEIVE_BUFFER_SIZE_LEGACY; else - net_dev->rx_buf_size = NETVSC_RECEIVE_BUFFER_SIZE; - net_dev->send_buf_size = NETVSC_SEND_BUFFER_SIZE; + rxbuf_size = NETVSC_RECEIVE_BUFFER_SIZE; - ret = hv_nv_init_rx_buffer_with_net_vsp(sc); + ret = hv_nv_init_rx_buffer_with_net_vsp(sc, rxbuf_size); if (ret == 0) ret = hv_nv_init_send_buffer_with_net_vsp(sc); @@ -653,10 +579,10 @@ cleanup: * Net VSC disconnect from VSP */ static void -hv_nv_disconnect_from_vsp(netvsc_dev *net_dev) +hv_nv_disconnect_from_vsp(struct hn_softc *sc) { - hv_nv_destroy_rx_buffer(net_dev); - hv_nv_destroy_send_buffer(net_dev); + hv_nv_destroy_rx_buffer(sc); + hv_nv_destroy_send_buffer(sc); } void @@ -675,20 +601,12 @@ hv_nv_subchan_attach(struct vmbus_channe * * Callback when the device belonging to this driver is added */ -netvsc_dev * -hv_nv_on_device_add(struct hn_softc *sc, void *additional_info, - struct hn_rx_ring *rxr) +int +hv_nv_on_device_add(struct hn_softc *sc, struct hn_rx_ring *rxr) { struct vmbus_channel *chan = sc->hn_prichan; - netvsc_dev *net_dev; int ret = 0; - net_dev = hv_nv_alloc_net_device(sc); - if (net_dev == NULL) - return NULL; - - /* Initialize the NetVSC channel extension */ - /* * Open the channel */ @@ -708,20 +626,13 @@ hv_nv_on_device_add(struct hn_softc *sc, if (ret != 0) goto close; - return (net_dev); + return (0); close: /* Now, we can close the channel safely */ vmbus_chan_close(chan); - cleanup: - /* - * Free the packet buffers on the netvsc device packet queue. - * Release other resources. - */ - free(net_dev, M_NETVSC); - - return (NULL); + return (ret); } /* @@ -730,27 +641,19 @@ cleanup: int hv_nv_on_device_remove(struct hn_softc *sc, boolean_t destroy_channel) { - netvsc_dev *net_dev = sc->net_dev;; - /* Stop outbound traffic ie sends and receives completions */ - net_dev->destroy = TRUE; - - hv_nv_disconnect_from_vsp(net_dev); - - /* At this point, no one should be accessing net_dev except in here */ + hv_nv_disconnect_from_vsp(sc); /* Now, we can close the channel safely */ vmbus_chan_close(sc->hn_prichan); - free(net_dev, M_NETVSC); - return (0); } -void +static void hn_nvs_sent_xact(struct hn_send_ctx *sndc, - struct netvsc_dev_ *net_dev __unused, struct vmbus_channel *chan __unused, + struct hn_softc *sc __unused, struct vmbus_channel *chan __unused, const void *data, int dlen) { @@ -759,42 +662,42 @@ hn_nvs_sent_xact(struct hn_send_ctx *snd static void hn_nvs_sent_none(struct hn_send_ctx *sndc __unused, - struct netvsc_dev_ *net_dev __unused, struct vmbus_channel *chan __unused, + struct hn_softc *sc __unused, struct vmbus_channel *chan __unused, const void *data __unused, int dlen __unused) { /* EMPTY */ } void -hn_chim_free(struct netvsc_dev_ *net_dev, uint32_t chim_idx) +hn_chim_free(struct hn_softc *sc, uint32_t chim_idx) { u_long mask; uint32_t idx; - idx = chim_idx / BITS_PER_LONG; - KASSERT(idx < net_dev->bitsmap_words, + idx = chim_idx / LONG_BIT; + KASSERT(idx < sc->hn_chim_bmap_cnt, ("invalid chimney index 0x%x", chim_idx)); - mask = 1UL << (chim_idx % BITS_PER_LONG); - KASSERT(net_dev->send_section_bitsmap[idx] & mask, + mask = 1UL << (chim_idx % LONG_BIT); + KASSERT(sc->hn_chim_bmap[idx] & mask, ("index bitmap 0x%lx, chimney index %u, " "bitmap idx %d, bitmask 0x%lx", - net_dev->send_section_bitsmap[idx], chim_idx, idx, mask)); + sc->hn_chim_bmap[idx], chim_idx, idx, mask)); - atomic_clear_long(&net_dev->send_section_bitsmap[idx], mask); + atomic_clear_long(&sc->hn_chim_bmap[idx], mask); } /* * Net VSC on send completion */ static void -hv_nv_on_send_completion(netvsc_dev *net_dev, struct vmbus_channel *chan, +hv_nv_on_send_completion(struct hn_softc *sc, struct vmbus_channel *chan, const struct vmbus_chanpkt_hdr *pkt) { struct hn_send_ctx *sndc; sndc = (struct hn_send_ctx *)(uintptr_t)pkt->cph_xactid; - sndc->hn_cb(sndc, net_dev, chan, VMBUS_CHANPKT_CONST_DATA(pkt), + sndc->hn_cb(sndc, sc, chan, VMBUS_CHANPKT_CONST_DATA(pkt), VMBUS_CHANPKT_DATALEN(pkt)); /* * NOTE: @@ -838,7 +741,7 @@ hv_nv_on_send(struct vmbus_channel *chan * with virtual addresses. */ static void -hv_nv_on_receive(netvsc_dev *net_dev, struct hn_rx_ring *rxr, +hv_nv_on_receive(struct hn_softc *sc, struct hn_rx_ring *rxr, struct vmbus_channel *chan, const struct vmbus_chanpkt_hdr *pkthdr) { const struct vmbus_chanpkt_rxbuf *pkt; @@ -866,8 +769,8 @@ hv_nv_on_receive(netvsc_dev *net_dev, st /* Each range represents 1 RNDIS pkt that contains 1 Ethernet frame */ for (i = 0; i < count; i++) { - hv_rf_on_receive(net_dev, rxr, - (const uint8_t *)net_dev->rx_buf + pkt->cp_rxbuf[i].rb_ofs, + hv_rf_on_receive(sc, rxr, + rxr->hn_rxbuf + pkt->cp_rxbuf[i].rb_ofs, pkt->cp_rxbuf[i].rb_len); } @@ -933,14 +836,9 @@ hv_nv_on_channel_callback(struct vmbus_c { struct hn_rx_ring *rxr = xrxr; struct hn_softc *sc = rxr->hn_ifp->if_softc; - netvsc_dev *net_dev; void *buffer; int bufferlen = NETVSC_PACKET_SIZE; - net_dev = hv_nv_get_inbound_net_device(sc); - if (net_dev == NULL) - return; - buffer = rxr->hn_rdbuf; do { struct vmbus_chanpkt_hdr *pkt = buffer; @@ -953,11 +851,10 @@ hv_nv_on_channel_callback(struct vmbus_c if (bytes_rxed > 0) { switch (pkt->cph_type) { case VMBUS_CHANPKT_TYPE_COMP: - hv_nv_on_send_completion(net_dev, chan, - pkt); + hv_nv_on_send_completion(sc, chan, pkt); break; case VMBUS_CHANPKT_TYPE_RXBUF: - hv_nv_on_receive(net_dev, rxr, chan, pkt); + hv_nv_on_receive(sc, rxr, chan, pkt); break; case VMBUS_CHANPKT_TYPE_INBAND: hn_proc_notify(sc, pkt); Modified: stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h Thu Oct 13 03:10:04 2016 (r307173) +++ stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h Thu Oct 13 03:16:15 2016 (r307174) @@ -212,40 +212,6 @@ typedef struct rndis_recv_scale_param_ { * Data types */ -/* - * Per netvsc channel-specific - */ -typedef struct netvsc_dev_ { - struct hn_softc *sc; - - /* Send buffer allocated by us but manages by NetVSP */ - void *send_buf; - uint32_t send_buf_size; - uint32_t send_buf_gpadl_handle; - uint32_t send_section_size; - uint32_t send_section_count; - unsigned long bitsmap_words; - unsigned long *send_section_bitsmap; - - /* Receive buffer allocated by us but managed by NetVSP */ - void *rx_buf; - uint32_t rx_buf_size; - uint32_t rx_buf_gpadl_handle; - uint32_t rx_section_count; - - /* Holds rndis device info */ - void *extension; - - uint8_t destroy; - /* Negotiated NVSP version */ - uint32_t nvsp_version; - - uint32_t num_channel; - - struct hyperv_dma rxbuf_dma; - struct hyperv_dma txbuf_dma; -} netvsc_dev; - struct vmbus_channel; typedef void (*pfn_on_send_rx_completion)(struct vmbus_channel *, void *); @@ -268,12 +234,6 @@ typedef void (*pfn_on_send_rx_completion #define TRANSPORT_TYPE_IPV6_TCP ((TYPE_IPV6 << 16) | TYPE_TCP) #define TRANSPORT_TYPE_IPV6_UDP ((TYPE_IPV6 << 16) | TYPE_UDP) -#ifdef __LP64__ -#define BITS_PER_LONG 64 -#else -#define BITS_PER_LONG 32 -#endif - typedef struct { uint8_t mac_addr[6]; /* Assumption unsigned long */ uint8_t link_state; @@ -292,6 +252,7 @@ struct hn_rx_ring { struct ifnet *hn_ifp; struct hn_tx_ring *hn_txr; void *hn_rdbuf; + uint8_t *hn_rxbuf; /* shadow sc->hn_rxbuf */ int hn_rx_idx; /* Trust csum verification on host side */ @@ -345,7 +306,7 @@ struct hn_tx_ring { struct vmbus_channel *hn_chan; int hn_direct_tx_size; - int hn_tx_chimney_size; + int hn_chim_size; bus_dma_tag_t hn_tx_data_dtag; uint64_t hn_csum_assist; @@ -384,7 +345,7 @@ typedef struct hn_softc { int hn_initdone; /* See hv_netvsc_drv_freebsd.c for rules on how to use */ int temp_unusable; - netvsc_dev *net_dev; + struct rndis_device_ *rndis_dev; struct vmbus_channel *hn_prichan; int hn_rx_ring_cnt; @@ -395,14 +356,31 @@ typedef struct hn_softc { int hn_tx_ring_inuse; struct hn_tx_ring *hn_tx_ring; + uint8_t *hn_chim; + u_long *hn_chim_bmap; + int hn_chim_bmap_cnt; + int hn_chim_cnt; + int hn_chim_szmax; + int hn_cpu; - int hn_tx_chimney_max; struct taskqueue *hn_tx_taskq; struct sysctl_oid *hn_tx_sysctl_tree; struct sysctl_oid *hn_rx_sysctl_tree; struct vmbus_xact_ctx *hn_xact; + uint32_t hn_nvs_ver; + + uint32_t hn_flags; + void *hn_rxbuf; + uint32_t hn_rxbuf_gpadl; + struct hyperv_dma hn_rxbuf_dma; + + uint32_t hn_chim_gpadl; + struct hyperv_dma hn_chim_dma; } hn_softc_t; +#define HN_FLAG_RXBUF_CONNECTED 0x0001 +#define HN_FLAG_CHIM_CONNECTED 0x0002 + /* * Externs */ @@ -410,13 +388,11 @@ extern int hv_promisc_mode; struct hn_send_ctx; void netvsc_linkstatus_callback(struct hn_softc *sc, uint32_t status); -netvsc_dev *hv_nv_on_device_add(struct hn_softc *sc, - void *additional_info, struct hn_rx_ring *rxr); +int hv_nv_on_device_add(struct hn_softc *sc, struct hn_rx_ring *rxr); int hv_nv_on_device_remove(struct hn_softc *sc, boolean_t destroy_channel); int hv_nv_on_send(struct vmbus_channel *chan, uint32_t rndis_mtype, struct hn_send_ctx *sndc, struct vmbus_gpa *gpa, int gpa_cnt); -int hv_nv_get_next_send_section(netvsc_dev *net_dev); void hv_nv_subchan_attach(struct vmbus_channel *chan, struct hn_rx_ring *rxr); Modified: stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Thu Oct 13 03:10:04 2016 (r307173) +++ stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Thu Oct 13 03:16:15 2016 (r307174) @@ -328,7 +328,7 @@ static int hn_lro_lenlim_sysctl(SYSCTL_H static int hn_lro_ackcnt_sysctl(SYSCTL_HANDLER_ARGS); #endif static int hn_trust_hcsum_sysctl(SYSCTL_HANDLER_ARGS); -static int hn_tx_chimney_size_sysctl(SYSCTL_HANDLER_ARGS); +static int hn_chim_size_sysctl(SYSCTL_HANDLER_ARGS); #if __FreeBSD_version < 1100095 static int hn_rx_stat_int_sysctl(SYSCTL_HANDLER_ARGS); #else @@ -346,9 +346,9 @@ static void hn_start_taskfunc(void *, in static void hn_start_txeof_taskfunc(void *, int); static void hn_stop_tx_tasks(struct hn_softc *); static int hn_encap(struct hn_tx_ring *, struct hn_txdesc *, struct mbuf **); -static void hn_create_rx_data(struct hn_softc *sc, int); +static int hn_create_rx_data(struct hn_softc *sc, int); static void hn_destroy_rx_data(struct hn_softc *sc); -static void hn_set_tx_chimney_size(struct hn_softc *, int); +static void hn_set_chim_size(struct hn_softc *, int); static void hn_channel_attach(struct hn_softc *, struct vmbus_channel *); static void hn_subchan_attach(struct hn_softc *, struct vmbus_channel *); static void hn_subchan_setup(struct hn_softc *); @@ -520,7 +520,9 @@ netvsc_attach(device_t dev) *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-all@freebsd.org Thu Oct 13 03:22:09 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A2F23C0E885 for ; Thu, 13 Oct 2016 03:22:09 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: from mail-it0-x232.google.com (mail-it0-x232.google.com [IPv6:2607:f8b0:4001:c0b::232]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 6AAE17A for ; Thu, 13 Oct 2016 03:22:09 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: by mail-it0-x232.google.com with SMTP id k64so29247021itb.0 for ; Wed, 12 Oct 2016 20:22:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20150623.gappssmtp.com; s=20150623; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=kaGP9Vycd+ebFXtEJ4m+IdRISWdg7vnsKPEs/Dzvr5o=; b=LPczsdQXycZy1LM+zO8pdlEG815kR6j31gR1u3O4P5IbS7P01jrzXSZudS7AREapBA dkGNzVuCUBOUTYYNMfW+iwtgzWNJkdQ+PRYel5sMbqwv1T3oXOsWjEsY4Z+LEEQO4UuF txbrVlXtIHmZDLnItSJYTqktCl/pWL5wTCxCfy2LA/3/WRhx3nPbdQ5aTseuMU3DpZz2 TYiuFifvdMzbRoptXwAYBsoiWG6gBA8gOa0ZQTl+4K2Fvj5tqfvZizKCA5k/3BOKyh7f 4H+MZyy8/UgXKP0vVOm39Y2McmvNeU25Lje4/BRzoXI6NZkWpJBMPS0A543ofCoMmNFl wdmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=kaGP9Vycd+ebFXtEJ4m+IdRISWdg7vnsKPEs/Dzvr5o=; b=cPEJgnITiipVDscADlLMNaIs7ei2IQplhFk9Ld2rzFBwHa/wTkczLD7RQls4K0/Ucp e/SlPWsGzflvoA5l43fdPNq5LcYI48SKvBK57GGYQVxAAIXKmFNsCNZVYHr/pvtEstET 7n/DbfVM3yI70SZMNNuhZz1NwOIHOU4wLijG8HN84b6Glb8yweS0s8GlOrUDI8Ujxgk0 NtGLABfWXtfSol07ae49y/FFOaDcQFdcjfnNDKbLK9Cm4UMeIz3eOtwgz4xTMRB+4ded 6zzQCX22Gz/us9JwsZu72Db19lBaX/pL5HtvMHgDVDum2p7dg64e6imp0RgyHbOSKVFI HyPg== X-Gm-Message-State: AA6/9RkTmAVRppf/7/4Up9h3A08XqoLNvFM4DL6OYrGbtrms0P8A82LutHmhDs3b0kmY/eZtHIAsfl1TWjfaKA== X-Received: by 10.36.19.147 with SMTP id 141mr5567929itz.85.1476328928778; Wed, 12 Oct 2016 20:22:08 -0700 (PDT) MIME-Version: 1.0 Sender: wlosh@bsdimp.com Received: by 10.79.77.85 with HTTP; Wed, 12 Oct 2016 20:22:08 -0700 (PDT) X-Originating-IP: [50.253.99.174] In-Reply-To: <20161012114920.GU68202@kib.kiev.ua> References: <201610112224.u9BMOUlp053188@repo.freebsd.org> <20161012114920.GU68202@kib.kiev.ua> From: Warner Losh Date: Wed, 12 Oct 2016 21:22:08 -0600 X-Google-Sender-Auth: u6LAcOIQOUGx52tmafsOfAYTQMI Message-ID: Subject: Re: svn commit: r307070 - in head/sys: amd64/amd64 conf dev/efidev i386/include modules/efirt sys To: Konstantin Belousov , "svn-src-all@freebsd.org" Cc: Warner Losh , src-committers , "svn-src-head@freebsd.org" Content-Type: text/plain; charset=UTF-8 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Oct 2016 03:22:09 -0000 Yea, I'd made most of those changes in git and lost them :( Warner On Wed, Oct 12, 2016 at 5:49 AM, Konstantin Belousov wrote: > On Tue, Oct 11, 2016 at 10:24:30PM +0000, Warner Losh wrote: > >> Added: head/sys/dev/efidev/efidev.c >> ============================================================================== >> --- /dev/null 00:00:00 1970 (empty, because file is newly added) >> +++ head/sys/dev/efidev/efidev.c Tue Oct 11 22:24:30 2016 (r307070) >> @@ -0,0 +1,199 @@ >> +/*- >> + * Copyright (c) 2016 Netflix, Inc. >> + * All rights reserved. >> + * >> + * Redistribution and use in source and binary forms, with or without >> + * modification, are permitted provided that the following conditions >> + * are met: >> + * 1. Redistributions of source code must retain the above copyright >> + * notice, this list of conditions and the following disclaimer >> + * in this position and unchanged. >> + * 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 ``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 BE LIABLE FOR ANY DIRECT, INDIRECT, >> + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT >> + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, >> + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY >> + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >> + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF >> + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >> + */ >> + >> +#include >> +__FBSDID("$FreeBSD$"); >> + >> +#include >> +#include >> +#include >> +#include >> +#include >> +#include >> +#include >> +#include >> + >> +#include > As I asked in review, please use , not > >> +#include >> + >> +static d_ioctl_t efidev_ioctl; >> + >> +static struct cdevsw efi_cdevsw = { >> + .d_name = "efi", >> + .d_version = D_VERSION, >> + .d_ioctl = efidev_ioctl, >> +}; >> + >> +/* ARGSUSED */ >> +static int >> +efidev_ioctl(struct cdev *dev __unused, u_long cmd, caddr_t addr, >> + int flags __unused, struct thread *td __unused) >> +{ >> + int error; >> + >> + switch (cmd) { >> + case EFIIOC_GET_TABLE: >> + { >> + struct efi_get_table_ioc *egtioc = >> + (struct efi_get_table_ioc *)addr; >> + >> + error = efi_get_table(&egtioc->uuid, &egtioc->ptr); >> + break; >> + } >> + case EFIIOC_GET_TIME: >> + { >> + struct efi_tm *tm = (struct efi_tm *)addr; >> + >> + error = efi_get_time(tm); >> + break; >> + } >> + case EFIIOC_SET_TIME: >> + { >> + struct efi_tm *tm = (struct efi_tm *)addr; >> + >> + error = efi_set_time(tm); >> + break; >> + } >> + case EFIIOC_VAR_GET: >> + { >> + struct efi_var_ioc *ev = (struct efi_var_ioc *)addr; >> + void *data; >> + efi_char *name; >> + >> + data = malloc(ev->datasize, M_TEMP, M_WAITOK); >> + name = malloc(ev->namesize, M_TEMP, M_WAITOK); >> + error = copyin(ev->name, name, ev->namesize); >> + if (error) >> + goto vg_out; >> + if (name[ev->namesize / sizeof(efi_char) - 1] != 0) { >> + error = EINVAL; >> + goto vg_out; >> + } >> + >> + error = efi_var_get(name, &ev->vendor, &ev->attrib, >> + &ev->datasize, data); >> + >> + if (error == 0) { >> + error = copyout(data, ev->data, ev->datasize); >> + } else if (error == EOVERFLOW) { >> + /* >> + * Pass back the size we really need, but >> + * convert the error to 0 so the copyout >> + * happens. datasize was updated in the >> + * efi_var_get call. >> + */ >> + ev->data = NULL; >> + error = 0; >> + } >> +vg_out: >> + free(data, M_TEMP); >> + free(name, M_TEMP); >> + break; >> + } >> + case EFIIOC_VAR_NEXT: >> + { >> + struct efi_var_ioc *ev = (struct efi_var_ioc *)addr; >> + efi_char *name; >> + >> + name = malloc(ev->namesize, M_TEMP, M_WAITOK); >> + if (name == NULL) { > The check is for impossible condition. > >> + error = ENOMEM; >> + goto vn_out; >> + } >> + error = copyin(ev->name, name, ev->namesize); >> + if (error) >> + goto vn_out; >> + /* Note: namesize is the buffer size, not the string lenght */ >> + >> + error = efi_var_nextname(&ev->namesize, name, &ev->vendor); >> + if (error == 0) { >> + error = copyout(name, ev->name, ev->namesize); >> + } else if (error == EOVERFLOW) { >> + ev->name = NULL; >> + error = 0; >> + } >> + vn_out: >> + if (name != NULL) > The check is redundand. > >> + free(name, M_TEMP); >> + break; >> + } >> + case EFIIOC_VAR_SET: >> + { >> + struct efi_var_ioc *ev = (struct efi_var_ioc *)addr; >> + void *data = NULL; >> + efi_char *name; >> + >> + /* datasize == 0 -> delete (more or less) */ >> + if (ev->datasize > 0) >> + data = malloc(ev->datasize, M_TEMP, M_WAITOK); >> + name = malloc(ev->namesize, M_TEMP, M_WAITOK); >> + if (ev->datasize) { >> + error = copyin(ev->data, data, ev->datasize); >> + if (error) >> + goto vs_out; >> + } >> + error = copyin(ev->name, name, ev->namesize); >> + if (error) >> + goto vs_out; >> + if (name[ev->namesize / sizeof(efi_char) - 1] != 0) { >> + error = EINVAL; >> + goto vs_out; >> + } >> + >> + error = efi_var_set(name, &ev->vendor, ev->attrib, ev->datasize, >> + data); >> +vs_out: >> + if (data != NULL) > The check is redundand. > >> + free(data, M_TEMP); >> + free(name, M_TEMP); >> + break; >> + } >> + default: >> + error = ENOTTY; >> + break; >> + } >> + >> + return (error); >> +} >> + >> +int >> +efidev_init(struct cdev **cdev) >> +{ >> + >> + *cdev = make_dev(&efi_cdevsw, 0, UID_ROOT, GID_WHEEL, 0700, >> + "efidev"); > It is still "/dev/efidev". Please rename as discussed. > >> + >> + return (0); >> +} >> + >> +int >> +efidev_uninit(struct cdev *cdev) >> +{ >> + >> + destroy_dev(cdev); >> + >> + return (0); >> +} >> >> Added: head/sys/i386/include/efi.h >> ============================================================================== >> --- /dev/null 00:00:00 1970 (empty, because file is newly added) >> +++ head/sys/i386/include/efi.h Tue Oct 11 22:24:30 2016 (r307070) >> @@ -0,0 +1,39 @@ >> +/*- >> + * Copyright (c) 2016 The FreeBSD Foundation >> + * All rights reserved. >> + * >> + * This software was developed by Konstantin Belousov >> + * under sponsorship from the FreeBSD Foundation. > It was not. > >> + * >> + * Redistribution and use in source and binary forms, with or without >> + * modification, are permitted provided that the following conditions >> + * are met: >> + * 1. Redistributions of source code must retain the above copyright >> + * notice, this list of conditions and the following disclaimer. >> + * 2. Redistributions in binary form must reproduce the above copyright >> + * notice, this list of conditions and the following disclaimer in the >> + * documentation and/or other materials provided with the distribution. >> + * >> + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND >> + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >> + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE >> + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE >> + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL >> + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS >> + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) >> + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT >> + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY >> + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF >> + * SUCH DAMAGE. >> + * >> + * $FreeBSD$ >> + */ >> + >> +#ifndef __I386_INCLUDE_EFI_H_ >> +#define __I386_INCLUDE_EFI_H_ >> + >> +#define EFIABI_ATTR /* __attribute__((ms_abi)) */ /* clang fails with this */ >> + >> +/* Note: we don't actually support this on i386 yet */ >> + >> +#endif /* __I386_INCLUDE_EFI_H_ */ From owner-svn-src-all@freebsd.org Thu Oct 13 03:23:44 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D4FE6C0E9E6; Thu, 13 Oct 2016 03:23:44 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id A3330242; Thu, 13 Oct 2016 03:23:44 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9D3Nhbc023737; Thu, 13 Oct 2016 03:23:43 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9D3Nhwi023734; Thu, 13 Oct 2016 03:23:43 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610130323.u9D3Nhwi023734@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Thu, 13 Oct 2016 03:23:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307175 - in stable/10/sys: dev/usb/net net X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Oct 2016 03:23:44 -0000 Author: sephe Date: Thu Oct 13 03:23:43 2016 New Revision: 307175 URL: https://svnweb.freebsd.org/changeset/base/307175 Log: MFC 304654,304722,304723 304654 net: Split RNDIS protocol structs/macros out of dev/usb/net/if_urndisreg.h So that Hyper-V can leverage them instead of rolling its own definition. Discussed with: hps Reviewed by: hps Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7592 304722 net/rndis: Add canonical RNDIS major/minor version as of today. Reviewed by: hps Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7593 304723 net/rndis: Fix RNDIS_STATUS_PENDING definition. While I'm here, sort the RNDIS status in ascending order. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7594 Added: stable/10/sys/net/rndis.h - copied, changed from r304654, head/sys/net/rndis.h Modified: stable/10/sys/dev/usb/net/if_urndis.c stable/10/sys/dev/usb/net/if_urndisreg.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/usb/net/if_urndis.c ============================================================================== --- stable/10/sys/dev/usb/net/if_urndis.c Thu Oct 13 03:16:15 2016 (r307174) +++ stable/10/sys/dev/usb/net/if_urndis.c Thu Oct 13 03:23:43 2016 (r307175) @@ -45,6 +45,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include @@ -79,17 +80,17 @@ static uether_fn_t urndis_setmulti; static uether_fn_t urndis_setpromisc; static uint32_t urndis_ctrl_query(struct urndis_softc *sc, uint32_t oid, - struct urndis_query_req *msg, uint16_t len, + struct rndis_query_req *msg, uint16_t len, const void **rbuf, uint16_t *rbufsz); static uint32_t urndis_ctrl_set(struct urndis_softc *sc, uint32_t oid, - struct urndis_set_req *msg, uint16_t len); + struct rndis_set_req *msg, uint16_t len); static uint32_t urndis_ctrl_handle_init(struct urndis_softc *sc, - const struct urndis_comp_hdr *hdr); + const struct rndis_comp_hdr *hdr); static uint32_t urndis_ctrl_handle_query(struct urndis_softc *sc, - const struct urndis_comp_hdr *hdr, const void **buf, + const struct rndis_comp_hdr *hdr, const void **buf, uint16_t *bufsz); static uint32_t urndis_ctrl_handle_reset(struct urndis_softc *sc, - const struct urndis_comp_hdr *hdr); + const struct rndis_comp_hdr *hdr); static uint32_t urndis_ctrl_init(struct urndis_softc *sc); static uint32_t urndis_ctrl_halt(struct urndis_softc *sc); @@ -211,8 +212,8 @@ urndis_attach(device_t dev) { static struct { union { - struct urndis_query_req query; - struct urndis_set_req set; + struct rndis_query_req query; + struct rndis_set_req set; } hdr; union { uint8_t eaddr[ETHER_ADDR_LEN]; @@ -452,10 +453,10 @@ urndis_ctrl_send(struct urndis_softc *sc return (err); } -static struct urndis_comp_hdr * +static struct rndis_comp_hdr * urndis_ctrl_recv(struct urndis_softc *sc) { - struct urndis_comp_hdr *hdr; + struct rndis_comp_hdr *hdr; usb_error_t err; err = urndis_ctrl_msg(sc, UT_READ_CLASS_INTERFACE, @@ -465,7 +466,7 @@ urndis_ctrl_recv(struct urndis_softc *sc if (err != USB_ERR_NORMAL_COMPLETION) return (NULL); - hdr = (struct urndis_comp_hdr *)sc->sc_response_buf; + hdr = (struct rndis_comp_hdr *)sc->sc_response_buf; DPRINTF("type 0x%x len %u\n", le32toh(hdr->rm_type), le32toh(hdr->rm_len)); @@ -479,7 +480,7 @@ urndis_ctrl_recv(struct urndis_softc *sc } static uint32_t -urndis_ctrl_handle(struct urndis_softc *sc, struct urndis_comp_hdr *hdr, +urndis_ctrl_handle(struct urndis_softc *sc, struct rndis_comp_hdr *hdr, const void **buf, uint16_t *bufsz) { uint32_t rval; @@ -520,11 +521,11 @@ urndis_ctrl_handle(struct urndis_softc * static uint32_t urndis_ctrl_handle_init(struct urndis_softc *sc, - const struct urndis_comp_hdr *hdr) + const struct rndis_comp_hdr *hdr) { - const struct urndis_init_comp *msg; + const struct rndis_init_comp *msg; - msg = (const struct urndis_init_comp *)hdr; + msg = (const struct rndis_init_comp *)hdr; DPRINTF("len %u rid %u status 0x%x " "ver_major %u ver_minor %u devflags 0x%x medium 0x%x pktmaxcnt %u " @@ -563,12 +564,12 @@ urndis_ctrl_handle_init(struct urndis_so static uint32_t urndis_ctrl_handle_query(struct urndis_softc *sc, - const struct urndis_comp_hdr *hdr, const void **buf, uint16_t *bufsz) + const struct rndis_comp_hdr *hdr, const void **buf, uint16_t *bufsz) { - const struct urndis_query_comp *msg; + const struct rndis_query_comp *msg; uint64_t limit; - msg = (const struct urndis_query_comp *)hdr; + msg = (const struct rndis_query_comp *)hdr; DPRINTF("len %u rid %u status 0x%x " "buflen %u bufoff %u\n", @@ -608,12 +609,12 @@ urndis_ctrl_handle_query(struct urndis_s static uint32_t urndis_ctrl_handle_reset(struct urndis_softc *sc, - const struct urndis_comp_hdr *hdr) + const struct rndis_comp_hdr *hdr) { - const struct urndis_reset_comp *msg; + const struct rndis_reset_comp *msg; uint32_t rval; - msg = (const struct urndis_reset_comp *)hdr; + msg = (const struct rndis_reset_comp *)hdr; rval = le32toh(msg->rm_status); @@ -629,7 +630,7 @@ urndis_ctrl_handle_reset(struct urndis_s } if (msg->rm_adrreset != 0) { struct { - struct urndis_set_req hdr; + struct rndis_set_req hdr; uint32_t filter; } msg_filter; @@ -649,14 +650,14 @@ urndis_ctrl_handle_reset(struct urndis_s static uint32_t urndis_ctrl_init(struct urndis_softc *sc) { - struct urndis_init_req msg; - struct urndis_comp_hdr *hdr; + struct rndis_init_req msg; + struct rndis_comp_hdr *hdr; uint32_t rval; msg.rm_type = htole32(REMOTE_NDIS_INITIALIZE_MSG); msg.rm_len = htole32(sizeof(msg)); msg.rm_rid = 0; - msg.rm_ver_major = htole32(1); + msg.rm_ver_major = htole32(RNDIS_VERSION_MAJOR); msg.rm_ver_minor = htole32(1); msg.rm_max_xfersz = htole32(RNDIS_RX_MAXLEN); @@ -687,7 +688,7 @@ urndis_ctrl_init(struct urndis_softc *sc static uint32_t urndis_ctrl_halt(struct urndis_softc *sc) { - struct urndis_halt_req msg; + struct rndis_halt_req msg; uint32_t rval; msg.rm_type = htole32(REMOTE_NDIS_HALT_MSG); @@ -713,10 +714,10 @@ urndis_ctrl_halt(struct urndis_softc *sc */ static uint32_t urndis_ctrl_query(struct urndis_softc *sc, uint32_t oid, - struct urndis_query_req *msg, uint16_t len, const void **rbuf, + struct rndis_query_req *msg, uint16_t len, const void **rbuf, uint16_t *rbufsz) { - struct urndis_comp_hdr *hdr; + struct rndis_comp_hdr *hdr; uint32_t datalen, rval; msg->rm_type = htole32(REMOTE_NDIS_QUERY_MSG); @@ -760,9 +761,9 @@ urndis_ctrl_query(struct urndis_softc *s static uint32_t urndis_ctrl_set(struct urndis_softc *sc, uint32_t oid, - struct urndis_set_req *msg, uint16_t len) + struct rndis_set_req *msg, uint16_t len) { - struct urndis_comp_hdr *hdr; + struct rndis_comp_hdr *hdr; uint32_t datalen, rval; msg->rm_type = htole32(REMOTE_NDIS_SET_MSG); @@ -812,7 +813,7 @@ urndis_bulk_read_callback(struct usb_xfe struct urndis_softc *sc = usbd_xfer_softc(xfer); struct usb_page_cache *pc = usbd_xfer_get_frame(xfer, 0); struct ifnet *ifp = uether_getifp(&sc->sc_ue); - struct urndis_packet_msg msg; + struct rndis_packet_msg msg; struct mbuf *m; int actlen; int aframes; @@ -872,11 +873,11 @@ urndis_bulk_read_callback(struct usb_xfe "datalen %u\n", msg.rm_datalen, actlen); goto tr_setup; } else if ((msg.rm_dataoffset + msg.rm_datalen + - (uint32_t)__offsetof(struct urndis_packet_msg, + (uint32_t)__offsetof(struct rndis_packet_msg, rm_dataoffset)) > (uint32_t)actlen) { DPRINTF("invalid dataoffset %u larger than %u\n", msg.rm_dataoffset + msg.rm_datalen + - (uint32_t)__offsetof(struct urndis_packet_msg, + (uint32_t)__offsetof(struct rndis_packet_msg, rm_dataoffset), actlen); goto tr_setup; } else if (msg.rm_datalen < (uint32_t)sizeof(struct ether_header)) { @@ -902,7 +903,7 @@ urndis_bulk_read_callback(struct usb_xfe m_adj(m, ETHER_ALIGN); usbd_copy_out(pc, offset + msg.rm_dataoffset + - __offsetof(struct urndis_packet_msg, + __offsetof(struct rndis_packet_msg, rm_dataoffset), m->m_data, msg.rm_datalen); /* enqueue */ @@ -938,7 +939,7 @@ tr_setup: static void urndis_bulk_write_callback(struct usb_xfer *xfer, usb_error_t error) { - struct urndis_packet_msg msg; + struct rndis_packet_msg msg; struct urndis_softc *sc = usbd_xfer_softc(xfer); struct ifnet *ifp = uether_getifp(&sc->sc_ue); struct mbuf *m; Modified: stable/10/sys/dev/usb/net/if_urndisreg.h ============================================================================== --- stable/10/sys/dev/usb/net/if_urndisreg.h Thu Oct 13 03:16:15 2016 (r307174) +++ stable/10/sys/dev/usb/net/if_urndisreg.h Thu Oct 13 03:23:43 2016 (r307175) @@ -55,242 +55,4 @@ struct urndis_softc { #define URNDIS_UNLOCK(sc) mtx_unlock(&(sc)->sc_mtx) #define URNDIS_LOCK_ASSERT(sc, what) mtx_assert(&(sc)->sc_mtx, (what)) -#define RNDIS_STATUS_BUFFER_OVERFLOW 0x80000005L -#define RNDIS_STATUS_FAILURE 0xC0000001L -#define RNDIS_STATUS_INVALID_DATA 0xC0010015L -#define RNDIS_STATUS_MEDIA_CONNECT 0x4001000BL -#define RNDIS_STATUS_MEDIA_DISCONNECT 0x4001000CL -#define RNDIS_STATUS_NOT_SUPPORTED 0xC00000BBL -#define RNDIS_STATUS_PENDING STATUS_PENDING /* XXX */ -#define RNDIS_STATUS_RESOURCES 0xC000009AL -#define RNDIS_STATUS_SUCCESS 0x00000000L - -#define OID_GEN_SUPPORTED_LIST 0x00010101 -#define OID_GEN_HARDWARE_STATUS 0x00010102 -#define OID_GEN_MEDIA_SUPPORTED 0x00010103 -#define OID_GEN_MEDIA_IN_USE 0x00010104 -#define OID_GEN_MAXIMUM_LOOKAHEAD 0x00010105 -#define OID_GEN_MAXIMUM_FRAME_SIZE 0x00010106 -#define OID_GEN_LINK_SPEED 0x00010107 -#define OID_GEN_TRANSMIT_BUFFER_SPACE 0x00010108 -#define OID_GEN_RECEIVE_BUFFER_SPACE 0x00010109 -#define OID_GEN_TRANSMIT_BLOCK_SIZE 0x0001010A -#define OID_GEN_RECEIVE_BLOCK_SIZE 0x0001010B -#define OID_GEN_VENDOR_ID 0x0001010C -#define OID_GEN_VENDOR_DESCRIPTION 0x0001010D -#define OID_GEN_CURRENT_PACKET_FILTER 0x0001010E -#define OID_GEN_CURRENT_LOOKAHEAD 0x0001010F -#define OID_GEN_DRIVER_VERSION 0x00010110 -#define OID_GEN_MAXIMUM_TOTAL_SIZE 0x00010111 -#define OID_GEN_PROTOCOL_OPTIONS 0x00010112 -#define OID_GEN_MAC_OPTIONS 0x00010113 -#define OID_GEN_MEDIA_CONNECT_STATUS 0x00010114 -#define OID_GEN_MAXIMUM_SEND_PACKETS 0x00010115 -#define OID_GEN_VENDOR_DRIVER_VERSION 0x00010116 -#define OID_GEN_SUPPORTED_GUIDS 0x00010117 -#define OID_GEN_NETWORK_LAYER_ADDRESSES 0x00010118 -#define OID_GEN_TRANSPORT_HEADER_OFFSET 0x00010119 -#define OID_GEN_MACHINE_NAME 0x0001021A -#define OID_GEN_RNDIS_CONFIG_PARAMETER 0x0001021B -#define OID_GEN_VLAN_ID 0x0001021C - -#define OID_802_3_PERMANENT_ADDRESS 0x01010101 -#define OID_802_3_CURRENT_ADDRESS 0x01010102 -#define OID_802_3_MULTICAST_LIST 0x01010103 -#define OID_802_3_MAXIMUM_LIST_SIZE 0x01010104 -#define OID_802_3_MAC_OPTIONS 0x01010105 -#define OID_802_3_RCV_ERROR_ALIGNMENT 0x01020101 -#define OID_802_3_XMIT_ONE_COLLISION 0x01020102 -#define OID_802_3_XMIT_MORE_COLLISIONS 0x01020103 -#define OID_802_3_XMIT_DEFERRED 0x01020201 -#define OID_802_3_XMIT_MAX_COLLISIONS 0x01020202 -#define OID_802_3_RCV_OVERRUN 0x01020203 -#define OID_802_3_XMIT_UNDERRUN 0x01020204 -#define OID_802_3_XMIT_HEARTBEAT_FAILURE 0x01020205 -#define OID_802_3_XMIT_TIMES_CRS_LOST 0x01020206 -#define OID_802_3_XMIT_LATE_COLLISIONS 0x01020207 - -#define RNDIS_MEDIUM_802_3 0x00000000 - -/* Device flags */ -#define RNDIS_DF_CONNECTIONLESS 0x00000001 -#define RNDIS_DF_CONNECTION_ORIENTED 0x00000002 - -/* - * RNDIS data message - */ -#define REMOTE_NDIS_PACKET_MSG 0x00000001 - -struct urndis_packet_msg { - uint32_t rm_type; - uint32_t rm_len; - uint32_t rm_dataoffset; - uint32_t rm_datalen; - uint32_t rm_oobdataoffset; - uint32_t rm_oobdatalen; - uint32_t rm_oobdataelements; - uint32_t rm_pktinfooffset; - uint32_t rm_pktinfolen; - uint32_t rm_vchandle; - uint32_t rm_reserved; -}; - -/* - * RNDIS control messages - */ -struct urndis_comp_hdr { - uint32_t rm_type; - uint32_t rm_len; - uint32_t rm_rid; - uint32_t rm_status; -}; - -/* Initialize the device. */ -#define REMOTE_NDIS_INITIALIZE_MSG 0x00000002 -#define REMOTE_NDIS_INITIALIZE_CMPLT 0x80000002 - -struct urndis_init_req { - uint32_t rm_type; - uint32_t rm_len; - uint32_t rm_rid; - uint32_t rm_ver_major; - uint32_t rm_ver_minor; - uint32_t rm_max_xfersz; -}; - -struct urndis_init_comp { - uint32_t rm_type; - uint32_t rm_len; - uint32_t rm_rid; - uint32_t rm_status; - uint32_t rm_ver_major; - uint32_t rm_ver_minor; - uint32_t rm_devflags; - uint32_t rm_medium; - uint32_t rm_pktmaxcnt; - uint32_t rm_pktmaxsz; - uint32_t rm_align; - uint32_t rm_aflistoffset; - uint32_t rm_aflistsz; -}; - -/* Halt the device. No response sent. */ -#define REMOTE_NDIS_HALT_MSG 0x00000003 - -struct urndis_halt_req { - uint32_t rm_type; - uint32_t rm_len; - uint32_t rm_rid; -}; - -/* Send a query object. */ -#define REMOTE_NDIS_QUERY_MSG 0x00000004 -#define REMOTE_NDIS_QUERY_CMPLT 0x80000004 - -struct urndis_query_req { - uint32_t rm_type; - uint32_t rm_len; - uint32_t rm_rid; - uint32_t rm_oid; - uint32_t rm_infobuflen; - uint32_t rm_infobufoffset; - uint32_t rm_devicevchdl; -}; - -struct urndis_query_comp { - uint32_t rm_type; - uint32_t rm_len; - uint32_t rm_rid; - uint32_t rm_status; - uint32_t rm_infobuflen; - uint32_t rm_infobufoffset; -}; - -/* Send a set object request. */ -#define REMOTE_NDIS_SET_MSG 0x00000005 -#define REMOTE_NDIS_SET_CMPLT 0x80000005 - -struct urndis_set_req { - uint32_t rm_type; - uint32_t rm_len; - uint32_t rm_rid; - uint32_t rm_oid; - uint32_t rm_infobuflen; - uint32_t rm_infobufoffset; - uint32_t rm_devicevchdl; -}; - -struct urndis_set_comp { - uint32_t rm_type; - uint32_t rm_len; - uint32_t rm_rid; - uint32_t rm_status; -}; - -#define REMOTE_NDIS_SET_PARAM_NUMERIC 0x00000000 -#define REMOTE_NDIS_SET_PARAM_STRING 0x00000002 - -struct urndis_set_parameter { - uint32_t rm_nameoffset; - uint32_t rm_namelen; - uint32_t rm_type; - uint32_t rm_valueoffset; - uint32_t rm_valuelen; -}; - -/* Perform a soft reset on the device. */ -#define REMOTE_NDIS_RESET_MSG 0x00000006 -#define REMOTE_NDIS_RESET_CMPLT 0x80000006 - -struct urndis_reset_req { - uint32_t rm_type; - uint32_t rm_len; - uint32_t rm_rid; -}; - -struct urndis_reset_comp { - uint32_t rm_type; - uint32_t rm_len; - uint32_t rm_status; - uint32_t rm_adrreset; -}; - -/* 802.3 link-state or undefined message error. */ -#define REMOTE_NDIS_INDICATE_STATUS_MSG 0x00000007 - -/* Keepalive messsage. May be sent by device. */ -#define REMOTE_NDIS_KEEPALIVE_MSG 0x00000008 -#define REMOTE_NDIS_KEEPALIVE_CMPLT 0x80000008 - -struct urndis_keepalive_req { - uint32_t rm_type; - uint32_t rm_len; - uint32_t rm_rid; -}; - -struct urndis_keepalive_comp { - uint32_t rm_type; - uint32_t rm_len; - uint32_t rm_rid; - uint32_t rm_status; -}; - -/* packet filter bits used by OID_GEN_CURRENT_PACKET_FILTER */ -#define RNDIS_PACKET_TYPE_DIRECTED 0x00000001 -#define RNDIS_PACKET_TYPE_MULTICAST 0x00000002 -#define RNDIS_PACKET_TYPE_ALL_MULTICAST 0x00000004 -#define RNDIS_PACKET_TYPE_BROADCAST 0x00000008 -#define RNDIS_PACKET_TYPE_SOURCE_ROUTING 0x00000010 -#define RNDIS_PACKET_TYPE_PROMISCUOUS 0x00000020 -#define RNDIS_PACKET_TYPE_SMT 0x00000040 -#define RNDIS_PACKET_TYPE_ALL_LOCAL 0x00000080 -#define RNDIS_PACKET_TYPE_GROUP 0x00001000 -#define RNDIS_PACKET_TYPE_ALL_FUNCTIONAL 0x00002000 -#define RNDIS_PACKET_TYPE_FUNCTIONAL 0x00004000 -#define RNDIS_PACKET_TYPE_MAC_FRAME 0x00008000 - -/* RNDIS offsets */ -#define RNDIS_HEADER_OFFSET 8 /* bytes */ -#define RNDIS_DATA_OFFSET ((uint32_t)(sizeof(struct urndis_packet_msg) - RNDIS_HEADER_OFFSET)) - #endif /* _IF_URNDISREG_H_ */ Copied and modified: stable/10/sys/net/rndis.h (from r304654, head/sys/net/rndis.h) ============================================================================== --- head/sys/net/rndis.h Tue Aug 23 02:54:06 2016 (r304654, copy source) +++ stable/10/sys/net/rndis.h Thu Oct 13 03:23:43 2016 (r307175) @@ -23,15 +23,19 @@ #ifndef _NET_RNDIS_H_ #define _NET_RNDIS_H_ -#define RNDIS_STATUS_BUFFER_OVERFLOW 0x80000005L -#define RNDIS_STATUS_FAILURE 0xC0000001L -#define RNDIS_STATUS_INVALID_DATA 0xC0010015L +/* Canonical major/minor version as of 22th Aug. 2016. */ +#define RNDIS_VERSION_MAJOR 0x00000001 +#define RNDIS_VERSION_MINOR 0x00000000 + +#define RNDIS_STATUS_SUCCESS 0x00000000L +#define RNDIS_STATUS_PENDING 0x00000103L #define RNDIS_STATUS_MEDIA_CONNECT 0x4001000BL #define RNDIS_STATUS_MEDIA_DISCONNECT 0x4001000CL +#define RNDIS_STATUS_BUFFER_OVERFLOW 0x80000005L +#define RNDIS_STATUS_FAILURE 0xC0000001L #define RNDIS_STATUS_NOT_SUPPORTED 0xC00000BBL -#define RNDIS_STATUS_PENDING STATUS_PENDING /* XXX */ #define RNDIS_STATUS_RESOURCES 0xC000009AL -#define RNDIS_STATUS_SUCCESS 0x00000000L +#define RNDIS_STATUS_INVALID_DATA 0xC0010015L #define OID_GEN_SUPPORTED_LIST 0x00010101 #define OID_GEN_HARDWARE_STATUS 0x00010102 From owner-svn-src-all@freebsd.org Thu Oct 13 04:24:35 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A5C89C0F77D; Thu, 13 Oct 2016 04:24:35 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 7F35FD27; Thu, 13 Oct 2016 04:24:35 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9D4OYkS046778; Thu, 13 Oct 2016 04:24:34 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9D4OY4b046777; Thu, 13 Oct 2016 04:24:34 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610130424.u9D4OY4b046777@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Thu, 13 Oct 2016 04:24:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307176 - stable/10/sys/dev/hyperv/netvsc X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Oct 2016 04:24:35 -0000 Author: sephe Date: Thu Oct 13 04:24:34 2016 New Revision: 307176 URL: https://svnweb.freebsd.org/changeset/base/307176 Log: MFC 304724,304728 304724 hyperv/hn: Remove the redundant rid setting for RNDIS HALT. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7595 304728 hyperv/hn: Log a warning for RESET_CMPLT. RESET is not used by the hn(4) at all, and RESET_CMPLT does not even have a rid to match with the pending requests. So, let's put it onto an independent switch branch and log a warning about it. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7602 Modified: stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.c Thu Oct 13 03:23:43 2016 (r307175) +++ stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.c Thu Oct 13 04:24:34 2016 (r307176) @@ -325,16 +325,9 @@ hv_rf_receive_response(rndis_device *dev memcpy(&request->response_msg, response, response->msg_len); } else { - if (response->ndis_msg_type == REMOTE_NDIS_RESET_CMPLT) { - /* Does not have a request id field */ - request->response_msg.msg.reset_complete.status = - STATUS_BUFFER_OVERFLOW; - } else { - request->response_msg.msg.init_complete.status = - STATUS_BUFFER_OVERFLOW; - } + request->response_msg.msg.init_complete.status = + STATUS_BUFFER_OVERFLOW; } - sema_post(&request->wait_sema); } } @@ -567,29 +560,40 @@ hv_rf_on_receive(struct hn_softc *sc, st rndis_hdr = data; switch (rndis_hdr->ndis_msg_type) { - /* data message */ case REMOTE_NDIS_PACKET_MSG: hv_rf_receive_data(rxr, data, dlen); break; + /* completion messages */ case REMOTE_NDIS_INITIALIZE_CMPLT: case REMOTE_NDIS_QUERY_CMPLT: case REMOTE_NDIS_SET_CMPLT: - case REMOTE_NDIS_RESET_CMPLT: case REMOTE_NDIS_KEEPALIVE_CMPLT: hv_rf_receive_response(rndis_dev, rndis_hdr); break; + /* notification message */ case REMOTE_NDIS_INDICATE_STATUS_MSG: hv_rf_receive_indicate_status(rndis_dev, rndis_hdr); break; + + case REMOTE_NDIS_RESET_CMPLT: + /* + * Reset completed, no rid. + * + * NOTE: + * RESET is not issued by hn(4), so this message should + * _not_ be observed. + */ + if_printf(sc->hn_ifp, "RESET CMPLT received\n"); + break; + default: - printf("hv_rf_on_receive(): Unknown msg_type 0x%x\n", + if_printf(sc->hn_ifp, "unknown RNDIS message 0x%x\n", rndis_hdr->ndis_msg_type); break; } - return (0); } @@ -929,7 +933,6 @@ static int hv_rf_halt_device(rndis_device *device) { rndis_request *request; - rndis_halt_request *halt; int i, ret; /* Attempt to do a rndis device halt */ @@ -942,12 +945,6 @@ hv_rf_halt_device(rndis_device *device) /* initialize "poor man's semaphore" */ request->halt_complete_flag = 0; - /* Set up the rndis set */ - halt = &request->request_msg.msg.halt_request; - halt->request_id = atomic_fetchadd_int(&device->new_request_id, 1); - /* Increment to get the new value (call above returns old value) */ - halt->request_id += 1; - ret = hv_rf_send_request(device, request, REMOTE_NDIS_HALT_MSG); if (ret != 0) { return (-1); From owner-svn-src-all@freebsd.org Thu Oct 13 04:32:57 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 526ADC0F907; Thu, 13 Oct 2016 04:32:57 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 1008C126; Thu, 13 Oct 2016 04:32:56 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9D4WuRJ050592; Thu, 13 Oct 2016 04:32:56 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9D4WtqT050586; Thu, 13 Oct 2016 04:32:55 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610130432.u9D4WtqT050586@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Thu, 13 Oct 2016 04:32:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307177 - stable/10/sys/dev/hyperv/utilities X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Oct 2016 04:32:57 -0000 Author: sephe Date: Thu Oct 13 04:32:55 2016 New Revision: 307177 URL: https://svnweb.freebsd.org/changeset/base/307177 Log: MFC 304730 hyperv/ic: Redefine IC version negotiate message. And stringent input IC version negotiate message checks. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7614 Added: stable/10/sys/dev/hyperv/utilities/vmbus_icreg.h - copied unchanged from r304730, head/sys/dev/hyperv/utilities/vmbus_icreg.h Modified: stable/10/sys/dev/hyperv/utilities/hv_heartbeat.c stable/10/sys/dev/hyperv/utilities/hv_shutdown.c stable/10/sys/dev/hyperv/utilities/hv_timesync.c stable/10/sys/dev/hyperv/utilities/hv_util.c stable/10/sys/dev/hyperv/utilities/hv_util.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/hyperv/utilities/hv_heartbeat.c ============================================================================== --- stable/10/sys/dev/hyperv/utilities/hv_heartbeat.c Thu Oct 13 04:24:34 2016 (r307176) +++ stable/10/sys/dev/hyperv/utilities/hv_heartbeat.c Thu Oct 13 04:32:55 2016 (r307177) @@ -80,7 +80,11 @@ hv_heartbeat_cb(struct vmbus_channel *ch &buf[sizeof(struct hv_vmbus_pipe_hdr)]; if (icmsghdrp->icmsgtype == HV_ICMSGTYPE_NEGOTIATE) { - hv_negotiate_version(icmsghdrp, buf); + int error; + + error = vmbus_ic_negomsg(softc, buf, recvlen); + if (error) + return; } else { heartbeat_msg = (struct hv_vmbus_heartbeat_msg_data *) Modified: stable/10/sys/dev/hyperv/utilities/hv_shutdown.c ============================================================================== --- stable/10/sys/dev/hyperv/utilities/hv_shutdown.c Thu Oct 13 04:24:34 2016 (r307176) +++ stable/10/sys/dev/hyperv/utilities/hv_shutdown.c Thu Oct 13 04:32:55 2016 (r307177) @@ -85,7 +85,11 @@ hv_shutdown_cb(struct vmbus_channel *cha &buf[sizeof(struct hv_vmbus_pipe_hdr)]; if (icmsghdrp->icmsgtype == HV_ICMSGTYPE_NEGOTIATE) { - hv_negotiate_version(icmsghdrp, buf); + int error; + + error = vmbus_ic_negomsg(softc, buf, recv_len); + if (error) + return; } else { shutdown_msg = (struct hv_vmbus_shutdown_msg_data *) Modified: stable/10/sys/dev/hyperv/utilities/hv_timesync.c ============================================================================== --- stable/10/sys/dev/hyperv/utilities/hv_timesync.c Thu Oct 13 04:24:34 2016 (r307176) +++ stable/10/sys/dev/hyperv/utilities/hv_timesync.c Thu Oct 13 04:32:55 2016 (r307177) @@ -160,7 +160,11 @@ hv_timesync_cb(struct vmbus_channel *cha sizeof(struct hv_vmbus_pipe_hdr)]; if (icmsghdrp->icmsgtype == HV_ICMSGTYPE_NEGOTIATE) { - hv_negotiate_version(icmsghdrp, time_buf); + int error; + + error = vmbus_ic_negomsg(&softc->util_sc, time_buf, recvlen); + if (error) + return; } else { timedatap = (struct hv_ictimesync_data *) &time_buf[ sizeof(struct hv_vmbus_pipe_hdr) + Modified: stable/10/sys/dev/hyperv/utilities/hv_util.c ============================================================================== --- stable/10/sys/dev/hyperv/utilities/hv_util.c Thu Oct 13 04:24:34 2016 (r307176) +++ stable/10/sys/dev/hyperv/utilities/hv_util.c Thu Oct 13 04:32:55 2016 (r307177) @@ -36,44 +36,62 @@ #include #include #include +#include #include -#include #include #include -#include #include +#include #include "vmbus_if.h" #define VMBUS_IC_BRSIZE (4 * PAGE_SIZE) -void -hv_negotiate_version(struct hv_vmbus_icmsg_hdr *icmsghdrp, uint8_t *buf) +CTASSERT(sizeof(struct vmbus_icmsg_negotiate) < VMBUS_IC_BRSIZE); + +int +vmbus_ic_negomsg(struct hv_util_sc *sc, void *data, int dlen) { - struct hv_vmbus_icmsg_negotiate *negop; + struct vmbus_icmsg_negotiate *nego; + int cnt, major; - icmsghdrp->icmsgsize = 0x10; + /* + * Preliminary message size verification + */ + if (dlen < sizeof(*nego)) { + device_printf(sc->ic_dev, "truncated ic negotiate, len %d\n", + dlen); + return EINVAL; + } + nego = data; - negop = (struct hv_vmbus_icmsg_negotiate *)&buf[ - sizeof(struct hv_vmbus_pipe_hdr) + - sizeof(struct hv_vmbus_icmsg_hdr)]; - - if (negop->icframe_vercnt >= 2 && - negop->icversion_data[1].major == 3) { - negop->icversion_data[0].major = 3; - negop->icversion_data[0].minor = 0; - negop->icversion_data[1].major = 3; - negop->icversion_data[1].minor = 0; - } else { - negop->icversion_data[0].major = 1; - negop->icversion_data[0].minor = 0; - negop->icversion_data[1].major = 1; - negop->icversion_data[1].minor = 0; + cnt = nego->ic_fwver_cnt + nego->ic_msgver_cnt; + if (dlen < __offsetof(struct vmbus_icmsg_negotiate, ic_ver[cnt])) { + device_printf(sc->ic_dev, "ic negotiate does not contain " + "versions %d\n", dlen); + return EINVAL; } - negop->icframe_vercnt = 1; - negop->icmsg_vercnt = 1; + /* Select major version; XXX looks wrong. */ + if (nego->ic_fwver_cnt >= 2 && VMBUS_ICVER_MAJOR(nego->ic_ver[1]) == 3) + major = 3; + else + major = 1; + + /* One framework version */ + nego->ic_fwver_cnt = 1; + nego->ic_ver[0] = VMBUS_IC_VERSION(major, 0); + + /* One message version */ + nego->ic_msgver_cnt = 1; + nego->ic_ver[1] = VMBUS_IC_VERSION(major, 0); + + /* Data contains two versions */ + nego->ic_hdr.ic_dsize = __offsetof(struct vmbus_icmsg_negotiate, + ic_ver[2]) - sizeof(struct vmbus_icmsg_hdr); + + return 0; } int @@ -101,6 +119,7 @@ hv_util_attach(device_t dev, vmbus_chan_ struct vmbus_channel *chan = vmbus_get_channel(dev); int error; + sc->ic_dev = dev; sc->ic_buflen = VMBUS_IC_BRSIZE; sc->receive_buffer = malloc(VMBUS_IC_BRSIZE, M_DEVBUF, M_WAITOK | M_ZERO); Modified: stable/10/sys/dev/hyperv/utilities/hv_util.h ============================================================================== --- stable/10/sys/dev/hyperv/utilities/hv_util.h Thu Oct 13 04:24:34 2016 (r307176) +++ stable/10/sys/dev/hyperv/utilities/hv_util.h Thu Oct 13 04:32:55 2016 (r307177) @@ -39,6 +39,7 @@ * */ typedef struct hv_util_sc { + device_t ic_dev; uint8_t *receive_buffer; int ic_buflen; } hv_util_sc; @@ -50,10 +51,9 @@ struct vmbus_ic_desc { #define VMBUS_IC_DESC_END { .ic_desc = NULL } -void hv_negotiate_version(struct hv_vmbus_icmsg_hdr *icmsghdrp, uint8_t *buf); - int hv_util_attach(device_t dev, vmbus_chan_callback_t cb); int hv_util_detach(device_t dev); int vmbus_ic_probe(device_t dev, const struct vmbus_ic_desc descs[]); +int vmbus_ic_negomsg(struct hv_util_sc *, void *data, int dlen); #endif Copied: stable/10/sys/dev/hyperv/utilities/vmbus_icreg.h (from r304730, head/sys/dev/hyperv/utilities/vmbus_icreg.h) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/10/sys/dev/hyperv/utilities/vmbus_icreg.h Thu Oct 13 04:32:55 2016 (r307177, copy of r304730, head/sys/dev/hyperv/utilities/vmbus_icreg.h) @@ -0,0 +1,84 @@ +/*- + * Copyright (c) 2016 Microsoft Corp. + * 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 unmodified, 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 ``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 BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#ifndef _VMBUS_ICREG_H_ +#define _VMBUS_ICREG_H_ + +#define VMBUS_ICMSG_TYPE_NEGOTIATE 0 +#define VMBUS_ICMSG_TYPE_HEARTBEAT 1 +#define VMBUS_ICMSG_TYPE_KVP 2 +#define VMBUS_ICMSG_TYPE_SHUTDOWN 3 +#define VMBUS_ICMSG_TYPE_TIMESYNC 4 +#define VMBUS_ICMSG_TYPE_VSS 5 + +#define VMBUS_ICMSG_STATUS_OK 0x00000000 +#define VMBUS_ICMSG_STATUS_FAIL 0x80004005 + +#define VMBUS_IC_VERSION(major, minor) ((major) | (((uint32_t)(minor)) << 16)) +#define VMBUS_ICVER_MAJOR(ver) ((ver) & 0xffff) +#define VMBUS_ICVER_MINOR(ver) (((ver) & 0xffff0000) >> 16) + +struct vmbus_pipe_hdr { + uint32_t ph_flags; + uint32_t ph_msgsz; +} __packed; + +struct vmbus_icmsg_hdr { + struct vmbus_pipe_hdr ic_pipe; + uint32_t ic_fwver; /* framework version */ + uint16_t ic_type; + uint32_t ic_msgver; /* message version */ + uint16_t ic_dsize; /* data size */ + uint32_t ic_status; /* VMBUS_ICMSG_STATUS_ */ + uint8_t ic_xactid; + uint8_t ic_flags; /* VMBUS_ICMSG_FLAG_ */ + uint8_t ic_rsvd[2]; +} __packed; + +#define VMBUS_ICMSG_FLAG_XACT 0x0001 +#define VMBUS_ICMSG_FLAG_REQ 0x0002 +#define VMBUS_ICMSG_FLAG_RESP 0x0004 + +/* VMBUS_ICMSG_TYPE_NEGOTIATE */ +struct vmbus_icmsg_negotiate { + struct vmbus_icmsg_hdr ic_hdr; + uint16_t ic_fwver_cnt; + uint16_t ic_msgver_cnt; + uint32_t ic_rsvd; + /* + * This version array contains two set of supported + * versions: + * - The first set consists of #ic_fwver_cnt supported framework + * versions. + * - The second set consists of #ic_msgver_cnt supported message + * versions. + */ + uint32_t ic_ver[]; +} __packed; + +#endif /* !_VMBUS_ICREG_H_ */ From owner-svn-src-all@freebsd.org Thu Oct 13 05:20:33 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 0D416C0F245; Thu, 13 Oct 2016 05:20:33 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id CEB892CC; Thu, 13 Oct 2016 05:20:32 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9D5KWuF065857; Thu, 13 Oct 2016 05:20:32 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9D5KVc5065850; Thu, 13 Oct 2016 05:20:31 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610130520.u9D5KVc5065850@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Thu, 13 Oct 2016 05:20:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307178 - in stable/10/sys: dev/hyperv/netvsc net X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Oct 2016 05:20:33 -0000 Author: sephe Date: Thu Oct 13 05:20:31 2016 New Revision: 307178 URL: https://svnweb.freebsd.org/changeset/base/307178 Log: MFC 304783-304785 304783 hyperv/hn: Use definition in net/rndis.h for message type and status code. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7620 304784 hyperv/hn: Add compat code for RNDIS reorganization phase. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7621 304785 hyperv/hn: Use vmbus xact for RNDIS initialize. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7624 Modified: stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.c stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c stable/10/sys/dev/hyperv/netvsc/hv_rndis.h stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.c stable/10/sys/dev/hyperv/netvsc/if_hnvar.h stable/10/sys/net/rndis.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.c Thu Oct 13 04:32:55 2016 (r307177) +++ stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.c Thu Oct 13 05:20:31 2016 (r307178) @@ -76,7 +76,7 @@ static void hn_nvs_sent_none(struct hn_s static void hn_nvs_sent_xact(struct hn_send_ctx *, struct hn_softc *sc, struct vmbus_channel *, const void *, int); -static struct hn_send_ctx hn_send_ctx_none = +struct hn_send_ctx hn_send_ctx_none = HN_SEND_CTX_INITIALIZER(hn_nvs_sent_none, NULL); uint32_t Modified: stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h Thu Oct 13 04:32:55 2016 (r307177) +++ stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h Thu Oct 13 05:20:31 2016 (r307178) @@ -239,6 +239,11 @@ typedef struct { uint8_t link_state; } netvsc_device_info; +#define HN_XACT_REQ_PGCNT 2 +#define HN_XACT_RESP_PGCNT 2 +#define HN_XACT_REQ_SIZE (HN_XACT_REQ_PGCNT * PAGE_SIZE) +#define HN_XACT_RESP_SIZE (HN_XACT_RESP_PGCNT * PAGE_SIZE) + #ifndef HN_USE_TXDESC_BUFRING struct hn_txdesc; SLIST_HEAD(hn_txdesc_list, hn_txdesc); @@ -376,6 +381,8 @@ typedef struct hn_softc { uint32_t hn_chim_gpadl; struct hyperv_dma hn_chim_dma; + + uint32_t hn_rndis_rid; } hn_softc_t; #define HN_FLAG_RXBUF_CONNECTED 0x0001 Modified: stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Thu Oct 13 04:32:55 2016 (r307177) +++ stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Thu Oct 13 05:20:31 2016 (r307178) @@ -127,9 +127,6 @@ __FBSDID("$FreeBSD$"); /* Short for Hyper-V network interface */ #define NETVSC_DEVNAME "hn" -#define HN_XACT_REQ_SIZE (2 * PAGE_SIZE) -#define HN_XACT_RESP_SIZE (2 * PAGE_SIZE) - /* * It looks like offset 0 of buf is reserved to hold the softc pointer. * The sc pointer evidently not needed, and is not presently populated. Modified: stable/10/sys/dev/hyperv/netvsc/hv_rndis.h ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_rndis.h Thu Oct 13 04:32:55 2016 (r307177) +++ stable/10/sys/dev/hyperv/netvsc/hv_rndis.h Thu Oct 13 05:20:31 2016 (r307178) @@ -31,6 +31,7 @@ #ifndef __HV_RNDIS_H__ #define __HV_RNDIS_H__ +#include /* * NDIS protocol version numbers @@ -48,95 +49,6 @@ #define NDIS_VERSION (NDIS_VERSION_5_1) /* - * Status codes - */ - -#define STATUS_SUCCESS (0x00000000L) -#define STATUS_UNSUCCESSFUL (0xC0000001L) -#define STATUS_PENDING (0x00000103L) -#define STATUS_INSUFFICIENT_RESOURCES (0xC000009AL) -#define STATUS_BUFFER_OVERFLOW (0x80000005L) -#define STATUS_NOT_SUPPORTED (0xC00000BBL) - -#define RNDIS_STATUS_SUCCESS (STATUS_SUCCESS) -#define RNDIS_STATUS_PENDING (STATUS_PENDING) -#define RNDIS_STATUS_NOT_RECOGNIZED (0x00010001L) -#define RNDIS_STATUS_NOT_COPIED (0x00010002L) -#define RNDIS_STATUS_NOT_ACCEPTED (0x00010003L) -#define RNDIS_STATUS_CALL_ACTIVE (0x00010007L) - -#define RNDIS_STATUS_ONLINE (0x40010003L) -#define RNDIS_STATUS_RESET_START (0x40010004L) -#define RNDIS_STATUS_RESET_END (0x40010005L) -#define RNDIS_STATUS_RING_STATUS (0x40010006L) -#define RNDIS_STATUS_CLOSED (0x40010007L) -#define RNDIS_STATUS_WAN_LINE_UP (0x40010008L) -#define RNDIS_STATUS_WAN_LINE_DOWN (0x40010009L) -#define RNDIS_STATUS_WAN_FRAGMENT (0x4001000AL) -#define RNDIS_STATUS_MEDIA_CONNECT (0x4001000BL) -#define RNDIS_STATUS_MEDIA_DISCONNECT (0x4001000CL) -#define RNDIS_STATUS_HARDWARE_LINE_UP (0x4001000DL) -#define RNDIS_STATUS_HARDWARE_LINE_DOWN (0x4001000EL) -#define RNDIS_STATUS_INTERFACE_UP (0x4001000FL) -#define RNDIS_STATUS_INTERFACE_DOWN (0x40010010L) -#define RNDIS_STATUS_MEDIA_BUSY (0x40010011L) -#define RNDIS_STATUS_MEDIA_SPECIFIC_INDICATION (0x40010012L) -#define RNDIS_STATUS_WW_INDICATION RNDIS_STATUS_MEDIA_SPECIFIC_INDICATION -#define RNDIS_STATUS_LINK_SPEED_CHANGE (0x40010013L) - -#define RNDIS_STATUS_NOT_RESETTABLE (0x80010001L) -#define RNDIS_STATUS_SOFT_ERRORS (0x80010003L) -#define RNDIS_STATUS_HARD_ERRORS (0x80010004L) -#define RNDIS_STATUS_BUFFER_OVERFLOW (STATUS_BUFFER_OVERFLOW) - -#define RNDIS_STATUS_FAILURE (STATUS_UNSUCCESSFUL) -#define RNDIS_STATUS_RESOURCES (STATUS_INSUFFICIENT_RESOURCES) -#define RNDIS_STATUS_CLOSING (0xC0010002L) -#define RNDIS_STATUS_BAD_VERSION (0xC0010004L) -#define RNDIS_STATUS_BAD_CHARACTERISTICS (0xC0010005L) -#define RNDIS_STATUS_ADAPTER_NOT_FOUND (0xC0010006L) -#define RNDIS_STATUS_OPEN_FAILED (0xC0010007L) -#define RNDIS_STATUS_DEVICE_FAILED (0xC0010008L) -#define RNDIS_STATUS_MULTICAST_FULL (0xC0010009L) -#define RNDIS_STATUS_MULTICAST_EXISTS (0xC001000AL) -#define RNDIS_STATUS_MULTICAST_NOT_FOUND (0xC001000BL) -#define RNDIS_STATUS_REQUEST_ABORTED (0xC001000CL) -#define RNDIS_STATUS_RESET_IN_PROGRESS (0xC001000DL) -#define RNDIS_STATUS_CLOSING_INDICATING (0xC001000EL) -#define RNDIS_STATUS_NOT_SUPPORTED (STATUS_NOT_SUPPORTED) -#define RNDIS_STATUS_INVALID_PACKET (0xC001000FL) -#define RNDIS_STATUS_OPEN_LIST_FULL (0xC0010010L) -#define RNDIS_STATUS_ADAPTER_NOT_READY (0xC0010011L) -#define RNDIS_STATUS_ADAPTER_NOT_OPEN (0xC0010012L) -#define RNDIS_STATUS_NOT_INDICATING (0xC0010013L) -#define RNDIS_STATUS_INVALID_LENGTH (0xC0010014L) -#define RNDIS_STATUS_INVALID_DATA (0xC0010015L) -#define RNDIS_STATUS_BUFFER_TOO_SHORT (0xC0010016L) -#define RNDIS_STATUS_INVALID_OID (0xC0010017L) -#define RNDIS_STATUS_ADAPTER_REMOVED (0xC0010018L) -#define RNDIS_STATUS_UNSUPPORTED_MEDIA (0xC0010019L) -#define RNDIS_STATUS_GROUP_ADDRESS_IN_USE (0xC001001AL) -#define RNDIS_STATUS_FILE_NOT_FOUND (0xC001001BL) -#define RNDIS_STATUS_ERROR_READING_FILE (0xC001001CL) -#define RNDIS_STATUS_ALREADY_MAPPED (0xC001001DL) -#define RNDIS_STATUS_RESOURCE_CONFLICT (0xC001001EL) -#define RNDIS_STATUS_NO_CABLE (0xC001001FL) - -#define RNDIS_STATUS_INVALID_SAP (0xC0010020L) -#define RNDIS_STATUS_SAP_IN_USE (0xC0010021L) -#define RNDIS_STATUS_INVALID_ADDRESS (0xC0010022L) -#define RNDIS_STATUS_VC_NOT_ACTIVATED (0xC0010023L) -#define RNDIS_STATUS_DEST_OUT_OF_ORDER (0xC0010024L) -#define RNDIS_STATUS_VC_NOT_AVAILABLE (0xC0010025L) -#define RNDIS_STATUS_CELLRATE_NOT_AVAILABLE (0xC0010026L) -#define RNDIS_STATUS_INCOMPATABLE_QOS (0xC0010027L) -#define RNDIS_STATUS_AAL_PARAMS_UNSUPPORTED (0xC0010028L) -#define RNDIS_STATUS_NO_ROUTE_TO_DESTINATION (0xC0010029L) - -#define RNDIS_STATUS_TOKEN_RING_OPEN_ERROR (0xC0011000L) - - -/* * Object Identifiers used by NdisRequest Query/Set Information */ @@ -289,82 +201,6 @@ */ #define OID_RNDISMP_GET_RECEIVE_BUFFERS 0xFFA0C90D // Query only - -/* - * Remote NDIS message types - */ -#define REMOTE_NDIS_PACKET_MSG 0x00000001 -#define REMOTE_NDIS_INITIALIZE_MSG 0x00000002 -#define REMOTE_NDIS_HALT_MSG 0x00000003 -#define REMOTE_NDIS_QUERY_MSG 0x00000004 -#define REMOTE_NDIS_SET_MSG 0x00000005 -#define REMOTE_NDIS_RESET_MSG 0x00000006 -#define REMOTE_NDIS_INDICATE_STATUS_MSG 0x00000007 -#define REMOTE_NDIS_KEEPALIVE_MSG 0x00000008 - -#define REMOTE_CONDIS_MP_CREATE_VC_MSG 0x00008001 -#define REMOTE_CONDIS_MP_DELETE_VC_MSG 0x00008002 -#define REMOTE_CONDIS_MP_ACTIVATE_VC_MSG 0x00008005 -#define REMOTE_CONDIS_MP_DEACTIVATE_VC_MSG 0x00008006 -#define REMOTE_CONDIS_INDICATE_STATUS_MSG 0x00008007 - -/* - * Remote NDIS message completion types - */ -#define REMOTE_NDIS_INITIALIZE_CMPLT 0x80000002 -#define REMOTE_NDIS_QUERY_CMPLT 0x80000004 -#define REMOTE_NDIS_SET_CMPLT 0x80000005 -#define REMOTE_NDIS_RESET_CMPLT 0x80000006 -#define REMOTE_NDIS_KEEPALIVE_CMPLT 0x80000008 - -#define REMOTE_CONDIS_MP_CREATE_VC_CMPLT 0x80008001 -#define REMOTE_CONDIS_MP_DELETE_VC_CMPLT 0x80008002 -#define REMOTE_CONDIS_MP_ACTIVATE_VC_CMPLT 0x80008005 -#define REMOTE_CONDIS_MP_DEACTIVATE_VC_CMPLT 0x80008006 - -/* - * Reserved message type for private communication between lower-layer - * host driver and remote device, if necessary. - */ -#define REMOTE_NDIS_BUS_MSG 0xff000001 - -/* - * Defines for DeviceFlags in rndis_initialize_complete - */ -#define RNDIS_DF_CONNECTIONLESS 0x00000001 -#define RNDIS_DF_CONNECTION_ORIENTED 0x00000002 -#define RNDIS_DF_RAW_DATA 0x00000004 - -/* - * Remote NDIS medium types. - */ -#define RNDIS_MEDIUM_802_3 0x00000000 -#define RNDIS_MEDIUM_802_5 0x00000001 -#define RNDIS_MEDIUM_FDDI 0x00000002 -#define RNDIS_MEDIUM_WAN 0x00000003 -#define RNDIS_MEDIUM_LOCAL_TALK 0x00000004 -#define RNDIS_MEDIUM_ARCNET_RAW 0x00000006 -#define RNDIS_MEDIUM_ARCNET_878_2 0x00000007 -#define RNDIS_MEDIUM_ATM 0x00000008 -#define RNDIS_MEDIUM_WIRELESS_WAN 0x00000009 -#define RNDIS_MEDIUM_IRDA 0x0000000a -#define RNDIS_MEDIUM_CO_WAN 0x0000000b -/* Not a real medium, defined as an upper bound */ -#define RNDIS_MEDIUM_MAX 0x0000000d - -/* - * Remote NDIS medium connection states. - */ -#define RNDIS_MEDIA_STATE_CONNECTED 0x00000000 -#define RNDIS_MEDIA_STATE_DISCONNECTED 0x00000001 - -/* - * Remote NDIS version numbers - */ -#define RNDIS_MAJOR_VERSION 0x00000001 -#define RNDIS_MINOR_VERSION 0x00000000 - - /* * Remote NDIS offload parameters */ Modified: stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.c Thu Oct 13 04:32:55 2016 (r307177) +++ stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.c Thu Oct 13 05:20:31 2016 (r307178) @@ -63,6 +63,11 @@ __FBSDID("$FreeBSD$"); HV_RF_RECVINFO_HASHINF | \ HV_RF_RECVINFO_HASHVAL) +#define HN_RNDIS_RID_COMPAT_MASK 0xffff +#define HN_RNDIS_RID_COMPAT_MAX HN_RNDIS_RID_COMPAT_MASK + +#define HN_RNDIS_XFER_SIZE 2048 + /* * Forward declarations */ @@ -93,6 +98,20 @@ static void hn_rndis_sent_cb(struct hn_s struct hn_softc *sc, struct vmbus_channel *chan, const void *data, int dlen); +static __inline uint32_t +hn_rndis_rid(struct hn_softc *sc) +{ + uint32_t rid; + +again: + rid = atomic_fetchadd_int(&sc->hn_rndis_rid, 1); + if (rid == 0) + goto again; + + /* Use upper 16 bits for non-compat RNDIS messages. */ + return ((rid & 0xffff) << 16); +} + /* * Set the Per-Packet-Info with the specified type */ @@ -203,9 +222,8 @@ hv_rndis_request(rndis_device *device, u * as a template. */ set = &rndis_mesg->msg.set_request; - set->request_id = atomic_fetchadd_int(&device->new_request_id, 1); - /* Increment to get the new value (call above returns old value) */ - set->request_id += 1; + set->request_id = atomic_fetchadd_int(&device->new_request_id, 1) & + HN_RNDIS_RID_COMPAT_MASK; /* Add to the request list */ mtx_lock(&device->req_lock); @@ -326,7 +344,7 @@ hv_rf_receive_response(rndis_device *dev response->msg_len); } else { request->response_msg.msg.init_complete.status = - STATUS_BUFFER_OVERFLOW; + RNDIS_STATUS_BUFFER_OVERFLOW; } sema_post(&request->wait_sema); } @@ -390,7 +408,7 @@ hv_rf_send_offload_request(struct hn_sof device_printf(dev, "hv send offload request succeeded\n"); ret = 0; } else { - if (set_complete->status == STATUS_NOT_SUPPORTED) { + if (set_complete->status == RNDIS_STATUS_NOT_SUPPORTED) { device_printf(dev, "HV Not support offload\n"); ret = 0; } else { @@ -553,6 +571,7 @@ hv_rf_on_receive(struct hn_softc *sc, st { rndis_device *rndis_dev; const rndis_msg *rndis_hdr; + const struct rndis_comp_hdr *comp; rndis_dev = sc->rndis_dev; if (rndis_dev->state == RNDIS_DEV_UNINITIALIZED) @@ -570,7 +589,13 @@ hv_rf_on_receive(struct hn_softc *sc, st case REMOTE_NDIS_QUERY_CMPLT: case REMOTE_NDIS_SET_CMPLT: case REMOTE_NDIS_KEEPALIVE_CMPLT: - hv_rf_receive_response(rndis_dev, rndis_hdr); + comp = data; + if (comp->rm_rid <= HN_RNDIS_RID_COMPAT_MAX) { + /* Transition time compat code */ + hv_rf_receive_response(rndis_dev, rndis_hdr); + } else { + vmbus_xact_ctx_wakeup(sc->hn_xact, data, dlen); + } break; /* notification message */ @@ -866,62 +891,139 @@ exit: return (ret); } -/* - * RNDIS filter init device - */ -static int -hv_rf_init_device(rndis_device *device) -{ - rndis_request *request; - rndis_initialize_request *init; - rndis_initialize_complete *init_complete; - uint32_t status; - int ret; +static const void * +hn_rndis_xact_execute(struct hn_softc *sc, struct vmbus_xact *xact, uint32_t rid, + size_t reqlen, size_t min_complen, uint32_t comp_type) +{ + struct vmbus_gpa gpa[HN_XACT_REQ_PGCNT]; + const struct rndis_comp_hdr *comp; + bus_addr_t paddr; + size_t comp_len; + int gpa_cnt, error; + + KASSERT(rid > HN_RNDIS_RID_COMPAT_MAX, ("invalid rid %u\n", rid)); + KASSERT(reqlen <= HN_XACT_REQ_SIZE && reqlen > 0, + ("invalid request length %zu", reqlen)); + KASSERT(min_complen >= sizeof(*comp), + ("invalid minimum complete len %zu", min_complen)); - request = hv_rndis_request(device, REMOTE_NDIS_INITIALIZE_MSG, - RNDIS_MESSAGE_SIZE(rndis_initialize_request)); - if (!request) { - ret = -1; - goto cleanup; + /* + * Setup the SG list. + */ + paddr = vmbus_xact_req_paddr(xact); + KASSERT((paddr & PAGE_MASK) == 0, + ("vmbus xact request is not page aligned 0x%jx", (uintmax_t)paddr)); + for (gpa_cnt = 0; gpa_cnt < HN_XACT_REQ_PGCNT; ++gpa_cnt) { + int len = PAGE_SIZE; + + if (reqlen == 0) + break; + if (reqlen < len) + len = reqlen; + + gpa[gpa_cnt].gpa_page = atop(paddr) + gpa_cnt; + gpa[gpa_cnt].gpa_len = len; + gpa[gpa_cnt].gpa_ofs = 0; + + reqlen -= len; } + KASSERT(reqlen == 0, ("still have %zu request data left", reqlen)); - /* Set up the rndis set */ - init = &request->request_msg.msg.init_request; - init->major_version = RNDIS_MAJOR_VERSION; - init->minor_version = RNDIS_MINOR_VERSION; /* - * Per the RNDIS document, this should be set to the max MTU - * plus the header size. However, 2048 works fine, so leaving - * it as is. + * Send this RNDIS control message and wait for its completion + * message. */ - init->max_xfer_size = 2048; - - device->state = RNDIS_DEV_INITIALIZING; + vmbus_xact_activate(xact); + error = hv_nv_on_send(sc->hn_prichan, HN_NVS_RNDIS_MTYPE_CTRL, + &hn_send_ctx_none, gpa, gpa_cnt); + if (error) { + vmbus_xact_deactivate(xact); + if_printf(sc->hn_ifp, "RNDIS ctrl send failed: %d\n", error); + return (NULL); + } + comp = vmbus_xact_wait(xact, &comp_len); - ret = hv_rf_send_request(device, request, REMOTE_NDIS_INITIALIZE_MSG); - if (ret != 0) { - device->state = RNDIS_DEV_UNINITIALIZED; - goto cleanup; + /* + * Check this RNDIS complete message. + */ + if (comp_len < min_complen) { + if_printf(sc->hn_ifp, "invalid RNDIS comp len %zu\n", comp_len); + return (NULL); + } + if (comp->rm_len < min_complen) { + if_printf(sc->hn_ifp, "invalid RNDIS comp msglen %u\n", + comp->rm_len); + return (NULL); + } + if (comp->rm_type != comp_type) { + if_printf(sc->hn_ifp, "unexpected RNDIS comp 0x%08x, " + "expect 0x%08x\n", comp->rm_type, comp_type); + return (NULL); + } + if (comp->rm_rid != rid) { + if_printf(sc->hn_ifp, "RNDIS comp rid mismatch %u, " + "expect %u\n", comp->rm_rid, rid); + return (NULL); } + /* All pass! */ + return (comp); +} - sema_wait(&request->wait_sema); +/* + * RNDIS filter init device + */ +static int +hv_rf_init_device(rndis_device *device) +{ + struct hn_softc *sc = device->sc; + struct rndis_init_req *req; + const struct rndis_init_comp *comp; + struct vmbus_xact *xact; + uint32_t rid; + int error; - init_complete = &request->response_msg.msg.init_complete; - status = init_complete->status; - if (status == RNDIS_STATUS_SUCCESS) { - device->state = RNDIS_DEV_INITIALIZED; - ret = 0; - } else { - device->state = RNDIS_DEV_UNINITIALIZED; - ret = -1; - } + /* XXX */ + device->state = RNDIS_DEV_INITIALIZED; -cleanup: - if (request) { - hv_put_rndis_request(device, request); + xact = vmbus_xact_get(sc->hn_xact, sizeof(*req)); + if (xact == NULL) { + if_printf(sc->hn_ifp, "no xact for RNDIS init\n"); + return (ENXIO); + } + rid = hn_rndis_rid(sc); + req = vmbus_xact_req_data(xact); + req->rm_type = REMOTE_NDIS_INITIALIZE_MSG; + req->rm_len = sizeof(*req); + req->rm_rid = rid; + req->rm_ver_major = RNDIS_VERSION_MAJOR; + req->rm_ver_minor = RNDIS_VERSION_MINOR; + req->rm_max_xfersz = HN_RNDIS_XFER_SIZE; + + comp = hn_rndis_xact_execute(sc, xact, rid, sizeof(*req), + RNDIS_INIT_COMP_SIZE_MIN, REMOTE_NDIS_INITIALIZE_CMPLT); + if (comp == NULL) { + if_printf(sc->hn_ifp, "exec RNDIS init failed\n"); + error = EIO; + goto done; + } + + if (comp->rm_status != RNDIS_STATUS_SUCCESS) { + if_printf(sc->hn_ifp, "RNDIS init failed: status 0x%08x\n", + comp->rm_status); + error = EIO; + goto done; + } + if (bootverbose) { + if_printf(sc->hn_ifp, "RNDIS ver %u.%u, pktsz %u, pktcnt %u\n", + comp->rm_ver_major, comp->rm_ver_minor, + comp->rm_pktmaxsz, comp->rm_pktmaxcnt); } + error = 0; - return (ret); +done: + if (xact != NULL) + vmbus_xact_put(xact); + return (error); } #define HALT_COMPLETION_WAIT_COUNT 25 Modified: stable/10/sys/dev/hyperv/netvsc/if_hnvar.h ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/if_hnvar.h Thu Oct 13 04:32:55 2016 (r307177) +++ stable/10/sys/dev/hyperv/netvsc/if_hnvar.h Thu Oct 13 05:20:31 2016 (r307178) @@ -115,4 +115,6 @@ const void *hn_nvs_xact_execute(struct h uint32_t hn_chim_alloc(struct hn_softc *sc); void hn_chim_free(struct hn_softc *sc, uint32_t chim_idx); +extern struct hn_send_ctx hn_send_ctx_none; + #endif /* !_IF_HNVAR_H_ */ Modified: stable/10/sys/net/rndis.h ============================================================================== --- stable/10/sys/net/rndis.h Thu Oct 13 04:32:55 2016 (r307177) +++ stable/10/sys/net/rndis.h Thu Oct 13 05:20:31 2016 (r307178) @@ -146,6 +146,9 @@ struct rndis_init_comp { uint32_t rm_aflistsz; }; +#define RNDIS_INIT_COMP_SIZE_MIN \ + __offsetof(struct rndis_init_comp, rm_aflistsz) + /* Halt the device. No response sent. */ #define REMOTE_NDIS_HALT_MSG 0x00000003 From owner-svn-src-all@freebsd.org Thu Oct 13 05:59:34 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E347EC0F8EC; Thu, 13 Oct 2016 05:59:34 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id BABB3221; Thu, 13 Oct 2016 05:59:34 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9D5xXlk080941; Thu, 13 Oct 2016 05:59:33 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9D5xXT5080935; Thu, 13 Oct 2016 05:59:33 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610130559.u9D5xXT5080935@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Thu, 13 Oct 2016 05:59:33 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307179 - stable/10/sys/dev/hyperv/utilities X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Oct 2016 05:59:35 -0000 Author: sephe Date: Thu Oct 13 05:59:33 2016 New Revision: 307179 URL: https://svnweb.freebsd.org/changeset/base/307179 Log: MFC 304786,304788 304786 hyperv/ic: Cleanup heartbeat channel callback. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7626 304788 hyperv/ic: Update total message size if negotiate message size grows. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7627 Modified: stable/10/sys/dev/hyperv/utilities/hv_heartbeat.c stable/10/sys/dev/hyperv/utilities/hv_shutdown.c stable/10/sys/dev/hyperv/utilities/hv_timesync.c stable/10/sys/dev/hyperv/utilities/hv_util.c stable/10/sys/dev/hyperv/utilities/hv_util.h stable/10/sys/dev/hyperv/utilities/vmbus_icreg.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/hyperv/utilities/hv_heartbeat.c ============================================================================== --- stable/10/sys/dev/hyperv/utilities/hv_heartbeat.c Thu Oct 13 05:20:31 2016 (r307178) +++ stable/10/sys/dev/hyperv/utilities/hv_heartbeat.c Thu Oct 13 05:59:33 2016 (r307179) @@ -22,23 +22,22 @@ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $FreeBSD$ */ +#include +__FBSDID("$FreeBSD$"); + #include -#include #include -#include +#include #include -#include -#include #include #include #include -#include -#include "hv_util.h" +#include +#include + #include "vmbus_if.h" static const struct vmbus_ic_desc vmbus_heartbeat_descs[] = { @@ -51,55 +50,64 @@ static const struct vmbus_ic_desc vmbus_ VMBUS_IC_DESC_END }; -/** - * Process heartbeat message - */ static void -hv_heartbeat_cb(struct vmbus_channel *channel, void *context) +vmbus_heartbeat_cb(struct vmbus_channel *chan, void *xsc) { - uint8_t* buf; - int recvlen; - uint64_t requestid; - int ret; - - struct hv_vmbus_heartbeat_msg_data* heartbeat_msg; - struct hv_vmbus_icmsg_hdr* icmsghdrp; - hv_util_sc *softc; - - softc = (hv_util_sc*)context; - buf = softc->receive_buffer;; - - recvlen = softc->ic_buflen; - ret = vmbus_chan_recv(channel, buf, &recvlen, &requestid); - KASSERT(ret != ENOBUFS, ("hvheartbeat recvbuf is not large enough")); - /* XXX check recvlen to make sure that it contains enough data */ - - if ((ret == 0) && recvlen > 0) { - - icmsghdrp = (struct hv_vmbus_icmsg_hdr *) - &buf[sizeof(struct hv_vmbus_pipe_hdr)]; - - if (icmsghdrp->icmsgtype == HV_ICMSGTYPE_NEGOTIATE) { - int error; + struct hv_util_sc *sc = xsc; + struct vmbus_icmsg_hdr *hdr; + int dlen, error; + uint64_t xactid; + void *data; + + /* + * Receive request. + */ + data = sc->receive_buffer; + dlen = sc->ic_buflen; + error = vmbus_chan_recv(chan, data, &dlen, &xactid); + KASSERT(error != ENOBUFS, ("icbuf is not large enough")); + if (error) + return; + + if (dlen < sizeof(struct vmbus_icmsg_hdr)) { + device_printf(sc->ic_dev, "invalid data len %d\n", dlen); + return; + } + hdr = data; - error = vmbus_ic_negomsg(softc, buf, recvlen); + /* + * Update request, which will be echoed back as response. + */ + switch (hdr->ic_type) { + case VMBUS_ICMSG_TYPE_NEGOTIATE: + error = vmbus_ic_negomsg(sc, data, &dlen); if (error) return; - } else { - heartbeat_msg = - (struct hv_vmbus_heartbeat_msg_data *) - &buf[sizeof(struct hv_vmbus_pipe_hdr) + - sizeof(struct hv_vmbus_icmsg_hdr)]; - - heartbeat_msg->seq_num += 1; - } + break; - icmsghdrp->icflags = HV_ICMSGHDRFLAG_TRANSACTION | - HV_ICMSGHDRFLAG_RESPONSE; - - vmbus_chan_send(channel, VMBUS_CHANPKT_TYPE_INBAND, 0, - buf, recvlen, requestid); + case VMBUS_ICMSG_TYPE_HEARTBEAT: + /* Only ic_seq is a must */ + if (dlen < VMBUS_ICMSG_HEARTBEAT_SIZE_MIN) { + device_printf(sc->ic_dev, "invalid heartbeat len %d\n", + dlen); + return; + } + ((struct vmbus_icmsg_heartbeat *)data)->ic_seq++; + break; + + default: + device_printf(sc->ic_dev, "got 0x%08x icmsg\n", hdr->ic_type); + break; } + + /* + * Send response by echoing the updated request back. + */ + hdr->ic_flags = VMBUS_ICMSG_FLAG_XACT | VMBUS_ICMSG_FLAG_RESP; + error = vmbus_chan_send(chan, VMBUS_CHANPKT_TYPE_INBAND, 0, + data, dlen, xactid); + if (error) + device_printf(sc->ic_dev, "resp send failed: %d\n", error); } static int @@ -112,7 +120,8 @@ hv_heartbeat_probe(device_t dev) static int hv_heartbeat_attach(device_t dev) { - return hv_util_attach(dev, hv_heartbeat_cb); + + return (hv_util_attach(dev, vmbus_heartbeat_cb)); } static device_method_t heartbeat_methods[] = { Modified: stable/10/sys/dev/hyperv/utilities/hv_shutdown.c ============================================================================== --- stable/10/sys/dev/hyperv/utilities/hv_shutdown.c Thu Oct 13 05:20:31 2016 (r307178) +++ stable/10/sys/dev/hyperv/utilities/hv_shutdown.c Thu Oct 13 05:59:33 2016 (r307179) @@ -87,7 +87,7 @@ hv_shutdown_cb(struct vmbus_channel *cha if (icmsghdrp->icmsgtype == HV_ICMSGTYPE_NEGOTIATE) { int error; - error = vmbus_ic_negomsg(softc, buf, recv_len); + error = vmbus_ic_negomsg(softc, buf, &recv_len); if (error) return; } else { Modified: stable/10/sys/dev/hyperv/utilities/hv_timesync.c ============================================================================== --- stable/10/sys/dev/hyperv/utilities/hv_timesync.c Thu Oct 13 05:20:31 2016 (r307178) +++ stable/10/sys/dev/hyperv/utilities/hv_timesync.c Thu Oct 13 05:59:33 2016 (r307179) @@ -162,7 +162,7 @@ hv_timesync_cb(struct vmbus_channel *cha if (icmsghdrp->icmsgtype == HV_ICMSGTYPE_NEGOTIATE) { int error; - error = vmbus_ic_negomsg(&softc->util_sc, time_buf, recvlen); + error = vmbus_ic_negomsg(&softc->util_sc, time_buf, &recvlen); if (error) return; } else { Modified: stable/10/sys/dev/hyperv/utilities/hv_util.c ============================================================================== --- stable/10/sys/dev/hyperv/utilities/hv_util.c Thu Oct 13 05:20:31 2016 (r307178) +++ stable/10/sys/dev/hyperv/utilities/hv_util.c Thu Oct 13 05:59:33 2016 (r307179) @@ -48,13 +48,16 @@ #define VMBUS_IC_BRSIZE (4 * PAGE_SIZE) -CTASSERT(sizeof(struct vmbus_icmsg_negotiate) < VMBUS_IC_BRSIZE); +#define VMBUS_IC_VERCNT 2 +#define VMBUS_IC_NEGOSZ \ + __offsetof(struct vmbus_icmsg_negotiate, ic_ver[VMBUS_IC_VERCNT]) +CTASSERT(VMBUS_IC_NEGOSZ < VMBUS_IC_BRSIZE); int -vmbus_ic_negomsg(struct hv_util_sc *sc, void *data, int dlen) +vmbus_ic_negomsg(struct hv_util_sc *sc, void *data, int *dlen0) { struct vmbus_icmsg_negotiate *nego; - int cnt, major; + int cnt, major, dlen = *dlen0; /* * Preliminary message size verification @@ -87,9 +90,13 @@ vmbus_ic_negomsg(struct hv_util_sc *sc, nego->ic_msgver_cnt = 1; nego->ic_ver[1] = VMBUS_IC_VERSION(major, 0); - /* Data contains two versions */ - nego->ic_hdr.ic_dsize = __offsetof(struct vmbus_icmsg_negotiate, - ic_ver[2]) - sizeof(struct vmbus_icmsg_hdr); + /* Update data size */ + nego->ic_hdr.ic_dsize = VMBUS_IC_NEGOSZ - + sizeof(struct vmbus_icmsg_hdr); + + /* Update total size, if necessary */ + if (dlen < VMBUS_IC_NEGOSZ) + *dlen0 = VMBUS_IC_NEGOSZ; return 0; } Modified: stable/10/sys/dev/hyperv/utilities/hv_util.h ============================================================================== --- stable/10/sys/dev/hyperv/utilities/hv_util.h Thu Oct 13 05:20:31 2016 (r307178) +++ stable/10/sys/dev/hyperv/utilities/hv_util.h Thu Oct 13 05:59:33 2016 (r307179) @@ -54,6 +54,6 @@ struct vmbus_ic_desc { int hv_util_attach(device_t dev, vmbus_chan_callback_t cb); int hv_util_detach(device_t dev); int vmbus_ic_probe(device_t dev, const struct vmbus_ic_desc descs[]); -int vmbus_ic_negomsg(struct hv_util_sc *, void *data, int dlen); +int vmbus_ic_negomsg(struct hv_util_sc *, void *data, int *dlen); #endif Modified: stable/10/sys/dev/hyperv/utilities/vmbus_icreg.h ============================================================================== --- stable/10/sys/dev/hyperv/utilities/vmbus_icreg.h Thu Oct 13 05:20:31 2016 (r307178) +++ stable/10/sys/dev/hyperv/utilities/vmbus_icreg.h Thu Oct 13 05:59:33 2016 (r307179) @@ -81,4 +81,14 @@ struct vmbus_icmsg_negotiate { uint32_t ic_ver[]; } __packed; +/* VMBUS_ICMSG_TYPE_HEARTBEAT */ +struct vmbus_icmsg_heartbeat { + struct vmbus_icmsg_hdr ic_hdr; + uint64_t ic_seq; + uint32_t ic_rsvd[8]; +} __packed; + +#define VMBUS_ICMSG_HEARTBEAT_SIZE_MIN \ + __offsetof(struct vmbus_icmsg_heartbeat, ic_rsvd[0]) + #endif /* !_VMBUS_ICREG_H_ */ From owner-svn-src-all@freebsd.org Thu Oct 13 06:09:28 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 03821C0FB3F; Thu, 13 Oct 2016 06:09:28 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id BDDE59B6; Thu, 13 Oct 2016 06:09:27 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9D69R9J084838; Thu, 13 Oct 2016 06:09:27 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9D69QNh084833; Thu, 13 Oct 2016 06:09:26 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610130609.u9D69QNh084833@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Thu, 13 Oct 2016 06:09:26 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307180 - in stable/10/sys/dev/hyperv: include storvsc vmbus X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Oct 2016 06:09:28 -0000 Author: sephe Date: Thu Oct 13 06:09:26 2016 New Revision: 307180 URL: https://svnweb.freebsd.org/changeset/base/307180 Log: MFC 304790,304791 304790 hyperv/vmbus: Add function to calculate max # of elements in a bufring. Sponsored by: Microsoft 304791 hyperv/storvsc: Increase queue depth and rework channel selection. - Increasing queue depth gives ~100% performance improvement for randwrite fio test in Azure. - New channel selection, which takes LUN id and the current cpuid into consideration, gives additional ~20% performance improvement for ranwrite fio test in Azure. Submitted by: Hongzhang Jiang Modified by: sephe Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7622 Modified: stable/10/sys/dev/hyperv/include/vmbus.h stable/10/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c stable/10/sys/dev/hyperv/storvsc/hv_vstorage.h stable/10/sys/dev/hyperv/vmbus/vmbus_brvar.h stable/10/sys/dev/hyperv/vmbus/vmbus_chan.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/hyperv/include/vmbus.h ============================================================================== --- stable/10/sys/dev/hyperv/include/vmbus.h Thu Oct 13 05:59:33 2016 (r307179) +++ stable/10/sys/dev/hyperv/include/vmbus.h Thu Oct 13 06:09:26 2016 (r307180) @@ -162,5 +162,7 @@ uint32_t vmbus_chan_subidx(const struct bool vmbus_chan_is_primary(const struct vmbus_channel *chan); const struct hyperv_guid * vmbus_chan_guid_inst(const struct vmbus_channel *chan); +int vmbus_chan_prplist_nelem(int br_size, int prpcnt_max, + int dlen_max); #endif /* !_VMBUS_H_ */ Modified: stable/10/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c ============================================================================== --- stable/10/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c Thu Oct 13 05:59:33 2016 (r307179) +++ stable/10/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c Thu Oct 13 06:09:26 2016 (r307180) @@ -75,11 +75,9 @@ __FBSDID("$FreeBSD$"); #include #include - #include "hv_vstorage.h" #include "vmbus_if.h" -#define STORVSC_RINGBUFFER_SIZE (20*PAGE_SIZE) #define STORVSC_MAX_LUNS_PER_TARGET (64) #define STORVSC_MAX_IO_REQUESTS (STORVSC_MAX_LUNS_PER_TARGET * 2) #define BLKVSC_MAX_IDE_DISKS_PER_TARGET (1) @@ -121,8 +119,6 @@ struct hv_sgl_page_pool{ boolean_t is_init; } g_hv_sgl_page_pool; -#define STORVSC_MAX_SG_PAGE_CNT STORVSC_MAX_IO_REQUESTS * STORVSC_DATA_SEGCNT_MAX - enum storvsc_request_type { WRITE_TYPE, READ_TYPE, @@ -130,17 +126,35 @@ enum storvsc_request_type { }; SYSCTL_NODE(_hw, OID_AUTO, storvsc, CTLFLAG_RD | CTLFLAG_MPSAFE, NULL, - "Hyper-V storage interface"); + "Hyper-V storage interface"); + +static u_int hv_storvsc_use_win8ext_flags = 1; +SYSCTL_UINT(_hw_storvsc, OID_AUTO, use_win8ext_flags, CTLFLAG_RW, + &hv_storvsc_use_win8ext_flags, 0, + "Use win8 extension flags or not"); static u_int hv_storvsc_use_pim_unmapped = 1; -SYSCTL_INT(_hw_storvsc, OID_AUTO, use_pim_unmapped, CTLFLAG_RDTUN, - &hv_storvsc_use_pim_unmapped, 0, - "Optimize storvsc by using unmapped I/O"); +SYSCTL_UINT(_hw_storvsc, OID_AUTO, use_pim_unmapped, CTLFLAG_RDTUN, + &hv_storvsc_use_pim_unmapped, 0, + "Optimize storvsc by using unmapped I/O"); + +static u_int hv_storvsc_ringbuffer_size = (64 * PAGE_SIZE); +SYSCTL_UINT(_hw_storvsc, OID_AUTO, ringbuffer_size, CTLFLAG_RDTUN, + &hv_storvsc_ringbuffer_size, 0, "Hyper-V storage ringbuffer size"); + +static u_int hv_storvsc_max_io = 512; +SYSCTL_UINT(_hw_storvsc, OID_AUTO, max_io, CTLFLAG_RDTUN, + &hv_storvsc_max_io, 0, "Hyper-V storage max io limit"); + +#define STORVSC_MAX_IO \ + vmbus_chan_prplist_nelem(hv_storvsc_ringbuffer_size, \ + STORVSC_DATA_SEGCNT_MAX, VSTOR_PKT_SIZE) struct hv_storvsc_sysctl { u_long data_bio_cnt; u_long data_vaddr_cnt; u_long data_sg_cnt; + u_long chan_send_cnt[MAXCPU]; }; struct storvsc_gpa_range { @@ -184,10 +198,18 @@ struct storvsc_softc { device_t hs_dev; bus_dma_tag_t storvsc_req_dtag; struct hv_storvsc_sysctl sysctl_data; - - struct vmbus_channel *hs_cpu2chan[MAXCPU]; + uint32_t hs_nchan; + struct vmbus_channel *hs_sel_chan[MAXCPU]; }; +/* + * The size of the vmscsi_request has changed in win8. The + * additional size is for the newly added elements in the + * structure. These elements are valid only when we are talking + * to a win8 host. + * Track the correct size we need to apply. + */ +static int vmscsi_size_delta = sizeof(struct vmscsi_win8_extension); /** * HyperV storvsc timeout testing cases: @@ -211,7 +233,7 @@ struct storvsc_driver_props { char *drv_name; char *drv_desc; uint8_t drv_max_luns_per_target; - uint8_t drv_max_ios_per_target; + uint32_t drv_max_ios_per_target; uint32_t drv_ringbuffer_size; }; @@ -240,10 +262,10 @@ static const struct hyperv_guid gBlkVscD static struct storvsc_driver_props g_drv_props_table[] = { {"blkvsc", "Hyper-V IDE Storage Interface", BLKVSC_MAX_IDE_DISKS_PER_TARGET, BLKVSC_MAX_IO_REQUESTS, - STORVSC_RINGBUFFER_SIZE}, + 20*PAGE_SIZE}, {"storvsc", "Hyper-V SCSI Storage Interface", STORVSC_MAX_LUNS_PER_TARGET, STORVSC_MAX_IO_REQUESTS, - STORVSC_RINGBUFFER_SIZE} + 20*PAGE_SIZE} }; /* @@ -253,14 +275,6 @@ static struct storvsc_driver_props g_drv static int sense_buffer_size = PRE_WIN8_STORVSC_SENSE_BUFFER_SIZE; /* - * The size of the vmscsi_request has changed in win8. The - * additional size is for the newly added elements in the - * structure. These elements are valid only when we are talking - * to a win8 host. - * Track the correct size we need to apply. - */ -static int vmscsi_size_delta; -/* * The storage protocol version is determined during the * initial exchange with the host. It will indicate which * storage functionality is available in the host. @@ -413,6 +427,9 @@ storvsc_send_multichannel_request(struct return; } + /* Update channel count */ + sc->hs_nchan = request_channels_cnt + 1; + /* Wait for sub-channels setup to complete. */ subchan = vmbus_subchan_get(sc->hs_chan, request_channels_cnt); @@ -585,7 +602,6 @@ hv_storvsc_channel_init(struct storvsc_s */ if (support_multichannel) storvsc_send_multichannel_request(sc, max_chans); - cleanup: sema_destroy(&request->synch_sema); return (ret); @@ -624,7 +640,6 @@ hv_storvsc_connect_vsp(struct storvsc_so } ret = hv_storvsc_channel_init(sc); - return (ret); } @@ -686,7 +701,7 @@ hv_storvsc_io_request(struct storvsc_sof { struct vstor_packet *vstor_packet = &request->vstor_packet; struct vmbus_channel* outgoing_channel = NULL; - int ret = 0; + int ret = 0, ch_sel; vstor_packet->flags |= REQUEST_COMPLETION_FLAG; @@ -700,7 +715,8 @@ hv_storvsc_io_request(struct storvsc_sof vstor_packet->operation = VSTOR_OPERATION_EXECUTESRB; - outgoing_channel = sc->hs_cpu2chan[curcpu]; + ch_sel = (vstor_packet->u.vm_srb.lun + curcpu) % sc->hs_nchan; + outgoing_channel = sc->hs_sel_chan[ch_sel]; mtx_unlock(&request->softc->hs_lock); if (request->prp_list.gpa_range.gpa_len) { @@ -712,6 +728,10 @@ hv_storvsc_io_request(struct storvsc_sof VMBUS_CHANPKT_TYPE_INBAND, VMBUS_CHANPKT_FLAG_RC, vstor_packet, VSTOR_PKT_SIZE, (uint64_t)(uintptr_t)request); } + /* statistic for successful request sending on each channel */ + if (!ret) { + sc->sysctl_data.chan_send_cnt[ch_sel]++; + } mtx_lock(&request->softc->hs_lock); if (ret != 0) { @@ -907,17 +927,20 @@ storvsc_probe(device_t dev) } static void -storvsc_create_cpu2chan(struct storvsc_softc *sc) +storvsc_create_chan_sel(struct storvsc_softc *sc) { - int cpu; + struct vmbus_channel **subch; + int i, nsubch; - CPU_FOREACH(cpu) { - sc->hs_cpu2chan[cpu] = vmbus_chan_cpu2chan(sc->hs_chan, cpu); - if (bootverbose) { - device_printf(sc->hs_dev, "cpu%d -> chan%u\n", - cpu, vmbus_chan_id(sc->hs_cpu2chan[cpu])); - } - } + sc->hs_sel_chan[0] = sc->hs_chan; + nsubch = sc->hs_nchan - 1; + if (nsubch == 0) + return; + + subch = vmbus_subchan_get(sc->hs_chan, nsubch); + for (i = 0; i < nsubch; i++) + sc->hs_sel_chan[i + 1] = subch[i]; + vmbus_subchan_rel(subch, nsubch); } static int @@ -977,7 +1000,10 @@ storvsc_sysctl(device_t dev) { struct sysctl_oid_list *child; struct sysctl_ctx_list *ctx; + struct sysctl_oid *ch_tree, *chid_tree; struct storvsc_softc *sc; + char name[16]; + int i; sc = device_get_softc(dev); ctx = device_get_sysctl_ctx(dev); @@ -989,6 +1015,28 @@ storvsc_sysctl(device_t dev) &sc->sysctl_data.data_vaddr_cnt, "# of vaddr data block"); SYSCTL_ADD_ULONG(ctx, child, OID_AUTO, "data_sg_cnt", CTLFLAG_RW, &sc->sysctl_data.data_sg_cnt, "# of sg data block"); + + /* dev.storvsc.UNIT.channel */ + ch_tree = SYSCTL_ADD_NODE(ctx, child, OID_AUTO, "channel", + CTLFLAG_RD | CTLFLAG_MPSAFE, 0, ""); + if (ch_tree == NULL) + return; + + for (i = 0; i < sc->hs_nchan; i++) { + uint32_t ch_id; + + ch_id = vmbus_chan_id(sc->hs_sel_chan[i]); + snprintf(name, sizeof(name), "%d", ch_id); + /* dev.storvsc.UNIT.channel.CHID */ + chid_tree = SYSCTL_ADD_NODE(ctx, SYSCTL_CHILDREN(ch_tree), + OID_AUTO, name, CTLFLAG_RD | CTLFLAG_MPSAFE, 0, ""); + if (chid_tree == NULL) + return; + /* dev.storvsc.UNIT.channel.CHID.send_req */ + SYSCTL_ADD_ULONG(ctx, SYSCTL_CHILDREN(chid_tree), OID_AUTO, + "send_req", CTLFLAG_RD, &sc->sysctl_data.chan_send_cnt[i], + "# of request sending from this channel"); + } } /** @@ -1019,6 +1067,7 @@ storvsc_attach(device_t dev) root_mount_token = root_mount_hold("storvsc"); sc = device_get_softc(dev); + sc->hs_nchan = 1; sc->hs_chan = vmbus_get_channel(dev); stor_type = storvsc_get_storage_type(dev); @@ -1030,7 +1079,14 @@ storvsc_attach(device_t dev) /* fill in driver specific properties */ sc->hs_drv_props = &g_drv_props_table[stor_type]; - + sc->hs_drv_props->drv_ringbuffer_size = hv_storvsc_ringbuffer_size; + sc->hs_drv_props->drv_max_ios_per_target = + MIN(STORVSC_MAX_IO, hv_storvsc_max_io); + if (bootverbose) { + printf("storvsc ringbuffer size: %d, max_io: %d\n", + sc->hs_drv_props->drv_ringbuffer_size, + sc->hs_drv_props->drv_max_ios_per_target); + } /* fill in device specific properties */ sc->hs_unit = device_get_unit(dev); sc->hs_dev = dev; @@ -1052,7 +1108,7 @@ storvsc_attach(device_t dev) * STORVSC_DATA_SEGCNT_MAX segments, each * segment has one page buffer */ - for (i = 0; i < STORVSC_MAX_IO_REQUESTS; i++) { + for (i = 0; i < sc->hs_drv_props->drv_max_ios_per_target; i++) { sgl_node = malloc(sizeof(struct hv_sgl_node), M_DEVBUF, M_WAITOK|M_ZERO); @@ -1083,7 +1139,7 @@ storvsc_attach(device_t dev) } /* Construct cpu to channel mapping */ - storvsc_create_cpu2chan(sc); + storvsc_create_chan_sel(sc); /* * Create the device queue. @@ -1840,19 +1896,37 @@ create_storvsc_request(union ccb *ccb, s csio->cdb_len); } + if (hv_storvsc_use_win8ext_flags) { + reqp->vstor_packet.u.vm_srb.win8_extension.time_out_value = 60; + reqp->vstor_packet.u.vm_srb.win8_extension.srb_flags |= + SRB_FLAGS_DISABLE_SYNCH_TRANSFER; + } switch (ccb->ccb_h.flags & CAM_DIR_MASK) { case CAM_DIR_OUT: - reqp->vstor_packet.u.vm_srb.data_in = WRITE_TYPE; + reqp->vstor_packet.u.vm_srb.data_in = WRITE_TYPE; + if (hv_storvsc_use_win8ext_flags) { + reqp->vstor_packet.u.vm_srb.win8_extension.srb_flags |= + SRB_FLAGS_DATA_OUT; + } break; case CAM_DIR_IN: reqp->vstor_packet.u.vm_srb.data_in = READ_TYPE; + if (hv_storvsc_use_win8ext_flags) { + reqp->vstor_packet.u.vm_srb.win8_extension.srb_flags |= + SRB_FLAGS_DATA_IN; + } break; case CAM_DIR_NONE: reqp->vstor_packet.u.vm_srb.data_in = UNKNOWN_TYPE; + if (hv_storvsc_use_win8ext_flags) { + reqp->vstor_packet.u.vm_srb.win8_extension.srb_flags |= + SRB_FLAGS_NO_DATA_TRANSFER; + } break; default: - reqp->vstor_packet.u.vm_srb.data_in = UNKNOWN_TYPE; - break; + printf("Error: unexpected data direction: 0x%x\n", + ccb->ccb_h.flags & CAM_DIR_MASK); + return (EINVAL); } reqp->sense_data = &csio->sense_data; Modified: stable/10/sys/dev/hyperv/storvsc/hv_vstorage.h ============================================================================== --- stable/10/sys/dev/hyperv/storvsc/hv_vstorage.h Thu Oct 13 05:59:33 2016 (r307179) +++ stable/10/sys/dev/hyperv/storvsc/hv_vstorage.h Thu Oct 13 06:09:26 2016 (r307180) @@ -253,6 +253,22 @@ struct vstor_packet { #define SRB_STATUS_AUTOSENSE_VALID 0x80 #define SRB_STATUS_INVALID_LUN 0X20 +/* + * SRB Flag Bits + */ + +#define SRB_FLAGS_QUEUE_ACTION_ENABLE 0x00000002 +#define SRB_FLAGS_DISABLE_DISCONNECT 0x00000004 +#define SRB_FLAGS_DISABLE_SYNCH_TRANSFER 0x00000008 +#define SRB_FLAGS_BYPASS_FROZEN_QUEUE 0x00000010 +#define SRB_FLAGS_DISABLE_AUTOSENSE 0x00000020 +#define SRB_FLAGS_DATA_IN 0x00000040 +#define SRB_FLAGS_DATA_OUT 0x00000080 +#define SRB_FLAGS_NO_DATA_TRANSFER 0x00000000 +#define SRB_FLAGS_UNSPECIFIED_DIRECTION (SRB_FLAGS_DATA_IN | SRB_FLAGS_DATA_OUT) +#define SRB_FLAGS_NO_QUEUE_FREEZE 0x00000100 +#define SRB_FLAGS_ADAPTER_CACHE_ENABLE 0x00000200 +#define SRB_FLAGS_FREE_SENSE_BUFFER 0x00000400 /** * Packet flags */ Modified: stable/10/sys/dev/hyperv/vmbus/vmbus_brvar.h ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/vmbus_brvar.h Thu Oct 13 05:59:33 2016 (r307179) +++ stable/10/sys/dev/hyperv/vmbus/vmbus_brvar.h Thu Oct 13 06:09:26 2016 (r307180) @@ -74,6 +74,7 @@ struct sysctl_oid; static __inline int vmbus_txbr_maxpktsz(const struct vmbus_txbr *tbr) { + /* * - 64 bits for the trailing start index (- sizeof(uint64_t)). * - The rindex and windex can't be same (- 1). See @@ -82,6 +83,17 @@ vmbus_txbr_maxpktsz(const struct vmbus_t return (tbr->txbr_dsize - sizeof(uint64_t) - 1); } +static __inline int +vmbus_br_nelem(int br_size, int elem_size) +{ + + /* Strip bufring header */ + br_size -= sizeof(struct vmbus_bufring); + /* Add per-element trailing index */ + elem_size += sizeof(uint64_t); + return (br_size / elem_size); +} + void vmbus_br_sysctl_create(struct sysctl_ctx_list *ctx, struct sysctl_oid *br_tree, struct vmbus_br *br, const char *name); Modified: stable/10/sys/dev/hyperv/vmbus/vmbus_chan.c ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/vmbus_chan.c Thu Oct 13 05:59:33 2016 (r307179) +++ stable/10/sys/dev/hyperv/vmbus/vmbus_chan.c Thu Oct 13 06:09:26 2016 (r307180) @@ -1411,3 +1411,16 @@ vmbus_chan_guid_inst(const struct vmbus_ { return &chan->ch_guid_inst; } + +int +vmbus_chan_prplist_nelem(int br_size, int prpcnt_max, int dlen_max) +{ + int elem_size; + + elem_size = __offsetof(struct vmbus_chanpkt_prplist, + cp_range[0].gpa_page[prpcnt_max]); + elem_size += dlen_max; + elem_size = VMBUS_CHANPKT_TOTLEN(elem_size); + + return (vmbus_br_nelem(br_size, elem_size)); +} From owner-svn-src-all@freebsd.org Thu Oct 13 06:17:35 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 81E9CC0FD99; Thu, 13 Oct 2016 06:17:35 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4A357E62; Thu, 13 Oct 2016 06:17:35 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9D6HYx2088531; Thu, 13 Oct 2016 06:17:34 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9D6HXje088523; Thu, 13 Oct 2016 06:17:33 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610130617.u9D6HXje088523@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Thu, 13 Oct 2016 06:17:33 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307181 - in stable/10/sys: dev/hyperv/netvsc net X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Oct 2016 06:17:35 -0000 Author: sephe Date: Thu Oct 13 06:17:33 2016 New Revision: 307181 URL: https://svnweb.freebsd.org/changeset/base/307181 Log: MFC 304832-304834,304972 304832 hyperv/hn: Use vmbus xact for RNDIS query. And switch MAC address query to use new RNDIS query function. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7639 304833 hyperv/hn: Save the adopted NDIS version for RNDIS to use later. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7640 304834 hyperv/hn: Use vmbus xact for RNDIS set. And use new RNDIS set to configure NDIS offloading parameters. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7641 304972 hyperv/hn: Add definition for NDIS media state. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7652 Added: stable/10/sys/dev/hyperv/netvsc/ndis.h - copied, changed from r304834, head/sys/dev/hyperv/netvsc/ndis.h Modified: stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.c stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c stable/10/sys/dev/hyperv/netvsc/hv_rndis.h stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.c stable/10/sys/net/rndis.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.c Thu Oct 13 06:09:26 2016 (r307180) +++ stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.c Thu Oct 13 06:17:33 2016 (r307181) @@ -520,9 +520,15 @@ hv_nv_connect_to_vsp(struct hn_softc *sc for (i = protocol_number - 1; i >= 0; i--) { if (hv_nv_negotiate_nvsp_protocol(sc, protocol_list[i]) == 0) { sc->hn_nvs_ver = protocol_list[i]; + sc->hn_ndis_ver = NDIS_VERSION_6_30; + if (sc->hn_nvs_ver <= NVSP_PROTOCOL_VERSION_4) + sc->hn_ndis_ver = NDIS_VERSION_6_1; if (bootverbose) { - device_printf(dev, "NVS version 0x%x\n", - sc->hn_nvs_ver); + if_printf(sc->hn_ifp, "NVS version 0x%x, " + "NDIS version %u.%u\n", + sc->hn_nvs_ver, + NDIS_VERSION_MAJOR(sc->hn_ndis_ver), + NDIS_VERSION_MINOR(sc->hn_ndis_ver)); } break; } @@ -548,11 +554,8 @@ hv_nv_connect_to_vsp(struct hn_softc *sc memset(&ndis, 0, sizeof(ndis)); ndis.nvs_type = HN_NVS_TYPE_NDIS_INIT; - ndis.nvs_ndis_major = NDIS_VERSION_MAJOR_6; - if (sc->hn_nvs_ver <= NVSP_PROTOCOL_VERSION_4) - ndis.nvs_ndis_minor = NDIS_VERSION_MINOR_1; - else - ndis.nvs_ndis_minor = NDIS_VERSION_MINOR_30; + ndis.nvs_ndis_major = NDIS_VERSION_MAJOR(sc->hn_ndis_ver); + ndis.nvs_ndis_minor = NDIS_VERSION_MINOR(sc->hn_ndis_ver); /* NOTE: No response. */ ret = hn_nvs_req_send(sc, &ndis, sizeof(ndis)); Modified: stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h Thu Oct 13 06:09:26 2016 (r307180) +++ stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h Thu Oct 13 06:17:33 2016 (r307181) @@ -383,6 +383,7 @@ typedef struct hn_softc { struct hyperv_dma hn_chim_dma; uint32_t hn_rndis_rid; + uint32_t hn_ndis_ver; } hn_softc_t; #define HN_FLAG_RXBUF_CONNECTED 0x0001 Modified: stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Thu Oct 13 06:09:26 2016 (r307180) +++ stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Thu Oct 13 06:17:33 2016 (r307181) @@ -119,9 +119,11 @@ __FBSDID("$FreeBSD$"); #include #include -#include "hv_net_vsc.h" -#include "hv_rndis.h" -#include "hv_rndis_filter.h" +#include +#include +#include +#include + #include "vmbus_if.h" /* Short for Hyper-V network interface */ @@ -334,6 +336,7 @@ static int hn_rx_stat_u64_sysctl(SYSCTL_ static int hn_rx_stat_ulong_sysctl(SYSCTL_HANDLER_ARGS); static int hn_tx_stat_ulong_sysctl(SYSCTL_HANDLER_ARGS); static int hn_tx_conf_int_sysctl(SYSCTL_HANDLER_ARGS); +static int hn_ndis_version_sysctl(SYSCTL_HANDLER_ARGS); static int hn_check_iplen(const struct mbuf *, int); static int hn_create_tx_ring(struct hn_softc *, int); static void hn_destroy_tx_ring(struct hn_tx_ring *); @@ -444,6 +447,8 @@ hn_cpuset_setthread_task(void *xmask, in static int netvsc_attach(device_t dev) { + struct sysctl_oid_list *child; + struct sysctl_ctx_list *ctx; netvsc_device_info device_info; hn_softc_t *sc; int unit = device_get_unit(dev); @@ -597,7 +602,7 @@ netvsc_attach(device_t dev) } #endif - if (device_info.link_state == 0) { + if (device_info.link_state == NDIS_MEDIA_STATE_CONNECTED) { sc->hn_carrier = 1; } @@ -620,9 +625,13 @@ netvsc_attach(device_t dev) hn_tx_chimney_size < sc->hn_chim_szmax) hn_set_chim_size(sc, hn_tx_chimney_size); - SYSCTL_ADD_UINT(device_get_sysctl_ctx(dev), - SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), OID_AUTO, - "nvs_version", CTLFLAG_RD, &sc->hn_nvs_ver, 0, "NVS version"); + ctx = device_get_sysctl_ctx(dev); + child = SYSCTL_CHILDREN(device_get_sysctl_tree(dev)); + SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "nvs_version", CTLFLAG_RD, + &sc->hn_nvs_ver, 0, "NVS version"); + SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "ndis_version", + CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, sc, 0, + hn_ndis_version_sysctl, "A", "NDIS version"); return (0); failed: @@ -2141,6 +2150,18 @@ hn_tx_conf_int_sysctl(SYSCTL_HANDLER_ARG } static int +hn_ndis_version_sysctl(SYSCTL_HANDLER_ARGS) +{ + struct hn_softc *sc = arg1; + char verstr[16]; + + snprintf(verstr, sizeof(verstr), "%u.%u", + NDIS_VERSION_MAJOR(sc->hn_ndis_ver), + NDIS_VERSION_MINOR(sc->hn_ndis_ver)); + return sysctl_handle_string(oidp, verstr, sizeof(verstr), req); +} + +static int hn_check_iplen(const struct mbuf *m, int hoff) { const struct ip *ip; Modified: stable/10/sys/dev/hyperv/netvsc/hv_rndis.h ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_rndis.h Thu Oct 13 06:09:26 2016 (r307180) +++ stable/10/sys/dev/hyperv/netvsc/hv_rndis.h Thu Oct 13 06:17:33 2016 (r307181) @@ -42,11 +42,8 @@ #define NDIS_VERSION_6_1 0x00060001 #define NDIS_VERSION_6_30 0x0006001e -#define NDIS_VERSION_MAJOR_6 6 -#define NDIS_VERSION_MINOR_1 1 -#define NDIS_VERSION_MINOR_30 30 - -#define NDIS_VERSION (NDIS_VERSION_5_1) +#define NDIS_VERSION_MAJOR(ver) (((ver) & 0xffff0000) >> 16) +#define NDIS_VERSION_MINOR(ver) ((ver) & 0xffff) /* * Object Identifiers used by NdisRequest Query/Set Information Modified: stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.c Thu Oct 13 06:09:26 2016 (r307180) +++ stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.c Thu Oct 13 06:17:33 2016 (r307181) @@ -52,6 +52,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #define HV_RF_RECVINFO_VLAN 0x1 #define HV_RF_RECVINFO_CSUM 0x2 @@ -97,6 +98,11 @@ static void hn_rndis_sent_halt(struct hn static void hn_rndis_sent_cb(struct hn_send_ctx *sndc, struct hn_softc *sc, struct vmbus_channel *chan, const void *data, int dlen); +static int hn_rndis_query(struct hn_softc *sc, uint32_t oid, + const void *idata, size_t idlen, void *odata, size_t *odlen0); +static int hn_rndis_set(struct hn_softc *sc, uint32_t oid, const void *data, + size_t dlen); +static int hn_rndis_conf_offload(struct hn_softc *sc); static __inline uint32_t hn_rndis_rid(struct hn_softc *sc) @@ -696,13 +702,23 @@ cleanup: /* * RNDIS filter query device MAC address */ -static inline int +static int hv_rf_query_device_mac(rndis_device *device) { - uint32_t size = ETHER_ADDR_LEN; + struct hn_softc *sc = device->sc; + size_t hwaddr_len; + int error; - return (hv_rf_query_device(device, - RNDIS_OID_802_3_PERMANENT_ADDRESS, device->hw_mac_addr, &size)); + hwaddr_len = ETHER_ADDR_LEN; + error = hn_rndis_query(sc, OID_802_3_PERMANENT_ADDRESS, NULL, 0, + device->hw_mac_addr, &hwaddr_len); + if (error) + return error; + if (hwaddr_len != ETHER_ADDR_LEN) { + if_printf(sc->hn_ifp, "invalid hwaddr len %zu\n", hwaddr_len); + return EINVAL; + } + return 0; } /* @@ -893,12 +909,12 @@ exit: static const void * hn_rndis_xact_execute(struct hn_softc *sc, struct vmbus_xact *xact, uint32_t rid, - size_t reqlen, size_t min_complen, uint32_t comp_type) + size_t reqlen, size_t *comp_len0, uint32_t comp_type) { struct vmbus_gpa gpa[HN_XACT_REQ_PGCNT]; const struct rndis_comp_hdr *comp; bus_addr_t paddr; - size_t comp_len; + size_t comp_len, min_complen = *comp_len0; int gpa_cnt, error; KASSERT(rid > HN_RNDIS_RID_COMPAT_MAX, ("invalid rid %u\n", rid)); @@ -947,7 +963,14 @@ hn_rndis_xact_execute(struct hn_softc *s * Check this RNDIS complete message. */ if (comp_len < min_complen) { - if_printf(sc->hn_ifp, "invalid RNDIS comp len %zu\n", comp_len); + if (comp_len >= sizeof(*comp)) { + /* rm_status field is valid */ + if_printf(sc->hn_ifp, "invalid RNDIS comp len %zu, " + "status 0x%08x\n", comp_len, comp->rm_status); + } else { + if_printf(sc->hn_ifp, "invalid RNDIS comp len %zu\n", + comp_len); + } return (NULL); } if (comp->rm_len < min_complen) { @@ -966,9 +989,190 @@ hn_rndis_xact_execute(struct hn_softc *s return (NULL); } /* All pass! */ + *comp_len0 = comp_len; return (comp); } +static int +hn_rndis_query(struct hn_softc *sc, uint32_t oid, + const void *idata, size_t idlen, void *odata, size_t *odlen0) +{ + struct rndis_query_req *req; + const struct rndis_query_comp *comp; + struct vmbus_xact *xact; + size_t reqlen, odlen = *odlen0, comp_len; + int error, ofs; + uint32_t rid; + + reqlen = sizeof(*req) + idlen; + xact = vmbus_xact_get(sc->hn_xact, reqlen); + if (xact == NULL) { + if_printf(sc->hn_ifp, "no xact for RNDIS query 0x%08x\n", oid); + return (ENXIO); + } + rid = hn_rndis_rid(sc); + req = vmbus_xact_req_data(xact); + req->rm_type = REMOTE_NDIS_QUERY_MSG; + req->rm_len = reqlen; + req->rm_rid = rid; + req->rm_oid = oid; + /* + * XXX + * This is _not_ RNDIS Spec conforming: + * "This MUST be set to 0 when there is no input data + * associated with the OID." + * + * If this field was set to 0 according to the RNDIS Spec, + * Hyper-V would set non-SUCCESS status in the query + * completion. + */ + req->rm_infobufoffset = RNDIS_QUERY_REQ_INFOBUFOFFSET; + + if (idlen > 0) { + req->rm_infobuflen = idlen; + /* Input data immediately follows RNDIS query. */ + memcpy(req + 1, idata, idlen); + } + + comp_len = sizeof(*comp) + odlen; + comp = hn_rndis_xact_execute(sc, xact, rid, reqlen, &comp_len, + REMOTE_NDIS_QUERY_CMPLT); + if (comp == NULL) { + if_printf(sc->hn_ifp, "exec RNDIS query 0x%08x failed\n", oid); + error = EIO; + goto done; + } + + if (comp->rm_status != RNDIS_STATUS_SUCCESS) { + if_printf(sc->hn_ifp, "RNDIS query 0x%08x failed: " + "status 0x%08x\n", oid, comp->rm_status); + error = EIO; + goto done; + } + if (comp->rm_infobuflen == 0 || comp->rm_infobufoffset == 0) { + /* No output data! */ + if_printf(sc->hn_ifp, "RNDIS query 0x%08x, no data\n", oid); + *odlen0 = 0; + error = 0; + goto done; + } + + /* + * Check output data length and offset. + */ + /* ofs is the offset from the beginning of comp. */ + ofs = RNDIS_QUERY_COMP_INFOBUFABS(comp->rm_infobufoffset); + if (ofs < sizeof(*comp) || ofs + comp->rm_infobuflen > comp_len) { + if_printf(sc->hn_ifp, "RNDIS query invalid comp ib off/len, " + "%u/%u\n", comp->rm_infobufoffset, comp->rm_infobuflen); + error = EINVAL; + goto done; + } + + /* + * Save output data. + */ + if (comp->rm_infobuflen < odlen) + odlen = comp->rm_infobuflen; + memcpy(odata, ((const uint8_t *)comp) + ofs, odlen); + *odlen0 = odlen; + + error = 0; +done: + vmbus_xact_put(xact); + return (error); +} + +static int +hn_rndis_set(struct hn_softc *sc, uint32_t oid, const void *data, size_t dlen) +{ + struct rndis_set_req *req; + const struct rndis_set_comp *comp; + struct vmbus_xact *xact; + size_t reqlen, comp_len; + uint32_t rid; + int error; + + KASSERT(dlen > 0, ("invalid dlen %zu", dlen)); + + reqlen = sizeof(*req) + dlen; + xact = vmbus_xact_get(sc->hn_xact, reqlen); + if (xact == NULL) { + if_printf(sc->hn_ifp, "no xact for RNDIS set 0x%08x\n", oid); + return (ENXIO); + } + rid = hn_rndis_rid(sc); + req = vmbus_xact_req_data(xact); + req->rm_type = REMOTE_NDIS_SET_MSG; + req->rm_len = reqlen; + req->rm_rid = rid; + req->rm_oid = oid; + req->rm_infobuflen = dlen; + req->rm_infobufoffset = RNDIS_SET_REQ_INFOBUFOFFSET; + /* Data immediately follows RNDIS set. */ + memcpy(req + 1, data, dlen); + + comp_len = sizeof(*comp); + comp = hn_rndis_xact_execute(sc, xact, rid, reqlen, &comp_len, + REMOTE_NDIS_SET_CMPLT); + if (comp == NULL) { + if_printf(sc->hn_ifp, "exec RNDIS set 0x%08x failed\n", oid); + error = EIO; + goto done; + } + + if (comp->rm_status != RNDIS_STATUS_SUCCESS) { + if_printf(sc->hn_ifp, "RNDIS set 0x%08x failed: " + "status 0x%08x\n", oid, comp->rm_status); + error = EIO; + goto done; + } + error = 0; +done: + vmbus_xact_put(xact); + return (error); +} + +static int +hn_rndis_conf_offload(struct hn_softc *sc) +{ + struct ndis_offload_params params; + size_t paramsz; + int error; + + /* NOTE: 0 means "no change" */ + memset(¶ms, 0, sizeof(params)); + + params.ndis_hdr.ndis_type = NDIS_OBJTYPE_DEFAULT; + if (sc->hn_ndis_ver < NDIS_VERSION_6_30) { + params.ndis_hdr.ndis_rev = NDIS_OFFLOAD_PARAMS_REV_2; + paramsz = NDIS_OFFLOAD_PARAMS_SIZE_6_1; + } else { + params.ndis_hdr.ndis_rev = NDIS_OFFLOAD_PARAMS_REV_3; + paramsz = NDIS_OFFLOAD_PARAMS_SIZE; + } + params.ndis_hdr.ndis_size = paramsz; + + params.ndis_ip4csum = NDIS_OFFLOAD_PARAM_TXRX; + params.ndis_tcp4csum = NDIS_OFFLOAD_PARAM_TXRX; + params.ndis_tcp6csum = NDIS_OFFLOAD_PARAM_TXRX; + if (sc->hn_ndis_ver >= NDIS_VERSION_6_30) { + params.ndis_udp4csum = NDIS_OFFLOAD_PARAM_TXRX; + params.ndis_udp6csum = NDIS_OFFLOAD_PARAM_TXRX; + } + params.ndis_lsov2_ip4 = NDIS_OFFLOAD_LSOV2_ON; + /* XXX ndis_lsov2_ip6 = NDIS_OFFLOAD_LSOV2_ON */ + + error = hn_rndis_set(sc, OID_TCP_OFFLOAD_PARAMETERS, ¶ms, paramsz); + if (error) { + if_printf(sc->hn_ifp, "offload config failed: %d\n", error); + } else { + if (bootverbose) + if_printf(sc->hn_ifp, "offload config done\n"); + } + return (error); +} + /* * RNDIS filter init device */ @@ -979,6 +1183,7 @@ hv_rf_init_device(rndis_device *device) struct rndis_init_req *req; const struct rndis_init_comp *comp; struct vmbus_xact *xact; + size_t comp_len; uint32_t rid; int error; @@ -999,8 +1204,9 @@ hv_rf_init_device(rndis_device *device) req->rm_ver_minor = RNDIS_VERSION_MINOR; req->rm_max_xfersz = HN_RNDIS_XFER_SIZE; - comp = hn_rndis_xact_execute(sc, xact, rid, sizeof(*req), - RNDIS_INIT_COMP_SIZE_MIN, REMOTE_NDIS_INITIALIZE_CMPLT); + comp_len = RNDIS_INIT_COMP_SIZE_MIN; + comp = hn_rndis_xact_execute(sc, xact, rid, sizeof(*req), &comp_len, + REMOTE_NDIS_INITIALIZE_CMPLT); if (comp == NULL) { if_printf(sc->hn_ifp, "exec RNDIS init failed\n"); error = EIO; @@ -1132,7 +1338,6 @@ hv_rf_on_device_add(struct hn_softc *sc, { int ret; rndis_device *rndis_dev; - rndis_offload_params offloads; struct rndis_recv_scale_cap rsscaps; uint32_t rsscaps_size = sizeof(struct rndis_recv_scale_cap); netvsc_device_info *dev_info = (netvsc_device_info *)additl_info; @@ -1182,21 +1387,8 @@ hv_rf_on_device_add(struct hn_softc *sc, /* TODO: shut down rndis device and the channel */ } - /* config csum offload and send request to host */ - memset(&offloads, 0, sizeof(offloads)); - offloads.ipv4_csum = RNDIS_OFFLOAD_PARAMETERS_TX_RX_ENABLED; - offloads.tcp_ipv4_csum = RNDIS_OFFLOAD_PARAMETERS_TX_RX_ENABLED; - offloads.udp_ipv4_csum = RNDIS_OFFLOAD_PARAMETERS_TX_RX_ENABLED; - offloads.tcp_ipv6_csum = RNDIS_OFFLOAD_PARAMETERS_TX_RX_ENABLED; - offloads.udp_ipv6_csum = RNDIS_OFFLOAD_PARAMETERS_TX_RX_ENABLED; - offloads.lso_v2_ipv4 = RNDIS_OFFLOAD_PARAMETERS_LSOV2_ENABLED; - - ret = hv_rf_send_offload_request(sc, &offloads); - if (ret != 0) { - /* TODO: shut down rndis device and the channel */ - device_printf(dev, - "hv_rf_send_offload_request failed, ret=%d\n", ret); - } + /* Configure NDIS offload settings */ + hn_rndis_conf_offload(sc); memcpy(dev_info->mac_addr, rndis_dev->hw_mac_addr, ETHER_ADDR_LEN); Copied and modified: stable/10/sys/dev/hyperv/netvsc/ndis.h (from r304834, head/sys/dev/hyperv/netvsc/ndis.h) ============================================================================== --- head/sys/dev/hyperv/netvsc/ndis.h Fri Aug 26 05:18:27 2016 (r304834, copy source) +++ stable/10/sys/dev/hyperv/netvsc/ndis.h Thu Oct 13 06:17:33 2016 (r307181) @@ -29,6 +29,9 @@ #ifndef _NET_NDIS_H_ #define _NET_NDIS_H_ +#define NDIS_MEDIA_STATE_CONNECTED 0 +#define NDIS_MEDIA_STATE_DISCONNECTED 1 + #define OID_TCP_OFFLOAD_PARAMETERS 0xFC01020C #define NDIS_OBJTYPE_DEFAULT 0x80 Modified: stable/10/sys/net/rndis.h ============================================================================== --- stable/10/sys/net/rndis.h Thu Oct 13 06:09:26 2016 (r307180) +++ stable/10/sys/net/rndis.h Thu Oct 13 06:17:33 2016 (r307181) @@ -172,6 +172,10 @@ struct rndis_query_req { uint32_t rm_devicevchdl; }; +#define RNDIS_QUERY_REQ_INFOBUFOFFSET \ + (sizeof(struct rndis_query_req) - \ + __offsetof(struct rndis_query_req, rm_rid)) + struct rndis_query_comp { uint32_t rm_type; uint32_t rm_len; @@ -181,6 +185,9 @@ struct rndis_query_comp { uint32_t rm_infobufoffset; }; +#define RNDIS_QUERY_COMP_INFOBUFABS(ofs) \ + ((ofs) + __offsetof(struct rndis_query_req, rm_rid)) + /* Send a set object request. */ #define REMOTE_NDIS_SET_MSG 0x00000005 #define REMOTE_NDIS_SET_CMPLT 0x80000005 @@ -195,6 +202,10 @@ struct rndis_set_req { uint32_t rm_devicevchdl; }; +#define RNDIS_SET_REQ_INFOBUFOFFSET \ + (sizeof(struct rndis_set_req) - \ + __offsetof(struct rndis_set_req, rm_rid)) + struct rndis_set_comp { uint32_t rm_type; uint32_t rm_len; From owner-svn-src-all@freebsd.org Thu Oct 13 06:19:55 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D9845C0FE49; Thu, 13 Oct 2016 06:19:55 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 9A2E0FE2; Thu, 13 Oct 2016 06:19:55 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9D6JsvV088688; Thu, 13 Oct 2016 06:19:54 GMT (envelope-from avg@FreeBSD.org) Received: (from avg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9D6JsMd088686; Thu, 13 Oct 2016 06:19:54 GMT (envelope-from avg@FreeBSD.org) Message-Id: <201610130619.u9D6JsMd088686@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avg set sender to avg@FreeBSD.org using -f From: Andriy Gapon Date: Thu, 13 Oct 2016 06:19:54 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307182 - head/etc/rc.d X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Oct 2016 06:19:55 -0000 Author: avg Date: Thu Oct 13 06:19:54 2016 New Revision: 307182 URL: https://svnweb.freebsd.org/changeset/base/307182 Log: rc.d/zfsbe: a new script designed for boot environment support Currently zfsbe ensures that subordinate filesystems are mounted at the right mount points. The script assumes that the subordinate filesystems of a boot environment have their canmount property set to noauto, so that they are not automatically mounted on boot. Whereas the root filesystem is mounted by the kernel, there was nothing to mount its subordinates. rc.d/zfsbe fills that gap. Discussed with: allanjude, will MFC after: 3 weeks Differential Revision: https://reviews.freebsd.org/D7797 Added: head/etc/rc.d/zfsbe (contents, props changed) Modified: head/etc/rc.d/zfs Modified: head/etc/rc.d/zfs ============================================================================== --- head/etc/rc.d/zfs Thu Oct 13 06:17:33 2016 (r307181) +++ head/etc/rc.d/zfs Thu Oct 13 06:19:54 2016 (r307182) @@ -4,7 +4,7 @@ # # PROVIDE: zfs -# REQUIRE: mountcritlocal +# REQUIRE: zfsbe # BEFORE: FILESYSTEMS var . /etc/rc.subr Added: head/etc/rc.d/zfsbe ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/etc/rc.d/zfsbe Thu Oct 13 06:19:54 2016 (r307182) @@ -0,0 +1,71 @@ +#!/bin/sh +# +# $FreeBSD$ +# + +# PROVIDE: zfsbe +# REQUIRE: mountcritlocal + +# Handle boot environment subordinate filesystems +# that may have canmount property set to noauto. +# For these filesystems mountpoint relative to / +# must be the same as their dataset name relative +# to BE root dataset. + +. /etc/rc.subr + +name="zfsbe" +rcvar="zfs_enable" +start_cmd="be_start" +stop_cmd="be_stop" +required_modules="zfs" + +mount_subordinate() +{ + local _be + + _be=$1 + zfs list -rH -o mountpoint,name,canmount,mounted -s mountpoint -t filesystem $_be | \ + while read _mp _name _canmount _mounted ; do + # skip filesystems that must not be mounted + [ "$_canmount" = "off" ] && continue + # skip filesystems that are already mounted + [ "$_mounted" = "yes" ] && continue + case "$_mp" in + "none" | "legacy" | "/" | "/$_be") + # do nothing for filesystems with unset or legacy mountpoint + # or those that would be mounted over / + ;; + "/$_be/"*) + # filesystems with mountpoint relative to BE + mount -t zfs $_name ${_mp#/$_be} + ;; + *) + # filesystems with mountpoint elsewhere + zfs mount $_name + ;; + esac + done +} + +be_start() +{ + if [ `$SYSCTL_N security.jail.jailed` -eq 1 ]; then + : + else + mount -p | while read _dev _mp _type _rest; do + [ $_mp = "/" ] || continue + if [ $_type = "zfs" ] ; then + mount_subordinate $_dev + fi + break + done + fi +} + +be_stop() +{ +} + +load_rc_config $name +run_rc_command "$1" From owner-svn-src-all@freebsd.org Thu Oct 13 06:32:22 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id BB2A1C0F312; Thu, 13 Oct 2016 06:32:22 +0000 (UTC) (envelope-from np@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 8792FAA1; Thu, 13 Oct 2016 06:32:22 +0000 (UTC) (envelope-from np@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9D6WL3o095999; Thu, 13 Oct 2016 06:32:21 GMT (envelope-from np@FreeBSD.org) Received: (from np@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9D6WLJ4095998; Thu, 13 Oct 2016 06:32:21 GMT (envelope-from np@FreeBSD.org) Message-Id: <201610130632.u9D6WLJ4095998@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: np set sender to np@FreeBSD.org using -f From: Navdeep Parhar Date: Thu, 13 Oct 2016 06:32:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307183 - stable/10/usr.sbin/bhyve X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Oct 2016 06:32:22 -0000 Author: np Date: Thu Oct 13 06:32:21 2016 New Revision: 307183 URL: https://svnweb.freebsd.org/changeset/base/307183 Log: bhyve(8): Fix typo from r294294 that prevented bhyve from working with vmnet devices. This is a direct commit to stable/10. Modified: stable/10/usr.sbin/bhyve/pci_virtio_net.c Modified: stable/10/usr.sbin/bhyve/pci_virtio_net.c ============================================================================== --- stable/10/usr.sbin/bhyve/pci_virtio_net.c Thu Oct 13 06:19:54 2016 (r307182) +++ stable/10/usr.sbin/bhyve/pci_virtio_net.c Thu Oct 13 06:32:21 2016 (r307183) @@ -851,7 +851,7 @@ pci_vtnet_init(struct vmctx *ctx, struct if (strncmp(devname, "vale", 4) == 0) pci_vtnet_netmap_setup(sc, devname); if ((strncmp(devname, "tap", 3) == 0) || - (strncmp(devname, "vmmnet", 5) == 0)) + (strncmp(devname, "vmnet", 5) == 0)) pci_vtnet_tap_setup(sc, devname); free(devname); From owner-svn-src-all@freebsd.org Thu Oct 13 06:34:20 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 3FC46C0F3BC; Thu, 13 Oct 2016 06:34:20 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 03A57C54; Thu, 13 Oct 2016 06:34:19 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9D6YJs9096142; Thu, 13 Oct 2016 06:34:19 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9D6YIrt096136; Thu, 13 Oct 2016 06:34:18 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610130634.u9D6YIrt096136@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Thu, 13 Oct 2016 06:34:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307184 - in stable/10/sys: dev/hyperv/netvsc dev/usb/net net X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Oct 2016 06:34:20 -0000 Author: sephe Date: Thu Oct 13 06:34:18 2016 New Revision: 307184 URL: https://svnweb.freebsd.org/changeset/base/307184 Log: MFC 304973,304975,304976,304979,305044-305048 304973 hyperv/hn: Switch to new RNDIS query for link status extraction. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7654 304975 hyperv/hn: Switch to new RNDIS query for RSS capabilities extraction. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7656 304976 hyperv/hn: Fix # of channels setting, if RSS is not available. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7657 304979 hyperv/hn: Switch to new RNDIS set for RSS parameters. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7658 305044 hyperv/hn: Move OIDs to net/rndis.h; they are standard NDIS OIDs. Actually all OIDs defined in net/rndis.h are standard NDIS OIDs. While I'm here, use the verbose macro name as in NDIS spec. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7679 305045 hyperv/hn: Indentation and field comment fixup for ndis.h. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7680 305046 net/rndis: Packet types are defined by NDIS; not RNDIS specific. Reviewed by: hps Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7681 305047 hyperv/hn: Switch to new RNDIS set for RX filters. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7683 305048 hyperv/hn: Remove unused function Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7684 Modified: stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h stable/10/sys/dev/hyperv/netvsc/hv_rndis.h stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.c stable/10/sys/dev/hyperv/netvsc/ndis.h stable/10/sys/dev/usb/net/if_urndis.c stable/10/sys/net/rndis.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h Thu Oct 13 06:32:21 2016 (r307183) +++ stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h Thu Oct 13 06:34:18 2016 (r307184) @@ -62,6 +62,8 @@ #include #include +#include + #define HN_USE_TXDESC_BUFRING MALLOC_DECLARE(M_NETVSC); @@ -384,6 +386,8 @@ typedef struct hn_softc { uint32_t hn_rndis_rid; uint32_t hn_ndis_ver; + + struct ndis_rssprm_toeplitz hn_rss; } hn_softc_t; #define HN_FLAG_RXBUF_CONNECTED 0x0001 Modified: stable/10/sys/dev/hyperv/netvsc/hv_rndis.h ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_rndis.h Thu Oct 13 06:32:21 2016 (r307183) +++ stable/10/sys/dev/hyperv/netvsc/hv_rndis.h Thu Oct 13 06:34:18 2016 (r307184) @@ -536,20 +536,6 @@ struct rndis_hash_info { uint32_t hash_info; } __packed; -#define NDIS_HASH_FUNCTION_MASK 0x000000FF /* see hash function */ -#define NDIS_HASH_TYPE_MASK 0x00FFFF00 /* see hash type */ - -/* hash function */ -#define NDIS_HASH_FUNCTION_TOEPLITZ 0x00000001 - -/* hash type */ -#define NDIS_HASH_IPV4 0x00000100 -#define NDIS_HASH_TCP_IPV4 0x00000200 -#define NDIS_HASH_IPV6 0x00000400 -#define NDIS_HASH_IPV6_EX 0x00000800 -#define NDIS_HASH_TCP_IPV6 0x00001000 -#define NDIS_HASH_TCP_IPV6_EX 0x00002000 - typedef struct rndis_tcp_tso_info_ { union { struct { @@ -903,19 +889,6 @@ typedef struct rndismp_rx_bufs_info_ { #define RNDIS_HEADER_SIZE (sizeof(rndis_msg) - sizeof(rndis_msg_container)) -#define NDIS_PACKET_TYPE_DIRECTED 0x00000001 -#define NDIS_PACKET_TYPE_MULTICAST 0x00000002 -#define NDIS_PACKET_TYPE_ALL_MULTICAST 0x00000004 -#define NDIS_PACKET_TYPE_BROADCAST 0x00000008 -#define NDIS_PACKET_TYPE_SOURCE_ROUTING 0x00000010 -#define NDIS_PACKET_TYPE_PROMISCUOUS 0x00000020 -#define NDIS_PACKET_TYPE_SMT 0x00000040 -#define NDIS_PACKET_TYPE_ALL_LOCAL 0x00000080 -#define NDIS_PACKET_TYPE_GROUP 0x00000100 -#define NDIS_PACKET_TYPE_ALL_FUNCTIONAL 0x00000200 -#define NDIS_PACKET_TYPE_FUNCTIONAL 0x00000400 -#define NDIS_PACKET_TYPE_MAC_FRAME 0x00000800 - /* * Externs */ Modified: stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.c Thu Oct 13 06:32:21 2016 (r307183) +++ stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.c Thu Oct 13 06:34:18 2016 (r307184) @@ -80,17 +80,9 @@ static void hv_rf_receive_indicate_statu const rndis_msg *response); static void hv_rf_receive_data(struct hn_rx_ring *rxr, const void *data, int dlen); -static int hv_rf_query_device(rndis_device *device, uint32_t oid, - void *result, uint32_t *result_size); static inline int hv_rf_query_device_mac(rndis_device *device); static inline int hv_rf_query_device_link_status(rndis_device *device); -static int hv_rf_set_packet_filter(rndis_device *device, uint32_t new_filter); static int hv_rf_init_device(rndis_device *device); -static int hv_rf_open_device(rndis_device *device); -static int hv_rf_close_device(rndis_device *device); -int -hv_rf_send_offload_request(struct hn_softc *sc, - rndis_offload_params *offloads); static void hn_rndis_sent_halt(struct hn_send_ctx *sndc, struct hn_softc *sc, struct vmbus_channel *chan, @@ -103,6 +95,8 @@ static int hn_rndis_query(struct hn_soft static int hn_rndis_set(struct hn_softc *sc, uint32_t oid, const void *data, size_t dlen); static int hn_rndis_conf_offload(struct hn_softc *sc); +static int hn_rndis_get_rsscaps(struct hn_softc *sc, int *rxr_cnt); +static int hn_rndis_conf_rss(struct hn_softc *sc, int nchan); static __inline uint32_t hn_rndis_rid(struct hn_softc *sc) @@ -356,78 +350,6 @@ hv_rf_receive_response(rndis_device *dev } } -int -hv_rf_send_offload_request(struct hn_softc *sc, - rndis_offload_params *offloads) -{ - rndis_request *request; - rndis_set_request *set; - rndis_offload_params *offload_req; - rndis_set_complete *set_complete; - rndis_device *rndis_dev = sc->rndis_dev; - device_t dev = sc->hn_dev; - uint32_t extlen = sizeof(rndis_offload_params); - int ret; - - if (sc->hn_nvs_ver <= NVSP_PROTOCOL_VERSION_4) { - extlen = VERSION_4_OFFLOAD_SIZE; - /* On NVSP_PROTOCOL_VERSION_4 and below, we do not support - * UDP checksum offload. - */ - offloads->udp_ipv4_csum = 0; - offloads->udp_ipv6_csum = 0; - } - - request = hv_rndis_request(rndis_dev, REMOTE_NDIS_SET_MSG, - RNDIS_MESSAGE_SIZE(rndis_set_request) + extlen); - if (!request) - return (ENOMEM); - - set = &request->request_msg.msg.set_request; - set->oid = RNDIS_OID_TCP_OFFLOAD_PARAMETERS; - set->info_buffer_length = extlen; - set->info_buffer_offset = sizeof(rndis_set_request); - set->device_vc_handle = 0; - - offload_req = (rndis_offload_params *)((unsigned long)set + - set->info_buffer_offset); - *offload_req = *offloads; - offload_req->header.type = RNDIS_OBJECT_TYPE_DEFAULT; - offload_req->header.revision = RNDIS_OFFLOAD_PARAMETERS_REVISION_3; - offload_req->header.size = extlen; - - ret = hv_rf_send_request(rndis_dev, request, REMOTE_NDIS_SET_MSG); - if (ret != 0) { - device_printf(dev, "hv send offload request failed, ret=%d!\n", - ret); - goto cleanup; - } - - ret = sema_timedwait(&request->wait_sema, 5 * hz); - if (ret != 0) { - device_printf(dev, "hv send offload request timeout\n"); - goto cleanup; - } - - set_complete = &request->response_msg.msg.set_complete; - if (set_complete->status == RNDIS_STATUS_SUCCESS) { - device_printf(dev, "hv send offload request succeeded\n"); - ret = 0; - } else { - if (set_complete->status == RNDIS_STATUS_NOT_SUPPORTED) { - device_printf(dev, "HV Not support offload\n"); - ret = 0; - } else { - ret = set_complete->status; - } - } - -cleanup: - hv_put_rndis_request(rndis_dev, request); - - return (ret); -} - /* * RNDIS filter receive indicate status */ @@ -629,77 +551,6 @@ hv_rf_on_receive(struct hn_softc *sc, st } /* - * RNDIS filter query device - */ -static int -hv_rf_query_device(rndis_device *device, uint32_t oid, void *result, - uint32_t *result_size) -{ - rndis_request *request; - uint32_t in_result_size = *result_size; - rndis_query_request *query; - rndis_query_complete *query_complete; - int ret = 0; - - *result_size = 0; - request = hv_rndis_request(device, REMOTE_NDIS_QUERY_MSG, - RNDIS_MESSAGE_SIZE(rndis_query_request)); - if (request == NULL) { - ret = -1; - goto cleanup; - } - - /* Set up the rndis query */ - query = &request->request_msg.msg.query_request; - query->oid = oid; - query->info_buffer_offset = sizeof(rndis_query_request); - query->info_buffer_length = 0; - query->device_vc_handle = 0; - - if (oid == RNDIS_OID_GEN_RSS_CAPABILITIES) { - struct rndis_recv_scale_cap *cap; - - request->request_msg.msg_len += - sizeof(struct rndis_recv_scale_cap); - query->info_buffer_length = sizeof(struct rndis_recv_scale_cap); - cap = (struct rndis_recv_scale_cap *)((unsigned long)query + - query->info_buffer_offset); - cap->hdr.type = RNDIS_OBJECT_TYPE_RSS_CAPABILITIES; - cap->hdr.rev = RNDIS_RECEIVE_SCALE_CAPABILITIES_REVISION_2; - cap->hdr.size = sizeof(struct rndis_recv_scale_cap); - } - - ret = hv_rf_send_request(device, request, REMOTE_NDIS_QUERY_MSG); - if (ret != 0) { - /* Fixme: printf added */ - printf("RNDISFILTER request failed to Send!\n"); - goto cleanup; - } - - sema_wait(&request->wait_sema); - - /* Copy the response back */ - query_complete = &request->response_msg.msg.query_complete; - - if (query_complete->info_buffer_length > in_result_size) { - ret = EINVAL; - goto cleanup; - } - - memcpy(result, (void *)((unsigned long)query_complete + - query_complete->info_buffer_offset), - query_complete->info_buffer_length); - - *result_size = query_complete->info_buffer_length; - -cleanup: - if (request != NULL) - hv_put_rndis_request(device, request); - - return (ret); -} - -/* * RNDIS filter query device MAC address */ static int @@ -713,12 +564,12 @@ hv_rf_query_device_mac(rndis_device *dev error = hn_rndis_query(sc, OID_802_3_PERMANENT_ADDRESS, NULL, 0, device->hw_mac_addr, &hwaddr_len); if (error) - return error; + return (error); if (hwaddr_len != ETHER_ADDR_LEN) { if_printf(sc->hn_ifp, "invalid hwaddr len %zu\n", hwaddr_len); - return EINVAL; + return (EINVAL); } - return 0; + return (0); } /* @@ -727,13 +578,23 @@ hv_rf_query_device_mac(rndis_device *dev static inline int hv_rf_query_device_link_status(rndis_device *device) { - uint32_t size = sizeof(uint32_t); + struct hn_softc *sc = device->sc; + size_t size; + int error; - return (hv_rf_query_device(device, - RNDIS_OID_GEN_MEDIA_CONNECT_STATUS, &device->link_status, &size)); + size = sizeof(uint32_t); + error = hn_rndis_query(sc, OID_GEN_MEDIA_CONNECT_STATUS, NULL, 0, + &device->link_status, &size); + if (error) + return (error); + if (size != sizeof(uint32_t)) { + if_printf(sc->hn_ifp, "invalid link status len %zu\n", size); + return (EINVAL); + } + return (0); } -static uint8_t netvsc_hash_key[HASH_KEYLEN] = { +static uint8_t netvsc_hash_key[NDIS_HASH_KEYSIZE_TOEPLITZ] = { 0x6d, 0x5a, 0x56, 0xda, 0x25, 0x5b, 0x0e, 0xc2, 0x41, 0x67, 0x25, 0x3d, 0x43, 0xa3, 0x8f, 0xb0, 0xd0, 0xca, 0x2b, 0xcb, 0xae, 0x7b, 0x30, 0xb4, @@ -741,172 +602,6 @@ static uint8_t netvsc_hash_key[HASH_KEYL 0x6a, 0x42, 0xb7, 0x3b, 0xbe, 0xac, 0x01, 0xfa }; -/* - * RNDIS set vRSS parameters - */ -static int -hv_rf_set_rss_param(rndis_device *device, int num_queue) -{ - rndis_request *request; - rndis_set_request *set; - rndis_set_complete *set_complete; - rndis_recv_scale_param *rssp; - uint32_t extlen = sizeof(rndis_recv_scale_param) + - (4 * ITAB_NUM) + HASH_KEYLEN; - uint32_t *itab, status; - uint8_t *keyp; - int i, ret; - - - request = hv_rndis_request(device, REMOTE_NDIS_SET_MSG, - RNDIS_MESSAGE_SIZE(rndis_set_request) + extlen); - if (request == NULL) { - if (bootverbose) - printf("Netvsc: No memory to set vRSS parameters.\n"); - ret = -1; - goto cleanup; - } - - set = &request->request_msg.msg.set_request; - set->oid = RNDIS_OID_GEN_RSS_PARAMETERS; - set->info_buffer_length = extlen; - set->info_buffer_offset = sizeof(rndis_set_request); - set->device_vc_handle = 0; - - /* Fill out the rssp parameter structure */ - rssp = (rndis_recv_scale_param *)(set + 1); - rssp->hdr.type = RNDIS_OBJECT_TYPE_RSS_PARAMETERS; - rssp->hdr.rev = RNDIS_RECEIVE_SCALE_PARAMETERS_REVISION_2; - rssp->hdr.size = sizeof(rndis_recv_scale_param); - rssp->flag = 0; - rssp->hashinfo = RNDIS_HASH_FUNC_TOEPLITZ | RNDIS_HASH_IPV4 | - RNDIS_HASH_TCP_IPV4 | RNDIS_HASH_IPV6 | RNDIS_HASH_TCP_IPV6; - rssp->indirect_tabsize = 4 * ITAB_NUM; - rssp->indirect_taboffset = sizeof(rndis_recv_scale_param); - rssp->hashkey_size = HASH_KEYLEN; - rssp->hashkey_offset = rssp->indirect_taboffset + - rssp->indirect_tabsize; - - /* Set indirection table entries */ - itab = (uint32_t *)(rssp + 1); - for (i = 0; i < ITAB_NUM; i++) - itab[i] = i % num_queue; - - /* Set hash key values */ - keyp = (uint8_t *)((unsigned long)rssp + rssp->hashkey_offset); - for (i = 0; i < HASH_KEYLEN; i++) - keyp[i] = netvsc_hash_key[i]; - - ret = hv_rf_send_request(device, request, REMOTE_NDIS_SET_MSG); - if (ret != 0) { - goto cleanup; - } - - /* - * Wait for the response from the host. Another thread will signal - * us when the response has arrived. In the failure case, - * sema_timedwait() returns a non-zero status after waiting 5 seconds. - */ - ret = sema_timedwait(&request->wait_sema, 5 * hz); - if (ret == 0) { - /* Response received, check status */ - set_complete = &request->response_msg.msg.set_complete; - status = set_complete->status; - if (status != RNDIS_STATUS_SUCCESS) { - /* Bad response status, return error */ - if (bootverbose) - printf("Netvsc: Failed to set vRSS " - "parameters.\n"); - ret = -2; - } else { - if (bootverbose) - printf("Netvsc: Successfully set vRSS " - "parameters.\n"); - } - } else { - /* - * We cannot deallocate the request since we may still - * receive a send completion for it. - */ - printf("Netvsc: vRSS set timeout, id = %u, ret = %d\n", - request->request_msg.msg.init_request.request_id, ret); - goto exit; - } - -cleanup: - if (request != NULL) { - hv_put_rndis_request(device, request); - } -exit: - return (ret); -} - -/* - * RNDIS filter set packet filter - * Sends an rndis request with the new filter, then waits for a response - * from the host. - * Returns zero on success, non-zero on failure. - */ -static int -hv_rf_set_packet_filter(rndis_device *device, uint32_t new_filter) -{ - rndis_request *request; - rndis_set_request *set; - rndis_set_complete *set_complete; - uint32_t status; - int ret; - - request = hv_rndis_request(device, REMOTE_NDIS_SET_MSG, - RNDIS_MESSAGE_SIZE(rndis_set_request) + sizeof(uint32_t)); - if (request == NULL) { - ret = -1; - goto cleanup; - } - - /* Set up the rndis set */ - set = &request->request_msg.msg.set_request; - set->oid = RNDIS_OID_GEN_CURRENT_PACKET_FILTER; - set->info_buffer_length = sizeof(uint32_t); - set->info_buffer_offset = sizeof(rndis_set_request); - - memcpy((void *)((unsigned long)set + sizeof(rndis_set_request)), - &new_filter, sizeof(uint32_t)); - - ret = hv_rf_send_request(device, request, REMOTE_NDIS_SET_MSG); - if (ret != 0) { - goto cleanup; - } - - /* - * Wait for the response from the host. Another thread will signal - * us when the response has arrived. In the failure case, - * sema_timedwait() returns a non-zero status after waiting 5 seconds. - */ - ret = sema_timedwait(&request->wait_sema, 5 * hz); - if (ret == 0) { - /* Response received, check status */ - set_complete = &request->response_msg.msg.set_complete; - status = set_complete->status; - if (status != RNDIS_STATUS_SUCCESS) { - /* Bad response status, return error */ - ret = -2; - } - } else { - /* - * We cannot deallocate the request since we may still - * receive a send completion for it. - */ - goto exit; - } - -cleanup: - if (request != NULL) { - hv_put_rndis_request(device, request); - } -exit: - return (ret); -} - static const void * hn_rndis_xact_execute(struct hn_softc *sc, struct vmbus_xact *xact, uint32_t rid, size_t reqlen, size_t *comp_len0, uint32_t comp_type) @@ -1084,6 +779,51 @@ done: } static int +hn_rndis_get_rsscaps(struct hn_softc *sc, int *rxr_cnt) +{ + struct ndis_rss_caps in, caps; + size_t caps_len; + int error; + + /* + * Only NDIS 6.30+ is supported. + */ + KASSERT(sc->hn_ndis_ver >= NDIS_VERSION_6_30, + ("NDIS 6.30+ is required, NDIS version 0x%08x", sc->hn_ndis_ver)); + *rxr_cnt = 0; + + memset(&in, 0, sizeof(in)); + in.ndis_hdr.ndis_type = NDIS_OBJTYPE_RSS_CAPS; + in.ndis_hdr.ndis_rev = NDIS_RSS_CAPS_REV_2; + in.ndis_hdr.ndis_size = NDIS_RSS_CAPS_SIZE; + + caps_len = NDIS_RSS_CAPS_SIZE; + error = hn_rndis_query(sc, OID_GEN_RECEIVE_SCALE_CAPABILITIES, + &in, NDIS_RSS_CAPS_SIZE, &caps, &caps_len); + if (error) + return (error); + if (caps_len < NDIS_RSS_CAPS_SIZE_6_0) { + if_printf(sc->hn_ifp, "invalid NDIS RSS caps len %zu", + caps_len); + return (EINVAL); + } + + if (caps.ndis_nrxr == 0) { + if_printf(sc->hn_ifp, "0 RX rings!?\n"); + return (EINVAL); + } + *rxr_cnt = caps.ndis_nrxr; + + if (caps_len == NDIS_RSS_CAPS_SIZE) { + if (bootverbose) { + if_printf(sc->hn_ifp, "RSS indirect table size %u\n", + caps.ndis_nind); + } + } + return (0); +} + +static int hn_rndis_set(struct hn_softc *sc, uint32_t oid, const void *data, size_t dlen) { struct rndis_set_req *req; @@ -1173,6 +913,72 @@ hn_rndis_conf_offload(struct hn_softc *s return (error); } +static int +hn_rndis_conf_rss(struct hn_softc *sc, int nchan) +{ + struct ndis_rssprm_toeplitz *rss = &sc->hn_rss; + struct ndis_rss_params *prm = &rss->rss_params; + int i, error; + + /* + * Only NDIS 6.30+ is supported. + */ + KASSERT(sc->hn_ndis_ver >= NDIS_VERSION_6_30, + ("NDIS 6.30+ is required, NDIS version 0x%08x", sc->hn_ndis_ver)); + + memset(rss, 0, sizeof(*rss)); + prm->ndis_hdr.ndis_type = NDIS_OBJTYPE_RSS_PARAMS; + prm->ndis_hdr.ndis_rev = NDIS_RSS_PARAMS_REV_2; + prm->ndis_hdr.ndis_size = sizeof(*rss); + prm->ndis_hash = NDIS_HASH_FUNCTION_TOEPLITZ | + NDIS_HASH_IPV4 | NDIS_HASH_TCP_IPV4 | + NDIS_HASH_IPV6 | NDIS_HASH_TCP_IPV6; + /* TODO: Take ndis_rss_caps.ndis_nind into account */ + prm->ndis_indsize = sizeof(rss->rss_ind); + prm->ndis_indoffset = + __offsetof(struct ndis_rssprm_toeplitz, rss_ind[0]); + prm->ndis_keysize = sizeof(rss->rss_key); + prm->ndis_keyoffset = + __offsetof(struct ndis_rssprm_toeplitz, rss_key[0]); + + /* Setup RSS key */ + memcpy(rss->rss_key, netvsc_hash_key, sizeof(rss->rss_key)); + + /* Setup RSS indirect table */ + /* TODO: Take ndis_rss_caps.ndis_nind into account */ + for (i = 0; i < NDIS_HASH_INDCNT; ++i) + rss->rss_ind[i] = i % nchan; + + error = hn_rndis_set(sc, OID_GEN_RECEIVE_SCALE_PARAMETERS, + rss, sizeof(*rss)); + if (error) { + if_printf(sc->hn_ifp, "RSS config failed: %d\n", error); + } else { + if (bootverbose) + if_printf(sc->hn_ifp, "RSS config done\n"); + } + return (error); +} + +static int +hn_rndis_set_rxfilter(struct hn_softc *sc, uint32_t filter) +{ + int error; + + error = hn_rndis_set(sc, OID_GEN_CURRENT_PACKET_FILTER, + &filter, sizeof(filter)); + if (error) { + if_printf(sc->hn_ifp, "set RX filter 0x%08x failed: %d\n", + filter, error); + } else { + if (bootverbose) { + if_printf(sc->hn_ifp, "set RX filter 0x%08x done\n", + filter); + } + } + return (error); +} + /* * RNDIS filter init device */ @@ -1281,55 +1087,6 @@ hv_rf_halt_device(rndis_device *device) } /* - * RNDIS filter open device - */ -static int -hv_rf_open_device(rndis_device *device) -{ - int ret; - - if (device->state != RNDIS_DEV_INITIALIZED) { - return (0); - } - - if (hv_promisc_mode != 1) { - ret = hv_rf_set_packet_filter(device, - NDIS_PACKET_TYPE_BROADCAST | - NDIS_PACKET_TYPE_ALL_MULTICAST | - NDIS_PACKET_TYPE_DIRECTED); - } else { - ret = hv_rf_set_packet_filter(device, - NDIS_PACKET_TYPE_PROMISCUOUS); - } - - if (ret == 0) { - device->state = RNDIS_DEV_DATAINITIALIZED; - } - - return (ret); -} - -/* - * RNDIS filter close device - */ -static int -hv_rf_close_device(rndis_device *device) -{ - int ret; - - if (device->state != RNDIS_DEV_DATAINITIALIZED) { - return (0); - } - - ret = hv_rf_set_packet_filter(device, 0); - if (ret == 0) { - device->state = RNDIS_DEV_INITIALIZED; - } - - return (ret); -} - -/* * RNDIS filter on device add */ int @@ -1338,8 +1095,6 @@ hv_rf_on_device_add(struct hn_softc *sc, { int ret; rndis_device *rndis_dev; - struct rndis_recv_scale_cap rsscaps; - uint32_t rsscaps_size = sizeof(struct rndis_recv_scale_cap); netvsc_device_info *dev_info = (netvsc_device_info *)additl_info; device_t dev = sc->hn_dev; struct hn_nvs_subch_req *req; @@ -1348,6 +1103,7 @@ hv_rf_on_device_add(struct hn_softc *sc, struct vmbus_xact *xact = NULL; uint32_t status, nsubch; int nchan = *nchan0; + int rxr_cnt; rndis_dev = hv_get_rndis_device(); if (rndis_dev == NULL) { @@ -1396,22 +1152,29 @@ hv_rf_on_device_add(struct hn_softc *sc, dev_info->link_state = rndis_dev->link_status; - if (sc->hn_nvs_ver < NVSP_PROTOCOL_VERSION_5 || nchan == 1) + if (sc->hn_ndis_ver < NDIS_VERSION_6_30 || nchan == 1) { + /* + * Either RSS is not supported, or multiple RX/TX rings + * are not requested. + */ + *nchan0 = 1; return (0); + } - memset(&rsscaps, 0, rsscaps_size); - ret = hv_rf_query_device(rndis_dev, - RNDIS_OID_GEN_RSS_CAPABILITIES, - &rsscaps, &rsscaps_size); - if ((ret != 0) || (rsscaps.num_recv_que < 2)) { - device_printf(dev, "hv_rf_query_device failed or " - "rsscaps.num_recv_que < 2 \n"); - goto out; + /* + * Get RSS capabilities, e.g. # of RX rings, and # of indirect + * table entries. + */ + ret = hn_rndis_get_rsscaps(sc, &rxr_cnt); + if (ret) { + /* No RSS; this is benign. */ + *nchan0 = 1; + return (0); } - device_printf(dev, "channel, offered %u, requested %d\n", - rsscaps.num_recv_que, nchan); - if (nchan > rsscaps.num_recv_que) - nchan = rsscaps.num_recv_que; + if (nchan > rxr_cnt) + nchan = rxr_cnt; + if_printf(sc->hn_ifp, "RX rings offered %u, requested %d\n", + rxr_cnt, nchan); if (nchan == 1) { device_printf(dev, "only 1 channel is supported, no vRSS\n"); @@ -1468,8 +1231,11 @@ hv_rf_on_device_add(struct hn_softc *sc, } nchan = nsubch + 1; - ret = hv_rf_set_rss_param(rndis_dev, nchan); - *nchan0 = nchan; + ret = hn_rndis_conf_rss(sc, nchan); + if (ret != 0) + *nchan0 = 1; + else + *nchan0 = nchan; out: if (xact != NULL) vmbus_xact_put(xact); @@ -1503,8 +1269,17 @@ hv_rf_on_device_remove(struct hn_softc * int hv_rf_on_open(struct hn_softc *sc) { + uint32_t filter; - return (hv_rf_open_device(sc->rndis_dev)); + /* XXX */ + if (hv_promisc_mode != 1) { + filter = NDIS_PACKET_TYPE_BROADCAST | + NDIS_PACKET_TYPE_ALL_MULTICAST | + NDIS_PACKET_TYPE_DIRECTED; + } else { + filter = NDIS_PACKET_TYPE_PROMISCUOUS; + } + return (hn_rndis_set_rxfilter(sc, filter)); } /* @@ -1514,7 +1289,7 @@ int hv_rf_on_close(struct hn_softc *sc) { - return (hv_rf_close_device(sc->rndis_dev)); + return (hn_rndis_set_rxfilter(sc, 0)); } static void Modified: stable/10/sys/dev/hyperv/netvsc/ndis.h ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/ndis.h Thu Oct 13 06:32:21 2016 (r307183) +++ stable/10/sys/dev/hyperv/netvsc/ndis.h Thu Oct 13 06:34:18 2016 (r307184) @@ -29,93 +29,178 @@ #ifndef _NET_NDIS_H_ #define _NET_NDIS_H_ -#define NDIS_MEDIA_STATE_CONNECTED 0 -#define NDIS_MEDIA_STATE_DISCONNECTED 1 +#define NDIS_MEDIA_STATE_CONNECTED 0 +#define NDIS_MEDIA_STATE_DISCONNECTED 1 -#define OID_TCP_OFFLOAD_PARAMETERS 0xFC01020C +#define NDIS_OFFLOAD_SET_NOCHG 0 +#define NDIS_OFFLOAD_SET_ON 1 +#define NDIS_OFFLOAD_SET_OFF 2 -#define NDIS_OBJTYPE_DEFAULT 0x80 +/* a.k.a GRE MAC */ +#define NDIS_ENCAP_TYPE_NVGRE 0x00000001 -/* common_set */ -#define NDIS_OFFLOAD_SET_NOCHG 0 -#define NDIS_OFFLOAD_SET_ON 1 -#define NDIS_OFFLOAD_SET_OFF 2 +#define NDIS_HASH_FUNCTION_MASK 0x000000FF /* see hash function */ +#define NDIS_HASH_TYPE_MASK 0x00FFFF00 /* see hash type */ -/* a.k.a GRE MAC */ -#define NDIS_ENCAP_TYPE_NVGRE 0x00000001 +/* hash function */ +#define NDIS_HASH_FUNCTION_TOEPLITZ 0x00000001 + +/* hash type */ +#define NDIS_HASH_IPV4 0x00000100 +#define NDIS_HASH_TCP_IPV4 0x00000200 +#define NDIS_HASH_IPV6 0x00000400 +#define NDIS_HASH_IPV6_EX 0x00000800 +#define NDIS_HASH_TCP_IPV6 0x00001000 +#define NDIS_HASH_TCP_IPV6_EX 0x00002000 + +#define NDIS_HASH_KEYSIZE_TOEPLITZ 40 +#define NDIS_HASH_INDCNT 128 + +#define NDIS_OBJTYPE_DEFAULT 0x80 +#define NDIS_OBJTYPE_RSS_CAPS 0x88 +#define NDIS_OBJTYPE_RSS_PARAMS 0x89 struct ndis_object_hdr { - uint8_t ndis_type; /* NDIS_OBJTYPE_ */ - uint8_t ndis_rev; /* type specific */ - uint16_t ndis_size; /* incl. this hdr */ + uint8_t ndis_type; /* NDIS_OBJTYPE_ */ + uint8_t ndis_rev; /* type specific */ + uint16_t ndis_size; /* incl. this hdr */ }; -/* OID_TCP_OFFLOAD_PARAMETERS */ +/* + * OID_TCP_OFFLOAD_PARAMETERS + * ndis_type: NDIS_OBJTYPE_DEFAULT + */ struct ndis_offload_params { struct ndis_object_hdr ndis_hdr; - uint8_t ndis_ip4csum; /* param_set */ - uint8_t ndis_tcp4csum; /* param_set */ - uint8_t ndis_udp4csum; /* param_set */ - uint8_t ndis_tcp6csum; /* param_set */ - uint8_t ndis_udp6csum; /* param_set */ - uint8_t ndis_lsov1; /* lsov1_set */ - uint8_t ndis_ipsecv1; /* ipsecv1_set */ - uint8_t ndis_lsov2_ip4; /* lsov2_set */ - uint8_t ndis_lsov2_ip6; /* lsov2_set */ - uint8_t ndis_tcp4conn; /* PARAM_NOCHG */ - uint8_t ndis_tcp6conn; /* PARAM_NOCHG */ - uint32_t ndis_flags; /* 0 */ + uint8_t ndis_ip4csum; /* NDIS_OFFLOAD_PARAM_ */ + uint8_t ndis_tcp4csum; /* NDIS_OFFLOAD_PARAM_ */ + uint8_t ndis_udp4csum; /* NDIS_OFFLOAD_PARAM_ */ + uint8_t ndis_tcp6csum; /* NDIS_OFFLOAD_PARAM_ */ + uint8_t ndis_udp6csum; /* NDIS_OFFLOAD_PARAM_ */ + uint8_t ndis_lsov1; /* NDIS_OFFLOAD_PARAM_ */ + uint8_t ndis_ipsecv1; /* NDIS_OFFLOAD_IPSECV1_ */ + uint8_t ndis_lsov2_ip4; /* NDIS_OFFLOAD_LSOV2_ */ + uint8_t ndis_lsov2_ip6; /* NDIS_OFFLOAD_LSOV2_ */ + uint8_t ndis_tcp4conn; /* 0 */ + uint8_t ndis_tcp6conn; /* 0 */ + uint32_t ndis_flags; /* 0 */ /* NDIS >= 6.1 */ - uint8_t ndis_ipsecv2; /* ipsecv2_set */ - uint8_t ndis_ipsecv2_ip4; /* ipsecv2_set */ + uint8_t ndis_ipsecv2; /* NDIS_OFFLOAD_IPSECV2_ */ + uint8_t ndis_ipsecv2_ip4;/* NDIS_OFFLOAD_IPSECV2_ */ /* NDIS >= 6.30 */ - uint8_t ndis_rsc_ip4; /* rsc_set */ - uint8_t ndis_rsc_ip6; /* rsc_set */ - uint8_t ndis_encap; /* common_set */ - uint8_t ndis_encap_types; /* NDIS_ENCAP_TYPE_ */ + uint8_t ndis_rsc_ip4; /* NDIS_OFFLOAD_RSC_ */ + uint8_t ndis_rsc_ip6; /* NDIS_OFFLOAD_RSC_ */ + uint8_t ndis_encap; /* NDIS_OFFLOAD_SET_ */ + uint8_t ndis_encap_types;/* NDIS_ENCAP_TYPE_ */ }; -#define NDIS_OFFLOAD_PARAMS_SIZE sizeof(struct ndis_offload_params) -#define NDIS_OFFLOAD_PARAMS_SIZE_6_1 \ +#define NDIS_OFFLOAD_PARAMS_SIZE sizeof(struct ndis_offload_params) +#define NDIS_OFFLOAD_PARAMS_SIZE_6_1 \ __offsetof(struct ndis_offload_params, ndis_rsc_ip4) -#define NDIS_OFFLOAD_PARAMS_REV_2 2 /* NDIS 6.1 */ -#define NDIS_OFFLOAD_PARAMS_REV_3 3 /* NDIS 6.30 */ +#define NDIS_OFFLOAD_PARAMS_REV_2 2 /* NDIS 6.1 */ +#define NDIS_OFFLOAD_PARAMS_REV_3 3 /* NDIS 6.30 */ -/* param_set */ -#define NDIS_OFFLOAD_PARAM_NOCHG 0 /* common to all sets */ -#define NDIS_OFFLOAD_PARAM_OFF 1 -#define NDIS_OFFLOAD_PARAM_TX 2 -#define NDIS_OFFLOAD_PARAM_RX 3 -#define NDIS_OFFLOAD_PARAM_TXRX 4 +#define NDIS_OFFLOAD_PARAM_NOCHG 0 /* common */ +#define NDIS_OFFLOAD_PARAM_OFF 1 +#define NDIS_OFFLOAD_PARAM_TX 2 +#define NDIS_OFFLOAD_PARAM_RX 3 +#define NDIS_OFFLOAD_PARAM_TXRX 4 -/* lsov1_set */ /* NDIS_OFFLOAD_PARAM_NOCHG */ -#define NDIS_OFFLOAD_LSOV1_OFF 1 -#define NDIS_OFFLOAD_LSOV1_ON 2 +#define NDIS_OFFLOAD_LSOV1_OFF 1 +#define NDIS_OFFLOAD_LSOV1_ON 2 -/* ipsecv1_set */ /* NDIS_OFFLOAD_PARAM_NOCHG */ -#define NDIS_OFFLOAD_IPSECV1_OFF 1 -#define NDIS_OFFLOAD_IPSECV1_AH 2 -#define NDIS_OFFLOAD_IPSECV1_ESP 3 -#define NDIS_OFFLOAD_IPSECV1_AH_ESP 4 +#define NDIS_OFFLOAD_IPSECV1_OFF 1 +#define NDIS_OFFLOAD_IPSECV1_AH 2 +#define NDIS_OFFLOAD_IPSECV1_ESP 3 +#define NDIS_OFFLOAD_IPSECV1_AH_ESP 4 -/* lsov2_set */ /* NDIS_OFFLOAD_PARAM_NOCHG */ -#define NDIS_OFFLOAD_LSOV2_OFF 1 -#define NDIS_OFFLOAD_LSOV2_ON 2 +#define NDIS_OFFLOAD_LSOV2_OFF 1 +#define NDIS_OFFLOAD_LSOV2_ON 2 -/* ipsecv2_set */ /* NDIS_OFFLOAD_PARAM_NOCHG */ -#define NDIS_OFFLOAD_IPSECV2_OFF 1 -#define NDIS_OFFLOAD_IPSECV2_AH 2 -#define NDIS_OFFLOAD_IPSECV2_ESP 3 -#define NDIS_OFFLOAD_IPSECV2_AH_ESP 4 +#define NDIS_OFFLOAD_IPSECV2_OFF 1 +#define NDIS_OFFLOAD_IPSECV2_AH 2 +#define NDIS_OFFLOAD_IPSECV2_ESP 3 +#define NDIS_OFFLOAD_IPSECV2_AH_ESP 4 -/* rsc_set */ /* NDIS_OFFLOAD_PARAM_NOCHG */ -#define NDIS_OFFLOAD_RSC_OFF 1 -#define NDIS_OFFLOAD_RSC_ON 2 +#define NDIS_OFFLOAD_RSC_OFF 1 +#define NDIS_OFFLOAD_RSC_ON 2 + +/* + * OID_GEN_RECEIVE_SCALE_CAPABILITIES + * ndis_type: NDIS_OBJTYPE_RSS_CAPS + */ +struct ndis_rss_caps { + struct ndis_object_hdr ndis_hdr; + uint32_t ndis_flags; /* NDIS_RSS_CAP_ */ + uint32_t ndis_nmsi; /* # of MSIs */ + uint32_t ndis_nrxr; /* # of RX rings */ + /* NDIS >= 6.30 */ + uint16_t ndis_nind; /* # of indtbl ent. */ + uint16_t ndis_pad; +}; + +#define NDIS_RSS_CAPS_SIZE \ + __offsetof(struct ndis_rss_caps, ndis_pad) +#define NDIS_RSS_CAPS_SIZE_6_0 \ + __offsetof(struct ndis_rss_caps, ndis_nind) + +#define NDIS_RSS_CAPS_REV_1 1 /* NDIS 6.{0,1,20} */ +#define NDIS_RSS_CAPS_REV_2 2 /* NDIS 6.30 */ + +#define NDIS_RSS_CAP_MSI 0x01000000 +#define NDIS_RSS_CAP_CLASSIFY_ISR 0x02000000 +#define NDIS_RSS_CAP_CLASSIFY_DPC 0x04000000 +#define NDIS_RSS_CAP_MSIX 0x08000000 +#define NDIS_RSS_CAP_IPV4 0x00000100 +#define NDIS_RSS_CAP_IPV6 0x00000200 +#define NDIS_RSS_CAP_IPV6_EX 0x00000400 +#define NDIS_RSS_CAP_HASH_TOEPLITZ 0x00000001 + +/* + * OID_GEN_RECEIVE_SCALE_PARAMETERS + * ndis_type: NDIS_OBJTYPE_RSS_PARAMS + */ +struct ndis_rss_params { + struct ndis_object_hdr ndis_hdr; + uint16_t ndis_flags; /* NDIS_RSS_FLAG_ */ + uint16_t ndis_bcpu; /* base cpu 0 */ + uint32_t ndis_hash; /* NDIS_HASH_ */ + uint16_t ndis_indsize; /* indirect table */ + uint32_t ndis_indoffset; + uint16_t ndis_keysize; /* hash key */ + uint32_t ndis_keyoffset; + /* NDIS >= 6.20 */ + uint32_t ndis_cpumaskoffset; + uint32_t ndis_cpumaskcnt; + uint32_t ndis_cpumaskentsz; +}; + +#define NDIS_RSS_PARAMS_SIZE sizeof(struct ndis_rss_params) +#define NDIS_RSS_PARAMS_SIZE_6_0 \ + __offsetof(struct ndis_rss_params, ndis_cpumaskoffset) + +#define NDIS_RSS_PARAMS_REV_1 1 /* NDIS 6.0 */ +#define NDIS_RSS_PARAMS_REV_2 2 /* NDIS 6.20 */ + +#define NDIS_RSS_FLAG_BCPU_UNCHG 0x0001 +#define NDIS_RSS_FLAG_HASH_UNCHG 0x0002 +#define NDIS_RSS_FLAG_IND_UNCHG 0x0004 +#define NDIS_RSS_FLAG_KEY_UNCHG 0x0008 +#define NDIS_RSS_FLAG_DISABLE 0x0010 + +/* non-standard convenient struct */ +struct ndis_rssprm_toeplitz { + struct ndis_rss_params rss_params; + /* Toeplitz hash key */ + uint8_t rss_key[NDIS_HASH_KEYSIZE_TOEPLITZ]; + /* Indirect table */ + uint32_t rss_ind[NDIS_HASH_INDCNT]; +}; #endif /* !_NET_NDIS_H_ */ Modified: stable/10/sys/dev/usb/net/if_urndis.c ============================================================================== --- stable/10/sys/dev/usb/net/if_urndis.c Thu Oct 13 06:32:21 2016 (r307183) +++ stable/10/sys/dev/usb/net/if_urndis.c Thu Oct 13 06:34:18 2016 (r307184) @@ -291,8 +291,8 @@ urndis_attach(device_t dev) memcpy(&sc->sc_ue.ue_eaddr, buf, ETHER_ADDR_LEN); /* Initialize packet filter */ - sc->sc_filter = RNDIS_PACKET_TYPE_BROADCAST | - RNDIS_PACKET_TYPE_ALL_MULTICAST; + sc->sc_filter = NDIS_PACKET_TYPE_BROADCAST | *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-all@freebsd.org Thu Oct 13 06:39:07 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C95E2C0F4B7; Thu, 13 Oct 2016 06:39:07 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id A497DDF7; Thu, 13 Oct 2016 06:39:07 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9D6d6Wp096382; Thu, 13 Oct 2016 06:39:06 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9D6d6OC096379; Thu, 13 Oct 2016 06:39:06 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610130639.u9D6d6OC096379@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Thu, 13 Oct 2016 06:39:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307185 - stable/10/sys/dev/hyperv/netvsc X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Oct 2016 06:39:07 -0000 Author: sephe Date: Thu Oct 13 06:39:06 2016 New Revision: 307185 URL: https://svnweb.freebsd.org/changeset/base/307185 Log: MFC 305049,305050 305049 hyperv/hn: Factor out func to exec RNDIS transaction w/o checking result It will be used by RNDIS HALT and RESET. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7685 305050 hyperv/hn: Switch to new RNDIS transaction execution for halt. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7686 Modified: stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.c stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.c stable/10/sys/dev/hyperv/netvsc/if_hnvar.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.c Thu Oct 13 06:34:18 2016 (r307184) +++ stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.c Thu Oct 13 06:39:06 2016 (r307185) @@ -73,8 +73,6 @@ static void hv_nv_on_receive(struct hn_s static void hn_nvs_sent_none(struct hn_send_ctx *sndc, struct hn_softc *, struct vmbus_channel *chan, const void *, int); -static void hn_nvs_sent_xact(struct hn_send_ctx *, struct hn_softc *sc, - struct vmbus_channel *, const void *, int); struct hn_send_ctx hn_send_ctx_none = HN_SEND_CTX_INITIALIZER(hn_nvs_sent_none, NULL); @@ -654,7 +652,7 @@ hv_nv_on_device_remove(struct hn_softc * return (0); } -static void +void hn_nvs_sent_xact(struct hn_send_ctx *sndc, struct hn_softc *sc __unused, struct vmbus_channel *chan __unused, const void *data, int dlen) Modified: stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.c Thu Oct 13 06:34:18 2016 (r307184) +++ stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.c Thu Oct 13 06:39:06 2016 (r307185) @@ -72,8 +72,6 @@ __FBSDID("$FreeBSD$"); /* * Forward declarations */ -static int hv_rf_send_request(rndis_device *device, rndis_request *request, - uint32_t message_type); static void hv_rf_receive_response(rndis_device *device, const rndis_msg *response); static void hv_rf_receive_indicate_status(rndis_device *device, @@ -84,12 +82,6 @@ static inline int hv_rf_query_device_mac static inline int hv_rf_query_device_link_status(rndis_device *device); static int hv_rf_init_device(rndis_device *device); -static void hn_rndis_sent_halt(struct hn_send_ctx *sndc, - struct hn_softc *sc, struct vmbus_channel *chan, - const void *data, int dlen); -static void hn_rndis_sent_cb(struct hn_send_ctx *sndc, - struct hn_softc *sc, struct vmbus_channel *chan, - const void *data, int dlen); static int hn_rndis_query(struct hn_softc *sc, uint32_t oid, const void *idata, size_t idlen, void *odata, size_t *odlen0); static int hn_rndis_set(struct hn_softc *sc, uint32_t oid, const void *data, @@ -198,120 +190,6 @@ hv_put_rndis_device(rndis_device *device } /* - * - */ -static inline rndis_request * -hv_rndis_request(rndis_device *device, uint32_t message_type, - uint32_t message_length) -{ - rndis_request *request; - rndis_msg *rndis_mesg; - rndis_set_request *set; - - request = malloc(sizeof(rndis_request), M_NETVSC, M_WAITOK | M_ZERO); - - sema_init(&request->wait_sema, 0, "rndis sema"); - - rndis_mesg = &request->request_msg; - rndis_mesg->ndis_msg_type = message_type; - rndis_mesg->msg_len = message_length; - - /* - * Set the request id. This field is always after the rndis header - * for request/response packet types so we just use the set_request - * as a template. - */ - set = &rndis_mesg->msg.set_request; - set->request_id = atomic_fetchadd_int(&device->new_request_id, 1) & - HN_RNDIS_RID_COMPAT_MASK; - - /* Add to the request list */ - mtx_lock(&device->req_lock); - STAILQ_INSERT_TAIL(&device->myrequest_list, request, mylist_entry); - mtx_unlock(&device->req_lock); - - return (request); -} - -/* - * - */ -static inline void -hv_put_rndis_request(rndis_device *device, rndis_request *request) -{ - mtx_lock(&device->req_lock); - /* Fixme: Has O(n) performance */ - /* - * XXXKYS: Use Doubly linked lists. - */ - STAILQ_REMOVE(&device->myrequest_list, request, rndis_request_, - mylist_entry); - mtx_unlock(&device->req_lock); - - sema_destroy(&request->wait_sema); - free(request, M_NETVSC); -} - -/* - * - */ -static int -hv_rf_send_request(rndis_device *device, rndis_request *request, - uint32_t message_type) -{ - struct hn_softc *sc = device->sc; - uint32_t send_buf_section_idx, tot_data_buf_len; - struct vmbus_gpa gpa[2]; - int gpa_cnt, send_buf_section_size; - hn_sent_callback_t cb; - - /* Set up the packet to send it */ - tot_data_buf_len = request->request_msg.msg_len; - - gpa_cnt = 1; - gpa[0].gpa_page = hv_get_phys_addr(&request->request_msg) >> PAGE_SHIFT; - gpa[0].gpa_len = request->request_msg.msg_len; - gpa[0].gpa_ofs = (unsigned long)&request->request_msg & (PAGE_SIZE - 1); - - if (gpa[0].gpa_ofs + gpa[0].gpa_len > PAGE_SIZE) { - gpa_cnt = 2; - gpa[0].gpa_len = PAGE_SIZE - gpa[0].gpa_ofs; - gpa[1].gpa_page = - hv_get_phys_addr((char*)&request->request_msg + - gpa[0].gpa_len) >> PAGE_SHIFT; - gpa[1].gpa_ofs = 0; - gpa[1].gpa_len = request->request_msg.msg_len - gpa[0].gpa_len; - } - - if (message_type != REMOTE_NDIS_HALT_MSG) - cb = hn_rndis_sent_cb; - else - cb = hn_rndis_sent_halt; - - if (tot_data_buf_len < sc->hn_chim_szmax) { - send_buf_section_idx = hn_chim_alloc(sc); - if (send_buf_section_idx != HN_NVS_CHIM_IDX_INVALID) { - uint8_t *dest = sc->hn_chim + - (send_buf_section_idx * sc->hn_chim_szmax); - - memcpy(dest, &request->request_msg, request->request_msg.msg_len); - send_buf_section_size = tot_data_buf_len; - gpa_cnt = 0; - goto sendit; - } - /* Failed to allocate chimney send buffer; move on */ - } - send_buf_section_idx = HN_NVS_CHIM_IDX_INVALID; - send_buf_section_size = 0; - -sendit: - hn_send_ctx_init(&request->send_ctx, cb, request, - send_buf_section_idx, send_buf_section_size); - return hv_nv_on_send(sc->hn_prichan, HN_NVS_RNDIS_MTYPE_CTRL, - &request->send_ctx, gpa, gpa_cnt); -} - -/* * RNDIS filter receive response */ static void @@ -603,20 +481,15 @@ static uint8_t netvsc_hash_key[NDIS_HASH }; static const void * -hn_rndis_xact_execute(struct hn_softc *sc, struct vmbus_xact *xact, uint32_t rid, - size_t reqlen, size_t *comp_len0, uint32_t comp_type) +hn_rndis_xact_exec1(struct hn_softc *sc, struct vmbus_xact *xact, size_t reqlen, + struct hn_send_ctx *sndc, size_t *comp_len) { struct vmbus_gpa gpa[HN_XACT_REQ_PGCNT]; - const struct rndis_comp_hdr *comp; - bus_addr_t paddr; - size_t comp_len, min_complen = *comp_len0; int gpa_cnt, error; + bus_addr_t paddr; - KASSERT(rid > HN_RNDIS_RID_COMPAT_MAX, ("invalid rid %u\n", rid)); KASSERT(reqlen <= HN_XACT_REQ_SIZE && reqlen > 0, ("invalid request length %zu", reqlen)); - KASSERT(min_complen >= sizeof(*comp), - ("invalid minimum complete len %zu", min_complen)); /* * Setup the SG list. @@ -645,14 +518,34 @@ hn_rndis_xact_execute(struct hn_softc *s * message. */ vmbus_xact_activate(xact); - error = hv_nv_on_send(sc->hn_prichan, HN_NVS_RNDIS_MTYPE_CTRL, - &hn_send_ctx_none, gpa, gpa_cnt); + error = hv_nv_on_send(sc->hn_prichan, HN_NVS_RNDIS_MTYPE_CTRL, sndc, + gpa, gpa_cnt); if (error) { vmbus_xact_deactivate(xact); if_printf(sc->hn_ifp, "RNDIS ctrl send failed: %d\n", error); return (NULL); } - comp = vmbus_xact_wait(xact, &comp_len); + return (vmbus_xact_wait(xact, comp_len)); +} + +static const void * +hn_rndis_xact_execute(struct hn_softc *sc, struct vmbus_xact *xact, uint32_t rid, + size_t reqlen, size_t *comp_len0, uint32_t comp_type) +{ + const struct rndis_comp_hdr *comp; + size_t comp_len, min_complen = *comp_len0; + + KASSERT(rid > HN_RNDIS_RID_COMPAT_MAX, ("invalid rid %u\n", rid)); + KASSERT(min_complen >= sizeof(*comp), + ("invalid minimum complete len %zu", min_complen)); + + /* + * Execute the xact setup by the caller. + */ + comp = hn_rndis_xact_exec1(sc, xact, reqlen, &hn_send_ctx_none, + &comp_len); + if (comp == NULL) + return (NULL); /* * Check this RNDIS complete message. @@ -1038,51 +931,34 @@ done: return (error); } -#define HALT_COMPLETION_WAIT_COUNT 25 - /* * RNDIS filter halt device */ static int -hv_rf_halt_device(rndis_device *device) +hv_rf_halt_device(struct hn_softc *sc) { - rndis_request *request; - int i, ret; - - /* Attempt to do a rndis device halt */ - request = hv_rndis_request(device, REMOTE_NDIS_HALT_MSG, - RNDIS_MESSAGE_SIZE(rndis_halt_request)); - if (request == NULL) { - return (-1); - } - - /* initialize "poor man's semaphore" */ - request->halt_complete_flag = 0; - - ret = hv_rf_send_request(device, request, REMOTE_NDIS_HALT_MSG); - if (ret != 0) { - return (-1); - } + struct vmbus_xact *xact; + struct rndis_halt_req *halt; + struct hn_send_ctx sndc; + size_t comp_len; - /* - * Wait for halt response from halt callback. We must wait for - * the transaction response before freeing the request and other - * resources. - */ - for (i=HALT_COMPLETION_WAIT_COUNT; i > 0; i--) { - if (request->halt_complete_flag != 0) { - break; - } - DELAY(400); - } - if (i == 0) { - return (-1); + xact = vmbus_xact_get(sc->hn_xact, sizeof(*halt)); + if (xact == NULL) { + if_printf(sc->hn_ifp, "no xact for RNDIS halt\n"); + return (ENXIO); } + halt = vmbus_xact_req_data(xact); + halt->rm_type = REMOTE_NDIS_HALT_MSG; + halt->rm_len = sizeof(*halt); + halt->rm_rid = hn_rndis_rid(sc); + + /* No RNDIS completion; rely on NVS message send completion */ + hn_send_ctx_init_simple(&sndc, hn_nvs_sent_xact, xact); + hn_rndis_xact_exec1(sc, xact, sizeof(*halt), &sndc, &comp_len); - device->state = RNDIS_DEV_UNINITIALIZED; - - hv_put_rndis_request(device, request); - + vmbus_xact_put(xact); + if (bootverbose) + if_printf(sc->hn_ifp, "RNDIS halt done\n"); return (0); } @@ -1252,7 +1128,7 @@ hv_rf_on_device_remove(struct hn_softc * int ret; /* Halt and release the rndis device */ - ret = hv_rf_halt_device(rndis_dev); + ret = hv_rf_halt_device(sc); sc->rndis_dev = NULL; hv_put_rndis_device(rndis_dev); @@ -1292,33 +1168,6 @@ hv_rf_on_close(struct hn_softc *sc) return (hn_rndis_set_rxfilter(sc, 0)); } -static void -hn_rndis_sent_cb(struct hn_send_ctx *sndc, struct hn_softc *sc, - struct vmbus_channel *chan __unused, const void *data __unused, - int dlen __unused) -{ - if (sndc->hn_chim_idx != HN_NVS_CHIM_IDX_INVALID) - hn_chim_free(sc, sndc->hn_chim_idx); -} - -static void -hn_rndis_sent_halt(struct hn_send_ctx *sndc, struct hn_softc *sc, - struct vmbus_channel *chan __unused, const void *data __unused, - int dlen __unused) -{ - rndis_request *request = sndc->hn_cbarg; - - if (sndc->hn_chim_idx != HN_NVS_CHIM_IDX_INVALID) - hn_chim_free(sc, sndc->hn_chim_idx); - - /* - * Notify hv_rf_halt_device() about halt completion. - * The halt code must wait for completion before freeing - * the transaction resources. - */ - request->halt_complete_flag = 1; -} - void hv_rf_channel_rollup(struct hn_rx_ring *rxr, struct hn_tx_ring *txr) { Modified: stable/10/sys/dev/hyperv/netvsc/if_hnvar.h ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/if_hnvar.h Thu Oct 13 06:34:18 2016 (r307184) +++ stable/10/sys/dev/hyperv/netvsc/if_hnvar.h Thu Oct 13 06:39:06 2016 (r307185) @@ -112,6 +112,8 @@ struct vmbus_xact; const void *hn_nvs_xact_execute(struct hn_softc *sc, struct vmbus_xact *xact, void *req, int reqlen, size_t *resp_len); +void hn_nvs_sent_xact(struct hn_send_ctx *sndc, struct hn_softc *sc, + struct vmbus_channel *chan, const void *data, int dlen); uint32_t hn_chim_alloc(struct hn_softc *sc); void hn_chim_free(struct hn_softc *sc, uint32_t chim_idx); From owner-svn-src-all@freebsd.org Thu Oct 13 06:47:04 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 10FEEC0F704; Thu, 13 Oct 2016 06:47:04 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id C5B5C1498; Thu, 13 Oct 2016 06:47:03 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9D6l2Vl000146; Thu, 13 Oct 2016 06:47:02 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9D6l2Jp000140; Thu, 13 Oct 2016 06:47:02 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610130647.u9D6l2Jp000140@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Thu, 13 Oct 2016 06:47:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307186 - stable/10/sys/dev/hyperv/netvsc X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Oct 2016 06:47:04 -0000 Author: sephe Date: Thu Oct 13 06:47:02 2016 New Revision: 307186 URL: https://svnweb.freebsd.org/changeset/base/307186 Log: MFC 305052-305054,305110 305052 hyperv/hn: Remove the useless rndis_device and related bits Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7687 305053 hyperv/hn: Log packet message alignment. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7689 305054 hyperv/hn: Remove unnecessary NULL check. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7690 305110 hyperv/hn: Consolidate NVS transaction execution. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7704 Modified: stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.c stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.c stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.h stable/10/sys/dev/hyperv/netvsc/if_hnvar.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.c Thu Oct 13 06:39:06 2016 (r307185) +++ stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.c Thu Oct 13 06:47:02 2016 (r307186) @@ -106,21 +106,45 @@ hn_chim_alloc(struct hn_softc *sc) const void * hn_nvs_xact_execute(struct hn_softc *sc, struct vmbus_xact *xact, - void *req, int reqlen, size_t *resp_len) + void *req, int reqlen, size_t *resplen0, uint32_t type) { struct hn_send_ctx sndc; + size_t resplen, min_resplen = *resplen0; + const struct hn_nvs_hdr *hdr; int error; + KASSERT(min_resplen >= sizeof(*hdr), + ("invalid minimum response len %zu", min_resplen)); + + /* + * Execute the xact setup by the caller. + */ hn_send_ctx_init_simple(&sndc, hn_nvs_sent_xact, xact); - vmbus_xact_activate(xact); + vmbus_xact_activate(xact); error = hn_nvs_send(sc->hn_prichan, VMBUS_CHANPKT_FLAG_RC, req, reqlen, &sndc); if (error) { vmbus_xact_deactivate(xact); - return NULL; + return (NULL); } - return (vmbus_xact_wait(xact, resp_len)); + hdr = vmbus_xact_wait(xact, &resplen); + + /* + * Check this NVS response message. + */ + if (resplen < min_resplen) { + if_printf(sc->hn_ifp, "invalid NVS resp len %zu\n", resplen); + return (NULL); + } + if (hdr->nvs_type != type) { + if_printf(sc->hn_ifp, "unexpected NVS resp 0x%08x, " + "expect 0x%08x\n", hdr->nvs_type, type); + return (NULL); + } + /* All pass! */ + *resplen0 = resplen; + return (hdr); } static __inline int @@ -180,24 +204,14 @@ hv_nv_init_rx_buffer_with_net_vsp(struct conn->nvs_gpadl = sc->hn_rxbuf_gpadl; conn->nvs_sig = HN_NVS_RXBUF_SIG; - resp = hn_nvs_xact_execute(sc, xact, conn, sizeof(*conn), &resp_len); + resp_len = sizeof(*resp); + resp = hn_nvs_xact_execute(sc, xact, conn, sizeof(*conn), &resp_len, + HN_NVS_TYPE_RXBUF_CONNRESP); if (resp == NULL) { if_printf(sc->hn_ifp, "exec rxbuf conn failed\n"); error = EIO; goto cleanup; } - if (resp_len < sizeof(*resp)) { - if_printf(sc->hn_ifp, "invalid rxbuf conn resp length %zu\n", - resp_len); - error = EINVAL; - goto cleanup; - } - if (resp->nvs_type != HN_NVS_TYPE_RXBUF_CONNRESP) { - if_printf(sc->hn_ifp, "not rxbuf conn resp, type %u\n", - resp->nvs_type); - error = EINVAL; - goto cleanup; - } status = resp->nvs_status; vmbus_xact_put(xact); @@ -263,24 +277,14 @@ hv_nv_init_send_buffer_with_net_vsp(stru chim->nvs_gpadl = sc->hn_chim_gpadl; chim->nvs_sig = HN_NVS_CHIM_SIG; - resp = hn_nvs_xact_execute(sc, xact, chim, sizeof(*chim), &resp_len); + resp_len = sizeof(*resp); + resp = hn_nvs_xact_execute(sc, xact, chim, sizeof(*chim), &resp_len, + HN_NVS_TYPE_CHIM_CONNRESP); if (resp == NULL) { if_printf(sc->hn_ifp, "exec chim conn failed\n"); error = EIO; goto cleanup; } - if (resp_len < sizeof(*resp)) { - if_printf(sc->hn_ifp, "invalid chim conn resp length %zu\n", - resp_len); - error = EINVAL; - goto cleanup; - } - if (resp->nvs_type != HN_NVS_TYPE_CHIM_CONNRESP) { - if_printf(sc->hn_ifp, "not chim conn resp, type %u\n", - resp->nvs_type); - error = EINVAL; - goto cleanup; - } status = resp->nvs_status; sectsz = resp->nvs_sectsz; @@ -441,24 +445,14 @@ hv_nv_negotiate_nvsp_protocol(struct hn_ init->nvs_ver_min = nvs_ver; init->nvs_ver_max = nvs_ver; - resp = hn_nvs_xact_execute(sc, xact, init, sizeof(*init), &resp_len); + resp_len = sizeof(*resp); + resp = hn_nvs_xact_execute(sc, xact, init, sizeof(*init), &resp_len, + HN_NVS_TYPE_INIT_RESP); if (resp == NULL) { if_printf(sc->hn_ifp, "exec init failed\n"); vmbus_xact_put(xact); return (EIO); } - if (resp_len < sizeof(*resp)) { - if_printf(sc->hn_ifp, "invalid init resp length %zu\n", - resp_len); - vmbus_xact_put(xact); - return (EINVAL); - } - if (resp->nvs_type != HN_NVS_TYPE_INIT_RESP) { - if_printf(sc->hn_ifp, "not init resp, type %u\n", - resp->nvs_type); - vmbus_xact_put(xact); - return (EINVAL); - } status = resp->nvs_status; vmbus_xact_put(xact); @@ -640,7 +634,7 @@ cleanup: * Net VSC on device remove */ int -hv_nv_on_device_remove(struct hn_softc *sc, boolean_t destroy_channel) +hv_nv_on_device_remove(struct hn_softc *sc) { hv_nv_disconnect_from_vsp(sc); Modified: stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h Thu Oct 13 06:39:06 2016 (r307185) +++ stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h Thu Oct 13 06:47:02 2016 (r307186) @@ -237,8 +237,8 @@ typedef void (*pfn_on_send_rx_completion #define TRANSPORT_TYPE_IPV6_UDP ((TYPE_IPV6 << 16) | TYPE_UDP) typedef struct { - uint8_t mac_addr[6]; /* Assumption unsigned long */ - uint8_t link_state; + uint8_t mac_addr[ETHER_ADDR_LEN]; + uint32_t link_state; } netvsc_device_info; #define HN_XACT_REQ_PGCNT 2 @@ -352,7 +352,6 @@ typedef struct hn_softc { int hn_initdone; /* See hv_netvsc_drv_freebsd.c for rules on how to use */ int temp_unusable; - struct rndis_device_ *rndis_dev; struct vmbus_channel *hn_prichan; int hn_rx_ring_cnt; @@ -401,8 +400,7 @@ struct hn_send_ctx; void netvsc_linkstatus_callback(struct hn_softc *sc, uint32_t status); int hv_nv_on_device_add(struct hn_softc *sc, struct hn_rx_ring *rxr); -int hv_nv_on_device_remove(struct hn_softc *sc, - boolean_t destroy_channel); +int hv_nv_on_device_remove(struct hn_softc *sc); int hv_nv_on_send(struct vmbus_channel *chan, uint32_t rndis_mtype, struct hn_send_ctx *sndc, struct vmbus_gpa *gpa, int gpa_cnt); void hv_nv_subchan_attach(struct vmbus_channel *chan, Modified: stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Thu Oct 13 06:39:06 2016 (r307185) +++ stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Thu Oct 13 06:47:02 2016 (r307186) @@ -156,8 +156,8 @@ __FBSDID("$FreeBSD$"); #define HN_TX_DATA_BOUNDARY PAGE_SIZE #define HN_TX_DATA_MAXSIZE IP_MAXPACKET #define HN_TX_DATA_SEGSIZE PAGE_SIZE -#define HN_TX_DATA_SEGCNT_MAX \ - (NETVSC_PACKET_MAXPAGE - HV_RF_NUM_TX_RESERVED_PAGE_BUFS) +/* -1 for RNDIS packet message */ +#define HN_TX_DATA_SEGCNT_MAX (NETVSC_PACKET_MAXPAGE - 1) #define HN_DIRECT_TX_SIZE_DEF 128 @@ -663,7 +663,7 @@ netvsc_detach(device_t dev) * the netdevice. */ - hv_rf_on_device_remove(sc, HV_RF_NV_DESTROY_CHANNEL); + hv_rf_on_device_remove(sc); hn_stop_tx_tasks(sc); @@ -1047,7 +1047,8 @@ hn_encap(struct hn_tx_ring *txr, struct } *m_head0 = m_head; - txr->hn_gpa_cnt = nsegs + HV_RF_NUM_TX_RESERVED_PAGE_BUFS; + /* +1 RNDIS packet message */ + txr->hn_gpa_cnt = nsegs + 1; /* send packet with page buffer */ txr->hn_gpa[0].gpa_page = atop(txd->rndis_msg_paddr); @@ -1055,12 +1056,11 @@ hn_encap(struct hn_tx_ring *txr, struct txr->hn_gpa[0].gpa_len = rndis_msg_size; /* - * Fill the page buffers with mbuf info starting at index - * HV_RF_NUM_TX_RESERVED_PAGE_BUFS. + * Fill the page buffers with mbuf info after the page + * buffer for RNDIS packet message. */ for (i = 0; i < nsegs; ++i) { - struct vmbus_gpa *gpa = &txr->hn_gpa[ - i + HV_RF_NUM_TX_RESERVED_PAGE_BUFS]; + struct vmbus_gpa *gpa = &txr->hn_gpa[i + 1]; gpa->gpa_page = atop(segs[i].ds_addr); gpa->gpa_ofs = segs[i].ds_addr & PAGE_MASK; @@ -1594,7 +1594,7 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, * MTU to take effect. This includes tearing down, but not * deleting the channel, then bringing it back up. */ - error = hv_rf_on_device_remove(sc, HV_RF_NV_RETAIN_CHANNEL); + error = hv_rf_on_device_remove(sc); if (error) { NV_LOCK(sc); sc->temp_unusable = FALSE; Modified: stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.c Thu Oct 13 06:39:06 2016 (r307185) +++ stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.c Thu Oct 13 06:47:02 2016 (r307186) @@ -72,15 +72,14 @@ __FBSDID("$FreeBSD$"); /* * Forward declarations */ -static void hv_rf_receive_response(rndis_device *device, - const rndis_msg *response); -static void hv_rf_receive_indicate_status(rndis_device *device, +static void hv_rf_receive_indicate_status(struct hn_softc *sc, const rndis_msg *response); static void hv_rf_receive_data(struct hn_rx_ring *rxr, const void *data, int dlen); -static inline int hv_rf_query_device_mac(rndis_device *device); -static inline int hv_rf_query_device_link_status(rndis_device *device); -static int hv_rf_init_device(rndis_device *device); +static int hv_rf_query_device_mac(struct hn_softc *sc, uint8_t *eaddr); +static int hv_rf_query_device_link_status(struct hn_softc *sc, + uint32_t *link_status); +static int hv_rf_init_device(struct hn_softc *sc); static int hn_rndis_query(struct hn_softc *sc, uint32_t oid, const void *idata, size_t idlen, void *odata, size_t *odlen0); @@ -158,94 +157,24 @@ hv_get_ppi_data(rndis_packet *rpkt, uint return (NULL); } - -/* - * Allow module_param to work and override to switch to promiscuous mode. - */ -static inline rndis_device * -hv_get_rndis_device(void) -{ - rndis_device *device; - - device = malloc(sizeof(rndis_device), M_NETVSC, M_WAITOK | M_ZERO); - - mtx_init(&device->req_lock, "HV-FRL", NULL, MTX_DEF); - - /* Same effect as STAILQ_HEAD_INITIALIZER() static initializer */ - STAILQ_INIT(&device->myrequest_list); - - device->state = RNDIS_DEV_UNINITIALIZED; - - return (device); -} - -/* - * - */ -static inline void -hv_put_rndis_device(rndis_device *device) -{ - mtx_destroy(&device->req_lock); - free(device, M_NETVSC); -} - -/* - * RNDIS filter receive response - */ -static void -hv_rf_receive_response(rndis_device *device, const rndis_msg *response) -{ - rndis_request *request = NULL; - rndis_request *next_request; - boolean_t found = FALSE; - - mtx_lock(&device->req_lock); - request = STAILQ_FIRST(&device->myrequest_list); - while (request != NULL) { - /* - * All request/response message contains request_id as the - * first field - */ - if (request->request_msg.msg.init_request.request_id == - response->msg.init_complete.request_id) { - found = TRUE; - break; - } - next_request = STAILQ_NEXT(request, mylist_entry); - request = next_request; - } - mtx_unlock(&device->req_lock); - - if (found) { - if (response->msg_len <= sizeof(rndis_msg)) { - memcpy(&request->response_msg, response, - response->msg_len); - } else { - request->response_msg.msg.init_complete.status = - RNDIS_STATUS_BUFFER_OVERFLOW; - } - sema_post(&request->wait_sema); - } -} - /* * RNDIS filter receive indicate status */ static void -hv_rf_receive_indicate_status(rndis_device *device, const rndis_msg *response) +hv_rf_receive_indicate_status(struct hn_softc *sc, const rndis_msg *response) { const rndis_indicate_status *indicate = &response->msg.indicate_status; switch(indicate->status) { case RNDIS_STATUS_MEDIA_CONNECT: - netvsc_linkstatus_callback(device->sc, 1); + netvsc_linkstatus_callback(sc, 1); break; case RNDIS_STATUS_MEDIA_DISCONNECT: - netvsc_linkstatus_callback(device->sc, 0); + netvsc_linkstatus_callback(sc, 0); break; default: /* TODO: */ - device_printf(device->sc->hn_dev, + if_printf(sc->hn_ifp, "unknown status %d received\n", indicate->status); break; } @@ -375,14 +304,9 @@ int hv_rf_on_receive(struct hn_softc *sc, struct hn_rx_ring *rxr, const void *data, int dlen) { - rndis_device *rndis_dev; const rndis_msg *rndis_hdr; const struct rndis_comp_hdr *comp; - rndis_dev = sc->rndis_dev; - if (rndis_dev->state == RNDIS_DEV_UNINITIALIZED) - return (EINVAL); - rndis_hdr = data; switch (rndis_hdr->ndis_msg_type) { /* data message */ @@ -396,17 +320,14 @@ hv_rf_on_receive(struct hn_softc *sc, st case REMOTE_NDIS_SET_CMPLT: case REMOTE_NDIS_KEEPALIVE_CMPLT: comp = data; - if (comp->rm_rid <= HN_RNDIS_RID_COMPAT_MAX) { - /* Transition time compat code */ - hv_rf_receive_response(rndis_dev, rndis_hdr); - } else { - vmbus_xact_ctx_wakeup(sc->hn_xact, data, dlen); - } + KASSERT(comp->rm_rid > HN_RNDIS_RID_COMPAT_MAX, + ("invalid rid 0x%08x\n", comp->rm_rid)); + vmbus_xact_ctx_wakeup(sc->hn_xact, comp, dlen); break; /* notification message */ case REMOTE_NDIS_INDICATE_STATUS_MSG: - hv_rf_receive_indicate_status(rndis_dev, rndis_hdr); + hv_rf_receive_indicate_status(sc, rndis_hdr); break; case REMOTE_NDIS_RESET_CMPLT: @@ -432,19 +353,18 @@ hv_rf_on_receive(struct hn_softc *sc, st * RNDIS filter query device MAC address */ static int -hv_rf_query_device_mac(rndis_device *device) +hv_rf_query_device_mac(struct hn_softc *sc, uint8_t *eaddr) { - struct hn_softc *sc = device->sc; - size_t hwaddr_len; + size_t eaddr_len; int error; - hwaddr_len = ETHER_ADDR_LEN; + eaddr_len = ETHER_ADDR_LEN; error = hn_rndis_query(sc, OID_802_3_PERMANENT_ADDRESS, NULL, 0, - device->hw_mac_addr, &hwaddr_len); + eaddr, &eaddr_len); if (error) return (error); - if (hwaddr_len != ETHER_ADDR_LEN) { - if_printf(sc->hn_ifp, "invalid hwaddr len %zu\n", hwaddr_len); + if (eaddr_len != ETHER_ADDR_LEN) { + if_printf(sc->hn_ifp, "invalid eaddr len %zu\n", eaddr_len); return (EINVAL); } return (0); @@ -453,16 +373,15 @@ hv_rf_query_device_mac(rndis_device *dev /* * RNDIS filter query device link status */ -static inline int -hv_rf_query_device_link_status(rndis_device *device) +static int +hv_rf_query_device_link_status(struct hn_softc *sc, uint32_t *link_status) { - struct hn_softc *sc = device->sc; size_t size; int error; - size = sizeof(uint32_t); + size = sizeof(*link_status); error = hn_rndis_query(sc, OID_GEN_MEDIA_CONNECT_STATUS, NULL, 0, - &device->link_status, &size); + link_status, &size); if (error) return (error); if (size != sizeof(uint32_t)) { @@ -876,9 +795,8 @@ hn_rndis_set_rxfilter(struct hn_softc *s * RNDIS filter init device */ static int -hv_rf_init_device(rndis_device *device) +hv_rf_init_device(struct hn_softc *sc) { - struct hn_softc *sc = device->sc; struct rndis_init_req *req; const struct rndis_init_comp *comp; struct vmbus_xact *xact; @@ -886,9 +804,6 @@ hv_rf_init_device(rndis_device *device) uint32_t rid; int error; - /* XXX */ - device->state = RNDIS_DEV_INITIALIZED; - xact = vmbus_xact_get(sc->hn_xact, sizeof(*req)); if (xact == NULL) { if_printf(sc->hn_ifp, "no xact for RNDIS init\n"); @@ -919,15 +834,14 @@ hv_rf_init_device(rndis_device *device) goto done; } if (bootverbose) { - if_printf(sc->hn_ifp, "RNDIS ver %u.%u, pktsz %u, pktcnt %u\n", - comp->rm_ver_major, comp->rm_ver_minor, - comp->rm_pktmaxsz, comp->rm_pktmaxcnt); + if_printf(sc->hn_ifp, "RNDIS ver %u.%u, pktsz %u, pktcnt %u, " + "align %u\n", comp->rm_ver_major, comp->rm_ver_minor, + comp->rm_pktmaxsz, comp->rm_pktmaxcnt, + 1U << comp->rm_align); } error = 0; - done: - if (xact != NULL) - vmbus_xact_put(xact); + vmbus_xact_put(xact); return (error); } @@ -970,7 +884,6 @@ hv_rf_on_device_add(struct hn_softc *sc, int *nchan0, struct hn_rx_ring *rxr) { int ret; - rndis_device *rndis_dev; netvsc_device_info *dev_info = (netvsc_device_info *)additl_info; device_t dev = sc->hn_dev; struct hn_nvs_subch_req *req; @@ -981,13 +894,6 @@ hv_rf_on_device_add(struct hn_softc *sc, int nchan = *nchan0; int rxr_cnt; - rndis_dev = hv_get_rndis_device(); - if (rndis_dev == NULL) { - return (ENOMEM); - } - sc->rndis_dev = rndis_dev; - rndis_dev->sc = sc; - /* * Let the inner driver handle this first to create the netvsc channel * NOTE! Once the channel is created, we may get a receive callback @@ -995,17 +901,15 @@ hv_rf_on_device_add(struct hn_softc *sc, * Note: Earlier code used a function pointer here. */ ret = hv_nv_on_device_add(sc, rxr); - if (ret != 0) { - hv_put_rndis_device(rndis_dev); + if (ret != 0) return (ret); - } /* * Initialize the rndis device */ /* Send the rndis initialization message */ - ret = hv_rf_init_device(rndis_dev); + ret = hv_rf_init_device(sc); if (ret != 0) { /* * TODO: If rndis init failed, we will need to shut down @@ -1014,19 +918,15 @@ hv_rf_on_device_add(struct hn_softc *sc, } /* Get the mac address */ - ret = hv_rf_query_device_mac(rndis_dev); + ret = hv_rf_query_device_mac(sc, dev_info->mac_addr); if (ret != 0) { /* TODO: shut down rndis device and the channel */ } /* Configure NDIS offload settings */ hn_rndis_conf_offload(sc); - - memcpy(dev_info->mac_addr, rndis_dev->hw_mac_addr, ETHER_ADDR_LEN); - hv_rf_query_device_link_status(rndis_dev); - - dev_info->link_state = rndis_dev->link_status; + hv_rf_query_device_link_status(sc, &dev_info->link_state); if (sc->hn_ndis_ver < NDIS_VERSION_6_30 || nchan == 1) { /* @@ -1071,24 +971,14 @@ hv_rf_on_device_add(struct hn_softc *sc, req->nvs_op = HN_NVS_SUBCH_OP_ALLOC; req->nvs_nsubch = nchan - 1; - resp = hn_nvs_xact_execute(sc, xact, req, sizeof(*req), &resp_len); + resp_len = sizeof(*resp); + resp = hn_nvs_xact_execute(sc, xact, req, sizeof(*req), &resp_len, + HN_NVS_TYPE_SUBCH_RESP); if (resp == NULL) { if_printf(sc->hn_ifp, "exec subch failed\n"); ret = EIO; goto out; } - if (resp_len < sizeof(*resp)) { - if_printf(sc->hn_ifp, "invalid subch resp length %zu\n", - resp_len); - ret = EINVAL; - goto out; - } - if (resp->nvs_type != HN_NVS_TYPE_SUBCH_RESP) { - if_printf(sc->hn_ifp, "not subch resp, type %u\n", - resp->nvs_type); - ret = EINVAL; - goto out; - } status = resp->nvs_status; nsubch = resp->nvs_nsubch; @@ -1122,19 +1012,15 @@ out: * RNDIS filter on device remove */ int -hv_rf_on_device_remove(struct hn_softc *sc, boolean_t destroy_channel) +hv_rf_on_device_remove(struct hn_softc *sc) { - rndis_device *rndis_dev = sc->rndis_dev; int ret; /* Halt and release the rndis device */ ret = hv_rf_halt_device(sc); - sc->rndis_dev = NULL; - hv_put_rndis_device(rndis_dev); - /* Pass control to inner driver to remove the device */ - ret |= hv_nv_on_device_remove(sc, destroy_channel); + ret |= hv_nv_on_device_remove(sc); return (ret); } Modified: stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.h ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.h Thu Oct 13 06:39:06 2016 (r307185) +++ stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.h Thu Oct 13 06:47:02 2016 (r307186) @@ -36,80 +36,6 @@ #include /* - * Defines - */ - -/* Destroy or preserve channel on filter/netvsc teardown */ -#define HV_RF_NV_DESTROY_CHANNEL TRUE -#define HV_RF_NV_RETAIN_CHANNEL FALSE - -/* - * Number of page buffers to reserve for the RNDIS filter packet in the - * transmitted message. - */ -#define HV_RF_NUM_TX_RESERVED_PAGE_BUFS 1 - - -/* - * Data types - */ - -typedef enum { - RNDIS_DEV_UNINITIALIZED = 0, - RNDIS_DEV_INITIALIZING, - RNDIS_DEV_INITIALIZED, - RNDIS_DEV_DATAINITIALIZED, -} rndis_device_state; - -typedef struct rndis_request_ { - STAILQ_ENTRY(rndis_request_) mylist_entry; - struct sema wait_sema; - - /* - * The max response size is sizeof(rndis_msg) + PAGE_SIZE. - * - * XXX - * This is ugly and should be cleaned up once we busdma-fy - * RNDIS request bits. - */ - rndis_msg response_msg; - uint8_t buf_resp[PAGE_SIZE]; - - /* Simplify allocation by having a netvsc packet inline */ - struct hn_send_ctx send_ctx; - - /* - * The max request size is sizeof(rndis_msg) + PAGE_SIZE. - * - * NOTE: - * This is required for the large request like RSS settings. - * - * XXX - * This is ugly and should be cleaned up once we busdma-fy - * RNDIS request bits. - */ - rndis_msg request_msg; - uint8_t buf_req[PAGE_SIZE]; - - /* Fixme: Poor man's semaphore. */ - uint32_t halt_complete_flag; -} rndis_request; - -typedef struct rndis_device_ { - struct hn_softc *sc; - - rndis_device_state state; - uint32_t link_status; - uint32_t new_request_id; - - struct mtx req_lock; - - STAILQ_HEAD(RQ, rndis_request_) myrequest_list; - - uint8_t hw_mac_addr[ETHER_ADDR_LEN]; -} rndis_device; - -/* * Externs */ struct hn_rx_ring; @@ -119,7 +45,7 @@ int hv_rf_on_receive(struct hn_softc *sc void hv_rf_channel_rollup(struct hn_rx_ring *rxr, struct hn_tx_ring *txr); int hv_rf_on_device_add(struct hn_softc *sc, void *additl_info, int *nchan, struct hn_rx_ring *rxr); -int hv_rf_on_device_remove(struct hn_softc *sc, boolean_t destroy_channel); +int hv_rf_on_device_remove(struct hn_softc *sc); int hv_rf_on_open(struct hn_softc *sc); int hv_rf_on_close(struct hn_softc *sc); Modified: stable/10/sys/dev/hyperv/netvsc/if_hnvar.h ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/if_hnvar.h Thu Oct 13 06:39:06 2016 (r307185) +++ stable/10/sys/dev/hyperv/netvsc/if_hnvar.h Thu Oct 13 06:47:02 2016 (r307186) @@ -111,7 +111,7 @@ struct vmbus_xact; const void *hn_nvs_xact_execute(struct hn_softc *sc, struct vmbus_xact *xact, void *req, int reqlen, - size_t *resp_len); + size_t *resp_len, uint32_t type); void hn_nvs_sent_xact(struct hn_send_ctx *sndc, struct hn_softc *sc, struct vmbus_channel *chan, const void *data, int dlen); uint32_t hn_chim_alloc(struct hn_softc *sc); From owner-svn-src-all@freebsd.org Thu Oct 13 06:49:01 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id BD571C0F80D; Thu, 13 Oct 2016 06:49:01 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 8067916CB; Thu, 13 Oct 2016 06:49:01 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9D6n0W3000267; Thu, 13 Oct 2016 06:49:00 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9D6n0n6000266; Thu, 13 Oct 2016 06:49:00 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610130649.u9D6n0n6000266@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Thu, 13 Oct 2016 06:49:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307187 - stable/10/sys/dev/hyperv/utilities X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Oct 2016 06:49:01 -0000 Author: sephe Date: Thu Oct 13 06:49:00 2016 New Revision: 307187 URL: https://svnweb.freebsd.org/changeset/base/307187 Log: MFC 305111 hyperv/timesync: Rework time adjustment policy - By default, adjust time upon SYNC request. It can be disabled through hw.hvtimesync.ignore_sync_req. SYNC request will be sent by hypervisor the host is resumed, rebooted, etc. - By default, adjust time upon SAMPLE request, if there is 100ms difference between VM time and hypervisor time. This can be disabled through hw.hvtimesync.sample_drift. And nuke the unnecessary task, since channel callback is running in a Hyper-V taskqueue nowadays. Submitted by: YanZhe Chen Discussed with: Dexuan Cui , Hongjiang Zhang , sephe Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7707 Modified: stable/10/sys/dev/hyperv/utilities/hv_timesync.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/hyperv/utilities/hv_timesync.c ============================================================================== --- stable/10/sys/dev/hyperv/utilities/hv_timesync.c Thu Oct 13 06:47:02 2016 (r307186) +++ stable/10/sys/dev/hyperv/utilities/hv_timesync.c Thu Oct 13 06:49:00 2016 (r307187) @@ -39,7 +39,7 @@ #include #include #include -#include +#include #include #include @@ -52,11 +52,7 @@ #define HV_ICTIMESYNCFLAG_SYNC 1 #define HV_ICTIMESYNCFLAG_SAMPLE 2 #define HV_NANO_SEC_PER_SEC 1000000000 - -/* Time Sync data */ -typedef struct { - uint64_t data; -} time_sync_data; +#define HV_NANO_SEC_PER_MILLI_SEC 1000000 static const struct vmbus_ic_desc vmbus_timesync_descs[] = { { @@ -75,22 +71,43 @@ struct hv_ictimesync_data { uint8_t flags; } __packed; -typedef struct hv_timesync_sc { - hv_util_sc util_sc; - struct task task; - time_sync_data time_msg; -} hv_timesync_sc; +/* + * Globals + */ +SYSCTL_NODE(_hw, OID_AUTO, hvtimesync, CTLFLAG_RW | CTLFLAG_MPSAFE, NULL, + "Hyper-V timesync interface"); + +/* Ignore the sync request when set to 1. */ +static int ignore_sync_req = 0; +SYSCTL_INT(_hw_hvtimesync, OID_AUTO, ignore_sync_req, CTLFLAG_RWTUN, + &ignore_sync_req, 0, + "Ignore the sync request when set to 1."); + +/* + * Trigger sample sync when drift exceeds threshold (ms). + * Ignore the sample request when set to 0. + */ +static int sample_drift = 100; +SYSCTL_INT(_hw_hvtimesync, OID_AUTO, sample_drift, CTLFLAG_RWTUN, + &sample_drift, 0, + "Threshold that makes sample request trigger the sync."); /** - * Set host time based on time sync message from host + * @brief Synchronize time with host after reboot, restore, etc. + * + * ICTIMESYNCFLAG_SYNC flag bit indicates reboot, restore events of the VM. + * After reboot the flag ICTIMESYNCFLAG_SYNC is included in the first time + * message after the timesync channel is opened. Since the hv_utils module is + * loaded after hv_vmbus, the first message is usually missed. The other + * thing is, systime is automatically set to emulated hardware clock which may + * not be UTC time or in the same time zone. So, to override these effects, we + * use the first 50 time samples for initial system time setting. */ -static void -hv_set_host_time(void *context, int pending) +static inline +void hv_adj_guesttime(hv_util_sc *sc, uint64_t hosttime, uint8_t flags) { - hv_timesync_sc *softc = (hv_timesync_sc*)context; - uint64_t hosttime = softc->time_msg.data; struct timespec guest_ts, host_ts; - uint64_t host_tns; + uint64_t host_tns, guest_tns; int64_t diff; int error; @@ -99,37 +116,35 @@ hv_set_host_time(void *context, int pend host_ts.tv_nsec = (long)(host_tns%HV_NANO_SEC_PER_SEC); nanotime(&guest_ts); + guest_tns = guest_ts.tv_sec * HV_NANO_SEC_PER_SEC + guest_ts.tv_nsec; - diff = (int64_t)host_ts.tv_sec - (int64_t)guest_ts.tv_sec; + if ((flags & HV_ICTIMESYNCFLAG_SYNC) != 0 && ignore_sync_req == 0) { + if (bootverbose) { + device_printf(sc->ic_dev, "handle sync request " + "{host: %ju, guest: %ju}\n", + (uintmax_t)host_tns, (uintmax_t)guest_tns); + } - /* - * If host differs by 5 seconds then make the guest catch up - */ - if (diff > 5 || diff < -5) { error = kern_clock_settime(curthread, CLOCK_REALTIME, &host_ts); + return; } -} -/** - * @brief Synchronize time with host after reboot, restore, etc. - * - * ICTIMESYNCFLAG_SYNC flag bit indicates reboot, restore events of the VM. - * After reboot the flag ICTIMESYNCFLAG_SYNC is included in the first time - * message after the timesync channel is opened. Since the hv_utils module is - * loaded after hv_vmbus, the first message is usually missed. The other - * thing is, systime is automatically set to emulated hardware clock which may - * not be UTC time or in the same time zone. So, to override these effects, we - * use the first 50 time samples for initial system time setting. - */ -static inline -void hv_adj_guesttime(hv_timesync_sc *sc, uint64_t hosttime, uint8_t flags) -{ - sc->time_msg.data = hosttime; - - if (((flags & HV_ICTIMESYNCFLAG_SYNC) != 0) || - ((flags & HV_ICTIMESYNCFLAG_SAMPLE) != 0)) { - taskqueue_enqueue(taskqueue_thread, &sc->task); + if ((flags & HV_ICTIMESYNCFLAG_SAMPLE) != 0 && sample_drift != 0) { + if (bootverbose) { + device_printf(sc->ic_dev, "handle sample request " + "{host: %ju, guest: %ju}\n", + (uintmax_t)host_tns, (uintmax_t)guest_tns); + } + + diff = (int64_t)(host_tns - guest_tns) / HV_NANO_SEC_PER_MILLI_SEC; + if (diff > sample_drift || diff < -sample_drift) { + error = kern_clock_settime(curthread, CLOCK_REALTIME, + &host_ts); + if (bootverbose) + device_printf(sc->ic_dev, "trigger sample sync"); + } + return; } } @@ -145,12 +160,12 @@ hv_timesync_cb(struct vmbus_channel *cha int ret; uint8_t* time_buf; struct hv_ictimesync_data* timedatap; - hv_timesync_sc *softc; + hv_util_sc *softc; - softc = (hv_timesync_sc*)context; - time_buf = softc->util_sc.receive_buffer; + softc = (hv_util_sc*)context; + time_buf = softc->receive_buffer; - recvlen = softc->util_sc.ic_buflen; + recvlen = softc->ic_buflen; ret = vmbus_chan_recv(channel, time_buf, &recvlen, &requestId); KASSERT(ret != ENOBUFS, ("hvtimesync recvbuf is not large enough")); /* XXX check recvlen to make sure that it contains enough data */ @@ -162,7 +177,7 @@ hv_timesync_cb(struct vmbus_channel *cha if (icmsghdrp->icmsgtype == HV_ICMSGTYPE_NEGOTIATE) { int error; - error = vmbus_ic_negomsg(&softc->util_sc, time_buf, &recvlen); + error = vmbus_ic_negomsg(softc, time_buf, &recvlen); if (error) return; } else { @@ -190,18 +205,12 @@ hv_timesync_probe(device_t dev) static int hv_timesync_attach(device_t dev) { - hv_timesync_sc *softc = device_get_softc(dev); - - TASK_INIT(&softc->task, 1, hv_set_host_time, softc); return hv_util_attach(dev, hv_timesync_cb); } static int hv_timesync_detach(device_t dev) { - hv_timesync_sc *softc = device_get_softc(dev); - - taskqueue_drain(taskqueue_thread, &softc->task); return hv_util_detach(dev); } @@ -213,7 +222,7 @@ static device_method_t timesync_methods[ { 0, 0 } }; -static driver_t timesync_driver = { "hvtimesync", timesync_methods, sizeof(hv_timesync_sc)}; +static driver_t timesync_driver = { "hvtimesync", timesync_methods, sizeof(hv_util_sc)}; static devclass_t timesync_devclass; From owner-svn-src-all@freebsd.org Thu Oct 13 06:55:53 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 8A647C0FB08; Thu, 13 Oct 2016 06:55:53 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 400C41AD5; Thu, 13 Oct 2016 06:55:53 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9D6tq0o003893; Thu, 13 Oct 2016 06:55:52 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9D6tqCH003890; Thu, 13 Oct 2016 06:55:52 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610130655.u9D6tqCH003890@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Thu, 13 Oct 2016 06:55:52 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307188 - in stable/10/sys: dev/hyperv/netvsc net X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Oct 2016 06:55:53 -0000 Author: sephe Date: Thu Oct 13 06:55:51 2016 New Revision: 307188 URL: https://svnweb.freebsd.org/changeset/base/307188 Log: MFC 305173,305174 305173 net/rndis: Add comment for rndis_set_parameter Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7705 305174 hyperv/hn: Remove unused function Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7706 Modified: stable/10/sys/dev/hyperv/netvsc/hv_rndis.h stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.c stable/10/sys/net/rndis.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/hyperv/netvsc/hv_rndis.h ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_rndis.h Thu Oct 13 06:49:00 2016 (r307187) +++ stable/10/sys/dev/hyperv/netvsc/hv_rndis.h Thu Oct 13 06:55:51 2016 (r307188) @@ -904,7 +904,5 @@ void* hv_set_rppi_data(rndis_msg *rndis_ uint32_t rppi_size, int pkt_type); -void* hv_get_ppi_data(rndis_packet *rpkt, uint32_t type); - #endif /* __HV_RNDIS_H__ */ Modified: stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.c Thu Oct 13 06:49:00 2016 (r307187) +++ stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.c Thu Oct 13 06:55:51 2016 (r307188) @@ -129,35 +129,6 @@ hv_set_rppi_data(rndis_msg *rndis_mesg, } /* - * Get the Per-Packet-Info with the specified type - * return NULL if not found. - */ -void * -hv_get_ppi_data(rndis_packet *rpkt, uint32_t type) -{ - rndis_per_packet_info *ppi; - int len; - - if (rpkt->per_pkt_info_offset == 0) - return (NULL); - - ppi = (rndis_per_packet_info *)((unsigned long)rpkt + - rpkt->per_pkt_info_offset); - len = rpkt->per_pkt_info_length; - - while (len > 0) { - if (ppi->type == type) - return (void *)((unsigned long)ppi + - ppi->per_packet_info_offset); - - len -= ppi->size; - ppi = (rndis_per_packet_info *)((unsigned long)ppi + ppi->size); - } - - return (NULL); -} - -/* * RNDIS filter receive indicate status */ static void Modified: stable/10/sys/net/rndis.h ============================================================================== --- stable/10/sys/net/rndis.h Thu Oct 13 06:49:00 2016 (r307187) +++ stable/10/sys/net/rndis.h Thu Oct 13 06:55:51 2016 (r307188) @@ -217,6 +217,9 @@ struct rndis_set_comp { uint32_t rm_status; }; +/* + * Parameter used by OID_GEN_RNDIS_CONFIG_PARAMETER. + */ #define REMOTE_NDIS_SET_PARAM_NUMERIC 0x00000000 #define REMOTE_NDIS_SET_PARAM_STRING 0x00000002 From owner-svn-src-all@freebsd.org Thu Oct 13 06:56:25 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 9A5F7C0FB70; Thu, 13 Oct 2016 06:56:25 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 671701C48; Thu, 13 Oct 2016 06:56:25 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9D6uOh7003978; Thu, 13 Oct 2016 06:56:24 GMT (envelope-from imp@FreeBSD.org) Received: (from imp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9D6uNUa003963; Thu, 13 Oct 2016 06:56:23 GMT (envelope-from imp@FreeBSD.org) Message-Id: <201610130656.u9D6uNUa003963@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: imp set sender to imp@FreeBSD.org using -f From: Warner Losh Date: Thu, 13 Oct 2016 06:56:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307189 - in head: lib lib/libefivar sys/arm/include sys/arm64/include sys/dev/efidev sys/i386/include sys/mips/include sys/pc98/include sys/powerpc/include sys/riscv/include sys/sparc6... X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Oct 2016 06:56:25 -0000 Author: imp Date: Thu Oct 13 06:56:23 2016 New Revision: 307189 URL: https://svnweb.freebsd.org/changeset/base/307189 Log: Fix building on i386 and arm. But 'public domain' headers on the files with no creative content. Include "lost" changes from git: o Use /dev/efi instead of /dev/efidev o Remove redundant NULL checks. Submitted by: kib@, dim@, zbb@, emaste@ Modified: head/lib/Makefile head/lib/libefivar/efivar.c head/sys/arm/include/efi.h head/sys/arm64/include/efi.h head/sys/dev/efidev/efidev.c head/sys/i386/include/efi.h head/sys/mips/include/efi.h head/sys/pc98/include/efi.h head/sys/powerpc/include/efi.h head/sys/riscv/include/efi.h head/sys/sparc64/include/efi.h head/usr.sbin/Makefile head/usr.sbin/efivar/efivar.8 head/usr.sbin/efivar/efivar.c Modified: head/lib/Makefile ============================================================================== --- head/lib/Makefile Thu Oct 13 06:55:51 2016 (r307188) +++ head/lib/Makefile Thu Oct 13 06:56:23 2016 (r307189) @@ -241,7 +241,7 @@ _libcxxrt= libcxxrt _libcplusplus= libc++ .endif -.if ${MACHINE_ARCH} == "amd64" +.if ${MK_EFI} != "no" _libefivar= libefivar .endif Modified: head/lib/libefivar/efivar.c ============================================================================== --- head/lib/libefivar/efivar.c Thu Oct 13 06:55:51 2016 (r307188) +++ head/lib/libefivar/efivar.c Thu Oct 13 06:56:23 2016 (r307189) @@ -108,7 +108,7 @@ efi_open_dev(void) { if (efi_fd == -2) - efi_fd = open("/dev/efidev", O_RDWR); + efi_fd = open("/dev/efi", O_RDWR); if (efi_fd < 0) efi_fd = -1; else Modified: head/sys/arm/include/efi.h ============================================================================== --- head/sys/arm/include/efi.h Thu Oct 13 06:55:51 2016 (r307188) +++ head/sys/arm/include/efi.h Thu Oct 13 06:56:23 2016 (r307189) @@ -1,30 +1,5 @@ /*- - * Copyright (c) 2016 The FreeBSD Foundation - * All rights reserved. - * - * This software was developed by Konstantin Belousov - * under sponsorship from the FreeBSD Foundation. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 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 is in the public domain since it's just boilerplate. * * $FreeBSD$ */ Modified: head/sys/arm64/include/efi.h ============================================================================== --- head/sys/arm64/include/efi.h Thu Oct 13 06:55:51 2016 (r307188) +++ head/sys/arm64/include/efi.h Thu Oct 13 06:56:23 2016 (r307189) @@ -1,30 +1,5 @@ /*- - * Copyright (c) 2016 The FreeBSD Foundation - * All rights reserved. - * - * This software was developed by Konstantin Belousov - * under sponsorship from the FreeBSD Foundation. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 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 is in the public domain since it's just boilerplate. * * $FreeBSD$ */ Modified: head/sys/dev/efidev/efidev.c ============================================================================== --- head/sys/dev/efidev/efidev.c Thu Oct 13 06:55:51 2016 (r307188) +++ head/sys/dev/efidev/efidev.c Thu Oct 13 06:56:23 2016 (r307189) @@ -119,10 +119,6 @@ vg_out: efi_char *name; name = malloc(ev->namesize, M_TEMP, M_WAITOK); - if (name == NULL) { - error = ENOMEM; - goto vn_out; - } error = copyin(ev->name, name, ev->namesize); if (error) goto vn_out; @@ -136,8 +132,7 @@ vg_out: error = 0; } vn_out: - if (name != NULL) - free(name, M_TEMP); + free(name, M_TEMP); break; } case EFIIOC_VAR_SET: @@ -166,8 +161,7 @@ vg_out: error = efi_var_set(name, &ev->vendor, ev->attrib, ev->datasize, data); vs_out: - if (data != NULL) - free(data, M_TEMP); + free(data, M_TEMP); free(name, M_TEMP); break; } @@ -184,7 +178,7 @@ efidev_init(struct cdev **cdev) { *cdev = make_dev(&efi_cdevsw, 0, UID_ROOT, GID_WHEEL, 0700, - "efidev"); + "efi"); return (0); } Modified: head/sys/i386/include/efi.h ============================================================================== --- head/sys/i386/include/efi.h Thu Oct 13 06:55:51 2016 (r307188) +++ head/sys/i386/include/efi.h Thu Oct 13 06:56:23 2016 (r307189) @@ -1,30 +1,5 @@ /*- - * Copyright (c) 2016 The FreeBSD Foundation - * All rights reserved. - * - * This software was developed by Konstantin Belousov - * under sponsorship from the FreeBSD Foundation. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 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 is in the public domain since it's just boilerplate. * * $FreeBSD$ */ Modified: head/sys/mips/include/efi.h ============================================================================== --- head/sys/mips/include/efi.h Thu Oct 13 06:55:51 2016 (r307188) +++ head/sys/mips/include/efi.h Thu Oct 13 06:56:23 2016 (r307189) @@ -1,30 +1,5 @@ /*- - * Copyright (c) 2016 The FreeBSD Foundation - * All rights reserved. - * - * This software was developed by Konstantin Belousov - * under sponsorship from the FreeBSD Foundation. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 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 is in the public domain since it's just boilerplate. * * $FreeBSD$ */ Modified: head/sys/pc98/include/efi.h ============================================================================== --- head/sys/pc98/include/efi.h Thu Oct 13 06:55:51 2016 (r307188) +++ head/sys/pc98/include/efi.h Thu Oct 13 06:56:23 2016 (r307189) @@ -1,30 +1,5 @@ /*- - * Copyright (c) 2016 The FreeBSD Foundation - * All rights reserved. - * - * This software was developed by Konstantin Belousov - * under sponsorship from the FreeBSD Foundation. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 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 is in the public domain since it's just boilerplate. * * $FreeBSD$ */ Modified: head/sys/powerpc/include/efi.h ============================================================================== --- head/sys/powerpc/include/efi.h Thu Oct 13 06:55:51 2016 (r307188) +++ head/sys/powerpc/include/efi.h Thu Oct 13 06:56:23 2016 (r307189) @@ -1,30 +1,5 @@ /*- - * Copyright (c) 2016 The FreeBSD Foundation - * All rights reserved. - * - * This software was developed by Konstantin Belousov - * under sponsorship from the FreeBSD Foundation. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 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 is in the public domain since it's just boilerplate. * * $FreeBSD$ */ Modified: head/sys/riscv/include/efi.h ============================================================================== --- head/sys/riscv/include/efi.h Thu Oct 13 06:55:51 2016 (r307188) +++ head/sys/riscv/include/efi.h Thu Oct 13 06:56:23 2016 (r307189) @@ -1,30 +1,5 @@ /*- - * Copyright (c) 2016 The FreeBSD Foundation - * All rights reserved. - * - * This software was developed by Konstantin Belousov - * under sponsorship from the FreeBSD Foundation. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 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 is in the public domain since it's just boilerplate. * * $FreeBSD$ */ Modified: head/sys/sparc64/include/efi.h ============================================================================== --- head/sys/sparc64/include/efi.h Thu Oct 13 06:55:51 2016 (r307188) +++ head/sys/sparc64/include/efi.h Thu Oct 13 06:56:23 2016 (r307189) @@ -1,30 +1,5 @@ /*- - * Copyright (c) 2016 The FreeBSD Foundation - * All rights reserved. - * - * This software was developed by Konstantin Belousov - * under sponsorship from the FreeBSD Foundation. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 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 is in the public domain since it's just boilerplate. * * $FreeBSD$ */ Modified: head/usr.sbin/Makefile ============================================================================== --- head/usr.sbin/Makefile Thu Oct 13 06:55:51 2016 (r307188) +++ head/usr.sbin/Makefile Thu Oct 13 06:56:23 2016 (r307189) @@ -123,7 +123,7 @@ SUBDIR.${MK_BSNMP}+= bsnmpd SUBDIR.${MK_CTM}+= ctm SUBDIR.${MK_DIALOG}+= tzsetup SUBDIR.${MK_DIALOG}+= bsdconfig -#SUBDIR.${MK_EFI}+= efivar +SUBDIR.${MK_EFI}+= efivar SUBDIR.${MK_FLOPPY}+= fdcontrol SUBDIR.${MK_FLOPPY}+= fdformat SUBDIR.${MK_FLOPPY}+= fdread Modified: head/usr.sbin/efivar/efivar.8 ============================================================================== --- head/usr.sbin/efivar/efivar.8 Thu Oct 13 06:55:51 2016 (r307188) +++ head/usr.sbin/efivar/efivar.8 Thu Oct 13 06:56:23 2016 (r307189) @@ -10,10 +10,10 @@ .\" 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" 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 REGENTS OR CONTRIBUTORS BE LIABLE +.\" 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) Modified: head/usr.sbin/efivar/efivar.c ============================================================================== --- head/usr.sbin/efivar/efivar.c Thu Oct 13 06:55:51 2016 (r307188) +++ head/usr.sbin/efivar/efivar.c Thu Oct 13 06:56:23 2016 (r307189) @@ -11,10 +11,10 @@ * 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 NETAPP, INC ``AS IS'' AND + * 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 NETAPP, INC OR CONTRIBUTORS BE LIABLE + * 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) From owner-svn-src-all@freebsd.org Thu Oct 13 07:02:55 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id AB212C0FD04; Thu, 13 Oct 2016 07:02:55 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 750F0AE; Thu, 13 Oct 2016 07:02:55 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9D72srF007581; Thu, 13 Oct 2016 07:02:54 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9D72sgd007580; Thu, 13 Oct 2016 07:02:54 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201610130702.u9D72sgd007580@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Ngie Cooper Date: Thu, 13 Oct 2016 07:02:54 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307190 - head/contrib/netbsd-tests/fs/tmpfs X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Oct 2016 07:02:55 -0000 Author: ngie Date: Thu Oct 13 07:02:54 2016 New Revision: 307190 URL: https://svnweb.freebsd.org/changeset/base/307190 Log: Skip :uchg on FreeBSD Unfortunately removing files with uchg set always succeeds with root on FreeBSD. Unfortunately running the test as an unprivileged user isn't doable because mounting tmpfs requires root PR: 212861 Sponsored by: Dell EMC Isilon Modified: head/contrib/netbsd-tests/fs/tmpfs/t_remove.sh Modified: head/contrib/netbsd-tests/fs/tmpfs/t_remove.sh ============================================================================== --- head/contrib/netbsd-tests/fs/tmpfs/t_remove.sh Thu Oct 13 06:56:23 2016 (r307189) +++ head/contrib/netbsd-tests/fs/tmpfs/t_remove.sh Thu Oct 13 07:02:54 2016 (r307190) @@ -53,6 +53,10 @@ uchg_head() { atf_set "require.user" "root" } uchg_body() { + # Begin FreeBSD + atf_skip "this fails on FreeBSD with root - bug 212861" + # End FreeBSD + test_mount atf_check -s eq:0 -o empty -e empty touch a From owner-svn-src-all@freebsd.org Thu Oct 13 07:05:05 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id EBC5FC0FE79 for ; Thu, 13 Oct 2016 07:05:05 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: from mail-it0-x231.google.com (mail-it0-x231.google.com [IPv6:2607:f8b0:4001:c0b::231]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id B1CF2329 for ; Thu, 13 Oct 2016 07:05:05 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: by mail-it0-x231.google.com with SMTP id o19so74774939ito.1 for ; Thu, 13 Oct 2016 00:05:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20150623.gappssmtp.com; s=20150623; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=rOCsmo+Zk/z9Bvkk3FnpHDaoT/gUh6sxinDgCfZc5bw=; b=F/0TGoeE6Tc5mR0F8sq1bQpt9UGNAxQq4AUUwIcs978qux8wZiLwUMAv11A8sjFF2N SvZulj1OqvJByftNg6eBlfUJkzZ7nnlz3noyfKC+HFY9q9TyE3th+IYIW63cqFF55Vex GJEc9q5Jy+kvsCYD2hKazuRMb7F6k6o1PWqXaYFzGSb2DjxlIwiqXDGNHwdEvi/8DnkM biBL7uAHD+zKV7tQdNn7oAo/0zzp2Jj/bfzk4esJEJbvw8TcpfeAI5SxJ/lE5D0ISld8 cy7G3l9TBLs+Hlw4nvP1Q7IoFAPFcIBstvoq+jq3WpU+PmjtoeKL1LREIP8zmbScsJzs mJsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=rOCsmo+Zk/z9Bvkk3FnpHDaoT/gUh6sxinDgCfZc5bw=; b=OAfZlxokmBPEOzeAntvVyOoXRFvE7SQVGyh1QalaP5qNlcagKCte89+p66r6/qmZ1A ffyEOxfkL0LRfAS8LR4OgBXAwrmnJwOd0b+dEWKFsLOUB6tFZJ8xHpLxZ+RwQnWfPl70 GyCQfzLpuDT7OeGkArs6pqOGDY7aVuZ9t+SRqoIosqqgxBkM7BXad1jrlI/eWguJ79el Z81VMfrUwlT9DmCuVbLHOI/9c57ryeffXoG6n3DFJAbRIbnTrdrU4dTm7XdbCNwrcGFZ uwuijKKylTyOGxzpFDrEX2bSl3gguQpOUAAJXmtN7RMDV0AxnY22OFwflL9v7SfE2G7B N5Kg== X-Gm-Message-State: AA6/9RkYhIEcp5VUEO9R5F31WEhDFsCBW42jitbQ96fWpkSTb9WYl/NtkGp9J+E8ZeJQWZ8hknHkjEjiCNT98Q== X-Received: by 10.36.53.214 with SMTP id k205mr5056945ita.85.1476342305076; Thu, 13 Oct 2016 00:05:05 -0700 (PDT) MIME-Version: 1.0 Sender: wlosh@bsdimp.com Received: by 10.79.77.85 with HTTP; Thu, 13 Oct 2016 00:05:04 -0700 (PDT) X-Originating-IP: [50.253.99.174] In-Reply-To: References: <201610122341.u9CNf2qO056708@slippy.cwsent.com> From: Warner Losh Date: Thu, 13 Oct 2016 01:05:04 -0600 X-Google-Sender-Auth: CuHy_nE4uMwrjHSvFjvjcsQ3C30 Message-ID: Subject: Re: svn commit: r307072 - in head/usr.sbin: . efivar To: Cy Schubert Cc: Ed Maste , Zbigniew Bodek , Warner Losh , "src-committers@freebsd.org" , "svn-src-all@freebsd.org" , "svn-src-head@freebsd.org" Content-Type: text/plain; charset=UTF-8 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Oct 2016 07:05:06 -0000 All these issues should be fixed. Sorry for the mixup. I'm learning git and mis-merged trees from two different laptops :(. Warner On Wed, Oct 12, 2016 at 6:22 PM, Warner Losh wrote: > I'll look into it. It worked just fine for me for all the builds I did > on many different machines. Ugg. > > Warner > > On Wed, Oct 12, 2016 at 5:41 PM, Cy Schubert wrote: >> In message > om> >> , Ed Maste writes: >>> On 12 October 2016 at 12:55, Zbigniew Bodek wrote: >>> > Hello Warner, >>> > >>> > Did you try to build world for ARMv6 on HEAD? I'm not able to do so and the >>> > issues seems to be related to this commit (missing efivar.h file). >>> >>> Indeed, my tinderbox build failed for arm.arm, arm.armeb, arm.armv6, >>> arm64.aarch64, pc98.i386, i386.i386 with >>> >>> /scratch/tmp/emaste/freebsd/usr.sbin/efivar/efivar.c:31:10: fatal >>> error: 'efivar.h' file not found >>> #include >>> ^ >>> >>> I temporarily unhooked it from the build in r307157. >>> >>> >> >> I had the same on amd64. >> >> >> -- >> Cheers, >> Cy Schubert >> FreeBSD UNIX: Web: http://www.FreeBSD.org >> >> The need of the many outweighs the greed of the few. >> >> From owner-svn-src-all@freebsd.org Thu Oct 13 07:10:28 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 7291FC0FEFF; Thu, 13 Oct 2016 07:10:28 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 42637777; Thu, 13 Oct 2016 07:10:28 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9D7ARPp007927; Thu, 13 Oct 2016 07:10:27 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9D7ARZa007926; Thu, 13 Oct 2016 07:10:27 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201610130710.u9D7ARZa007926@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Ngie Cooper Date: Thu, 13 Oct 2016 07:10:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307191 - head/etc/rc.d X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Oct 2016 07:10:28 -0000 Author: ngie Date: Thu Oct 13 07:10:27 2016 New Revision: 307191 URL: https://svnweb.freebsd.org/changeset/base/307191 Log: Install etc/rc.d/zfsbe when MK_ZFS != no X-MFC with: r307182 Sponsored by: Dell EMC Isilon Modified: head/etc/rc.d/Makefile Modified: head/etc/rc.d/Makefile ============================================================================== --- head/etc/rc.d/Makefile Thu Oct 13 07:02:54 2016 (r307190) +++ head/etc/rc.d/Makefile Thu Oct 13 07:10:27 2016 (r307191) @@ -314,6 +314,7 @@ FILES+= wpa_supplicant .if ${MK_ZFS} != "no" FILESGROUPS+= ZFS ZFS+= zfs +ZFS+= zfsbe ZFS+= zfsd ZFS+= zvol ZFSPACKAGE= zfs From owner-svn-src-all@freebsd.org Thu Oct 13 07:12:22 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 19944C0F0A1; Thu, 13 Oct 2016 07:12:22 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id DC787A35; Thu, 13 Oct 2016 07:12:21 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9D7CK8w011335; Thu, 13 Oct 2016 07:12:20 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9D7CKvt011334; Thu, 13 Oct 2016 07:12:20 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201610130712.u9D7CKvt011334@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Ngie Cooper Date: Thu, 13 Oct 2016 07:12:20 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307192 - head/tools/build/mk X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Oct 2016 07:12:22 -0000 Author: ngie Date: Thu Oct 13 07:12:20 2016 New Revision: 307192 URL: https://svnweb.freebsd.org/changeset/base/307192 Log: Also, remove etc/rc.d/zfsbe when MK_ZFS == no X-MFC with: r307182, r307191 Sponsored by: Dell EMC Isilon Modified: head/tools/build/mk/OptionalObsoleteFiles.inc Modified: head/tools/build/mk/OptionalObsoleteFiles.inc ============================================================================== --- head/tools/build/mk/OptionalObsoleteFiles.inc Thu Oct 13 07:10:27 2016 (r307191) +++ head/tools/build/mk/OptionalObsoleteFiles.inc Thu Oct 13 07:12:20 2016 (r307192) @@ -1089,6 +1089,7 @@ OLD_FILES+=boot/gptzfsboot OLD_FILES+=boot/zfsboot OLD_FILES+=boot/zfsloader OLD_FILES+=etc/rc.d/zfs +OLD_FILES+=etc/rc.d/zfsbe OLD_FILES+=etc/rc.d/zvol OLD_FILES+=etc/devd/zfs.conf OLD_FILES+=etc/periodic/daily/404.status-zfs From owner-svn-src-all@freebsd.org Thu Oct 13 07:12:52 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 53ACEC0F0FE; Thu, 13 Oct 2016 07:12:52 +0000 (UTC) (envelope-from yaneurabeya@gmail.com) Received: from mail-pa0-x243.google.com (mail-pa0-x243.google.com [IPv6:2607:f8b0:400e:c03::243]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 267C4C7E; Thu, 13 Oct 2016 07:12:52 +0000 (UTC) (envelope-from yaneurabeya@gmail.com) Received: by mail-pa0-x243.google.com with SMTP id qn10so4378703pac.2; Thu, 13 Oct 2016 00:12:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:mime-version:from:in-reply-to:date:cc:message-id:references :to; bh=O9YQUZ2b5M6bplzmbKyCU1qe+peGtc0crJxb/XoMal8=; b=hq6vSjRHx5xgQFTd8qdaPXhcpjZ++SKklG0bu10tVUZtUOAy5z5hXHTH3PNulvOia6 JcGLb8qWX+BYE4FMfdcK8aS3WmVzFzJ0ogUvBGZ74EFGlAVBV7qUqGdd54PsBA2Cy5x9 JoHVApaVKzAGSOLm9PCVaOyix0duS/C+FGrXvVUXdvF4iGwp2RFnZ6tgCXx5mtNx4oII WJ1ow9w+ApXH03w3lXNmDZGmN6OCddnBwnmoDu9429aIs0I1uSRCZjqf5EzaNZf7/Sg9 BmC3hRPOAmWTvFcbHzsE+7qmKGHdO9HTmv6AStokX2NvLWyjPpJP7FGKzXMKi0arqKFJ GfKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:mime-version:from:in-reply-to:date:cc :message-id:references:to; bh=O9YQUZ2b5M6bplzmbKyCU1qe+peGtc0crJxb/XoMal8=; b=Bj1VqCwDh5LHQh7rQaBk59R/3etknyJuMpHPZ2sR/NrI2nAMEZ2dIgrPTBu+JYPEXm 6+dqLAt2YNgk2yK7cj9ZGRCBsFKiRQMF0+bcKMAOWvFcgUxJmL5QHYSaNMN8TkWDhvlm Z1OCW4/iGz9X0kjrVLoF3CqKfqKVx6dqASpWr0dr9UNg17IsKTCeialdPflfVkivL1UO g6dgkIlfL5MbGfF7E1H9cOdHyBHGJ+gCmcnk3nMBcC4rE/G0PivKd0z/j5kaVx5lweE1 9kFDcr0+0jWyie6p+8P78xppuERA3IGVyT6TIuwLSvrNLE9ihfgrwfgdhVgd25CBUnMm ouzg== X-Gm-Message-State: AA6/9Rkb8fGWcFdHEkx0sSAG0P94MHSrYRmSiyC5P33yvXtaFHHttIBizf0ND+Cml61Avw== X-Received: by 10.66.15.134 with SMTP id x6mr6609674pac.171.1476342771558; Thu, 13 Oct 2016 00:12:51 -0700 (PDT) Received: from [192.168.20.12] (c-73-19-52-228.hsd1.wa.comcast.net. [73.19.52.228]) by smtp.gmail.com with ESMTPSA id s6sm16739840pfg.46.2016.10.13.00.12.50 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 13 Oct 2016 00:12:50 -0700 (PDT) Subject: Re: svn commit: r307182 - head/etc/rc.d Mime-Version: 1.0 (Mac OS X Mail 9.3 \(3124\)) Content-Type: multipart/signed; boundary="Apple-Mail=_54297E1D-3029-4543-A475-1E9B91393B50"; protocol="application/pgp-signature"; micalg=pgp-sha512 X-Pgp-Agent: GPGMail From: "Ngie Cooper (yaneurabeya)" In-Reply-To: <201610130619.u9D6JsMd088686@repo.freebsd.org> Date: Thu, 13 Oct 2016 00:12:49 -0700 Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Message-Id: <27A78442-3CB6-4245-892B-EFACB3860B38@gmail.com> References: <201610130619.u9D6JsMd088686@repo.freebsd.org> To: Andriy Gapon X-Mailer: Apple Mail (2.3124) X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Oct 2016 07:12:52 -0000 --Apple-Mail=_54297E1D-3029-4543-A475-1E9B91393B50 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=us-ascii > On Oct 12, 2016, at 23:19, Andriy Gapon wrote: > > Author: avg > Date: Thu Oct 13 06:19:54 2016 > New Revision: 307182 > URL: https://svnweb.freebsd.org/changeset/base/307182 > > Log: > rc.d/zfsbe: a new script designed for boot environment support > > Currently zfsbe ensures that subordinate filesystems are mounted at the > right mount points. > The script assumes that the subordinate filesystems of a boot environment > have their canmount property set to noauto, so that they are not > automatically mounted on boot. Whereas the root filesystem is mounted > by the kernel, there was nothing to mount its subordinates. > rc.d/zfsbe fills that gap. > > Discussed with: allanjude, will > MFC after: 3 weeks > Differential Revision: https://reviews.freebsd.org/D7797 I committed the Makefile changes in r307191/r307192. Cheers! -Ngie --Apple-Mail=_54297E1D-3029-4543-A475-1E9B91393B50 Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=signature.asc Content-Type: application/pgp-signature; name=signature.asc Content-Description: Message signed with OpenPGP using GPGMail -----BEGIN PGP SIGNATURE----- Comment: GPGTools - https://gpgtools.org iQIcBAEBCgAGBQJX/zPxAAoJEPWDqSZpMIYVJRAP+wW4UxwFb9pkVOEYCAoqfG3K XpfPv0+hP4CCJghZNxEMetzDM6NjzFvbtaaFNsDn8MkeOMmqkrY7NjW5CKjOiPK3 Aj2SzTzPb7LPAMv/E7T+PLRxuRJqWrZ3S1t0ou22ZSJtOcdvig8RkvxDfOIPMsMh srJrB7UBgeGOEeBa749/oSlGhKxsaxjoz4JsJ7obK+OF6SiBc1ukjRax/AcVDpZy Dan1CiHE2IxPJfUDFQ2B08lpTHHTVDP0aYC1H0EGBHVuru6M7XxHoU3WI0tv6Yw/ bILo8DE/8KZ0HHipwsXXBZ37YXkH1Wr6XxNGGuZ4WmV9s1LpbhSynEmquGILNTTg G4YWIEFDxbiLebLhHvA8dZAwX3RMQGUogcHbomWaxJFF4T6LqXsPryO2cjfxiTUi 5/C33OkYfNk+QNxQ8KkfekWS8LSqWTjf+3/oc8iynNtTndqQlySev2NSRHmpLmTU fnsEA3/x+pRmvXkgMOd1Ls+5bUzv+gqAscjB5vs6TSWjCWSgKCWK+PyUZ/ajpdYU WW9HcVhD5izN8qUNaQNAhBGHQkUhKI6NC4JnN15Sr8z6iVn/YXnRG/kEWkBF81+F 8B0cvZcyR3BSTOj4tiuDTxWo2zyH5E5Orjmq9EUELoMrZpklXOFAAGvzOQNptcCg w+3RibhkJ+3iN2T57fHZ =p5N8 -----END PGP SIGNATURE----- --Apple-Mail=_54297E1D-3029-4543-A475-1E9B91393B50-- From owner-svn-src-all@freebsd.org Thu Oct 13 07:17:06 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 70AF2C0F2CE; Thu, 13 Oct 2016 07:17:06 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 3C20CF02; Thu, 13 Oct 2016 07:17:06 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9D7H5Or011550; Thu, 13 Oct 2016 07:17:05 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9D7H4r9011543; Thu, 13 Oct 2016 07:17:04 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610130717.u9D7H4r9011543@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Thu, 13 Oct 2016 07:17:04 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307193 - in stable/10/sys: dev/hyperv/netvsc net X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Oct 2016 07:17:06 -0000 Author: sephe Date: Thu Oct 13 07:17:04 2016 New Revision: 307193 URL: https://svnweb.freebsd.org/changeset/base/307193 Log: MFC 305175,305176,305179,305182,305268,305270,305276 305175 net/rndis: Define per-packet-info for RNDIS packet message Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7708 305176 hyperv/hn: Stringent per-packet-info verification. While I'm here, minor style changes. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7709 305179 hyperv/hn: Fix VLAN tag construction. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7716 305182 net/rndis: Define types for RNDIS pktinfo rm_type field. They are defined by NDIS spec, so the NDIS prefix. Reviewed by: hps Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7717 305268 hyperv/hn: Rework RXCSUM related bits Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7735 305270 hyperv/hn: Simplify RX hash related bits. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7736 305276 hyperv/hn: Use the per-packet-info types defined by net/rndis.h Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7737 Modified: stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.c stable/10/sys/dev/hyperv/netvsc/if_hnreg.h stable/10/sys/dev/hyperv/netvsc/if_hnvar.h stable/10/sys/dev/hyperv/netvsc/ndis.h stable/10/sys/net/rndis.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Thu Oct 13 07:12:20 2016 (r307192) +++ stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Thu Oct 13 07:17:04 2016 (r307193) @@ -1307,6 +1307,7 @@ netvsc_recv(struct hn_rx_ring *rxr, cons struct ifnet *ifp = rxr->hn_ifp; struct mbuf *m_new; int size, do_lro = 0, do_csum = 1; + int hash_type = M_HASHTYPE_OPAQUE; if (!(ifp->if_drv_flags & IFF_DRV_RUNNING)) return (0); @@ -1352,28 +1353,29 @@ netvsc_recv(struct hn_rx_ring *rxr, cons do_csum = 0; /* receive side checksum offload */ - if (info->csum_info != NULL) { + if (info->csum_info != HN_NDIS_RXCSUM_INFO_INVALID) { /* IP csum offload */ - if (info->csum_info->receive.ip_csum_succeeded && do_csum) { + if ((info->csum_info & NDIS_RXCSUM_INFO_IPCS_OK) && do_csum) { m_new->m_pkthdr.csum_flags |= (CSUM_IP_CHECKED | CSUM_IP_VALID); rxr->hn_csum_ip++; } /* TCP/UDP csum offload */ - if ((info->csum_info->receive.tcp_csum_succeeded || - info->csum_info->receive.udp_csum_succeeded) && do_csum) { + if ((info->csum_info & (NDIS_RXCSUM_INFO_UDPCS_OK | + NDIS_RXCSUM_INFO_TCPCS_OK)) && do_csum) { m_new->m_pkthdr.csum_flags |= (CSUM_DATA_VALID | CSUM_PSEUDO_HDR); m_new->m_pkthdr.csum_data = 0xffff; - if (info->csum_info->receive.tcp_csum_succeeded) + if (info->csum_info & NDIS_RXCSUM_INFO_TCPCS_OK) rxr->hn_csum_tcp++; else rxr->hn_csum_udp++; } - if (info->csum_info->receive.ip_csum_succeeded && - info->csum_info->receive.tcp_csum_succeeded) + if ((info->csum_info & + (NDIS_RXCSUM_INFO_TCPCS_OK | NDIS_RXCSUM_INFO_IPCS_OK)) == + (NDIS_RXCSUM_INFO_TCPCS_OK | NDIS_RXCSUM_INFO_IPCS_OK)) do_lro = 1; } else { const struct ether_header *eh; @@ -1429,20 +1431,20 @@ netvsc_recv(struct hn_rx_ring *rxr, cons } } skip: - if (info->vlan_info != NULL) { - m_new->m_pkthdr.ether_vtag = info->vlan_info->u1.s1.vlan_id; + if (info->vlan_info != HN_NDIS_VLAN_INFO_INVALID) { + m_new->m_pkthdr.ether_vtag = EVL_MAKETAG( + NDIS_VLAN_INFO_ID(info->vlan_info), + NDIS_VLAN_INFO_PRI(info->vlan_info), + NDIS_VLAN_INFO_CFI(info->vlan_info)); m_new->m_flags |= M_VLANTAG; } - if (info->hash_info != NULL && info->hash_value != NULL) { - int hash_type = M_HASHTYPE_OPAQUE; - + if (info->hash_info != HN_NDIS_HASH_INFO_INVALID) { rxr->hn_rss_pkts++; - m_new->m_pkthdr.flowid = info->hash_value->hash_value; - if ((info->hash_info->hash_info & NDIS_HASH_FUNCTION_MASK) == + m_new->m_pkthdr.flowid = info->hash_value; + if ((info->hash_info & NDIS_HASH_FUNCTION_MASK) == NDIS_HASH_FUNCTION_TOEPLITZ) { - uint32_t type = - (info->hash_info->hash_info & NDIS_HASH_TYPE_MASK); + uint32_t type = (info->hash_info & NDIS_HASH_TYPE_MASK); switch (type) { case NDIS_HASH_IPV4: @@ -1470,14 +1472,10 @@ skip: break; } } - M_HASHTYPE_SET(m_new, hash_type); } else { - if (info->hash_value != NULL) - m_new->m_pkthdr.flowid = info->hash_value->hash_value; - else - m_new->m_pkthdr.flowid = rxr->hn_rx_idx; - M_HASHTYPE_SET(m_new, M_HASHTYPE_OPAQUE); + m_new->m_pkthdr.flowid = rxr->hn_rx_idx; } + M_HASHTYPE_SET(m_new, hash_type); /* * Note: Moved RX completion back to hv_nv_on_receive() so all Modified: stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.c Thu Oct 13 07:12:20 2016 (r307192) +++ stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.c Thu Oct 13 07:17:04 2016 (r307193) @@ -154,79 +154,92 @@ hv_rf_receive_indicate_status(struct hn_ static int hv_rf_find_recvinfo(const rndis_packet *rpkt, struct hn_recvinfo *info) { - const rndis_per_packet_info *ppi; - uint32_t mask, len; + const struct rndis_pktinfo *pi; + uint32_t mask = 0, len; - info->vlan_info = NULL; - info->csum_info = NULL; - info->hash_info = NULL; - info->hash_value = NULL; + info->vlan_info = HN_NDIS_VLAN_INFO_INVALID; + info->csum_info = HN_NDIS_RXCSUM_INFO_INVALID; + info->hash_info = HN_NDIS_HASH_INFO_INVALID; if (rpkt->per_pkt_info_offset == 0) - return 0; + return (0); + if (__predict_false(rpkt->per_pkt_info_offset & + (RNDIS_PKTINFO_ALIGN - 1))) + return (EINVAL); + if (__predict_false(rpkt->per_pkt_info_offset < + RNDIS_PACKET_MSG_OFFSET_MIN)) + return (EINVAL); - ppi = (const rndis_per_packet_info *) + pi = (const struct rndis_pktinfo *) ((const uint8_t *)rpkt + rpkt->per_pkt_info_offset); len = rpkt->per_pkt_info_length; - mask = 0; while (len != 0) { - const void *ppi_dptr; - uint32_t ppi_dlen; + const void *data; + uint32_t dlen; - if (__predict_false(ppi->size < ppi->per_packet_info_offset)) - return EINVAL; - ppi_dlen = ppi->size - ppi->per_packet_info_offset; - ppi_dptr = (const uint8_t *)ppi + ppi->per_packet_info_offset; - - switch (ppi->type) { - case ieee_8021q_info: - if (__predict_false(ppi_dlen < sizeof(ndis_8021q_info))) - return EINVAL; - info->vlan_info = ppi_dptr; + if (__predict_false(len < sizeof(*pi))) + return (EINVAL); + if (__predict_false(len < pi->rm_size)) + return (EINVAL); + len -= pi->rm_size; + + if (__predict_false(pi->rm_size & (RNDIS_PKTINFO_ALIGN - 1))) + return (EINVAL); + if (__predict_false(pi->rm_size < pi->rm_pktinfooffset)) + return (EINVAL); + dlen = pi->rm_size - pi->rm_pktinfooffset; + data = pi->rm_data; + + switch (pi->rm_type) { + case NDIS_PKTINFO_TYPE_VLAN: + if (__predict_false(dlen < NDIS_VLAN_INFO_SIZE)) + return (EINVAL); + info->vlan_info = *((const uint32_t *)data); mask |= HV_RF_RECVINFO_VLAN; break; - case tcpip_chksum_info: - if (__predict_false(ppi_dlen < - sizeof(rndis_tcp_ip_csum_info))) - return EINVAL; - info->csum_info = ppi_dptr; + case NDIS_PKTINFO_TYPE_CSUM: + if (__predict_false(dlen < NDIS_RXCSUM_INFO_SIZE)) + return (EINVAL); + info->csum_info = *((const uint32_t *)data); mask |= HV_RF_RECVINFO_CSUM; break; - case nbl_hash_value: - if (__predict_false(ppi_dlen < - sizeof(struct rndis_hash_value))) - return EINVAL; - info->hash_value = ppi_dptr; + case HN_NDIS_PKTINFO_TYPE_HASHVAL: + if (__predict_false(dlen < HN_NDIS_HASH_VALUE_SIZE)) + return (EINVAL); + info->hash_value = *((const uint32_t *)data); mask |= HV_RF_RECVINFO_HASHVAL; break; - case nbl_hash_info: - if (__predict_false(ppi_dlen < - sizeof(struct rndis_hash_info))) - return EINVAL; - info->hash_info = ppi_dptr; + case HN_NDIS_PKTINFO_TYPE_HASHINF: + if (__predict_false(dlen < HN_NDIS_HASH_INFO_SIZE)) + return (EINVAL); + info->hash_info = *((const uint32_t *)data); mask |= HV_RF_RECVINFO_HASHINF; break; default: - goto skip; + goto next; } if (mask == HV_RF_RECVINFO_ALL) { /* All found; done */ break; } -skip: - if (__predict_false(len < ppi->size)) - return EINVAL; - len -= ppi->size; - ppi = (const rndis_per_packet_info *) - ((const uint8_t *)ppi + ppi->size); +next: + pi = (const struct rndis_pktinfo *) + ((const uint8_t *)pi + pi->rm_size); } - return 0; + + /* + * Final fixup. + * - If there is no hash value, invalidate the hash info. + */ + if ((mask & HV_RF_RECVINFO_HASHVAL) == 0) + info->hash_info = HN_NDIS_HASH_INFO_INVALID; + return (0); } /* Modified: stable/10/sys/dev/hyperv/netvsc/if_hnreg.h ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/if_hnreg.h Thu Oct 13 07:12:20 2016 (r307192) +++ stable/10/sys/dev/hyperv/netvsc/if_hnreg.h Thu Oct 13 07:17:04 2016 (r307193) @@ -208,4 +208,17 @@ struct hn_nvs_rndis_ack { } __packed; CTASSERT(sizeof(struct hn_nvs_rndis_ack) >= HN_NVS_REQSIZE_MIN); +/* + * RNDIS extension + */ + +/* Per-packet hash info */ +#define HN_NDIS_HASH_INFO_SIZE sizeof(uint32_t) +#define HN_NDIS_PKTINFO_TYPE_HASHINF NDIS_PKTINFO_TYPE_ORIG_NBLIST +/* NDIS_HASH_ */ + +/* Per-packet hash value */ +#define HN_NDIS_HASH_VALUE_SIZE sizeof(uint32_t) +#define HN_NDIS_PKTINFO_TYPE_HASHVAL NDIS_PKTINFO_TYPE_PKT_CANCELID + #endif /* !_IF_HNREG_H_ */ Modified: stable/10/sys/dev/hyperv/netvsc/if_hnvar.h ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/if_hnvar.h Thu Oct 13 07:12:20 2016 (r307192) +++ stable/10/sys/dev/hyperv/netvsc/if_hnvar.h Thu Oct 13 07:17:04 2016 (r307193) @@ -55,11 +55,15 @@ struct rndix_hash_value; struct ndis_8021q_info_; struct rndis_tcp_ip_csum_info_; +#define HN_NDIS_VLAN_INFO_INVALID 0xffffffff +#define HN_NDIS_RXCSUM_INFO_INVALID 0 +#define HN_NDIS_HASH_INFO_INVALID 0 + struct hn_recvinfo { - const struct ndis_8021q_info_ *vlan_info; - const struct rndis_tcp_ip_csum_info_ *csum_info; - const struct rndis_hash_info *hash_info; - const struct rndis_hash_value *hash_value; + uint32_t vlan_info; + uint32_t csum_info; + uint32_t hash_info; + uint32_t hash_value; }; #define HN_SEND_CTX_INITIALIZER(cb, cbarg) \ Modified: stable/10/sys/dev/hyperv/netvsc/ndis.h ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/ndis.h Thu Oct 13 07:12:20 2016 (r307192) +++ stable/10/sys/dev/hyperv/netvsc/ndis.h Thu Oct 13 07:17:04 2016 (r307193) @@ -203,4 +203,32 @@ struct ndis_rssprm_toeplitz { uint32_t rss_ind[NDIS_HASH_INDCNT]; }; +/* + * Per-packet-info + */ + +/* VLAN */ +#define NDIS_VLAN_INFO_SIZE sizeof(uint32_t) +#define NDIS_VLAN_INFO_PRI_MASK 0x0007 +#define NDIS_VLAN_INFO_CFI_MASK 0x0008 +#define NDIS_VLAN_INFO_ID_MASK 0xfff0 +#define NDIS_VLAN_INFO_MAKE(id, pri, cfi) \ + (((pri) & NVIS_VLAN_INFO_PRI_MASK) | \ + (((cfi) & 0x1) << 3) | (((id) & 0xfff) << 4)) +#define NDIS_VLAN_INFO_ID(inf) (((inf) & NDIS_VLAN_INFO_ID_MASK) >> 4) +#define NDIS_VLAN_INFO_CFI(inf) (((inf) & NDIS_VLAN_INFO_CFI_MASK) >> 3) +#define NDIS_VLAN_INFO_PRI(inf) ((inf) & NDIS_VLAN_INFO_PRI_MASK) + +/* Reception checksum */ +#define NDIS_RXCSUM_INFO_SIZE sizeof(uint32_t) +#define NDIS_RXCSUM_INFO_TCPCS_FAILED 0x0001 +#define NDIS_RXCSUM_INFO_UDPCS_FAILED 0x0002 +#define NDIS_RXCSUM_INFO_IPCS_FAILED 0x0004 +#define NDIS_RXCSUM_INFO_TCPCS_OK 0x0008 +#define NDIS_RXCSUM_INFO_UDPCS_OK 0x0010 +#define NDIS_RXCSUM_INFO_IPCS_OK 0x0020 +#define NDIS_RXCSUM_INFO_LOOPBACK 0x0040 +#define NDIS_RXCSUM_INFO_TCPCS_INVAL 0x0080 +#define NDIS_RXCSUM_INFO_IPCS_INVAL 0x0100 + #endif /* !_NET_NDIS_H_ */ Modified: stable/10/sys/net/rndis.h ============================================================================== --- stable/10/sys/net/rndis.h Thu Oct 13 07:12:20 2016 (r307192) +++ stable/10/sys/net/rndis.h Thu Oct 13 07:17:04 2016 (r307193) @@ -112,6 +112,39 @@ struct rndis_packet_msg { }; /* + * Minimum value for rm_dataoffset, rm_oobdataoffset, and + * rm_pktinfooffset. + */ +#define RNDIS_PACKET_MSG_OFFSET_MIN \ + (sizeof(struct rndis_packet_msg) - \ + __offsetof(struct rndis_packet_msg, rm_dataoffset)) + +/* Per-packet-info for RNDIS data message */ +struct rndis_pktinfo { + uint32_t rm_size; + uint32_t rm_type; /* NDIS_PKTINFO_TYPE_ */ + uint32_t rm_pktinfooffset; + uint8_t rm_data[]; +}; + +#define RNDIS_PKTINFO_OFFSET \ + __offsetof(struct rndis_pktinfo, rm_data[0]) +#define RNDIS_PKTINFO_ALIGN 4 + +#define NDIS_PKTINFO_TYPE_CSUM 0 +#define NDIS_PKTINFO_TYPE_IPSEC 1 +#define NDIS_PKTINFO_TYPE_LSO 2 +#define NDIS_PKTINFO_TYPE_CLASSIFY 3 +/* reserved 4 */ +#define NDIS_PKTINFO_TYPE_SGLIST 5 +#define NDIS_PKTINFO_TYPE_VLAN 6 +#define NDIS_PKTINFO_TYPE_ORIG 7 +#define NDIS_PKTINFO_TYPE_PKT_CANCELID 8 +#define NDIS_PKTINFO_TYPE_ORIG_NBLIST 9 +#define NDIS_PKTINFO_TYPE_CACHE_NBLIST 10 +#define NDIS_PKTINFO_TYPE_PKT_PAD 11 + +/* * RNDIS control messages */ struct rndis_comp_hdr { From owner-svn-src-all@freebsd.org Thu Oct 13 07:20:47 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 51CA5C0F48B for ; Thu, 13 Oct 2016 07:20:47 +0000 (UTC) (envelope-from julio@meroh.net) Received: from mail-qt0-x229.google.com (mail-qt0-x229.google.com [IPv6:2607:f8b0:400d:c0d::229]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 0BDC21AA for ; Thu, 13 Oct 2016 07:20:47 +0000 (UTC) (envelope-from julio@meroh.net) Received: by mail-qt0-x229.google.com with SMTP id m5so32434015qtb.3 for ; Thu, 13 Oct 2016 00:20:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=meroh.net; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=gzUAQOFOnkwVkWCkbjrJvbtja6F89WMimYPVqEobAZU=; b=BZr2WxGYHzO5e44WCDPFrRzFphjb+Ju3sJcFFHrm1gi4UMCz6yN9QRk+OBt9muARvi 8C70CHZLp+l6F5t0L27VlBm7gLFgmE037qghexQmYlTMafdx3teFNzuNmPR+XrHXr8o/ y2a6G28Lsewn5taVo7i6dzG0HQo0Is4ZGnc1dyAZeRMqOADb4ID6SMkseLf+YqfeI3bO iM1xrNpEjUEmAhrSHdpGGFm8ZWY51unZKdfmJCdt7T4j21gLhpjod81nDcUTRk0XTuwz jbxwhH9Xdp7g97zWapZ4IA7JOa8sFyQK0tu8lQBTiqaJTNiOvjuB441y0oFci8bDw5ZO iFUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=gzUAQOFOnkwVkWCkbjrJvbtja6F89WMimYPVqEobAZU=; b=Q0hvNCwjQFNm15ZUnW3OAi9L2tRKX9ktt6XwUIGzzTcJtsp9TcGXG9cDOeShBd1H1b USgyfUdQ3bXfuNQlNIYNDCo/Oss4StS9RerSwyAfc4bh4zUzyiEnB4WRiDyjJDUBv1c+ BZDFW839FSyCJJKwlhwhLPReKdzltVQAngH7Ch+i7PrBrpra8J5C7DpKyE5pDWvkwzB8 IwdWSwEg6jsj4bX4j/p2VkkxYi3QmFB8KQSi8k2mdf35Xiobnb2ZXTZWckguhUgO4cfp bB16FxM78CwyX82kn8m+Y1Sz9h1q+mwspI6wbN95XSr94Dj7IPeK5GjCJ2awFP75/41e 4I2w== X-Gm-Message-State: AA6/9RmvcacwBiIo28dQDHZOcNABTxD9O/v6bEtQeQjG8jzZ94xf/R21IdoanUY44X+c5wN/zNY9PO3d36FjEQ== X-Received: by 10.200.53.54 with SMTP id y51mr5284482qtb.132.1476343246155; Thu, 13 Oct 2016 00:20:46 -0700 (PDT) MIME-Version: 1.0 Received: by 10.200.56.93 with HTTP; Thu, 13 Oct 2016 00:20:25 -0700 (PDT) X-Originating-IP: [172.26.42.46] In-Reply-To: <201610130702.u9D72sgd007580@repo.freebsd.org> References: <201610130702.u9D72sgd007580@repo.freebsd.org> From: Julio Merino Date: Thu, 13 Oct 2016 03:20:25 -0400 Message-ID: Subject: Re: svn commit: r307190 - head/contrib/netbsd-tests/fs/tmpfs To: Ngie Cooper Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Content-Type: text/plain; charset=UTF-8 X-Content-Filtered-By: Mailman/MimeDel 2.1.23 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Oct 2016 07:20:47 -0000 On Thu, Oct 13, 2016 at 3:02 AM, Ngie Cooper wrote: > Author: ngie > Date: Thu Oct 13 07:02:54 2016 > New Revision: 307190 > URL: https://svnweb.freebsd.org/changeset/base/307190 > > Log: > Skip :uchg on FreeBSD > > Unfortunately removing files with uchg set always succeeds with root on > FreeBSD. Unfortunately running the test as an unprivileged user isn't > doable > because mounting tmpfs requires root > > PR: 212861 > Sponsored by: Dell EMC Isilon > > Modified: > head/contrib/netbsd-tests/fs/tmpfs/t_remove.sh > > Modified: head/contrib/netbsd-tests/fs/tmpfs/t_remove.sh > ============================================================ > ================== > --- head/contrib/netbsd-tests/fs/tmpfs/t_remove.sh Thu Oct 13 > 06:56:23 2016 (r307189) > +++ head/contrib/netbsd-tests/fs/tmpfs/t_remove.sh Thu Oct 13 > 07:02:54 2016 (r307190) > @@ -53,6 +53,10 @@ uchg_head() { > atf_set "require.user" "root" > } > uchg_body() { > + # Begin FreeBSD > + atf_skip "this fails on FreeBSD with root - bug 212861" > + # End FreeBSD > This is a bad way of disabling a test due to a known bug because, when the bug is resolved, the test won't notice. You should be using the "expected failures" functionality if possible, and based on the change description, I think you can do this here easily. Try: atf_expect_fail "FreeBSD bug 213861 blah blah" right before the line that triggers the test failure. -- Julio Merino -- http://julio.meroh.net/ From owner-svn-src-all@freebsd.org Thu Oct 13 07:22:14 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D40D2C0F5E0; Thu, 13 Oct 2016 07:22:14 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id A5A02774; Thu, 13 Oct 2016 07:22:14 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9D7MDwo014506; Thu, 13 Oct 2016 07:22:13 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9D7MDSw014505; Thu, 13 Oct 2016 07:22:13 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610130722.u9D7MDSw014505@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Thu, 13 Oct 2016 07:22:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307194 - stable/10/sys/net X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Oct 2016 07:22:14 -0000 Author: sephe Date: Thu Oct 13 07:22:13 2016 New Revision: 307194 URL: https://svnweb.freebsd.org/changeset/base/307194 Log: MFC 305277,305278 305277 net/rndis: Add comment for rndis_comp_hdr Reviewed by: hps Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7738 305278 net/rndis: Define common message header for RNDIS messages. And avoid RNDIS_HEADER_OFFSET hardcoding. Reviewed by: hps Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7739 Modified: stable/10/sys/net/rndis.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/net/rndis.h ============================================================================== --- stable/10/sys/net/rndis.h Thu Oct 13 07:17:04 2016 (r307193) +++ stable/10/sys/net/rndis.h Thu Oct 13 07:22:13 2016 (r307194) @@ -93,6 +93,14 @@ #define RNDIS_DF_CONNECTION_ORIENTED 0x00000002 /* + * Common RNDIS message header. + */ +struct rndis_msghdr { + uint32_t rm_type; + uint32_t rm_len; +}; + +/* * RNDIS data message */ #define REMOTE_NDIS_PACKET_MSG 0x00000001 @@ -147,6 +155,12 @@ struct rndis_pktinfo { /* * RNDIS control messages */ + +/* + * Common header for RNDIS completion messages. + * + * NOTE: It does not apply to REMOTE_NDIS_RESET_CMPLT. + */ struct rndis_comp_hdr { uint32_t rm_type; uint32_t rm_len; @@ -316,7 +330,7 @@ struct rndis_keepalive_comp { #define NDIS_PACKET_TYPE_MAC_FRAME 0x00008000 /* RNDIS offsets */ -#define RNDIS_HEADER_OFFSET 8 /* bytes */ +#define RNDIS_HEADER_OFFSET ((uint32_t)sizeof(struct rndis_msghdr)) #define RNDIS_DATA_OFFSET \ ((uint32_t)(sizeof(struct rndis_packet_msg) - RNDIS_HEADER_OFFSET)) From owner-svn-src-all@freebsd.org Thu Oct 13 07:25:19 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D151DC0F718; Thu, 13 Oct 2016 07:25:19 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 8F5AA98A; Thu, 13 Oct 2016 07:25:19 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9D7PIL9015271; Thu, 13 Oct 2016 07:25:18 GMT (envelope-from avg@FreeBSD.org) Received: (from avg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9D7PIA0015270; Thu, 13 Oct 2016 07:25:18 GMT (envelope-from avg@FreeBSD.org) Message-Id: <201610130725.u9D7PIA0015270@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avg set sender to avg@FreeBSD.org using -f From: Andriy Gapon Date: Thu, 13 Oct 2016 07:25:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307195 - head/sys/dev/iicbus X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Oct 2016 07:25:19 -0000 Author: avg Date: Thu Oct 13 07:25:18 2016 New Revision: 307195 URL: https://svnweb.freebsd.org/changeset/base/307195 Log: convert iicsmb to use iicbus_transfer for all operations Previously the driver used more low level operations like iicbus_start and iicbus_write. The problem is that those operations are not implemented by iicbus(4) and the calls were effectively routed to a driver to which the bus is attached. But not all of the controllers implement such low level operations while all of the drivers are expected to have iicbus_transfer. While there fix incorrect implementation of iicsmb_bwrite and iicsmb_bread. The former should send a byte count before the actual bytes, while the latter should first receive the byte count and then receive the bytes. I have tested only these commands: - quick (r/w) - send byte - receive byte - read byte - write byte MFC after: 1 month Differential Revision: https://reviews.freebsd.org/D8170 Modified: head/sys/dev/iicbus/iicsmb.c Modified: head/sys/dev/iicbus/iicsmb.c ============================================================================== --- head/sys/dev/iicbus/iicsmb.c Thu Oct 13 07:22:13 2016 (r307194) +++ head/sys/dev/iicbus/iicsmb.c Thu Oct 13 07:25:18 2016 (r307195) @@ -131,8 +131,6 @@ static driver_t iicsmb_driver = { sizeof(struct iicsmb_softc), }; -#define IICBUS_TIMEOUT 100 /* us */ - static void iicsmb_identify(driver_t *driver, device_t parent) { @@ -276,237 +274,213 @@ iicsmb_callback(device_t dev, int index, } static int +iic2smb_error(int error) +{ + switch (error) { + case IIC_NOERR: + return (SMB_ENOERR); + case IIC_EBUSERR: + return (SMB_EBUSERR); + case IIC_ENOACK: + return (SMB_ENOACK); + case IIC_ETIMEOUT: + return (SMB_ETIMEOUT); + case IIC_EBUSBSY: + return (SMB_EBUSY); + case IIC_ESTATUS: + return (SMB_EBUSERR); + case IIC_EUNDERFLOW: + return (SMB_EBUSERR); + case IIC_EOVERFLOW: + return (SMB_EBUSERR); + case IIC_ENOTSUPP: + return (SMB_ENOTSUPP); + case IIC_ENOADDR: + return (SMB_EBUSERR); + case IIC_ERESOURCE: + return (SMB_EBUSERR); + default: + return (SMB_EBUSERR); + } +} + +#define TRANSFER_MSGS(dev, msgs) iicbus_transfer(dev, msgs, nitems(msgs)) + +static int iicsmb_quick(device_t dev, u_char slave, int how) { - device_t parent = device_get_parent(dev); + struct iic_msg msgs[] = { + { slave, how == SMB_QWRITE ? IIC_M_WR : IIC_M_RD, 0, NULL }, + }; int error; switch (how) { case SMB_QWRITE: - error = iicbus_start(parent, slave & ~LSB, IICBUS_TIMEOUT); - break; - case SMB_QREAD: - error = iicbus_start(parent, slave | LSB, IICBUS_TIMEOUT); break; - default: - error = EINVAL; - break; + return (SMB_EINVAL); } - if (!error) - error = iicbus_stop(parent); - - return (error); + error = TRANSFER_MSGS(dev, msgs); + return (iic2smb_error(error)); } static int iicsmb_sendb(device_t dev, u_char slave, char byte) { - device_t parent = device_get_parent(dev); - int error, sent; - - error = iicbus_start(parent, slave & ~LSB, IICBUS_TIMEOUT); - - if (!error) { - error = iicbus_write(parent, &byte, 1, &sent, IICBUS_TIMEOUT); - - iicbus_stop(parent); - } + struct iic_msg msgs[] = { + { slave, IIC_M_WR, 1, &byte }, + }; + int error; - return (error); + error = TRANSFER_MSGS(dev, msgs); + return (iic2smb_error(error)); } static int iicsmb_recvb(device_t dev, u_char slave, char *byte) { - device_t parent = device_get_parent(dev); - int error, read; - - error = iicbus_start(parent, slave | LSB, 0); - - if (!error) { - error = iicbus_read(parent, byte, 1, &read, IIC_LAST_READ, IICBUS_TIMEOUT); - - iicbus_stop(parent); - } + struct iic_msg msgs[] = { + { slave, IIC_M_RD, 1, byte }, + }; + int error; - return (error); + error = TRANSFER_MSGS(dev, msgs); + return (iic2smb_error(error)); } static int iicsmb_writeb(device_t dev, u_char slave, char cmd, char byte) { - device_t parent = device_get_parent(dev); - int error, sent; - - error = iicbus_start(parent, slave & ~LSB, 0); - - if (!error) { - if (!(error = iicbus_write(parent, &cmd, 1, &sent, IICBUS_TIMEOUT))) - error = iicbus_write(parent, &byte, 1, &sent, IICBUS_TIMEOUT); - - iicbus_stop(parent); - } + uint8_t bytes[] = { cmd, byte }; + struct iic_msg msgs[] = { + { slave, IIC_M_WR, nitems(bytes), bytes }, + }; + int error; - return (error); + error = TRANSFER_MSGS(dev, msgs); + return (iic2smb_error(error)); } static int iicsmb_writew(device_t dev, u_char slave, char cmd, short word) { - device_t parent = device_get_parent(dev); - int error, sent; - - char low = (char)(word & 0xff); - char high = (char)((word & 0xff00) >> 8); - - error = iicbus_start(parent, slave & ~LSB, 0); - - if (!error) { - if (!(error = iicbus_write(parent, &cmd, 1, &sent, IICBUS_TIMEOUT))) - if (!(error = iicbus_write(parent, &low, 1, &sent, IICBUS_TIMEOUT))) - error = iicbus_write(parent, &high, 1, &sent, IICBUS_TIMEOUT); - - iicbus_stop(parent); - } + uint8_t bytes[] = { cmd, word & 0xff, word >> 8 }; + struct iic_msg msgs[] = { + { slave, IIC_M_WR, nitems(bytes), bytes }, + }; + int error; - return (error); + error = TRANSFER_MSGS(dev, msgs); + return (iic2smb_error(error)); } static int iicsmb_readb(device_t dev, u_char slave, char cmd, char *byte) { - device_t parent = device_get_parent(dev); - int error, sent, read; - - if ((error = iicbus_start(parent, slave & ~LSB, IICBUS_TIMEOUT))) - return (error); - - if ((error = iicbus_write(parent, &cmd, 1, &sent, IICBUS_TIMEOUT))) - goto error; - - if ((error = iicbus_repeated_start(parent, slave | LSB, IICBUS_TIMEOUT))) - goto error; - - if ((error = iicbus_read(parent, byte, 1, &read, IIC_LAST_READ, IICBUS_TIMEOUT))) - goto error; + struct iic_msg msgs[] = { + { slave, IIC_M_WR | IIC_M_NOSTOP, 1, &cmd }, + { slave, IIC_M_RD, 1, byte }, + }; + int error; -error: - iicbus_stop(parent); - return (error); + error = TRANSFER_MSGS(dev, msgs); + return (iic2smb_error(error)); } -#define BUF2SHORT(low,high) \ - ((short)(((high) & 0xff) << 8) | (short)((low) & 0xff)) - static int iicsmb_readw(device_t dev, u_char slave, char cmd, short *word) { - device_t parent = device_get_parent(dev); - int error, sent, read; - char buf[2]; - - if ((error = iicbus_start(parent, slave & ~LSB, IICBUS_TIMEOUT))) - return (error); - - if ((error = iicbus_write(parent, &cmd, 1, &sent, IICBUS_TIMEOUT))) - goto error; - - if ((error = iicbus_repeated_start(parent, slave | LSB, IICBUS_TIMEOUT))) - goto error; - - if ((error = iicbus_read(parent, buf, 2, &read, IIC_LAST_READ, IICBUS_TIMEOUT))) - goto error; - - /* first, receive low, then high byte */ - *word = BUF2SHORT(buf[0], buf[1]); + uint8_t buf[2]; + struct iic_msg msgs[] = { + { slave, IIC_M_WR | IIC_M_NOSTOP, 1, &cmd }, + { slave, IIC_M_RD, nitems(buf), buf }, + }; + int error; -error: - iicbus_stop(parent); - return (error); + error = TRANSFER_MSGS(dev, msgs); + if (error == 0) + *word = ((uint16_t)buf[1] << 8) | buf[0]; + return (iic2smb_error(error)); } static int iicsmb_pcall(device_t dev, u_char slave, char cmd, short sdata, short *rdata) { - device_t parent = device_get_parent(dev); - int error, sent, read; - char buf[2]; - - if ((error = iicbus_start(parent, slave & ~LSB, IICBUS_TIMEOUT))) - return (error); - - if ((error = iicbus_write(parent, &cmd, 1, &sent, IICBUS_TIMEOUT))) - goto error; - - /* first, send low, then high byte */ - buf[0] = (char)(sdata & 0xff); - buf[1] = (char)((sdata & 0xff00) >> 8); - - if ((error = iicbus_write(parent, buf, 2, &sent, IICBUS_TIMEOUT))) - goto error; - - if ((error = iicbus_repeated_start(parent, slave | LSB, IICBUS_TIMEOUT))) - goto error; - - if ((error = iicbus_read(parent, buf, 2, &read, IIC_LAST_READ, IICBUS_TIMEOUT))) - goto error; - - /* first, receive low, then high byte */ - *rdata = BUF2SHORT(buf[0], buf[1]); + uint8_t in[3] = { cmd, sdata & 0xff, sdata >> 8 }; + uint8_t out[2]; + struct iic_msg msgs[] = { + { slave, IIC_M_WR | IIC_M_NOSTOP, nitems(in), in }, + { slave, IIC_M_RD, nitems(out), out }, + }; + int error; -error: - iicbus_stop(parent); - return (error); + error = TRANSFER_MSGS(dev, msgs); + if (error == 0) + *rdata = ((uint16_t)out[1] << 8) | out[0]; + return (iic2smb_error(error)); } static int iicsmb_bwrite(device_t dev, u_char slave, char cmd, u_char count, char *buf) { - device_t parent = device_get_parent(dev); - int error, sent; - - if ((error = iicbus_start(parent, slave & ~LSB, IICBUS_TIMEOUT))) - goto error; - - if ((error = iicbus_write(parent, &cmd, 1, &sent, IICBUS_TIMEOUT))) - goto error; - - if ((error = iicbus_write(parent, buf, (int)count, &sent, IICBUS_TIMEOUT))) - goto error; - - if ((error = iicbus_stop(parent))) - goto error; + uint8_t bytes[2] = { cmd, count }; + struct iic_msg msgs[] = { + { slave, IIC_M_WR | IIC_M_NOSTOP, nitems(bytes), bytes }, + { slave, IIC_M_WR | IIC_M_NOSTART, count, buf }, + }; + int error; -error: - return (error); + if (count > 32 || count == 0) + return (SMB_EINVAL); + error = TRANSFER_MSGS(dev, msgs); + return (iic2smb_error(error)); } static int iicsmb_bread(device_t dev, u_char slave, char cmd, u_char *count, char *buf) { + struct iic_msg msgs[] = { + { slave, IIC_M_WR | IIC_M_NOSTOP, 1, &cmd }, + { slave, IIC_M_RD | IIC_M_NOSTOP, 1, count }, + }; + struct iic_msg block_msg[] = { + { slave, IIC_M_RD | IIC_M_NOSTART, 0, buf }, + }; device_t parent = device_get_parent(dev); - int error, sent, read; - - if ((error = iicbus_start(parent, slave & ~LSB, IICBUS_TIMEOUT))) - return (error); - - if ((error = iicbus_write(parent, &cmd, 1, &sent, IICBUS_TIMEOUT))) - goto error; - - if ((error = iicbus_repeated_start(parent, slave | LSB, IICBUS_TIMEOUT))) - goto error; - - if ((error = iicbus_read(parent, buf, (int)*count, &read, - IIC_LAST_READ, IICBUS_TIMEOUT))) - goto error; - *count = read; + int error; + u_char bufsz; -error: - iicbus_stop(parent); - return (error); + /* Stash output buffer size before overwriting it. */ + bufsz = *count; + if (bufsz == 0) + return (SMB_EINVAL); + + /* Have to do this because the command is split in two transfers. */ + error = iicbus_request_bus(parent, dev, IIC_WAIT); + if (error == 0) + error = TRANSFER_MSGS(dev, msgs); + if (error == 0) { + /* + * If the slave offers an empty or a too long reply, + * read one byte to generate the stop or abort. + * XXX 32 is hardcoded until SMB_MAXBLOCKSIZE is restored + * to sanity. + */ + if (*count > 32 || *count == 0) + block_msg[0].len = 1; + /* If longer than the buffer, then clamp at the buffer size. */ + if (*count > bufsz) + block_msg[0].len = bufsz; + else + block_msg[0].len = *count; + error = TRANSFER_MSGS(dev, block_msg); + if (*count > 32 || *count == 0) + error = SMB_EINVAL; + } + (void)iicbus_release_bus(parent, dev); + return (iic2smb_error(error)); } DRIVER_MODULE(iicsmb, iicbus, iicsmb_driver, iicsmb_devclass, 0, 0); From owner-svn-src-all@freebsd.org Thu Oct 13 07:29:07 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 68CAAC0F866; Thu, 13 Oct 2016 07:29:07 +0000 (UTC) (envelope-from yaneurabeya@gmail.com) Received: from mail-pf0-x241.google.com (mail-pf0-x241.google.com [IPv6:2607:f8b0:400e:c00::241]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 34F78C8E; Thu, 13 Oct 2016 07:29:07 +0000 (UTC) (envelope-from yaneurabeya@gmail.com) Received: by mail-pf0-x241.google.com with SMTP id 128so4472277pfz.1; Thu, 13 Oct 2016 00:29:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:mime-version:from:in-reply-to:date:cc:message-id:references :to; bh=Q9Pc48UgwyFtzRPfU8aHXLV5E9WGw/wZ9Dgy5cRYQ6A=; b=Ro8tdM9RyMP0OR/3TGHccVHZY+8FDstOAfQTjtBAQ4YaPOClg3MfagPGWso2+ywtef 9tYl1ruTs/0ROs7RVXXMDV4VmYxJbc96VZXR82vkHifHYlN84Lu2ObO6ePFUTRN0jn8x BvwFFCtS7XXyjL2CwDItk4RZbyr7YXl1CIKjZ1tAx9YeOdKqqN4iGn6JbGDwpF0c99bT hp1K2G+XEsyAWJ8Yho0QLCp/reHD5srYXxF3htRqNJWvNLjfsygiuuf9y7hC9XwQz6xL 06wsSrGkTYks3PsuVIB1S2q6VmgTBTiaMUxy3nHAe40acQn2LM4LrbIcBDXNFJv/48KQ eBYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:mime-version:from:in-reply-to:date:cc :message-id:references:to; bh=Q9Pc48UgwyFtzRPfU8aHXLV5E9WGw/wZ9Dgy5cRYQ6A=; b=bE0dhirJrOC7Pmw6ug/c4H20t9Ii1kGXo3Fpma2kBnCfm20q0uh0B5jzX5rXDDpIm0 3Gjj44KLh9gIO5Qgh6Ez/Jrr6WtbikzNhyFvd+9Ravuvzw5sq3QJEIic+pVkuWnCwmzv tRg6g52d52JgdZ6XZCt2jDDvqkcUEizpbr3yPe7e2J+wLHB3yZh4HWgoztPVP9H7Rg2A BvcBSzHXkhBmwaAGd/em6+NBdXOl4LQal38wGWhhYQ/vKTJafoCc2RyyjNGZn+XZROlz LbHLmCxfoxhyaIDVESirUABVo1jV87Nj0ypSljLiVds7tyrW+6jGwRBANLabzuI4TAcv a9aA== X-Gm-Message-State: AA6/9Rn/VcJm5vj4V3ltjilkGxyRB1yJu54kqIl6Ikyfrjs1ch1WzfA8KzM5/9we/Mq25A== X-Received: by 10.98.158.143 with SMTP id f15mr7934784pfk.133.1476343746842; Thu, 13 Oct 2016 00:29:06 -0700 (PDT) Received: from [192.168.20.12] (c-73-19-52-228.hsd1.wa.comcast.net. [73.19.52.228]) by smtp.gmail.com with ESMTPSA id j63sm16888055pfj.70.2016.10.13.00.29.05 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 13 Oct 2016 00:29:06 -0700 (PDT) Subject: Re: svn commit: r307190 - head/contrib/netbsd-tests/fs/tmpfs Mime-Version: 1.0 (Mac OS X Mail 9.3 \(3124\)) Content-Type: multipart/signed; boundary="Apple-Mail=_A0114B37-B420-4886-AA83-5E15D9B6FAB4"; protocol="application/pgp-signature"; micalg=pgp-sha512 X-Pgp-Agent: GPGMail From: "Ngie Cooper (yaneurabeya)" In-Reply-To: Date: Thu, 13 Oct 2016 00:29:04 -0700 Cc: Ngie Cooper , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Message-Id: References: <201610130702.u9D72sgd007580@repo.freebsd.org> To: Julio Merino X-Mailer: Apple Mail (2.3124) X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Oct 2016 07:29:07 -0000 --Apple-Mail=_A0114B37-B420-4886-AA83-5E15D9B6FAB4 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > On Oct 13, 2016, at 00:20, Julio Merino wrote: >=20 > On Thu, Oct 13, 2016 at 3:02 AM, Ngie Cooper wrote: > Author: ngie > Date: Thu Oct 13 07:02:54 2016 > New Revision: 307190 > URL: https://svnweb.freebsd.org/changeset/base/307190 >=20 > Log: > Skip :uchg on FreeBSD >=20 > Unfortunately removing files with uchg set always succeeds with root = on > FreeBSD. Unfortunately running the test as an unprivileged user = isn't doable > because mounting tmpfs requires root >=20 > PR: 212861 > Sponsored by: Dell EMC Isilon >=20 > Modified: > head/contrib/netbsd-tests/fs/tmpfs/t_remove.sh >=20 > Modified: head/contrib/netbsd-tests/fs/tmpfs/t_remove.sh > = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D > --- head/contrib/netbsd-tests/fs/tmpfs/t_remove.sh Thu Oct 13 = 06:56:23 2016 (r307189) > +++ head/contrib/netbsd-tests/fs/tmpfs/t_remove.sh Thu Oct 13 = 07:02:54 2016 (r307190) > @@ -53,6 +53,10 @@ uchg_head() { > atf_set "require.user" "root" > } > uchg_body() { > + # Begin FreeBSD > + atf_skip "this fails on FreeBSD with root - bug 212861" > + # End FreeBSD >=20 > This is a bad way of disabling a test due to a known bug because, when = the bug is resolved, the test won't notice. You should be using the = "expected failures" functionality if possible, and based on the change = description, I think you can do this here easily. Try: >=20 > atf_expect_fail "FreeBSD bug 213861 blah blah" >=20 > right before the line that triggers the test failure. The problem is that this leaves tmpfs mounts lying around, which atf = won=E2=80=99t cleanup. Otherwise, I would totally agree with you. Thanks, -Ngie --Apple-Mail=_A0114B37-B420-4886-AA83-5E15D9B6FAB4 Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=signature.asc Content-Type: application/pgp-signature; name=signature.asc Content-Description: Message signed with OpenPGP using GPGMail -----BEGIN PGP SIGNATURE----- Comment: GPGTools - https://gpgtools.org iQIcBAEBCgAGBQJX/zfBAAoJEPWDqSZpMIYVs64P/0JR4ZNY5nhp66HcTDMWrc+y QK5SSjmLK1AGcguGs54Yt6RWR12zEozYaC6Aq8AojvEAe4oE6wCpUqeFSTChlZ6a NWS2gsZ658+MVyOeyQp2CnryeTWF9/QmUnEi7Z6YtDwLHfOauqzgihwsIkZ2zR47 WCqTuyXX5u/aQqWvmflFc02u6mfkeDDylFbcHEtSJJgoSqpc5VjKrB5WMg8rWw+r FgbK/jRgxmEW5dR+6lVsgVaeSNtTs5nju7QHFEwwwK4FNaAsXb0z4RcSi2ZKwl0R G/a/XhOn6WyuJyBgFWJLh6PRtfv5a2ZphO7NDC4Rwmb3N/ee1hHuJ726GPrKcmdm uniRWHOBgvGPnD78SVyA/z0L4WE7HmqXXxofxz25pNccpzIzAhCQnuEHiPa3FdHg en7r50w6pTEtctlRBWP7vv+7yOdvBtCHoIz2YGJxckF2V/Y6G9rHTeDFYZMLvhim UdXfGHUJfIvRCqMKpjC8OHGPco80mDPwB/prO0uyHdis/u70Wc6I58JD8KDd7t75 VyM8sHtwPEa7i92hWLAsKI/0kiYUd62TiWHi51rjnGyvr84vRAQvRY2VbwHNxfzI 9RbP2rcewIDnwqm2ly9KAqjDEIBa3NekdwRzIMnUOCoJCITO1GYhkGY8MB2dHdB3 fR2x+WzDUl1X3eF6wfFv =lAg2 -----END PGP SIGNATURE----- --Apple-Mail=_A0114B37-B420-4886-AA83-5E15D9B6FAB4-- From owner-svn-src-all@freebsd.org Thu Oct 13 07:32:26 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 66D8BC0FA7D; Thu, 13 Oct 2016 07:32:26 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 369FDC9; Thu, 13 Oct 2016 07:32:26 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9D7WPdG018875; Thu, 13 Oct 2016 07:32:25 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9D7WPBN018874; Thu, 13 Oct 2016 07:32:25 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201610130732.u9D7WPBN018874@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Ngie Cooper Date: Thu, 13 Oct 2016 07:32:25 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307196 - head/contrib/netbsd-tests/fs/tmpfs X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Oct 2016 07:32:26 -0000 Author: ngie Date: Thu Oct 13 07:32:25 2016 New Revision: 307196 URL: https://svnweb.freebsd.org/changeset/base/307196 Log: Port contrib/netbsd-tests/fs/tmpfs/h_tools.c to FreeBSD - Add inttypes.h #include for PRId64 macro - Use FreeBSD's copy of getfh(2), which doesn't include a `fh_size` parameter. Use sizeof(fhandle_t) instead as the size of fhp is always fixed as fhandle_t, unlike NetBSD's copy of fhp, which is void*. MFC after: 2 weeks Sponsored by: EMC / Isilon Storage Division Modified: head/contrib/netbsd-tests/fs/tmpfs/h_tools.c Modified: head/contrib/netbsd-tests/fs/tmpfs/h_tools.c ============================================================================== --- head/contrib/netbsd-tests/fs/tmpfs/h_tools.c Thu Oct 13 07:25:18 2016 (r307195) +++ head/contrib/netbsd-tests/fs/tmpfs/h_tools.c Thu Oct 13 07:32:25 2016 (r307196) @@ -50,6 +50,10 @@ #include #include +#ifdef __FreeBSD__ +#include +#endif + /* --------------------------------------------------------------------- */ static int getfh_main(int, char **); @@ -70,7 +74,12 @@ getfh_main(int argc, char **argv) if (argc < 2) return EXIT_FAILURE; +#ifdef __FreeBSD__ + fh_size = sizeof(fhandle_t); +#else fh_size = 0; +#endif + fh = NULL; for (;;) { if (fh_size) { @@ -85,7 +94,11 @@ getfh_main(int argc, char **argv) * but it may change if someone moves things around, * so retry untill we have enough memory. */ +#ifdef __FreeBSD__ + error = getfh(argv[1], fh); +#else error = getfh(argv[1], fh, &fh_size); +#endif if (error == 0) { break; } else { From owner-svn-src-all@freebsd.org Thu Oct 13 07:35:21 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 73B54C0FD60; Thu, 13 Oct 2016 07:35:21 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 3EEFF7D4; Thu, 13 Oct 2016 07:35:21 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9D7ZKpe019049; Thu, 13 Oct 2016 07:35:20 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9D7ZKtH019045; Thu, 13 Oct 2016 07:35:20 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610130735.u9D7ZKtH019045@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Thu, 13 Oct 2016 07:35:20 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307197 - stable/10/sys/dev/hyperv/utilities X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Oct 2016 07:35:21 -0000 Author: sephe Date: Thu Oct 13 07:35:19 2016 New Revision: 307197 URL: https://svnweb.freebsd.org/changeset/base/307197 Log: MFC 305279-305281 305279 hyperv/ic: Minor style fix. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7743 305280 hyperv/ic: Cleanup shutdown channel callback. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7744 305281 hyperv/ic: Cleanup timesync channel callback. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7745 Modified: stable/10/sys/dev/hyperv/utilities/hv_heartbeat.c stable/10/sys/dev/hyperv/utilities/hv_shutdown.c stable/10/sys/dev/hyperv/utilities/hv_timesync.c stable/10/sys/dev/hyperv/utilities/vmbus_icreg.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/hyperv/utilities/hv_heartbeat.c ============================================================================== --- stable/10/sys/dev/hyperv/utilities/hv_heartbeat.c Thu Oct 13 07:32:25 2016 (r307196) +++ stable/10/sys/dev/hyperv/utilities/hv_heartbeat.c Thu Oct 13 07:35:19 2016 (r307197) @@ -69,7 +69,7 @@ vmbus_heartbeat_cb(struct vmbus_channel if (error) return; - if (dlen < sizeof(struct vmbus_icmsg_hdr)) { + if (dlen < sizeof(*hdr)) { device_printf(sc->ic_dev, "invalid data len %d\n", dlen); return; } Modified: stable/10/sys/dev/hyperv/utilities/hv_shutdown.c ============================================================================== --- stable/10/sys/dev/hyperv/utilities/hv_shutdown.c Thu Oct 13 07:32:25 2016 (r307196) +++ stable/10/sys/dev/hyperv/utilities/hv_shutdown.c Thu Oct 13 07:35:19 2016 (r307197) @@ -22,28 +22,23 @@ * 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$ */ -/* - * A common driver for all hyper-V util services. - */ +#include +__FBSDID("$FreeBSD$"); #include -#include #include -#include +#include #include #include -#include -#include #include #include #include -#include -#include "hv_util.h" +#include +#include + #include "vmbus_if.h" static const struct vmbus_ic_desc vmbus_shutdown_descs[] = { @@ -56,73 +51,78 @@ static const struct vmbus_ic_desc vmbus_ VMBUS_IC_DESC_END }; -/** - * Shutdown - */ static void -hv_shutdown_cb(struct vmbus_channel *channel, void *context) +vmbus_shutdown_cb(struct vmbus_channel *chan, void *xsc) { - uint8_t* buf; - uint8_t execute_shutdown = 0; - hv_vmbus_icmsg_hdr* icmsghdrp; - uint32_t recv_len; - uint64_t request_id; - int ret; - hv_vmbus_shutdown_msg_data* shutdown_msg; - hv_util_sc *softc; - - softc = (hv_util_sc*)context; - buf = softc->receive_buffer;; - - recv_len = softc->ic_buflen; - ret = vmbus_chan_recv(channel, buf, &recv_len, &request_id); - KASSERT(ret != ENOBUFS, ("hvshutdown recvbuf is not large enough")); - /* XXX check recv_len to make sure that it contains enough data */ - - if ((ret == 0) && recv_len > 0) { - - icmsghdrp = (struct hv_vmbus_icmsg_hdr *) - &buf[sizeof(struct hv_vmbus_pipe_hdr)]; - - if (icmsghdrp->icmsgtype == HV_ICMSGTYPE_NEGOTIATE) { - int error; + struct hv_util_sc *sc = xsc; + struct vmbus_icmsg_hdr *hdr; + struct vmbus_icmsg_shutdown *msg; + int dlen, error, do_shutdown = 0; + uint64_t xactid; + void *data; + + /* + * Receive request. + */ + data = sc->receive_buffer; + dlen = sc->ic_buflen; + error = vmbus_chan_recv(chan, data, &dlen, &xactid); + KASSERT(error != ENOBUFS, ("icbuf is not large enough")); + if (error) + return; + + if (dlen < sizeof(*hdr)) { + device_printf(sc->ic_dev, "invalid data len %d\n", dlen); + return; + } + hdr = data; - error = vmbus_ic_negomsg(softc, buf, &recv_len); + /* + * Update request, which will be echoed back as response. + */ + switch (hdr->ic_type) { + case VMBUS_ICMSG_TYPE_NEGOTIATE: + error = vmbus_ic_negomsg(sc, data, &dlen); if (error) return; - } else { - shutdown_msg = - (struct hv_vmbus_shutdown_msg_data *) - &buf[sizeof(struct hv_vmbus_pipe_hdr) + - sizeof(struct hv_vmbus_icmsg_hdr)]; - - switch (shutdown_msg->flags) { - case 0: - case 1: - icmsghdrp->status = HV_S_OK; - execute_shutdown = 1; - if(bootverbose) - printf("Shutdown request received -" - " graceful shutdown initiated\n"); - break; - default: - icmsghdrp->status = HV_E_FAIL; - execute_shutdown = 0; - printf("Shutdown request received -" - " Invalid request\n"); - break; - } - } + break; - icmsghdrp->icflags = HV_ICMSGHDRFLAG_TRANSACTION | - HV_ICMSGHDRFLAG_RESPONSE; + case VMBUS_ICMSG_TYPE_SHUTDOWN: + if (dlen < VMBUS_ICMSG_SHUTDOWN_SIZE_MIN) { + device_printf(sc->ic_dev, "invalid shutdown len %d\n", + dlen); + return; + } + msg = data; - vmbus_chan_send(channel, VMBUS_CHANPKT_TYPE_INBAND, 0, - buf, recv_len, request_id); + /* XXX ic_flags definition? */ + if (msg->ic_haltflags == 0 || msg->ic_haltflags == 1) { + device_printf(sc->ic_dev, "shutdown requested\n"); + hdr->ic_status = VMBUS_ICMSG_STATUS_OK; + do_shutdown = 1; + } else { + device_printf(sc->ic_dev, "unknown shutdown flags " + "0x%08x\n", msg->ic_haltflags); + hdr->ic_status = VMBUS_ICMSG_STATUS_FAIL; + } + break; + + default: + device_printf(sc->ic_dev, "got 0x%08x icmsg\n", hdr->ic_type); + break; } - if (execute_shutdown) - shutdown_nice(RB_POWEROFF); + /* + * Send response by echoing the updated request back. + */ + hdr->ic_flags = VMBUS_ICMSG_FLAG_XACT | VMBUS_ICMSG_FLAG_RESP; + error = vmbus_chan_send(chan, VMBUS_CHANPKT_TYPE_INBAND, 0, + data, dlen, xactid); + if (error) + device_printf(sc->ic_dev, "resp send failed: %d\n", error); + + if (do_shutdown) + shutdown_nice(RB_POWEROFF); } static int @@ -135,7 +135,8 @@ hv_shutdown_probe(device_t dev) static int hv_shutdown_attach(device_t dev) { - return hv_util_attach(dev, hv_shutdown_cb); + + return (hv_util_attach(dev, vmbus_shutdown_cb)); } static device_method_t shutdown_methods[] = { Modified: stable/10/sys/dev/hyperv/utilities/hv_timesync.c ============================================================================== --- stable/10/sys/dev/hyperv/utilities/hv_timesync.c Thu Oct 13 07:32:25 2016 (r307196) +++ stable/10/sys/dev/hyperv/utilities/hv_timesync.c Thu Oct 13 07:35:19 2016 (r307197) @@ -22,37 +22,25 @@ * 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$ */ -/* - * A common driver for all hyper-V util services. - */ +#include +__FBSDID("$FreeBSD$"); #include -#include #include -#include +#include #include -#include -#include #include -#include #include +#include #include #include -#include -#include "hv_util.h" -#include "vmbus_if.h" +#include +#include -#define HV_WLTIMEDELTA 116444736000000000L /* in 100ns unit */ -#define HV_ICTIMESYNCFLAG_PROBE 0 -#define HV_ICTIMESYNCFLAG_SYNC 1 -#define HV_ICTIMESYNCFLAG_SAMPLE 2 -#define HV_NANO_SEC_PER_SEC 1000000000 -#define HV_NANO_SEC_PER_MILLI_SEC 1000000 +#include "vmbus_if.h" static const struct vmbus_ic_desc vmbus_timesync_descs[] = { { @@ -64,135 +52,144 @@ static const struct vmbus_ic_desc vmbus_ VMBUS_IC_DESC_END }; -struct hv_ictimesync_data { - uint64_t parenttime; - uint64_t childtime; - uint64_t roundtriptime; - uint8_t flags; -} __packed; - -/* - * Globals - */ SYSCTL_NODE(_hw, OID_AUTO, hvtimesync, CTLFLAG_RW | CTLFLAG_MPSAFE, NULL, "Hyper-V timesync interface"); -/* Ignore the sync request when set to 1. */ -static int ignore_sync_req = 0; -SYSCTL_INT(_hw_hvtimesync, OID_AUTO, ignore_sync_req, CTLFLAG_RWTUN, - &ignore_sync_req, 0, - "Ignore the sync request when set to 1."); +static int vmbus_ts_ignore_sync = 0; +SYSCTL_INT(_hw_hvtimesync, OID_AUTO, ignore_sync, CTLFLAG_RWTUN, + &vmbus_ts_ignore_sync, 0, "Ignore the sync request."); /* * Trigger sample sync when drift exceeds threshold (ms). * Ignore the sample request when set to 0. */ -static int sample_drift = 100; -SYSCTL_INT(_hw_hvtimesync, OID_AUTO, sample_drift, CTLFLAG_RWTUN, - &sample_drift, 0, - "Threshold that makes sample request trigger the sync."); - -/** - * @brief Synchronize time with host after reboot, restore, etc. - * - * ICTIMESYNCFLAG_SYNC flag bit indicates reboot, restore events of the VM. - * After reboot the flag ICTIMESYNCFLAG_SYNC is included in the first time - * message after the timesync channel is opened. Since the hv_utils module is - * loaded after hv_vmbus, the first message is usually missed. The other - * thing is, systime is automatically set to emulated hardware clock which may - * not be UTC time or in the same time zone. So, to override these effects, we - * use the first 50 time samples for initial system time setting. - */ -static inline -void hv_adj_guesttime(hv_util_sc *sc, uint64_t hosttime, uint8_t flags) +static int vmbus_ts_sample_thresh = 100; +SYSCTL_INT(_hw_hvtimesync, OID_AUTO, sample_thresh, CTLFLAG_RWTUN, + &vmbus_ts_sample_thresh, 0, + "Threshold that makes sample request trigger the sync (unit: ms)."); + +static int vmbus_ts_sample_verbose = 0; +SYSCTL_INT(_hw_hvtimesync, OID_AUTO, sample_verbose, CTLFLAG_RWTUN, + &vmbus_ts_sample_verbose, 0, "Increase sample request verbosity."); + +static void +vmbus_timesync(struct hv_util_sc *sc, uint64_t hvtime, uint8_t tsflags) { - struct timespec guest_ts, host_ts; - uint64_t host_tns, guest_tns; - int64_t diff; - int error; - - host_tns = (hosttime - HV_WLTIMEDELTA) * 100; - host_ts.tv_sec = (time_t)(host_tns/HV_NANO_SEC_PER_SEC); - host_ts.tv_nsec = (long)(host_tns%HV_NANO_SEC_PER_SEC); + struct timespec vm_ts; + uint64_t hv_ns, vm_ns; - nanotime(&guest_ts); - guest_tns = guest_ts.tv_sec * HV_NANO_SEC_PER_SEC + guest_ts.tv_nsec; + hv_ns = (hvtime - VMBUS_ICMSG_TS_BASE) * VMBUS_ICMSG_TS_FACTOR; + nanotime(&vm_ts); + vm_ns = (vm_ts.tv_sec * NANOSEC) + vm_ts.tv_nsec; + + if ((tsflags & VMBUS_ICMSG_TS_FLAG_SYNC) && !vmbus_ts_ignore_sync) { + struct timespec hv_ts; - if ((flags & HV_ICTIMESYNCFLAG_SYNC) != 0 && ignore_sync_req == 0) { if (bootverbose) { - device_printf(sc->ic_dev, "handle sync request " - "{host: %ju, guest: %ju}\n", - (uintmax_t)host_tns, (uintmax_t)guest_tns); + device_printf(sc->ic_dev, "apply sync request, " + "hv: %ju, vm: %ju\n", + (uintmax_t)hv_ns, (uintmax_t)vm_ns); } - - error = kern_clock_settime(curthread, CLOCK_REALTIME, - &host_ts); + hv_ts.tv_sec = hv_ns / NANOSEC; + hv_ts.tv_nsec = hv_ns % NANOSEC; + kern_clock_settime(curthread, CLOCK_REALTIME, &hv_ts); + /* Done! */ return; } - if ((flags & HV_ICTIMESYNCFLAG_SAMPLE) != 0 && sample_drift != 0) { - if (bootverbose) { - device_printf(sc->ic_dev, "handle sample request " - "{host: %ju, guest: %ju}\n", - (uintmax_t)host_tns, (uintmax_t)guest_tns); + if ((tsflags & VMBUS_ICMSG_TS_FLAG_SAMPLE) && + vmbus_ts_sample_thresh > 0) { + int64_t diff; + + if (vmbus_ts_sample_verbose) { + device_printf(sc->ic_dev, "sample request, " + "hv: %ju, vm: %ju\n", + (uintmax_t)hv_ns, (uintmax_t)vm_ns); } - diff = (int64_t)(host_tns - guest_tns) / HV_NANO_SEC_PER_MILLI_SEC; - if (diff > sample_drift || diff < -sample_drift) { - error = kern_clock_settime(curthread, CLOCK_REALTIME, - &host_ts); - if (bootverbose) - device_printf(sc->ic_dev, "trigger sample sync"); + if (hv_ns > vm_ns) + diff = hv_ns - vm_ns; + else + diff = vm_ns - hv_ns; + /* nanosec -> millisec */ + diff /= 1000000; + + if (diff > vmbus_ts_sample_thresh) { + struct timespec hv_ts; + + if (bootverbose) { + device_printf(sc->ic_dev, + "apply sample request, hv: %ju, vm: %ju\n", + (uintmax_t)hv_ns, (uintmax_t)vm_ns); + } + hv_ts.tv_sec = hv_ns / NANOSEC; + hv_ts.tv_nsec = hv_ns % NANOSEC; + kern_clock_settime(curthread, CLOCK_REALTIME, &hv_ts); } + /* Done */ return; } } -/** - * Time Sync Channel message handler - */ static void -hv_timesync_cb(struct vmbus_channel *channel, void *context) +vmbus_timesync_cb(struct vmbus_channel *chan, void *xsc) { - hv_vmbus_icmsg_hdr* icmsghdrp; - uint32_t recvlen; - uint64_t requestId; - int ret; - uint8_t* time_buf; - struct hv_ictimesync_data* timedatap; - hv_util_sc *softc; - - softc = (hv_util_sc*)context; - time_buf = softc->receive_buffer; - - recvlen = softc->ic_buflen; - ret = vmbus_chan_recv(channel, time_buf, &recvlen, &requestId); - KASSERT(ret != ENOBUFS, ("hvtimesync recvbuf is not large enough")); - /* XXX check recvlen to make sure that it contains enough data */ - - if ((ret == 0) && recvlen > 0) { - icmsghdrp = (struct hv_vmbus_icmsg_hdr *) &time_buf[ - sizeof(struct hv_vmbus_pipe_hdr)]; + struct hv_util_sc *sc = xsc; + struct vmbus_icmsg_hdr *hdr; + const struct vmbus_icmsg_timesync *msg; + int dlen, error; + uint64_t xactid; + void *data; + + /* + * Receive request. + */ + data = sc->receive_buffer; + dlen = sc->ic_buflen; + error = vmbus_chan_recv(chan, data, &dlen, &xactid); + KASSERT(error != ENOBUFS, ("icbuf is not large enough")); + if (error) + return; - if (icmsghdrp->icmsgtype == HV_ICMSGTYPE_NEGOTIATE) { - int error; + if (dlen < sizeof(*hdr)) { + device_printf(sc->ic_dev, "invalid data len %d\n", dlen); + return; + } + hdr = data; - error = vmbus_ic_negomsg(softc, time_buf, &recvlen); + /* + * Update request, which will be echoed back as response. + */ + switch (hdr->ic_type) { + case VMBUS_ICMSG_TYPE_NEGOTIATE: + error = vmbus_ic_negomsg(sc, data, &dlen); if (error) return; - } else { - timedatap = (struct hv_ictimesync_data *) &time_buf[ - sizeof(struct hv_vmbus_pipe_hdr) + - sizeof(struct hv_vmbus_icmsg_hdr)]; - hv_adj_guesttime(softc, timedatap->parenttime, timedatap->flags); - } + break; - icmsghdrp->icflags = HV_ICMSGHDRFLAG_TRANSACTION - | HV_ICMSGHDRFLAG_RESPONSE; - - vmbus_chan_send(channel, VMBUS_CHANPKT_TYPE_INBAND, 0, - time_buf, recvlen, requestId); + case VMBUS_ICMSG_TYPE_TIMESYNC: + if (dlen < sizeof(*msg)) { + device_printf(sc->ic_dev, "invalid timesync len %d\n", + dlen); + return; + } + msg = data; + vmbus_timesync(sc, msg->ic_hvtime, msg->ic_tsflags); + break; + + default: + device_printf(sc->ic_dev, "got 0x%08x icmsg\n", hdr->ic_type); + break; } + + /* + * Send response by echoing the updated request back. + */ + hdr->ic_flags = VMBUS_ICMSG_FLAG_XACT | VMBUS_ICMSG_FLAG_RESP; + error = vmbus_chan_send(chan, VMBUS_CHANPKT_TYPE_INBAND, 0, + data, dlen, xactid); + if (error) + device_printf(sc->ic_dev, "resp send failed: %d\n", error); } static int @@ -205,20 +202,15 @@ hv_timesync_probe(device_t dev) static int hv_timesync_attach(device_t dev) { - return hv_util_attach(dev, hv_timesync_cb); -} -static int -hv_timesync_detach(device_t dev) -{ - return hv_util_detach(dev); + return (hv_util_attach(dev, vmbus_timesync_cb)); } static device_method_t timesync_methods[] = { /* Device interface */ DEVMETHOD(device_probe, hv_timesync_probe), DEVMETHOD(device_attach, hv_timesync_attach), - DEVMETHOD(device_detach, hv_timesync_detach), + DEVMETHOD(device_detach, hv_util_detach), { 0, 0 } }; Modified: stable/10/sys/dev/hyperv/utilities/vmbus_icreg.h ============================================================================== --- stable/10/sys/dev/hyperv/utilities/vmbus_icreg.h Thu Oct 13 07:32:25 2016 (r307196) +++ stable/10/sys/dev/hyperv/utilities/vmbus_icreg.h Thu Oct 13 07:35:19 2016 (r307197) @@ -91,4 +91,35 @@ struct vmbus_icmsg_heartbeat { #define VMBUS_ICMSG_HEARTBEAT_SIZE_MIN \ __offsetof(struct vmbus_icmsg_heartbeat, ic_rsvd[0]) +/* VMBUS_ICMSG_TYPE_SHUTDOWN */ +struct vmbus_icmsg_shutdown { + struct vmbus_icmsg_hdr ic_hdr; + uint32_t ic_code; + uint32_t ic_timeo; + uint32_t ic_haltflags; + uint8_t ic_msg[2048]; +} __packed; + +#define VMBUS_ICMSG_SHUTDOWN_SIZE_MIN \ + __offsetof(struct vmbus_icmsg_shutdown, ic_msg[0]) + +/* VMBUS_ICMSG_TYPE_TIMESYNC */ +struct vmbus_icmsg_timesync { + struct vmbus_icmsg_hdr ic_hdr; + uint64_t ic_hvtime; + uint64_t ic_vmtime; + uint64_t ic_rtt; + uint8_t ic_tsflags; /* VMBUS_ICMSG_TS_FLAG_ */ +} __packed; + +#define VMBUS_ICMSG_TS_FLAG_SYNC 0x01 +#define VMBUS_ICMSG_TS_FLAG_SAMPLE 0x02 + +/* XXX consolidate w/ hyperv */ +#define VMBUS_ICMSG_TS_BASE 116444736000000000ULL +#define VMBUS_ICMSG_TS_FACTOR 100ULL +#ifndef NANOSEC +#define NANOSEC 1000000000ULL +#endif + #endif /* !_VMBUS_ICREG_H_ */ From owner-svn-src-all@freebsd.org Thu Oct 13 07:39:07 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 67B73C0FE83 for ; Thu, 13 Oct 2016 07:39:07 +0000 (UTC) (envelope-from julio@meroh.net) Received: from mail-yw0-x22c.google.com (mail-yw0-x22c.google.com [IPv6:2607:f8b0:4002:c05::22c]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 223A59AF for ; Thu, 13 Oct 2016 07:39:07 +0000 (UTC) (envelope-from julio@meroh.net) Received: by mail-yw0-x22c.google.com with SMTP id t193so47911148ywc.2 for ; Thu, 13 Oct 2016 00:39:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=meroh.net; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=9hJZ3YFwxU+q+af1MKtsqGdkC29+yV1JFAd6nJzT6Yw=; b=drw26ohdxBPmnchN7a/tGlvH4wRkSxnKy8xqFE7tG0VZvx3alEjkvz/xdwsf3DR2J0 4MGuQrM5NO4q2FfjyLkx05X9zyKkBP7tLKCA+TPcV7RjIjpHPhpZpbZ/DF/6aU9i6K4i dUeWK/+HwHvx6Rr7ARr/qXv9Yfuutn8Uu3CuCJMv70/ehXl3pEpX1xgTWOm7m+CEBBG5 V4Jd4JEAaW3aDOu2mZGzHlKAZy2rSwdV74+yu0jEMu5vjlU1q5Ggh+hcPSs65F6X34Fa 9PmgdYN2qu+xhUyhNE4wtoADrecohM5EubDb3Ier1KS5AIFLUxHYXo1gWmWGb5f55PQH 6yQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=9hJZ3YFwxU+q+af1MKtsqGdkC29+yV1JFAd6nJzT6Yw=; b=b3nEVUryuEy/63f6gQr9PEe4gSNPaw1/RzkYigZACt2WVCdCNAB4tY4GlHuAEsiFbx NnxgCfdIjyYtroV/wYLXWWg4M2qOJ8eTJTNLkWAIpzjQGQ3v4+NCSU4a6biUnotvHYJW x/3/L5EAfZryXloyfCqu85SWkp0fDcyTftKb6zLOaR8q3zUQuWxCSrZjhXi6Mn49/4W6 cFzyaYdJzdjHQMdm+pBTeerGoTd6FFiqb0D3/pDf3Ejog2rlQltFcYEsRc2RU8y2QVeC sc+EYzMmdvrGx6nXJXX/OZzV8tBbyyvSxCIgUFSORjjn3ctY5Nd8rfLvpBxSuIJtoqGB /JUg== X-Gm-Message-State: AA6/9RkVges6czvXxdQfON05IW2FlQ2lU6asCKCyuGmF27XP9t3OwyAaGkymFfg8M81mVFHYETYEmiDtAGKfWA== X-Received: by 10.13.219.146 with SMTP id d140mr4423301ywe.61.1476344346347; Thu, 13 Oct 2016 00:39:06 -0700 (PDT) MIME-Version: 1.0 Received: by 10.37.170.108 with HTTP; Thu, 13 Oct 2016 00:38:44 -0700 (PDT) X-Originating-IP: [172.26.42.46] In-Reply-To: References: <201610130702.u9D72sgd007580@repo.freebsd.org> From: Julio Merino Date: Thu, 13 Oct 2016 03:38:44 -0400 Message-ID: Subject: Re: svn commit: r307190 - head/contrib/netbsd-tests/fs/tmpfs To: "Ngie Cooper (yaneurabeya)" Cc: Ngie Cooper , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.23 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Oct 2016 07:39:07 -0000 On Thu, Oct 13, 2016 at 3:29 AM, Ngie Cooper (yaneurabeya) < yaneurabeya@gmail.com> wrote: > > > On Oct 13, 2016, at 00:20, Julio Merino wrote: > > > > On Thu, Oct 13, 2016 at 3:02 AM, Ngie Cooper wrote: > > Author: ngie > > Date: Thu Oct 13 07:02:54 2016 > > New Revision: 307190 > > URL: https://svnweb.freebsd.org/changeset/base/307190 > > > > Log: > > Skip :uchg on FreeBSD > > > > Unfortunately removing files with uchg set always succeeds with root = on > > FreeBSD. Unfortunately running the test as an unprivileged user isn't > doable > > because mounting tmpfs requires root > > > > PR: 212861 > > Sponsored by: Dell EMC Isilon > > > > Modified: > > head/contrib/netbsd-tests/fs/tmpfs/t_remove.sh > > > > Modified: head/contrib/netbsd-tests/fs/tmpfs/t_remove.sh > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > --- head/contrib/netbsd-tests/fs/tmpfs/t_remove.sh Thu Oct 13 > 06:56:23 2016 (r307189) > > +++ head/contrib/netbsd-tests/fs/tmpfs/t_remove.sh Thu Oct 13 > 07:02:54 2016 (r307190) > > @@ -53,6 +53,10 @@ uchg_head() { > > atf_set "require.user" "root" > > } > > uchg_body() { > > + # Begin FreeBSD > > + atf_skip "this fails on FreeBSD with root - bug 212861" > > + # End FreeBSD > > > > This is a bad way of disabling a test due to a known bug because, when > the bug is resolved, the test won't notice. You should be using the > "expected failures" functionality if possible, and based on the change > description, I think you can do this here easily. Try: > > > > atf_expect_fail "FreeBSD bug 213861 blah blah" > > > > right before the line that triggers the test failure. > > The problem is that this leaves tmpfs mounts lying around, which atf won= =E2=80=99t > cleanup. Otherwise, I would totally agree with you. > Replace: atf_test_case uchg with: atf_test_case uchg cleanup and then add: uchg_cleanup() { umount foo/bar 2>/dev/null || true } This is actually *necessary* regardless of how you skip the test to ensure the mount point is cleaned up on any failure of the test. If the tests are not doing that yet, they are bogus. --=20 Julio Merino -- http://julio.meroh.net/ From owner-svn-src-all@freebsd.org Thu Oct 13 07:42:46 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 444DCC0F210; Thu, 13 Oct 2016 07:42:46 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 101FEFCE; Thu, 13 Oct 2016 07:42:45 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9D7gjCs023008; Thu, 13 Oct 2016 07:42:45 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9D7gi6f023002; Thu, 13 Oct 2016 07:42:44 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610130742.u9D7gi6f023002@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Thu, 13 Oct 2016 07:42:44 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307198 - in stable/10/sys: dev/hyperv/netvsc dev/hyperv/vmbus net X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Oct 2016 07:42:46 -0000 Author: sephe Date: Thu Oct 13 07:42:44 2016 New Revision: 307198 URL: https://svnweb.freebsd.org/changeset/base/307198 Log: MFC 305405,305407,305408,305410,305411,305453 305405 hyperv/vmbus: Stringent header length and total length check. While I'm here, minor style changes. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7752 305407 hyperv/hn: Stringent NVS notification length check. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7753 305408 hyperv/hn: Stringent NVS RNDIS packets length checks. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7755 305410 net/rndis: Define RNDIS status message, which could be sent by device. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7757 305411 hyperv/hn: Stringent RNDIS control message length check. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7758 305453 hyperv/hn: Stringent RNDIS packet message length/offset check. While I'm here, use definition in net/rndis.h Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7782 Modified: stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.c stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.c stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.h stable/10/sys/dev/hyperv/vmbus/vmbus_chan.c stable/10/sys/dev/hyperv/vmbus/vmbus_reg.h stable/10/sys/net/rndis.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.c Thu Oct 13 07:35:19 2016 (r307197) +++ stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.c Thu Oct 13 07:42:44 2016 (r307198) @@ -741,32 +741,53 @@ hv_nv_on_receive(struct hn_softc *sc, st { const struct vmbus_chanpkt_rxbuf *pkt; const struct hn_nvs_hdr *nvs_hdr; - int count = 0; - int i = 0; + int count, i, hlen; - /* Make sure that this is a RNDIS message. */ + if (__predict_false(VMBUS_CHANPKT_DATALEN(pkthdr) < sizeof(*nvs_hdr))) { + if_printf(rxr->hn_ifp, "invalid nvs RNDIS\n"); + return; + } nvs_hdr = VMBUS_CHANPKT_CONST_DATA(pkthdr); + + /* Make sure that this is a RNDIS message. */ if (__predict_false(nvs_hdr->nvs_type != HN_NVS_TYPE_RNDIS)) { if_printf(rxr->hn_ifp, "nvs type %u, not RNDIS\n", nvs_hdr->nvs_type); return; } - + + hlen = VMBUS_CHANPKT_GETLEN(pkthdr->cph_hlen); + if (__predict_false(hlen < sizeof(*pkt))) { + if_printf(rxr->hn_ifp, "invalid rxbuf chanpkt\n"); + return; + } pkt = (const struct vmbus_chanpkt_rxbuf *)pkthdr; - if (pkt->cp_rxbuf_id != NETVSC_RECEIVE_BUFFER_ID) { - if_printf(rxr->hn_ifp, "rxbuf_id %d is invalid!\n", + if (__predict_false(pkt->cp_rxbuf_id != NETVSC_RECEIVE_BUFFER_ID)) { + if_printf(rxr->hn_ifp, "invalid rxbuf_id 0x%08x\n", pkt->cp_rxbuf_id); return; } count = pkt->cp_rxbuf_cnt; + if (__predict_false(hlen < + __offsetof(struct vmbus_chanpkt_rxbuf, cp_rxbuf[count]))) { + if_printf(rxr->hn_ifp, "invalid rxbuf_cnt %d\n", count); + return; + } /* Each range represents 1 RNDIS pkt that contains 1 Ethernet frame */ - for (i = 0; i < count; i++) { - hv_rf_on_receive(sc, rxr, - rxr->hn_rxbuf + pkt->cp_rxbuf[i].rb_ofs, - pkt->cp_rxbuf[i].rb_len); + for (i = 0; i < count; ++i) { + int ofs, len; + + ofs = pkt->cp_rxbuf[i].rb_ofs; + len = pkt->cp_rxbuf[i].rb_len; + if (__predict_false(ofs + len > NETVSC_RECEIVE_BUFFER_SIZE)) { + if_printf(rxr->hn_ifp, "%dth RNDIS msg overflow rxbuf, " + "ofs %d, len %d\n", i, ofs, len); + continue; + } + hv_rf_on_receive(sc, rxr, rxr->hn_rxbuf + ofs, len); } /* @@ -815,7 +836,12 @@ hn_proc_notify(struct hn_softc *sc, cons { const struct hn_nvs_hdr *hdr; + if (VMBUS_CHANPKT_DATALEN(pkt) < sizeof(*hdr)) { + if_printf(sc->hn_ifp, "invalid nvs notify\n"); + return; + } hdr = VMBUS_CHANPKT_CONST_DATA(pkt); + if (hdr->nvs_type == HN_NVS_TYPE_TXTBL_NOTE) { /* Useless; ignore */ return; Modified: stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.c Thu Oct 13 07:35:19 2016 (r307197) +++ stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.c Thu Oct 13 07:42:44 2016 (r307198) @@ -73,7 +73,7 @@ __FBSDID("$FreeBSD$"); * Forward declarations */ static void hv_rf_receive_indicate_status(struct hn_softc *sc, - const rndis_msg *response); + const void *data, int dlen); static void hv_rf_receive_data(struct hn_rx_ring *rxr, const void *data, int dlen); static int hv_rf_query_device_mac(struct hn_softc *sc, uint8_t *eaddr); @@ -132,59 +132,50 @@ hv_set_rppi_data(rndis_msg *rndis_mesg, * RNDIS filter receive indicate status */ static void -hv_rf_receive_indicate_status(struct hn_softc *sc, const rndis_msg *response) +hv_rf_receive_indicate_status(struct hn_softc *sc, const void *data, int dlen) { - const rndis_indicate_status *indicate = &response->msg.indicate_status; - - switch(indicate->status) { + const struct rndis_status_msg *msg; + + if (dlen < sizeof(*msg)) { + if_printf(sc->hn_ifp, "invalid RNDIS status\n"); + return; + } + msg = data; + + switch (msg->rm_status) { case RNDIS_STATUS_MEDIA_CONNECT: netvsc_linkstatus_callback(sc, 1); break; + case RNDIS_STATUS_MEDIA_DISCONNECT: netvsc_linkstatus_callback(sc, 0); break; + default: /* TODO: */ - if_printf(sc->hn_ifp, - "unknown status %d received\n", indicate->status); + if_printf(sc->hn_ifp, "unknown RNDIS status 0x%08x\n", + msg->rm_status); break; } } static int -hv_rf_find_recvinfo(const rndis_packet *rpkt, struct hn_recvinfo *info) +hn_rndis_rxinfo(const void *info_data, int info_dlen, struct hn_recvinfo *info) { - const struct rndis_pktinfo *pi; - uint32_t mask = 0, len; - - info->vlan_info = HN_NDIS_VLAN_INFO_INVALID; - info->csum_info = HN_NDIS_RXCSUM_INFO_INVALID; - info->hash_info = HN_NDIS_HASH_INFO_INVALID; - - if (rpkt->per_pkt_info_offset == 0) - return (0); - if (__predict_false(rpkt->per_pkt_info_offset & - (RNDIS_PKTINFO_ALIGN - 1))) - return (EINVAL); - if (__predict_false(rpkt->per_pkt_info_offset < - RNDIS_PACKET_MSG_OFFSET_MIN)) - return (EINVAL); + const struct rndis_pktinfo *pi = info_data; + uint32_t mask = 0; - pi = (const struct rndis_pktinfo *) - ((const uint8_t *)rpkt + rpkt->per_pkt_info_offset); - len = rpkt->per_pkt_info_length; - - while (len != 0) { + while (info_dlen != 0) { const void *data; uint32_t dlen; - if (__predict_false(len < sizeof(*pi))) + if (__predict_false(info_dlen < sizeof(*pi))) return (EINVAL); - if (__predict_false(len < pi->rm_size)) + if (__predict_false(info_dlen < pi->rm_size)) return (EINVAL); - len -= pi->rm_size; + info_dlen -= pi->rm_size; - if (__predict_false(pi->rm_size & (RNDIS_PKTINFO_ALIGN - 1))) + if (__predict_false(pi->rm_size & RNDIS_PKTINFO_SIZE_ALIGNMASK)) return (EINVAL); if (__predict_false(pi->rm_size < pi->rm_pktinfooffset)) return (EINVAL); @@ -242,76 +233,223 @@ next: return (0); } +static __inline bool +hn_rndis_check_overlap(int off, int len, int check_off, int check_len) +{ + + if (off < check_off) { + if (__predict_true(off + len <= check_off)) + return (false); + } else if (off > check_off) { + if (__predict_true(check_off + check_len <= off)) + return (false); + } + return (true); +} + /* * RNDIS filter receive data */ static void hv_rf_receive_data(struct hn_rx_ring *rxr, const void *data, int dlen) { - const rndis_msg *message = data; - const rndis_packet *rndis_pkt; - uint32_t data_offset; + const struct rndis_packet_msg *pkt; struct hn_recvinfo info; - - rndis_pkt = &message->msg.packet; + int data_off, pktinfo_off, data_len, pktinfo_len; /* - * Fixme: Handle multiple rndis pkt msgs that may be enclosed in this - * netvsc packet (ie tot_data_buf_len != message_length) + * Check length. */ + if (__predict_false(dlen < sizeof(*pkt))) { + if_printf(rxr->hn_ifp, "invalid RNDIS packet msg\n"); + return; + } + pkt = data; - /* Remove rndis header, then pass data packet up the stack */ - data_offset = RNDIS_HEADER_SIZE + rndis_pkt->data_offset; + if (__predict_false(dlen < pkt->rm_len)) { + if_printf(rxr->hn_ifp, "truncated RNDIS packet msg, " + "dlen %d, msglen %u\n", dlen, pkt->rm_len); + return; + } + if (__predict_false(pkt->rm_len < + pkt->rm_datalen + pkt->rm_oobdatalen + pkt->rm_pktinfolen)) { + if_printf(rxr->hn_ifp, "invalid RNDIS packet msglen, " + "msglen %u, data %u, oob %u, pktinfo %u\n", + pkt->rm_len, pkt->rm_datalen, pkt->rm_oobdatalen, + pkt->rm_pktinfolen); + return; + } + if (__predict_false(pkt->rm_datalen == 0)) { + if_printf(rxr->hn_ifp, "invalid RNDIS packet msg, no data\n"); + return; + } - dlen -= data_offset; - if (dlen < rndis_pkt->data_length) { - if_printf(rxr->hn_ifp, - "total length %u is less than data length %u\n", - dlen, rndis_pkt->data_length); + /* + * Check offests. + */ +#define IS_OFFSET_INVALID(ofs) \ + ((ofs) < RNDIS_PACKET_MSG_OFFSET_MIN || \ + ((ofs) & RNDIS_PACKET_MSG_OFFSET_ALIGNMASK)) + + /* XXX Hyper-V does not meet data offset alignment requirement */ + if (__predict_false(pkt->rm_dataoffset < RNDIS_PACKET_MSG_OFFSET_MIN)) { + if_printf(rxr->hn_ifp, "invalid RNDIS packet msg, " + "data offset %u\n", pkt->rm_dataoffset); + return; + } + if (__predict_false(pkt->rm_oobdataoffset > 0 && + IS_OFFSET_INVALID(pkt->rm_oobdataoffset))) { + if_printf(rxr->hn_ifp, "invalid RNDIS packet msg, " + "oob offset %u\n", pkt->rm_oobdataoffset); + return; + } + if (__predict_true(pkt->rm_pktinfooffset > 0) && + __predict_false(IS_OFFSET_INVALID(pkt->rm_pktinfooffset))) { + if_printf(rxr->hn_ifp, "invalid RNDIS packet msg, " + "pktinfo offset %u\n", pkt->rm_pktinfooffset); return; } - dlen = rndis_pkt->data_length; - data = (const uint8_t *)data + data_offset; +#undef IS_OFFSET_INVALID - if (hv_rf_find_recvinfo(rndis_pkt, &info)) { - if_printf(rxr->hn_ifp, "recvinfo parsing failed\n"); + data_off = RNDIS_PACKET_MSG_OFFSET_ABS(pkt->rm_dataoffset); + data_len = pkt->rm_datalen; + pktinfo_off = RNDIS_PACKET_MSG_OFFSET_ABS(pkt->rm_pktinfooffset); + pktinfo_len = pkt->rm_pktinfolen; + + /* + * Check OOB coverage. + */ + if (__predict_false(pkt->rm_oobdatalen != 0)) { + int oob_off, oob_len; + + if_printf(rxr->hn_ifp, "got oobdata\n"); + oob_off = RNDIS_PACKET_MSG_OFFSET_ABS(pkt->rm_oobdataoffset); + oob_len = pkt->rm_oobdatalen; + + if (__predict_false(oob_off + oob_len > pkt->rm_len)) { + if_printf(rxr->hn_ifp, "invalid RNDIS packet msg, " + "oob overflow, msglen %u, oob abs %d len %d\n", + pkt->rm_len, oob_off, oob_len); + return; + } + + /* + * Check against data. + */ + if (hn_rndis_check_overlap(oob_off, oob_len, + data_off, data_len)) { + if_printf(rxr->hn_ifp, "invalid RNDIS packet msg, " + "oob overlaps data, oob abs %d len %d, " + "data abs %d len %d\n", + oob_off, oob_len, data_off, data_len); + return; + } + + /* + * Check against pktinfo. + */ + if (pktinfo_len != 0 && + hn_rndis_check_overlap(oob_off, oob_len, + pktinfo_off, pktinfo_len)) { + if_printf(rxr->hn_ifp, "invalid RNDIS packet msg, " + "oob overlaps pktinfo, oob abs %d len %d, " + "pktinfo abs %d len %d\n", + oob_off, oob_len, pktinfo_off, pktinfo_len); + return; + } + } + + /* + * Check per-packet-info coverage and find useful per-packet-info. + */ + info.vlan_info = HN_NDIS_VLAN_INFO_INVALID; + info.csum_info = HN_NDIS_RXCSUM_INFO_INVALID; + info.hash_info = HN_NDIS_HASH_INFO_INVALID; + if (__predict_true(pktinfo_len != 0)) { + bool overlap; + int error; + + if (__predict_false(pktinfo_off + pktinfo_len > pkt->rm_len)) { + if_printf(rxr->hn_ifp, "invalid RNDIS packet msg, " + "pktinfo overflow, msglen %u, " + "pktinfo abs %d len %d\n", + pkt->rm_len, pktinfo_off, pktinfo_len); + return; + } + + /* + * Check packet info coverage. + */ + overlap = hn_rndis_check_overlap(pktinfo_off, pktinfo_len, + data_off, data_len); + if (__predict_false(overlap)) { + if_printf(rxr->hn_ifp, "invalid RNDIS packet msg, " + "pktinfo overlap data, pktinfo abs %d len %d, " + "data abs %d len %d\n", + pktinfo_off, pktinfo_len, data_off, data_len); + return; + } + + /* + * Find useful per-packet-info. + */ + error = hn_rndis_rxinfo(((const uint8_t *)pkt) + pktinfo_off, + pktinfo_len, &info); + if (__predict_false(error)) { + if_printf(rxr->hn_ifp, "invalid RNDIS packet msg " + "pktinfo\n"); + return; + } + } + + if (__predict_false(data_off + data_len > pkt->rm_len)) { + if_printf(rxr->hn_ifp, "invalid RNDIS packet msg, " + "data overflow, msglen %u, data abs %d len %d\n", + pkt->rm_len, data_off, data_len); return; } - netvsc_recv(rxr, data, dlen, &info); + netvsc_recv(rxr, ((const uint8_t *)pkt) + data_off, data_len, &info); } /* * RNDIS filter on receive */ -int +void hv_rf_on_receive(struct hn_softc *sc, struct hn_rx_ring *rxr, const void *data, int dlen) { - const rndis_msg *rndis_hdr; const struct rndis_comp_hdr *comp; + const struct rndis_msghdr *hdr; + + if (__predict_false(dlen < sizeof(*hdr))) { + if_printf(rxr->hn_ifp, "invalid RNDIS msg\n"); + return; + } + hdr = data; - rndis_hdr = data; - switch (rndis_hdr->ndis_msg_type) { - /* data message */ + switch (hdr->rm_type) { case REMOTE_NDIS_PACKET_MSG: hv_rf_receive_data(rxr, data, dlen); break; - /* completion messages */ case REMOTE_NDIS_INITIALIZE_CMPLT: case REMOTE_NDIS_QUERY_CMPLT: case REMOTE_NDIS_SET_CMPLT: - case REMOTE_NDIS_KEEPALIVE_CMPLT: + case REMOTE_NDIS_KEEPALIVE_CMPLT: /* unused */ + if (dlen < sizeof(*comp)) { + if_printf(rxr->hn_ifp, "invalid RNDIS cmplt\n"); + return; + } comp = data; + KASSERT(comp->rm_rid > HN_RNDIS_RID_COMPAT_MAX, - ("invalid rid 0x%08x\n", comp->rm_rid)); + ("invalid RNDIS rid 0x%08x\n", comp->rm_rid)); vmbus_xact_ctx_wakeup(sc->hn_xact, comp, dlen); break; - /* notification message */ case REMOTE_NDIS_INDICATE_STATUS_MSG: - hv_rf_receive_indicate_status(sc, rndis_hdr); + hv_rf_receive_indicate_status(sc, data, dlen); break; case REMOTE_NDIS_RESET_CMPLT: @@ -322,15 +460,14 @@ hv_rf_on_receive(struct hn_softc *sc, st * RESET is not issued by hn(4), so this message should * _not_ be observed. */ - if_printf(sc->hn_ifp, "RESET CMPLT received\n"); + if_printf(rxr->hn_ifp, "RESET cmplt received\n"); break; default: - if_printf(sc->hn_ifp, "unknown RNDIS message 0x%x\n", - rndis_hdr->ndis_msg_type); + if_printf(rxr->hn_ifp, "unknown RNDIS msg 0x%x\n", + hdr->rm_type); break; } - return (0); } /* @@ -552,7 +689,7 @@ hn_rndis_query(struct hn_softc *sc, uint * Check output data length and offset. */ /* ofs is the offset from the beginning of comp. */ - ofs = RNDIS_QUERY_COMP_INFOBUFABS(comp->rm_infobufoffset); + ofs = RNDIS_QUERY_COMP_INFOBUFOFFSET_ABS(comp->rm_infobufoffset); if (ofs < sizeof(*comp) || ofs + comp->rm_infobuflen > comp_len) { if_printf(sc->hn_ifp, "RNDIS query invalid comp ib off/len, " "%u/%u\n", comp->rm_infobufoffset, comp->rm_infobuflen); Modified: stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.h ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.h Thu Oct 13 07:35:19 2016 (r307197) +++ stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.h Thu Oct 13 07:42:44 2016 (r307198) @@ -40,7 +40,7 @@ */ struct hn_rx_ring; -int hv_rf_on_receive(struct hn_softc *sc, struct hn_rx_ring *rxr, +void hv_rf_on_receive(struct hn_softc *sc, struct hn_rx_ring *rxr, const void *data, int dlen); void hv_rf_channel_rollup(struct hn_rx_ring *rxr, struct hn_tx_ring *txr); int hv_rf_on_device_add(struct hn_softc *sc, void *additl_info, int *nchan, Modified: stable/10/sys/dev/hyperv/vmbus/vmbus_chan.c ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/vmbus_chan.c Thu Oct 13 07:35:19 2016 (r307197) +++ stable/10/sys/dev/hyperv/vmbus/vmbus_chan.c Thu Oct 13 07:42:44 2016 (r307198) @@ -721,7 +721,20 @@ vmbus_chan_recv(struct vmbus_channel *ch error = vmbus_rxbr_peek(&chan->ch_rxbr, &pkt, sizeof(pkt)); if (error) - return error; + return (error); + + if (__predict_false(pkt.cph_hlen < VMBUS_CHANPKT_HLEN_MIN)) { + device_printf(chan->ch_dev, "invalid hlen %u\n", + pkt.cph_hlen); + /* XXX this channel is dead actually. */ + return (EIO); + } + if (__predict_false(pkt.cph_hlen > pkt.cph_tlen)) { + device_printf(chan->ch_dev, "invalid hlen %u and tlen %u\n", + pkt.cph_hlen, pkt.cph_tlen); + /* XXX this channel is dead actually. */ + return (EIO); + } hlen = VMBUS_CHANPKT_GETLEN(pkt.cph_hlen); dlen = VMBUS_CHANPKT_GETLEN(pkt.cph_tlen) - hlen; @@ -729,7 +742,7 @@ vmbus_chan_recv(struct vmbus_channel *ch if (*dlen0 < dlen) { /* Return the size of this packet's data. */ *dlen0 = dlen; - return ENOBUFS; + return (ENOBUFS); } *xactid = pkt.cph_xactid; @@ -739,7 +752,7 @@ vmbus_chan_recv(struct vmbus_channel *ch error = vmbus_rxbr_read(&chan->ch_rxbr, data, dlen, hlen); KASSERT(!error, ("vmbus_rxbr_read failed")); - return 0; + return (0); } int @@ -751,13 +764,26 @@ vmbus_chan_recv_pkt(struct vmbus_channel error = vmbus_rxbr_peek(&chan->ch_rxbr, &pkt, sizeof(pkt)); if (error) - return error; + return (error); + + if (__predict_false(pkt.cph_hlen < VMBUS_CHANPKT_HLEN_MIN)) { + device_printf(chan->ch_dev, "invalid hlen %u\n", + pkt.cph_hlen); + /* XXX this channel is dead actually. */ + return (EIO); + } + if (__predict_false(pkt.cph_hlen > pkt.cph_tlen)) { + device_printf(chan->ch_dev, "invalid hlen %u and tlen %u\n", + pkt.cph_hlen, pkt.cph_tlen); + /* XXX this channel is dead actually. */ + return (EIO); + } pktlen = VMBUS_CHANPKT_GETLEN(pkt.cph_tlen); if (*pktlen0 < pktlen) { /* Return the size of this packet. */ *pktlen0 = pktlen; - return ENOBUFS; + return (ENOBUFS); } *pktlen0 = pktlen; @@ -765,7 +791,7 @@ vmbus_chan_recv_pkt(struct vmbus_channel error = vmbus_rxbr_read(&chan->ch_rxbr, pkt0, pktlen, 0); KASSERT(!error, ("vmbus_rxbr_read failed")); - return 0; + return (0); } static void Modified: stable/10/sys/dev/hyperv/vmbus/vmbus_reg.h ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/vmbus_reg.h Thu Oct 13 07:35:19 2016 (r307197) +++ stable/10/sys/dev/hyperv/vmbus/vmbus_reg.h Thu Oct 13 07:42:44 2016 (r307198) @@ -153,6 +153,9 @@ do { \ #define VMBUS_CHANPKT_TOTLEN(tlen) \ roundup2((tlen), VMBUS_CHANPKT_SIZE_ALIGN) +#define VMBUS_CHANPKT_HLEN_MIN \ + (sizeof(struct vmbus_chanpkt_hdr) >> VMBUS_CHANPKT_SIZE_SHIFT) + struct vmbus_chanpkt { struct vmbus_chanpkt_hdr cp_hdr; } __packed; Modified: stable/10/sys/net/rndis.h ============================================================================== --- stable/10/sys/net/rndis.h Thu Oct 13 07:35:19 2016 (r307197) +++ stable/10/sys/net/rndis.h Thu Oct 13 07:42:44 2016 (r307198) @@ -127,6 +127,14 @@ struct rndis_packet_msg { (sizeof(struct rndis_packet_msg) - \ __offsetof(struct rndis_packet_msg, rm_dataoffset)) +/* Offset from the beginning of rndis_packet_msg. */ +#define RNDIS_PACKET_MSG_OFFSET_ABS(ofs) \ + ((ofs) + __offsetof(struct rndis_packet_msg, rm_dataoffset)) + +#define RNDIS_PACKET_MSG_OFFSET_ALIGN 4 +#define RNDIS_PACKET_MSG_OFFSET_ALIGNMASK \ + (RNDIS_PACKET_MSG_OFFSET_ALIGN - 1) + /* Per-packet-info for RNDIS data message */ struct rndis_pktinfo { uint32_t rm_size; @@ -137,7 +145,8 @@ struct rndis_pktinfo { #define RNDIS_PKTINFO_OFFSET \ __offsetof(struct rndis_pktinfo, rm_data[0]) -#define RNDIS_PKTINFO_ALIGN 4 +#define RNDIS_PKTINFO_SIZE_ALIGN 4 +#define RNDIS_PKTINFO_SIZE_ALIGNMASK (RNDIS_PKTINFO_SIZE_ALIGN - 1) #define NDIS_PKTINFO_TYPE_CSUM 0 #define NDIS_PKTINFO_TYPE_IPSEC 1 @@ -236,7 +245,8 @@ struct rndis_query_comp { uint32_t rm_infobufoffset; }; -#define RNDIS_QUERY_COMP_INFOBUFABS(ofs) \ +/* infobuf offset from the beginning of rndis_query_comp. */ +#define RNDIS_QUERY_COMP_INFOBUFOFFSET_ABS(ofs) \ ((ofs) + __offsetof(struct rndis_query_req, rm_rid)) /* Send a set object request. */ @@ -295,9 +305,28 @@ struct rndis_reset_comp { uint32_t rm_adrreset; }; -/* 802.3 link-state or undefined message error. */ +/* 802.3 link-state or undefined message error. Sent by device. */ #define REMOTE_NDIS_INDICATE_STATUS_MSG 0x00000007 +struct rndis_status_msg { + uint32_t rm_type; + uint32_t rm_len; + uint32_t rm_status; + uint32_t rm_stbuflen; + uint32_t rm_stbufoffset; + /* rndis_diag_info */ +}; + +/* + * Immediately after rndis_status_msg.rm_stbufoffset, if a control + * message is malformatted, or a packet message contains inappropriate + * content. + */ +struct rndis_diag_info { + uint32_t rm_diagstatus; + uint32_t rm_erroffset; +}; + /* Keepalive messsage. May be sent by device. */ #define REMOTE_NDIS_KEEPALIVE_MSG 0x00000008 #define REMOTE_NDIS_KEEPALIVE_CMPLT 0x80000008 From owner-svn-src-all@freebsd.org Thu Oct 13 07:42:45 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 9E1F0C0F20D; Thu, 13 Oct 2016 07:42:45 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from citapm.icyb.net.ua (citapm.icyb.net.ua [212.40.38.140]) by mx1.freebsd.org (Postfix) with ESMTP id 6DFAEFCC; Thu, 13 Oct 2016 07:42:43 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from porto.starpoint.kiev.ua (porto-e.starpoint.kiev.ua [212.40.38.100]) by citapm.icyb.net.ua (8.8.8p3/ICyb-2.3exp) with ESMTP id KAA03757; Thu, 13 Oct 2016 10:42:42 +0300 (EEST) (envelope-from avg@FreeBSD.org) Received: from localhost ([127.0.0.1]) by porto.starpoint.kiev.ua with esmtp (Exim 4.34 (FreeBSD)) id 1buaf4-000J9M-Gs; Thu, 13 Oct 2016 10:42:42 +0300 Subject: Re: svn commit: r307191 - head/etc/rc.d To: Ngie Cooper , src-committers@FreeBSD.org, svn-src-all@FreeBSD.org, svn-src-head@FreeBSD.org References: <201610130710.u9D7ARZa007926@repo.freebsd.org> From: Andriy Gapon Message-ID: <875b3413-c8d6-8c48-3829-af0c3a587167@FreeBSD.org> Date: Thu, 13 Oct 2016 10:41:46 +0300 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <201610130710.u9D7ARZa007926@repo.freebsd.org> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Oct 2016 07:42:45 -0000 On 13/10/2016 10:10, Ngie Cooper wrote: > Author: ngie > Date: Thu Oct 13 07:10:27 2016 > New Revision: 307191 > URL: https://svnweb.freebsd.org/changeset/base/307191 > > Log: > Install etc/rc.d/zfsbe when MK_ZFS != no > > X-MFC with: r307182 > Sponsored by: Dell EMC Isilon Oh! Thank you! > Modified: > head/etc/rc.d/Makefile > > Modified: head/etc/rc.d/Makefile > ============================================================================== > --- head/etc/rc.d/Makefile Thu Oct 13 07:02:54 2016 (r307190) > +++ head/etc/rc.d/Makefile Thu Oct 13 07:10:27 2016 (r307191) > @@ -314,6 +314,7 @@ FILES+= wpa_supplicant > .if ${MK_ZFS} != "no" > FILESGROUPS+= ZFS > ZFS+= zfs > +ZFS+= zfsbe > ZFS+= zfsd > ZFS+= zvol > ZFSPACKAGE= zfs > -- Andriy Gapon From owner-svn-src-all@freebsd.org Thu Oct 13 07:44:17 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 70E91C0F30F; Thu, 13 Oct 2016 07:44:17 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from citapm.icyb.net.ua (citapm.icyb.net.ua [212.40.38.140]) by mx1.freebsd.org (Postfix) with ESMTP id 6191F355; Thu, 13 Oct 2016 07:44:15 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from porto.starpoint.kiev.ua (porto-e.starpoint.kiev.ua [212.40.38.100]) by citapm.icyb.net.ua (8.8.8p3/ICyb-2.3exp) with ESMTP id KAA03769; Thu, 13 Oct 2016 10:44:14 +0300 (EEST) (envelope-from avg@FreeBSD.org) Received: from localhost ([127.0.0.1]) by porto.starpoint.kiev.ua with esmtp (Exim 4.34 (FreeBSD)) id 1buagY-000J9d-IY; Thu, 13 Oct 2016 10:44:14 +0300 Subject: Re: svn commit: r307182 - head/etc/rc.d To: "Ngie Cooper (yaneurabeya)" References: <201610130619.u9D6JsMd088686@repo.freebsd.org> <27A78442-3CB6-4245-892B-EFACB3860B38@gmail.com> Cc: src-committers@FreeBSD.org, svn-src-all@FreeBSD.org, svn-src-head@FreeBSD.org From: Andriy Gapon Message-ID: Date: Thu, 13 Oct 2016 10:43:18 +0300 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <27A78442-3CB6-4245-892B-EFACB3860B38@gmail.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Oct 2016 07:44:17 -0000 On 13/10/2016 10:12, Ngie Cooper (yaneurabeya) wrote: > >> On Oct 12, 2016, at 23:19, Andriy Gapon wrote: >> >> Author: avg >> Date: Thu Oct 13 06:19:54 2016 >> New Revision: 307182 >> URL: https://svnweb.freebsd.org/changeset/base/307182 >> >> Log: >> rc.d/zfsbe: a new script designed for boot environment support >> >> Currently zfsbe ensures that subordinate filesystems are mounted at the >> right mount points. >> The script assumes that the subordinate filesystems of a boot environment >> have their canmount property set to noauto, so that they are not >> automatically mounted on boot. Whereas the root filesystem is mounted >> by the kernel, there was nothing to mount its subordinates. >> rc.d/zfsbe fills that gap. >> >> Discussed with: allanjude, will >> MFC after: 3 weeks >> Differential Revision: https://reviews.freebsd.org/D7797 > > I committed the Makefile changes in r307191/r307192. > Cheers! Thank you! Next time I make a change like this I'll make sure to add you as a reviewer :-) -- Andriy Gapon From owner-svn-src-all@freebsd.org Thu Oct 13 07:50:01 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 95EB0C0F6F9; Thu, 13 Oct 2016 07:50:01 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from citapm.icyb.net.ua (citapm.icyb.net.ua [212.40.38.140]) by mx1.freebsd.org (Postfix) with ESMTP id 580C7962; Thu, 13 Oct 2016 07:49:59 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from porto.starpoint.kiev.ua (porto-e.starpoint.kiev.ua [212.40.38.100]) by citapm.icyb.net.ua (8.8.8p3/ICyb-2.3exp) with ESMTP id KAA03802; Thu, 13 Oct 2016 10:49:58 +0300 (EEST) (envelope-from avg@FreeBSD.org) Received: from localhost ([127.0.0.1]) by porto.starpoint.kiev.ua with esmtp (Exim 4.34 (FreeBSD)) id 1buam5-000JA7-Oo; Thu, 13 Oct 2016 10:49:58 +0300 Subject: Re: svn commit: r307195 - head/sys/dev/iicbus To: src-committers@FreeBSD.org, svn-src-all@FreeBSD.org, svn-src-head@FreeBSD.org References: <201610130725.u9D7PIA0015270@repo.freebsd.org> From: Andriy Gapon Message-ID: Date: Thu, 13 Oct 2016 10:49:21 +0300 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <201610130725.u9D7PIA0015270@repo.freebsd.org> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Oct 2016 07:50:01 -0000 On 13/10/2016 10:25, Andriy Gapon wrote: > Author: avg > Date: Thu Oct 13 07:25:18 2016 > New Revision: 307195 > URL: https://svnweb.freebsd.org/changeset/base/307195 > > Log: > convert iicsmb to use iicbus_transfer for all operations > > Previously the driver used more low level operations like iicbus_start > and iicbus_write. The problem is that those operations are not > implemented by iicbus(4) and the calls were effectively routed to > a driver to which the bus is attached. > But not all of the controllers implement such low level operations > while all of the drivers are expected to have iicbus_transfer. > > While there fix incorrect implementation of iicsmb_bwrite and iicsmb_bread. > The former should send a byte count before the actual bytes, while the > latter should first receive the byte count and then receive the bytes. Just a thought. It would be much easier to implement iicsmb_bread() if we had a flag like I2C_M_RECV_LEN in Linux. The flag signals that the first byte received from slave is a count of how many more bytes we should read from that slave. But adding support for a new flag to all controller drivers is not fun. > I have tested only these commands: > - quick (r/w) > - send byte > - receive byte > - read byte > - write byte > > MFC after: 1 month > Differential Revision: https://reviews.freebsd.org/D8170 > > Modified: > head/sys/dev/iicbus/iicsmb.c > > Modified: head/sys/dev/iicbus/iicsmb.c > ============================================================================== > --- head/sys/dev/iicbus/iicsmb.c Thu Oct 13 07:22:13 2016 (r307194) > +++ head/sys/dev/iicbus/iicsmb.c Thu Oct 13 07:25:18 2016 (r307195) > @@ -131,8 +131,6 @@ static driver_t iicsmb_driver = { > sizeof(struct iicsmb_softc), > }; > > -#define IICBUS_TIMEOUT 100 /* us */ > - > static void > iicsmb_identify(driver_t *driver, device_t parent) > { > @@ -276,237 +274,213 @@ iicsmb_callback(device_t dev, int index, > } > > static int > +iic2smb_error(int error) > +{ > + switch (error) { > + case IIC_NOERR: > + return (SMB_ENOERR); > + case IIC_EBUSERR: > + return (SMB_EBUSERR); > + case IIC_ENOACK: > + return (SMB_ENOACK); > + case IIC_ETIMEOUT: > + return (SMB_ETIMEOUT); > + case IIC_EBUSBSY: > + return (SMB_EBUSY); > + case IIC_ESTATUS: > + return (SMB_EBUSERR); > + case IIC_EUNDERFLOW: > + return (SMB_EBUSERR); > + case IIC_EOVERFLOW: > + return (SMB_EBUSERR); > + case IIC_ENOTSUPP: > + return (SMB_ENOTSUPP); > + case IIC_ENOADDR: > + return (SMB_EBUSERR); > + case IIC_ERESOURCE: > + return (SMB_EBUSERR); > + default: > + return (SMB_EBUSERR); > + } > +} > + > +#define TRANSFER_MSGS(dev, msgs) iicbus_transfer(dev, msgs, nitems(msgs)) > + > +static int > iicsmb_quick(device_t dev, u_char slave, int how) > { > - device_t parent = device_get_parent(dev); > + struct iic_msg msgs[] = { > + { slave, how == SMB_QWRITE ? IIC_M_WR : IIC_M_RD, 0, NULL }, > + }; > int error; > > switch (how) { > case SMB_QWRITE: > - error = iicbus_start(parent, slave & ~LSB, IICBUS_TIMEOUT); > - break; > - > case SMB_QREAD: > - error = iicbus_start(parent, slave | LSB, IICBUS_TIMEOUT); > break; > - > default: > - error = EINVAL; > - break; > + return (SMB_EINVAL); > } > > - if (!error) > - error = iicbus_stop(parent); > - > - return (error); > + error = TRANSFER_MSGS(dev, msgs); > + return (iic2smb_error(error)); > } > > static int > iicsmb_sendb(device_t dev, u_char slave, char byte) > { > - device_t parent = device_get_parent(dev); > - int error, sent; > - > - error = iicbus_start(parent, slave & ~LSB, IICBUS_TIMEOUT); > - > - if (!error) { > - error = iicbus_write(parent, &byte, 1, &sent, IICBUS_TIMEOUT); > - > - iicbus_stop(parent); > - } > + struct iic_msg msgs[] = { > + { slave, IIC_M_WR, 1, &byte }, > + }; > + int error; > > - return (error); > + error = TRANSFER_MSGS(dev, msgs); > + return (iic2smb_error(error)); > } > > static int > iicsmb_recvb(device_t dev, u_char slave, char *byte) > { > - device_t parent = device_get_parent(dev); > - int error, read; > - > - error = iicbus_start(parent, slave | LSB, 0); > - > - if (!error) { > - error = iicbus_read(parent, byte, 1, &read, IIC_LAST_READ, IICBUS_TIMEOUT); > - > - iicbus_stop(parent); > - } > + struct iic_msg msgs[] = { > + { slave, IIC_M_RD, 1, byte }, > + }; > + int error; > > - return (error); > + error = TRANSFER_MSGS(dev, msgs); > + return (iic2smb_error(error)); > } > > static int > iicsmb_writeb(device_t dev, u_char slave, char cmd, char byte) > { > - device_t parent = device_get_parent(dev); > - int error, sent; > - > - error = iicbus_start(parent, slave & ~LSB, 0); > - > - if (!error) { > - if (!(error = iicbus_write(parent, &cmd, 1, &sent, IICBUS_TIMEOUT))) > - error = iicbus_write(parent, &byte, 1, &sent, IICBUS_TIMEOUT); > - > - iicbus_stop(parent); > - } > + uint8_t bytes[] = { cmd, byte }; > + struct iic_msg msgs[] = { > + { slave, IIC_M_WR, nitems(bytes), bytes }, > + }; > + int error; > > - return (error); > + error = TRANSFER_MSGS(dev, msgs); > + return (iic2smb_error(error)); > } > > static int > iicsmb_writew(device_t dev, u_char slave, char cmd, short word) > { > - device_t parent = device_get_parent(dev); > - int error, sent; > - > - char low = (char)(word & 0xff); > - char high = (char)((word & 0xff00) >> 8); > - > - error = iicbus_start(parent, slave & ~LSB, 0); > - > - if (!error) { > - if (!(error = iicbus_write(parent, &cmd, 1, &sent, IICBUS_TIMEOUT))) > - if (!(error = iicbus_write(parent, &low, 1, &sent, IICBUS_TIMEOUT))) > - error = iicbus_write(parent, &high, 1, &sent, IICBUS_TIMEOUT); > - > - iicbus_stop(parent); > - } > + uint8_t bytes[] = { cmd, word & 0xff, word >> 8 }; > + struct iic_msg msgs[] = { > + { slave, IIC_M_WR, nitems(bytes), bytes }, > + }; > + int error; > > - return (error); > + error = TRANSFER_MSGS(dev, msgs); > + return (iic2smb_error(error)); > } > > static int > iicsmb_readb(device_t dev, u_char slave, char cmd, char *byte) > { > - device_t parent = device_get_parent(dev); > - int error, sent, read; > - > - if ((error = iicbus_start(parent, slave & ~LSB, IICBUS_TIMEOUT))) > - return (error); > - > - if ((error = iicbus_write(parent, &cmd, 1, &sent, IICBUS_TIMEOUT))) > - goto error; > - > - if ((error = iicbus_repeated_start(parent, slave | LSB, IICBUS_TIMEOUT))) > - goto error; > - > - if ((error = iicbus_read(parent, byte, 1, &read, IIC_LAST_READ, IICBUS_TIMEOUT))) > - goto error; > + struct iic_msg msgs[] = { > + { slave, IIC_M_WR | IIC_M_NOSTOP, 1, &cmd }, > + { slave, IIC_M_RD, 1, byte }, > + }; > + int error; > > -error: > - iicbus_stop(parent); > - return (error); > + error = TRANSFER_MSGS(dev, msgs); > + return (iic2smb_error(error)); > } > > -#define BUF2SHORT(low,high) \ > - ((short)(((high) & 0xff) << 8) | (short)((low) & 0xff)) > - > static int > iicsmb_readw(device_t dev, u_char slave, char cmd, short *word) > { > - device_t parent = device_get_parent(dev); > - int error, sent, read; > - char buf[2]; > - > - if ((error = iicbus_start(parent, slave & ~LSB, IICBUS_TIMEOUT))) > - return (error); > - > - if ((error = iicbus_write(parent, &cmd, 1, &sent, IICBUS_TIMEOUT))) > - goto error; > - > - if ((error = iicbus_repeated_start(parent, slave | LSB, IICBUS_TIMEOUT))) > - goto error; > - > - if ((error = iicbus_read(parent, buf, 2, &read, IIC_LAST_READ, IICBUS_TIMEOUT))) > - goto error; > - > - /* first, receive low, then high byte */ > - *word = BUF2SHORT(buf[0], buf[1]); > + uint8_t buf[2]; > + struct iic_msg msgs[] = { > + { slave, IIC_M_WR | IIC_M_NOSTOP, 1, &cmd }, > + { slave, IIC_M_RD, nitems(buf), buf }, > + }; > + int error; > > -error: > - iicbus_stop(parent); > - return (error); > + error = TRANSFER_MSGS(dev, msgs); > + if (error == 0) > + *word = ((uint16_t)buf[1] << 8) | buf[0]; > + return (iic2smb_error(error)); > } > > static int > iicsmb_pcall(device_t dev, u_char slave, char cmd, short sdata, short *rdata) > { > - device_t parent = device_get_parent(dev); > - int error, sent, read; > - char buf[2]; > - > - if ((error = iicbus_start(parent, slave & ~LSB, IICBUS_TIMEOUT))) > - return (error); > - > - if ((error = iicbus_write(parent, &cmd, 1, &sent, IICBUS_TIMEOUT))) > - goto error; > - > - /* first, send low, then high byte */ > - buf[0] = (char)(sdata & 0xff); > - buf[1] = (char)((sdata & 0xff00) >> 8); > - > - if ((error = iicbus_write(parent, buf, 2, &sent, IICBUS_TIMEOUT))) > - goto error; > - > - if ((error = iicbus_repeated_start(parent, slave | LSB, IICBUS_TIMEOUT))) > - goto error; > - > - if ((error = iicbus_read(parent, buf, 2, &read, IIC_LAST_READ, IICBUS_TIMEOUT))) > - goto error; > - > - /* first, receive low, then high byte */ > - *rdata = BUF2SHORT(buf[0], buf[1]); > + uint8_t in[3] = { cmd, sdata & 0xff, sdata >> 8 }; > + uint8_t out[2]; > + struct iic_msg msgs[] = { > + { slave, IIC_M_WR | IIC_M_NOSTOP, nitems(in), in }, > + { slave, IIC_M_RD, nitems(out), out }, > + }; > + int error; > > -error: > - iicbus_stop(parent); > - return (error); > + error = TRANSFER_MSGS(dev, msgs); > + if (error == 0) > + *rdata = ((uint16_t)out[1] << 8) | out[0]; > + return (iic2smb_error(error)); > } > > static int > iicsmb_bwrite(device_t dev, u_char slave, char cmd, u_char count, char *buf) > { > - device_t parent = device_get_parent(dev); > - int error, sent; > - > - if ((error = iicbus_start(parent, slave & ~LSB, IICBUS_TIMEOUT))) > - goto error; > - > - if ((error = iicbus_write(parent, &cmd, 1, &sent, IICBUS_TIMEOUT))) > - goto error; > - > - if ((error = iicbus_write(parent, buf, (int)count, &sent, IICBUS_TIMEOUT))) > - goto error; > - > - if ((error = iicbus_stop(parent))) > - goto error; > + uint8_t bytes[2] = { cmd, count }; > + struct iic_msg msgs[] = { > + { slave, IIC_M_WR | IIC_M_NOSTOP, nitems(bytes), bytes }, > + { slave, IIC_M_WR | IIC_M_NOSTART, count, buf }, > + }; > + int error; > > -error: > - return (error); > + if (count > 32 || count == 0) > + return (SMB_EINVAL); > + error = TRANSFER_MSGS(dev, msgs); > + return (iic2smb_error(error)); > } > > static int > iicsmb_bread(device_t dev, u_char slave, char cmd, u_char *count, char *buf) > { > + struct iic_msg msgs[] = { > + { slave, IIC_M_WR | IIC_M_NOSTOP, 1, &cmd }, > + { slave, IIC_M_RD | IIC_M_NOSTOP, 1, count }, > + }; > + struct iic_msg block_msg[] = { > + { slave, IIC_M_RD | IIC_M_NOSTART, 0, buf }, > + }; > device_t parent = device_get_parent(dev); > - int error, sent, read; > - > - if ((error = iicbus_start(parent, slave & ~LSB, IICBUS_TIMEOUT))) > - return (error); > - > - if ((error = iicbus_write(parent, &cmd, 1, &sent, IICBUS_TIMEOUT))) > - goto error; > - > - if ((error = iicbus_repeated_start(parent, slave | LSB, IICBUS_TIMEOUT))) > - goto error; > - > - if ((error = iicbus_read(parent, buf, (int)*count, &read, > - IIC_LAST_READ, IICBUS_TIMEOUT))) > - goto error; > - *count = read; > + int error; > + u_char bufsz; > > -error: > - iicbus_stop(parent); > - return (error); > + /* Stash output buffer size before overwriting it. */ > + bufsz = *count; > + if (bufsz == 0) > + return (SMB_EINVAL); > + > + /* Have to do this because the command is split in two transfers. */ > + error = iicbus_request_bus(parent, dev, IIC_WAIT); > + if (error == 0) > + error = TRANSFER_MSGS(dev, msgs); > + if (error == 0) { > + /* > + * If the slave offers an empty or a too long reply, > + * read one byte to generate the stop or abort. > + * XXX 32 is hardcoded until SMB_MAXBLOCKSIZE is restored > + * to sanity. > + */ > + if (*count > 32 || *count == 0) > + block_msg[0].len = 1; > + /* If longer than the buffer, then clamp at the buffer size. */ > + if (*count > bufsz) > + block_msg[0].len = bufsz; > + else > + block_msg[0].len = *count; > + error = TRANSFER_MSGS(dev, block_msg); > + if (*count > 32 || *count == 0) > + error = SMB_EINVAL; > + } > + (void)iicbus_release_bus(parent, dev); > + return (iic2smb_error(error)); > } > > DRIVER_MODULE(iicsmb, iicbus, iicsmb_driver, iicsmb_devclass, 0, 0); > -- Andriy Gapon From owner-svn-src-all@freebsd.org Thu Oct 13 07:52:40 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id EEB9BC0FA61; Thu, 13 Oct 2016 07:52:40 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id B8176DE0; Thu, 13 Oct 2016 07:52:40 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9D7qdOK026947; Thu, 13 Oct 2016 07:52:39 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9D7qdsg026940; Thu, 13 Oct 2016 07:52:39 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610130752.u9D7qdsg026940@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Thu, 13 Oct 2016 07:52:39 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307199 - stable/10/sys/dev/hyperv/netvsc X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Oct 2016 07:52:41 -0000 Author: sephe Date: Thu Oct 13 07:52:39 2016 New Revision: 307199 URL: https://svnweb.freebsd.org/changeset/base/307199 Log: MFC 305454,305455,305521,305524-305526 305454 hyperv/hn: Fix VLAN tag setup for outgoing VLAN packets. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7785 305455 hyperv/hn: Avoid bit fields for LSOv2 setup. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7786 305521 hyperv/hn: Avoid bit fields for TXCSUM setup. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7792 305524 hyperv/hn: Cleanup RNDIS packet message encapsulation. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7793 305525 hyperv/hn: Simplify per-packet-info construction. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7794 305526 hyperv/hn: Nuke unused bits Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7795 Deleted: stable/10/sys/dev/hyperv/netvsc/hv_rndis.h Modified: stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.c stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.c stable/10/sys/dev/hyperv/netvsc/if_hnreg.h stable/10/sys/dev/hyperv/netvsc/if_hnvar.h stable/10/sys/dev/hyperv/netvsc/ndis.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.c Thu Oct 13 07:42:44 2016 (r307198) +++ stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.c Thu Oct 13 07:52:39 2016 (r307199) @@ -47,9 +47,9 @@ #include #include #include -#include #include #include +#include MALLOC_DEFINE(M_NETVSC, "netvsc", "Hyper-V netvsc driver"); @@ -512,15 +512,15 @@ hv_nv_connect_to_vsp(struct hn_softc *sc for (i = protocol_number - 1; i >= 0; i--) { if (hv_nv_negotiate_nvsp_protocol(sc, protocol_list[i]) == 0) { sc->hn_nvs_ver = protocol_list[i]; - sc->hn_ndis_ver = NDIS_VERSION_6_30; + sc->hn_ndis_ver = HN_NDIS_VERSION_6_30; if (sc->hn_nvs_ver <= NVSP_PROTOCOL_VERSION_4) - sc->hn_ndis_ver = NDIS_VERSION_6_1; + sc->hn_ndis_ver = HN_NDIS_VERSION_6_1; if (bootverbose) { if_printf(sc->hn_ifp, "NVS version 0x%x, " "NDIS version %u.%u\n", sc->hn_nvs_ver, - NDIS_VERSION_MAJOR(sc->hn_ndis_ver), - NDIS_VERSION_MINOR(sc->hn_ndis_ver)); + HN_NDIS_VERSION_MAJOR(sc->hn_ndis_ver), + HN_NDIS_VERSION_MINOR(sc->hn_ndis_ver)); } break; } @@ -546,8 +546,8 @@ hv_nv_connect_to_vsp(struct hn_softc *sc memset(&ndis, 0, sizeof(ndis)); ndis.nvs_type = HN_NVS_TYPE_NDIS_INIT; - ndis.nvs_ndis_major = NDIS_VERSION_MAJOR(sc->hn_ndis_ver); - ndis.nvs_ndis_minor = NDIS_VERSION_MINOR(sc->hn_ndis_ver); + ndis.nvs_ndis_major = HN_NDIS_VERSION_MAJOR(sc->hn_ndis_ver); + ndis.nvs_ndis_minor = HN_NDIS_VERSION_MINOR(sc->hn_ndis_ver); /* NOTE: No response. */ ret = hn_nvs_req_send(sc, &ndis, sizeof(ndis)); @@ -763,7 +763,7 @@ hv_nv_on_receive(struct hn_softc *sc, st } pkt = (const struct vmbus_chanpkt_rxbuf *)pkthdr; - if (__predict_false(pkt->cp_rxbuf_id != NETVSC_RECEIVE_BUFFER_ID)) { + if (__predict_false(pkt->cp_rxbuf_id != HN_NVS_RXBUF_SIG)) { if_printf(rxr->hn_ifp, "invalid rxbuf_id 0x%08x\n", pkt->cp_rxbuf_id); return; Modified: stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h Thu Oct 13 07:42:44 2016 (r307198) +++ stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h Thu Oct 13 07:52:39 2016 (r307199) @@ -74,110 +74,6 @@ MALLOC_DECLARE(M_NETVSC); #define NVSP_PROTOCOL_VERSION_2 0x30002 #define NVSP_PROTOCOL_VERSION_4 0x40000 #define NVSP_PROTOCOL_VERSION_5 0x50000 -#define NVSP_MIN_PROTOCOL_VERSION (NVSP_PROTOCOL_VERSION_1) -#define NVSP_MAX_PROTOCOL_VERSION (NVSP_PROTOCOL_VERSION_2) - -#define NVSP_PROTOCOL_VERSION_CURRENT NVSP_PROTOCOL_VERSION_2 - -#define VERSION_4_OFFLOAD_SIZE 22 - -#define NVSP_OPERATIONAL_STATUS_OK (0x00000000) -#define NVSP_OPERATIONAL_STATUS_DEGRADED (0x00000001) -#define NVSP_OPERATIONAL_STATUS_NONRECOVERABLE (0x00000002) -#define NVSP_OPERATIONAL_STATUS_NO_CONTACT (0x00000003) -#define NVSP_OPERATIONAL_STATUS_LOST_COMMUNICATION (0x00000004) - -/* - * Maximun number of transfer pages (packets) the VSP will use on a receive - */ -#define NVSP_MAX_PACKETS_PER_RECEIVE 375 - -/* vRSS stuff */ -#define RNDIS_OBJECT_TYPE_RSS_CAPABILITIES 0x88 -#define RNDIS_OBJECT_TYPE_RSS_PARAMETERS 0x89 - -#define RNDIS_RECEIVE_SCALE_CAPABILITIES_REVISION_2 2 -#define RNDIS_RECEIVE_SCALE_PARAMETERS_REVISION_2 2 - -struct rndis_obj_header { - uint8_t type; - uint8_t rev; - uint16_t size; -} __packed; - -/* rndis_recv_scale_cap/cap_flag */ -#define RNDIS_RSS_CAPS_MESSAGE_SIGNALED_INTERRUPTS 0x01000000 -#define RNDIS_RSS_CAPS_CLASSIFICATION_AT_ISR 0x02000000 -#define RNDIS_RSS_CAPS_CLASSIFICATION_AT_DPC 0x04000000 -#define RNDIS_RSS_CAPS_USING_MSI_X 0x08000000 -#define RNDIS_RSS_CAPS_RSS_AVAILABLE_ON_PORTS 0x10000000 -#define RNDIS_RSS_CAPS_SUPPORTS_MSI_X 0x20000000 -#define RNDIS_RSS_CAPS_HASH_TYPE_TCP_IPV4 0x00000100 -#define RNDIS_RSS_CAPS_HASH_TYPE_TCP_IPV6 0x00000200 -#define RNDIS_RSS_CAPS_HASH_TYPE_TCP_IPV6_EX 0x00000400 - -/* RNDIS_RECEIVE_SCALE_CAPABILITIES */ -struct rndis_recv_scale_cap { - struct rndis_obj_header hdr; - uint32_t cap_flag; - uint32_t num_int_msg; - uint32_t num_recv_que; - uint16_t num_indirect_tabent; -} __packed; - -/* rndis_recv_scale_param flags */ -#define RNDIS_RSS_PARAM_FLAG_BASE_CPU_UNCHANGED 0x0001 -#define RNDIS_RSS_PARAM_FLAG_HASH_INFO_UNCHANGED 0x0002 -#define RNDIS_RSS_PARAM_FLAG_ITABLE_UNCHANGED 0x0004 -#define RNDIS_RSS_PARAM_FLAG_HASH_KEY_UNCHANGED 0x0008 -#define RNDIS_RSS_PARAM_FLAG_DISABLE_RSS 0x0010 - -/* Hash info bits */ -#define RNDIS_HASH_FUNC_TOEPLITZ 0x00000001 -#define RNDIS_HASH_IPV4 0x00000100 -#define RNDIS_HASH_TCP_IPV4 0x00000200 -#define RNDIS_HASH_IPV6 0x00000400 -#define RNDIS_HASH_IPV6_EX 0x00000800 -#define RNDIS_HASH_TCP_IPV6 0x00001000 -#define RNDIS_HASH_TCP_IPV6_EX 0x00002000 - -#define RNDIS_RSS_INDIRECTION_TABLE_MAX_SIZE_REVISION_2 (128 * 4) -#define RNDIS_RSS_HASH_SECRET_KEY_MAX_SIZE_REVISION_2 40 - -#define ITAB_NUM 128 -#define HASH_KEYLEN RNDIS_RSS_HASH_SECRET_KEY_MAX_SIZE_REVISION_2 - -/* RNDIS_RECEIVE_SCALE_PARAMETERS */ -typedef struct rndis_recv_scale_param_ { - struct rndis_obj_header hdr; - - /* Qualifies the rest of the information */ - uint16_t flag; - - /* The base CPU number to do receive processing. not used */ - uint16_t base_cpu_number; - - /* This describes the hash function and type being enabled */ - uint32_t hashinfo; - - /* The size of indirection table array */ - uint16_t indirect_tabsize; - - /* The offset of the indirection table from the beginning of this - * structure - */ - uint32_t indirect_taboffset; - - /* The size of the hash secret key */ - uint16_t hashkey_size; - - /* The offset of the secret key from the beginning of this structure */ - uint32_t hashkey_offset; - - uint32_t processor_masks_offset; - uint32_t num_processor_masks; - uint32_t processor_masks_entry_size; -} rndis_recv_scale_param; /* * The following arguably belongs in a separate header file @@ -188,18 +84,10 @@ typedef struct rndis_recv_scale_param_ { */ #define NETVSC_SEND_BUFFER_SIZE (1024*1024*15) /* 15M */ -#define NETVSC_SEND_BUFFER_ID 0xface #define NETVSC_RECEIVE_BUFFER_SIZE_LEGACY (1024*1024*15) /* 15MB */ #define NETVSC_RECEIVE_BUFFER_SIZE (1024*1024*16) /* 16MB */ -#define NETVSC_RECEIVE_BUFFER_ID 0xcafe - -#define NETVSC_RECEIVE_SG_COUNT 1 - -/* Preallocated receive packets */ -#define NETVSC_RECEIVE_PACKETLIST_COUNT 256 - /* * Maximum MTU we permit to be configured for a netvsc interface. * When the code was developed, a max MTU of 12232 was tested and @@ -208,7 +96,6 @@ typedef struct rndis_recv_scale_param_ { #define NETVSC_MAX_CONFIGURABLE_MTU (9 * 1024) #define NETVSC_PACKET_SIZE PAGE_SIZE -#define VRSS_SEND_TABLE_SIZE 16 /* * Data types @@ -216,26 +103,9 @@ typedef struct rndis_recv_scale_param_ { struct vmbus_channel; -typedef void (*pfn_on_send_rx_completion)(struct vmbus_channel *, void *); - #define NETVSC_DEVICE_RING_BUFFER_SIZE (128 * PAGE_SIZE) #define NETVSC_PACKET_MAXPAGE 32 -#define NETVSC_VLAN_PRIO_MASK 0xe000 -#define NETVSC_VLAN_PRIO_SHIFT 13 -#define NETVSC_VLAN_VID_MASK 0x0fff - -#define TYPE_IPV4 2 -#define TYPE_IPV6 4 -#define TYPE_TCP 2 -#define TYPE_UDP 4 - -#define TRANSPORT_TYPE_NOT_IP 0 -#define TRANSPORT_TYPE_IPV4_TCP ((TYPE_IPV4 << 16) | TYPE_TCP) -#define TRANSPORT_TYPE_IPV4_UDP ((TYPE_IPV4 << 16) | TYPE_UDP) -#define TRANSPORT_TYPE_IPV6_TCP ((TYPE_IPV6 << 16) | TYPE_TCP) -#define TRANSPORT_TYPE_IPV6_UDP ((TYPE_IPV6 << 16) | TYPE_UDP) - typedef struct { uint8_t mac_addr[ETHER_ADDR_LEN]; uint32_t link_state; Modified: stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Thu Oct 13 07:42:44 2016 (r307198) +++ stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Thu Oct 13 07:52:39 2016 (r307199) @@ -79,7 +79,7 @@ __FBSDID("$FreeBSD$"); #include #include #include - +#include #include #include @@ -120,7 +120,6 @@ __FBSDID("$FreeBSD$"); #include #include -#include #include #include @@ -144,14 +143,14 @@ __FBSDID("$FreeBSD$"); #define HN_RING_CNT_DEF_MAX 8 -#define HN_RNDIS_MSG_LEN \ - (sizeof(rndis_msg) + \ - RNDIS_HASHVAL_PPI_SIZE + \ - RNDIS_VLAN_PPI_SIZE + \ - RNDIS_TSO_PPI_SIZE + \ - RNDIS_CSUM_PPI_SIZE) -#define HN_RNDIS_MSG_BOUNDARY PAGE_SIZE -#define HN_RNDIS_MSG_ALIGN CACHE_LINE_SIZE +#define HN_RNDIS_PKT_LEN \ + (sizeof(struct rndis_packet_msg) + \ + HN_RNDIS_PKTINFO_SIZE(HN_NDIS_HASH_VALUE_SIZE) + \ + HN_RNDIS_PKTINFO_SIZE(NDIS_VLAN_INFO_SIZE) + \ + HN_RNDIS_PKTINFO_SIZE(NDIS_LSO2_INFO_SIZE) + \ + HN_RNDIS_PKTINFO_SIZE(NDIS_TXCSUM_INFO_SIZE)) +#define HN_RNDIS_PKT_BOUNDARY PAGE_SIZE +#define HN_RNDIS_PKT_ALIGN CACHE_LINE_SIZE #define HN_TX_DATA_BOUNDARY PAGE_SIZE #define HN_TX_DATA_MAXSIZE IP_MAXPACKET @@ -175,9 +174,9 @@ struct hn_txdesc { bus_dmamap_t data_dmap; - bus_addr_t rndis_msg_paddr; - rndis_msg *rndis_msg; - bus_dmamap_t rndis_msg_dmap; + bus_addr_t rndis_pkt_paddr; + struct rndis_packet_msg *rndis_pkt; + bus_dmamap_t rndis_pkt_dmap; }; #define HN_TXD_FLAG_ONLIST 0x1 @@ -839,7 +838,7 @@ hn_tx_done(struct hn_send_ctx *sndc, str } void -netvsc_channel_rollup(struct hn_rx_ring *rxr, struct hn_tx_ring *txr) +hn_chan_rollup(struct hn_rx_ring *rxr, struct hn_tx_ring *txr) { #if defined(INET) || defined(INET6) struct lro_ctrl *lro = &rxr->hn_lro; @@ -863,6 +862,15 @@ netvsc_channel_rollup(struct hn_rx_ring hn_txeof(txr); } +static __inline uint32_t +hn_rndis_pktmsg_offset(uint32_t ofs) +{ + + KASSERT(ofs >= sizeof(struct rndis_packet_msg), + ("invalid RNDIS packet msg offset %u", ofs)); + return (ofs - __offsetof(struct rndis_packet_msg, rm_dataoffset)); +} + /* * NOTE: * If this function fails, then both txd and m_head0 will be freed. @@ -873,14 +881,10 @@ hn_encap(struct hn_tx_ring *txr, struct bus_dma_segment_t segs[HN_TX_DATA_SEGCNT_MAX]; int error, nsegs, i; struct mbuf *m_head = *m_head0; - rndis_msg *rndis_mesg; - rndis_packet *rndis_pkt; - rndis_per_packet_info *rppi; - struct rndis_hash_value *hash_value; - uint32_t rndis_msg_size, tot_data_buf_len, send_buf_section_idx; - int send_buf_section_size; - - tot_data_buf_len = m_head->m_pkthdr.len; + struct rndis_packet_msg *pkt; + uint32_t send_buf_section_idx; + int send_buf_section_size, pktlen; + uint32_t *pi_data; /* * extension points to the area reserved for the @@ -888,45 +892,34 @@ hn_encap(struct hn_tx_ring *txr, struct * the netvsc_packet (and rppi struct, if present; * length is updated later). */ - rndis_mesg = txd->rndis_msg; - /* XXX not necessary */ - memset(rndis_mesg, 0, HN_RNDIS_MSG_LEN); - rndis_mesg->ndis_msg_type = REMOTE_NDIS_PACKET_MSG; - - rndis_pkt = &rndis_mesg->msg.packet; - rndis_pkt->data_offset = sizeof(rndis_packet); - rndis_pkt->data_length = tot_data_buf_len; - rndis_pkt->per_pkt_info_offset = sizeof(rndis_packet); - - rndis_msg_size = RNDIS_MESSAGE_SIZE(rndis_packet); + pkt = txd->rndis_pkt; + pkt->rm_type = REMOTE_NDIS_PACKET_MSG; + pkt->rm_len = sizeof(*pkt) + m_head->m_pkthdr.len; + pkt->rm_dataoffset = sizeof(*pkt); + pkt->rm_datalen = m_head->m_pkthdr.len; + pkt->rm_pktinfooffset = sizeof(*pkt); + pkt->rm_pktinfolen = 0; /* * Set the hash value for this packet, so that the host could * dispatch the TX done event for this packet back to this TX * ring's channel. */ - rndis_msg_size += RNDIS_HASHVAL_PPI_SIZE; - rppi = hv_set_rppi_data(rndis_mesg, RNDIS_HASHVAL_PPI_SIZE, - nbl_hash_value); - hash_value = (struct rndis_hash_value *)((uint8_t *)rppi + - rppi->per_packet_info_offset); - hash_value->hash_value = txr->hn_tx_idx; + pi_data = hn_rndis_pktinfo_append(pkt, HN_RNDIS_PKT_LEN, + HN_NDIS_HASH_VALUE_SIZE, HN_NDIS_PKTINFO_TYPE_HASHVAL); + *pi_data = txr->hn_tx_idx; if (m_head->m_flags & M_VLANTAG) { - ndis_8021q_info *rppi_vlan_info; - - rndis_msg_size += RNDIS_VLAN_PPI_SIZE; - rppi = hv_set_rppi_data(rndis_mesg, RNDIS_VLAN_PPI_SIZE, - ieee_8021q_info); - - rppi_vlan_info = (ndis_8021q_info *)((uint8_t *)rppi + - rppi->per_packet_info_offset); - rppi_vlan_info->u1.s1.vlan_id = - m_head->m_pkthdr.ether_vtag & 0xfff; + pi_data = hn_rndis_pktinfo_append(pkt, HN_RNDIS_PKT_LEN, + NDIS_VLAN_INFO_SIZE, NDIS_PKTINFO_TYPE_VLAN); + *pi_data = NDIS_VLAN_INFO_MAKE( + EVL_VLANOFTAG(m_head->m_pkthdr.ether_vtag), + EVL_PRIOFTAG(m_head->m_pkthdr.ether_vtag), + EVL_CFIOFTAG(m_head->m_pkthdr.ether_vtag)); } if (m_head->m_pkthdr.csum_flags & CSUM_TSO) { - rndis_tcp_tso_info *tso_info; +#if defined(INET6) || defined(INET) struct ether_vlan_header *eh; int ether_len; @@ -939,15 +932,8 @@ hn_encap(struct hn_tx_ring *txr, struct else ether_len = ETHER_HDR_LEN; - rndis_msg_size += RNDIS_TSO_PPI_SIZE; - rppi = hv_set_rppi_data(rndis_mesg, RNDIS_TSO_PPI_SIZE, - tcp_large_send_info); - - tso_info = (rndis_tcp_tso_info *)((uint8_t *)rppi + - rppi->per_packet_info_offset); - tso_info->lso_v2_xmit.type = - RNDIS_TCP_LARGE_SEND_OFFLOAD_V2_TYPE; - + pi_data = hn_rndis_pktinfo_append(pkt, HN_RNDIS_PKT_LEN, + NDIS_LSO2_INFO_SIZE, NDIS_PKTINFO_TYPE_LSO); #ifdef INET if (m_head->m_pkthdr.csum_flags & CSUM_IP_TSO) { struct ip *ip = @@ -956,13 +942,12 @@ hn_encap(struct hn_tx_ring *txr, struct struct tcphdr *th = (struct tcphdr *)((caddr_t)ip + iph_len); - tso_info->lso_v2_xmit.ip_version = - RNDIS_TCP_LARGE_SEND_OFFLOAD_IPV4; ip->ip_len = 0; ip->ip_sum = 0; - th->th_sum = in_pseudo(ip->ip_src.s_addr, ip->ip_dst.s_addr, htons(IPPROTO_TCP)); + *pi_data = NDIS_LSO2_INFO_MAKEIPV4(0, + m_head->m_pkthdr.tso_segsz); } #endif #if defined(INET6) && defined(INET) @@ -974,53 +959,47 @@ hn_encap(struct hn_tx_ring *txr, struct (m_head->m_data + ether_len); struct tcphdr *th = (struct tcphdr *)(ip6 + 1); - tso_info->lso_v2_xmit.ip_version = - RNDIS_TCP_LARGE_SEND_OFFLOAD_IPV6; ip6->ip6_plen = 0; th->th_sum = in6_cksum_pseudo(ip6, 0, IPPROTO_TCP, 0); + *pi_data = NDIS_LSO2_INFO_MAKEIPV6(0, + m_head->m_pkthdr.tso_segsz); } #endif - tso_info->lso_v2_xmit.tcp_header_offset = 0; - tso_info->lso_v2_xmit.mss = m_head->m_pkthdr.tso_segsz; +#endif /* INET6 || INET */ } else if (m_head->m_pkthdr.csum_flags & txr->hn_csum_assist) { - rndis_tcp_ip_csum_info *csum_info; - - rndis_msg_size += RNDIS_CSUM_PPI_SIZE; - rppi = hv_set_rppi_data(rndis_mesg, RNDIS_CSUM_PPI_SIZE, - tcpip_chksum_info); - csum_info = (rndis_tcp_ip_csum_info *)((uint8_t *)rppi + - rppi->per_packet_info_offset); + pi_data = hn_rndis_pktinfo_append(pkt, HN_RNDIS_PKT_LEN, + NDIS_TXCSUM_INFO_SIZE, NDIS_PKTINFO_TYPE_CSUM); + *pi_data = NDIS_TXCSUM_INFO_IPV4; - csum_info->xmit.is_ipv4 = 1; if (m_head->m_pkthdr.csum_flags & CSUM_IP) - csum_info->xmit.ip_header_csum = 1; + *pi_data |= NDIS_TXCSUM_INFO_IPCS; - if (m_head->m_pkthdr.csum_flags & CSUM_TCP) { - csum_info->xmit.tcp_csum = 1; - csum_info->xmit.tcp_header_offset = 0; - } else if (m_head->m_pkthdr.csum_flags & CSUM_UDP) { - csum_info->xmit.udp_csum = 1; - } + if (m_head->m_pkthdr.csum_flags & CSUM_TCP) + *pi_data |= NDIS_TXCSUM_INFO_TCPCS; + else if (m_head->m_pkthdr.csum_flags & CSUM_UDP) + *pi_data |= NDIS_TXCSUM_INFO_UDPCS; } - rndis_mesg->msg_len = tot_data_buf_len + rndis_msg_size; - tot_data_buf_len = rndis_mesg->msg_len; + pktlen = pkt->rm_pktinfooffset + pkt->rm_pktinfolen; + /* Convert RNDIS packet message offsets */ + pkt->rm_dataoffset = hn_rndis_pktmsg_offset(pkt->rm_dataoffset); + pkt->rm_pktinfooffset = hn_rndis_pktmsg_offset(pkt->rm_pktinfooffset); /* * Chimney send, if the packet could fit into one chimney buffer. */ - if (tot_data_buf_len < txr->hn_chim_size) { + if (pkt->rm_len < txr->hn_chim_size) { txr->hn_tx_chimney_tried++; send_buf_section_idx = hn_chim_alloc(txr->hn_sc); if (send_buf_section_idx != HN_NVS_CHIM_IDX_INVALID) { uint8_t *dest = txr->hn_sc->hn_chim + (send_buf_section_idx * txr->hn_sc->hn_chim_szmax); - memcpy(dest, rndis_mesg, rndis_msg_size); - dest += rndis_msg_size; + memcpy(dest, pkt, pktlen); + dest += pktlen; m_copydata(m_head, 0, m_head->m_pkthdr.len, dest); - send_buf_section_size = tot_data_buf_len; + send_buf_section_size = pkt->rm_len; txr->hn_gpa_cnt = 0; txr->hn_tx_chimney++; goto done; @@ -1051,9 +1030,9 @@ hn_encap(struct hn_tx_ring *txr, struct txr->hn_gpa_cnt = nsegs + 1; /* send packet with page buffer */ - txr->hn_gpa[0].gpa_page = atop(txd->rndis_msg_paddr); - txr->hn_gpa[0].gpa_ofs = txd->rndis_msg_paddr & PAGE_MASK; - txr->hn_gpa[0].gpa_len = rndis_msg_size; + txr->hn_gpa[0].gpa_page = atop(txd->rndis_pkt_paddr); + txr->hn_gpa[0].gpa_ofs = txd->rndis_pkt_paddr & PAGE_MASK; + txr->hn_gpa[0].gpa_len = pktlen; /* * Fill the page buffers with mbuf info after the page @@ -1301,7 +1280,7 @@ hn_lro_rx(struct lro_ctrl *lc, struct mb * Note: This is no longer used as a callback */ int -netvsc_recv(struct hn_rx_ring *rxr, const void *data, int dlen, +hn_rxpkt(struct hn_rx_ring *rxr, const void *data, int dlen, const struct hn_recvinfo *info) { struct ifnet *ifp = rxr->hn_ifp; @@ -2154,8 +2133,8 @@ hn_ndis_version_sysctl(SYSCTL_HANDLER_AR char verstr[16]; snprintf(verstr, sizeof(verstr), "%u.%u", - NDIS_VERSION_MAJOR(sc->hn_ndis_ver), - NDIS_VERSION_MINOR(sc->hn_ndis_ver)); + HN_NDIS_VERSION_MAJOR(sc->hn_ndis_ver), + HN_NDIS_VERSION_MINOR(sc->hn_ndis_ver)); return sysctl_handle_string(oidp, verstr, sizeof(verstr), req); } @@ -2515,16 +2494,16 @@ hn_create_tx_ring(struct hn_softc *sc, i parent_dtag = bus_get_dma_tag(dev); - /* DMA tag for RNDIS messages. */ + /* DMA tag for RNDIS packet messages. */ error = bus_dma_tag_create(parent_dtag, /* parent */ - HN_RNDIS_MSG_ALIGN, /* alignment */ - HN_RNDIS_MSG_BOUNDARY, /* boundary */ + HN_RNDIS_PKT_ALIGN, /* alignment */ + HN_RNDIS_PKT_BOUNDARY, /* boundary */ BUS_SPACE_MAXADDR, /* lowaddr */ BUS_SPACE_MAXADDR, /* highaddr */ NULL, NULL, /* filter, filterarg */ - HN_RNDIS_MSG_LEN, /* maxsize */ + HN_RNDIS_PKT_LEN, /* maxsize */ 1, /* nsegments */ - HN_RNDIS_MSG_LEN, /* maxsegsize */ + HN_RNDIS_PKT_LEN, /* maxsegsize */ 0, /* flags */ NULL, /* lockfunc */ NULL, /* lockfuncarg */ @@ -2559,28 +2538,28 @@ hn_create_tx_ring(struct hn_softc *sc, i txd->txr = txr; /* - * Allocate and load RNDIS messages. + * Allocate and load RNDIS packet message. */ error = bus_dmamem_alloc(txr->hn_tx_rndis_dtag, - (void **)&txd->rndis_msg, - BUS_DMA_WAITOK | BUS_DMA_COHERENT, - &txd->rndis_msg_dmap); + (void **)&txd->rndis_pkt, + BUS_DMA_WAITOK | BUS_DMA_COHERENT | BUS_DMA_ZERO, + &txd->rndis_pkt_dmap); if (error) { device_printf(dev, - "failed to allocate rndis_msg, %d\n", i); + "failed to allocate rndis_packet_msg, %d\n", i); return error; } error = bus_dmamap_load(txr->hn_tx_rndis_dtag, - txd->rndis_msg_dmap, - txd->rndis_msg, HN_RNDIS_MSG_LEN, - hyperv_dma_map_paddr, &txd->rndis_msg_paddr, + txd->rndis_pkt_dmap, + txd->rndis_pkt, HN_RNDIS_PKT_LEN, + hyperv_dma_map_paddr, &txd->rndis_pkt_paddr, BUS_DMA_NOWAIT); if (error) { device_printf(dev, - "failed to load rndis_msg, %d\n", i); + "failed to load rndis_packet_msg, %d\n", i); bus_dmamem_free(txr->hn_tx_rndis_dtag, - txd->rndis_msg, txd->rndis_msg_dmap); + txd->rndis_pkt, txd->rndis_pkt_dmap); return error; } @@ -2591,9 +2570,9 @@ hn_create_tx_ring(struct hn_softc *sc, i device_printf(dev, "failed to allocate tx data dmamap\n"); bus_dmamap_unload(txr->hn_tx_rndis_dtag, - txd->rndis_msg_dmap); + txd->rndis_pkt_dmap); bus_dmamem_free(txr->hn_tx_rndis_dtag, - txd->rndis_msg, txd->rndis_msg_dmap); + txd->rndis_pkt, txd->rndis_pkt_dmap); return error; } @@ -2651,9 +2630,9 @@ hn_txdesc_dmamap_destroy(struct hn_txdes KASSERT(txd->m == NULL, ("still has mbuf installed")); KASSERT((txd->flags & HN_TXD_FLAG_DMAMAP) == 0, ("still dma mapped")); - bus_dmamap_unload(txr->hn_tx_rndis_dtag, txd->rndis_msg_dmap); - bus_dmamem_free(txr->hn_tx_rndis_dtag, txd->rndis_msg, - txd->rndis_msg_dmap); + bus_dmamap_unload(txr->hn_tx_rndis_dtag, txd->rndis_pkt_dmap); + bus_dmamem_free(txr->hn_tx_rndis_dtag, txd->rndis_pkt, + txd->rndis_pkt_dmap); bus_dmamap_destroy(txr->hn_tx_data_dtag, txd->data_dmap); } Modified: stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.c Thu Oct 13 07:42:44 2016 (r307198) +++ stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.c Thu Oct 13 07:52:39 2016 (r307199) @@ -39,6 +39,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -49,7 +50,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #include #include #include @@ -103,29 +103,40 @@ again: return ((rid & 0xffff) << 16); } -/* - * Set the Per-Packet-Info with the specified type - */ void * -hv_set_rppi_data(rndis_msg *rndis_mesg, uint32_t rppi_size, - int pkt_type) +hn_rndis_pktinfo_append(struct rndis_packet_msg *pkt, size_t pktsize, + size_t pi_dlen, uint32_t pi_type) { - rndis_packet *rndis_pkt; - rndis_per_packet_info *rppi; + const size_t pi_size = HN_RNDIS_PKTINFO_SIZE(pi_dlen); + struct rndis_pktinfo *pi; - rndis_pkt = &rndis_mesg->msg.packet; - rndis_pkt->data_offset += rppi_size; + KASSERT((pi_size & RNDIS_PACKET_MSG_OFFSET_ALIGNMASK) == 0, + ("unaligned pktinfo size %zu, pktinfo dlen %zu", pi_size, pi_dlen)); - rppi = (rndis_per_packet_info *)((char *)rndis_pkt + - rndis_pkt->per_pkt_info_offset + rndis_pkt->per_pkt_info_length); + /* + * Per-packet-info does not move; it only grows. + * + * NOTE: + * rm_pktinfooffset in this phase counts from the beginning + * of rndis_packet_msg. + */ + KASSERT(pkt->rm_pktinfooffset + pkt->rm_pktinfolen + pi_size <= pktsize, + ("%u pktinfo overflows RNDIS packet msg", pi_type)); + pi = (struct rndis_pktinfo *)((uint8_t *)pkt + pkt->rm_pktinfooffset + + pkt->rm_pktinfolen); + pkt->rm_pktinfolen += pi_size; + + pi->rm_size = pi_size; + pi->rm_type = pi_type; + pi->rm_pktinfooffset = RNDIS_PKTINFO_OFFSET; - rppi->size = rppi_size; - rppi->type = pkt_type; - rppi->per_packet_info_offset = sizeof(rndis_per_packet_info); + /* Data immediately follow per-packet-info. */ + pkt->rm_dataoffset += pi_size; - rndis_pkt->per_pkt_info_length += rppi_size; + /* Update RNDIS packet msg length */ + pkt->rm_len += pi_size; - return (rppi); + return (pi->rm_data); } /* @@ -409,7 +420,7 @@ hv_rf_receive_data(struct hn_rx_ring *rx pkt->rm_len, data_off, data_len); return; } - netvsc_recv(rxr, ((const uint8_t *)pkt) + data_off, data_len, &info); + hn_rxpkt(rxr, ((const uint8_t *)pkt) + data_off, data_len, &info); } /* @@ -721,7 +732,7 @@ hn_rndis_get_rsscaps(struct hn_softc *sc /* * Only NDIS 6.30+ is supported. */ - KASSERT(sc->hn_ndis_ver >= NDIS_VERSION_6_30, + KASSERT(sc->hn_ndis_ver >= HN_NDIS_VERSION_6_30, ("NDIS 6.30+ is required, NDIS version 0x%08x", sc->hn_ndis_ver)); *rxr_cnt = 0; @@ -817,7 +828,7 @@ hn_rndis_conf_offload(struct hn_softc *s memset(¶ms, 0, sizeof(params)); params.ndis_hdr.ndis_type = NDIS_OBJTYPE_DEFAULT; - if (sc->hn_ndis_ver < NDIS_VERSION_6_30) { + if (sc->hn_ndis_ver < HN_NDIS_VERSION_6_30) { params.ndis_hdr.ndis_rev = NDIS_OFFLOAD_PARAMS_REV_2; paramsz = NDIS_OFFLOAD_PARAMS_SIZE_6_1; } else { @@ -829,7 +840,7 @@ hn_rndis_conf_offload(struct hn_softc *s params.ndis_ip4csum = NDIS_OFFLOAD_PARAM_TXRX; params.ndis_tcp4csum = NDIS_OFFLOAD_PARAM_TXRX; params.ndis_tcp6csum = NDIS_OFFLOAD_PARAM_TXRX; - if (sc->hn_ndis_ver >= NDIS_VERSION_6_30) { + if (sc->hn_ndis_ver >= HN_NDIS_VERSION_6_30) { params.ndis_udp4csum = NDIS_OFFLOAD_PARAM_TXRX; params.ndis_udp6csum = NDIS_OFFLOAD_PARAM_TXRX; } @@ -856,7 +867,7 @@ hn_rndis_conf_rss(struct hn_softc *sc, i /* * Only NDIS 6.30+ is supported. */ - KASSERT(sc->hn_ndis_ver >= NDIS_VERSION_6_30, + KASSERT(sc->hn_ndis_ver >= HN_NDIS_VERSION_6_30, ("NDIS 6.30+ is required, NDIS version 0x%08x", sc->hn_ndis_ver)); memset(rss, 0, sizeof(*rss)); @@ -1049,7 +1060,7 @@ hv_rf_on_device_add(struct hn_softc *sc, hv_rf_query_device_link_status(sc, &dev_info->link_state); - if (sc->hn_ndis_ver < NDIS_VERSION_6_30 || nchan == 1) { + if (sc->hn_ndis_ver < HN_NDIS_VERSION_6_30 || nchan == 1) { /* * Either RSS is not supported, or multiple RX/TX rings * are not requested. @@ -1179,5 +1190,5 @@ void hv_rf_channel_rollup(struct hn_rx_ring *rxr, struct hn_tx_ring *txr) { - netvsc_channel_rollup(rxr, txr); + hn_chan_rollup(rxr, txr); } Modified: stable/10/sys/dev/hyperv/netvsc/if_hnreg.h ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/if_hnreg.h Thu Oct 13 07:42:44 2016 (r307198) +++ stable/10/sys/dev/hyperv/netvsc/if_hnreg.h Thu Oct 13 07:52:39 2016 (r307199) @@ -32,6 +32,14 @@ #include #include +/* + * NDIS protocol version numbers + */ +#define HN_NDIS_VERSION_6_1 0x00060001 +#define HN_NDIS_VERSION_6_30 0x0006001e +#define HN_NDIS_VERSION_MAJOR(ver) (((ver) & 0xffff0000) >> 16) +#define HN_NDIS_VERSION_MINOR(ver) ((ver) & 0xffff) + #define HN_NVS_RXBUF_SIG 0xcafe #define HN_NVS_CHIM_SIG 0xface @@ -221,4 +229,8 @@ CTASSERT(sizeof(struct hn_nvs_rndis_ack) #define HN_NDIS_HASH_VALUE_SIZE sizeof(uint32_t) #define HN_NDIS_PKTINFO_TYPE_HASHVAL NDIS_PKTINFO_TYPE_PKT_CANCELID +/* Per-packet-info size */ +#define HN_RNDIS_PKTINFO_SIZE(dlen) \ + __offsetof(struct rndis_pktinfo, rm_data[dlen]) + #endif /* !_IF_HNREG_H_ */ Modified: stable/10/sys/dev/hyperv/netvsc/if_hnvar.h ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/if_hnvar.h Thu Oct 13 07:42:44 2016 (r307198) +++ stable/10/sys/dev/hyperv/netvsc/if_hnvar.h Thu Oct 13 07:52:39 2016 (r307199) @@ -112,6 +112,7 @@ hn_nvs_send_sglist(struct vmbus_channel } struct vmbus_xact; +struct rndis_packet_msg; const void *hn_nvs_xact_execute(struct hn_softc *sc, struct vmbus_xact *xact, void *req, int reqlen, @@ -121,6 +122,13 @@ void hn_nvs_sent_xact(struct hn_send_ct uint32_t hn_chim_alloc(struct hn_softc *sc); void hn_chim_free(struct hn_softc *sc, uint32_t chim_idx); +void *hn_rndis_pktinfo_append(struct rndis_packet_msg *, + size_t pktsize, size_t pi_dlen, uint32_t pi_type); + +int hn_rxpkt(struct hn_rx_ring *rxr, const void *data, int dlen, + const struct hn_recvinfo *info); +void hn_chan_rollup(struct hn_rx_ring *rxr, struct hn_tx_ring *txr); + extern struct hn_send_ctx hn_send_ctx_none; #endif /* !_IF_HNVAR_H_ */ Modified: stable/10/sys/dev/hyperv/netvsc/ndis.h ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/ndis.h Thu Oct 13 07:42:44 2016 (r307198) +++ stable/10/sys/dev/hyperv/netvsc/ndis.h Thu Oct 13 07:52:39 2016 (r307199) @@ -213,7 +213,7 @@ struct ndis_rssprm_toeplitz { #define NDIS_VLAN_INFO_CFI_MASK 0x0008 #define NDIS_VLAN_INFO_ID_MASK 0xfff0 #define NDIS_VLAN_INFO_MAKE(id, pri, cfi) \ - (((pri) & NVIS_VLAN_INFO_PRI_MASK) | \ + (((pri) & NDIS_VLAN_INFO_PRI_MASK) | \ (((cfi) & 0x1) << 3) | (((id) & 0xfff) << 4)) #define NDIS_VLAN_INFO_ID(inf) (((inf) & NDIS_VLAN_INFO_ID_MASK) >> 4) #define NDIS_VLAN_INFO_CFI(inf) (((inf) & NDIS_VLAN_INFO_CFI_MASK) >> 3) @@ -231,4 +231,31 @@ struct ndis_rssprm_toeplitz { #define NDIS_RXCSUM_INFO_TCPCS_INVAL 0x0080 #define NDIS_RXCSUM_INFO_IPCS_INVAL 0x0100 +/* LSOv2 */ +#define NDIS_LSO2_INFO_SIZE sizeof(uint32_t) +#define NDIS_LSO2_INFO_MSS_MASK 0x000fffff +#define NDIS_LSO2_INFO_THOFF_MASK 0x3ff00000 +#define NDIS_LSO2_INFO_ISLSO2 0x40000000 +#define NDIS_LSO2_INFO_ISIPV6 0x80000000 + +#define NDIS_LSO2_INFO_MAKE(thoff, mss) \ + ((((uint32_t)(mss)) & NDIS_LSO2_INFO_MSS_MASK) | \ + ((((uint32_t)(thoff)) & 0x3ff) << 20) | \ + NDIS_LSO2_INFO_ISLSO2) + +#define NDIS_LSO2_INFO_MAKEIPV4(thoff, mss) \ + NDIS_LSO2_INFO_MAKE((thoff), (mss)) + +#define NDIS_LSO2_INFO_MAKEIPV6(thoff, mss) \ + (NDIS_LSO2_INFO_MAKE((thoff), (mss)) | NDIS_LSO2_INFO_ISIPV6) + +/* Transmission checksum */ +#define NDIS_TXCSUM_INFO_SIZE sizeof(uint32_t) +#define NDIS_TXCSUM_INFO_IPV4 0x00000001 +#define NDIS_TXCSUM_INFO_IPV6 0x00000002 +#define NDIS_TXCSUM_INFO_TCPCS 0x00000004 +#define NDIS_TXCSUM_INFO_UDPCS 0x00000008 +#define NDIS_TXCSUM_INFO_IPCS 0x00000010 +#define NDIS_TXCSUM_INFO_THOFF 0x03ff0000 + #endif /* !_NET_NDIS_H_ */ From owner-svn-src-all@freebsd.org Thu Oct 13 08:01:40 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 16BEAC0F1D3; Thu, 13 Oct 2016 08:01:40 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id B17633B1; Thu, 13 Oct 2016 08:01:39 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9D81cTX029403; Thu, 13 Oct 2016 08:01:38 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9D81c1C029397; Thu, 13 Oct 2016 08:01:38 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610130801.u9D81c1C029397@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Thu, 13 Oct 2016 08:01:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307200 - stable/10/sys/dev/hyperv/netvsc X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Oct 2016 08:01:40 -0000 Author: sephe Date: Thu Oct 13 08:01:38 2016 New Revision: 307200 URL: https://svnweb.freebsd.org/changeset/base/307200 Log: MFC 305578-305581 305578 hyperv/hn: Pull vmbus channel open up. While I'm here, pull up the channel callback related code too. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7805 305579 hyperv/hn: Push RXBUF size adjustment down. It is not used in other places. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7806 305580 hyperv/hn: Factor out function to do NVS initialization. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7807 305581 hyperv/hn: Pass MTU around. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7808 Modified: stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.c stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.c stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.h stable/10/sys/dev/hyperv/netvsc/if_hnreg.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.c Thu Oct 13 07:52:39 2016 (r307199) +++ stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.c Thu Oct 13 08:01:38 2016 (r307200) @@ -56,20 +56,11 @@ MALLOC_DEFINE(M_NETVSC, "netvsc", "Hyper /* * Forward declarations */ -static void hv_nv_on_channel_callback(struct vmbus_channel *chan, - void *xrxr); static int hv_nv_init_send_buffer_with_net_vsp(struct hn_softc *sc); -static int hv_nv_init_rx_buffer_with_net_vsp(struct hn_softc *, int); +static int hv_nv_init_rx_buffer_with_net_vsp(struct hn_softc *); static int hv_nv_destroy_send_buffer(struct hn_softc *sc); static int hv_nv_destroy_rx_buffer(struct hn_softc *sc); -static int hv_nv_connect_to_vsp(struct hn_softc *sc); -static void hv_nv_on_send_completion(struct hn_softc *sc, - struct vmbus_channel *, const struct vmbus_chanpkt_hdr *pkt); -static void hv_nv_on_receive_completion(struct vmbus_channel *chan, - uint64_t tid); -static void hv_nv_on_receive(struct hn_softc *sc, - struct hn_rx_ring *rxr, struct vmbus_channel *chan, - const struct vmbus_chanpkt_hdr *pkt); +static int hv_nv_connect_to_vsp(struct hn_softc *sc, int mtu); static void hn_nvs_sent_none(struct hn_send_ctx *sndc, struct hn_softc *, struct vmbus_channel *chan, const void *, int); @@ -77,6 +68,13 @@ static void hn_nvs_sent_none(struct hn_s struct hn_send_ctx hn_send_ctx_none = HN_SEND_CTX_INITIALIZER(hn_nvs_sent_none, NULL); +static const uint32_t hn_nvs_version[] = { + HN_NVS_VERSION_5, + HN_NVS_VERSION_4, + HN_NVS_VERSION_2, + HN_NVS_VERSION_1 +}; + uint32_t hn_chim_alloc(struct hn_softc *sc) { @@ -162,17 +160,22 @@ hn_nvs_req_send(struct hn_softc *sc, voi * Hyper-V extensible switch and the synthetic data path. */ static int -hv_nv_init_rx_buffer_with_net_vsp(struct hn_softc *sc, int rxbuf_size) +hv_nv_init_rx_buffer_with_net_vsp(struct hn_softc *sc) { struct vmbus_xact *xact = NULL; struct hn_nvs_rxbuf_conn *conn; const struct hn_nvs_rxbuf_connresp *resp; size_t resp_len; uint32_t status; - int error; + int error, rxbuf_size; - KASSERT(rxbuf_size <= NETVSC_RECEIVE_BUFFER_SIZE, - ("invalid rxbuf size %d", rxbuf_size)); + /* + * Limit RXBUF size for old NVS. + */ + if (sc->hn_nvs_ver <= HN_NVS_VERSION_2) + rxbuf_size = NETVSC_RECEIVE_BUFFER_SIZE_LEGACY; + else + rxbuf_size = NETVSC_RECEIVE_BUFFER_SIZE; /* * Connect the RXBUF GPADL to the primary channel. @@ -427,7 +430,7 @@ hv_nv_destroy_send_buffer(struct hn_soft } static int -hv_nv_negotiate_nvsp_protocol(struct hn_softc *sc, uint32_t nvs_ver) +hn_nvs_doinit(struct hn_softc *sc, uint32_t nvs_ver) { struct vmbus_xact *xact; struct hn_nvs_init *init; @@ -488,57 +491,55 @@ hv_nv_send_ndis_config(struct hn_softc * return (error); } -/* - * Net VSC connect to VSP - */ static int -hv_nv_connect_to_vsp(struct hn_softc *sc) +hn_nvs_init(struct hn_softc *sc) { - uint32_t protocol_list[] = { NVSP_PROTOCOL_VERSION_1, - NVSP_PROTOCOL_VERSION_2, - NVSP_PROTOCOL_VERSION_4, - NVSP_PROTOCOL_VERSION_5 }; int i; - int protocol_number = nitems(protocol_list); - int ret = 0; - device_t dev = sc->hn_dev; - struct ifnet *ifp = sc->arpcom.ac_ifp; - struct hn_nvs_ndis_init ndis; - int rxbuf_size; - /* - * Negotiate the NVSP version. Try the latest NVSP first. - */ - for (i = protocol_number - 1; i >= 0; i--) { - if (hv_nv_negotiate_nvsp_protocol(sc, protocol_list[i]) == 0) { - sc->hn_nvs_ver = protocol_list[i]; + for (i = 0; i < nitems(hn_nvs_version); ++i) { + int error; + + error = hn_nvs_doinit(sc, hn_nvs_version[i]); + if (!error) { + sc->hn_nvs_ver = hn_nvs_version[i]; + + /* Set NDIS version according to NVS version. */ sc->hn_ndis_ver = HN_NDIS_VERSION_6_30; - if (sc->hn_nvs_ver <= NVSP_PROTOCOL_VERSION_4) + if (sc->hn_nvs_ver <= HN_NVS_VERSION_4) sc->hn_ndis_ver = HN_NDIS_VERSION_6_1; + if (bootverbose) { if_printf(sc->hn_ifp, "NVS version 0x%x, " - "NDIS version %u.%u\n", - sc->hn_nvs_ver, + "NDIS version %u.%u\n", sc->hn_nvs_ver, HN_NDIS_VERSION_MAJOR(sc->hn_ndis_ver), HN_NDIS_VERSION_MINOR(sc->hn_ndis_ver)); } - break; + return (0); } } + if_printf(sc->hn_ifp, "no NVS available\n"); + return (ENXIO); +} - if (i < 0) { - if (bootverbose) - device_printf(dev, "failed to negotiate a valid " - "protocol.\n"); - return (EPROTO); - } +/* + * Net VSC connect to VSP + */ +static int +hv_nv_connect_to_vsp(struct hn_softc *sc, int mtu) +{ + int ret = 0; + struct hn_nvs_ndis_init ndis; + + ret = hn_nvs_init(sc); + if (ret != 0) + return (ret); /* * Set the MTU if supported by this NVSP protocol version * This needs to be right after the NVSP init message per Haiyang */ - if (sc->hn_nvs_ver >= NVSP_PROTOCOL_VERSION_2) - ret = hv_nv_send_ndis_config(sc, ifp->if_mtu); + if (sc->hn_nvs_ver >= HN_NVS_VERSION_2) + ret = hv_nv_send_ndis_config(sc, mtu); /* * Initialize NDIS. @@ -556,13 +557,7 @@ hv_nv_connect_to_vsp(struct hn_softc *sc goto cleanup; } - /* Post the big receive buffer to NetVSP */ - if (sc->hn_nvs_ver <= NVSP_PROTOCOL_VERSION_2) - rxbuf_size = NETVSC_RECEIVE_BUFFER_SIZE_LEGACY; - else - rxbuf_size = NETVSC_RECEIVE_BUFFER_SIZE; - - ret = hv_nv_init_rx_buffer_with_net_vsp(sc, rxbuf_size); + ret = hv_nv_init_rx_buffer_with_net_vsp(sc); if (ret == 0) ret = hv_nv_init_send_buffer_with_net_vsp(sc); @@ -580,54 +575,19 @@ hv_nv_disconnect_from_vsp(struct hn_soft hv_nv_destroy_send_buffer(sc); } -void -hv_nv_subchan_attach(struct vmbus_channel *chan, struct hn_rx_ring *rxr) -{ - KASSERT(rxr->hn_rx_idx == vmbus_chan_subidx(chan), - ("chan%u subidx %u, rxr%d mismatch", - vmbus_chan_id(chan), vmbus_chan_subidx(chan), rxr->hn_rx_idx)); - vmbus_chan_open(chan, NETVSC_DEVICE_RING_BUFFER_SIZE, - NETVSC_DEVICE_RING_BUFFER_SIZE, NULL, 0, - hv_nv_on_channel_callback, rxr); -} - /* * Net VSC on device add * * Callback when the device belonging to this driver is added */ int -hv_nv_on_device_add(struct hn_softc *sc, struct hn_rx_ring *rxr) +hv_nv_on_device_add(struct hn_softc *sc, int mtu) { - struct vmbus_channel *chan = sc->hn_prichan; - int ret = 0; - - /* - * Open the channel - */ - KASSERT(rxr->hn_rx_idx == vmbus_chan_subidx(chan), - ("chan%u subidx %u, rxr%d mismatch", - vmbus_chan_id(chan), vmbus_chan_subidx(chan), rxr->hn_rx_idx)); - ret = vmbus_chan_open(chan, - NETVSC_DEVICE_RING_BUFFER_SIZE, NETVSC_DEVICE_RING_BUFFER_SIZE, - NULL, 0, hv_nv_on_channel_callback, rxr); - if (ret != 0) - goto cleanup; /* * Connect with the NetVsp */ - ret = hv_nv_connect_to_vsp(sc); - if (ret != 0) - goto close; - - return (0); - -close: - /* Now, we can close the channel safely */ - vmbus_chan_close(chan); -cleanup: - return (ret); + return (hv_nv_connect_to_vsp(sc, mtu)); } /* @@ -683,25 +643,6 @@ hn_chim_free(struct hn_softc *sc, uint32 } /* - * Net VSC on send completion - */ -static void -hv_nv_on_send_completion(struct hn_softc *sc, struct vmbus_channel *chan, - const struct vmbus_chanpkt_hdr *pkt) -{ - struct hn_send_ctx *sndc; - - sndc = (struct hn_send_ctx *)(uintptr_t)pkt->cph_xactid; - sndc->hn_cb(sndc, sc, chan, VMBUS_CHANPKT_CONST_DATA(pkt), - VMBUS_CHANPKT_DATALEN(pkt)); - /* - * NOTE: - * 'sndc' CAN NOT be accessed anymore, since it can be freed by - * its callback. - */ -} - -/* * Net VSC on send * Sends a packet on the specified Hyper-V device. * Returns 0 on success, non-zero on failure. @@ -728,190 +669,3 @@ hv_nv_on_send(struct vmbus_channel *chan return (ret); } - -/* - * Net VSC on receive - * - * In the FreeBSD Hyper-V virtual world, this function deals exclusively - * with virtual addresses. - */ -static void -hv_nv_on_receive(struct hn_softc *sc, struct hn_rx_ring *rxr, - struct vmbus_channel *chan, const struct vmbus_chanpkt_hdr *pkthdr) -{ - const struct vmbus_chanpkt_rxbuf *pkt; - const struct hn_nvs_hdr *nvs_hdr; - int count, i, hlen; - - if (__predict_false(VMBUS_CHANPKT_DATALEN(pkthdr) < sizeof(*nvs_hdr))) { - if_printf(rxr->hn_ifp, "invalid nvs RNDIS\n"); - return; - } - nvs_hdr = VMBUS_CHANPKT_CONST_DATA(pkthdr); - - /* Make sure that this is a RNDIS message. */ - if (__predict_false(nvs_hdr->nvs_type != HN_NVS_TYPE_RNDIS)) { - if_printf(rxr->hn_ifp, "nvs type %u, not RNDIS\n", - nvs_hdr->nvs_type); - return; - } - - hlen = VMBUS_CHANPKT_GETLEN(pkthdr->cph_hlen); - if (__predict_false(hlen < sizeof(*pkt))) { - if_printf(rxr->hn_ifp, "invalid rxbuf chanpkt\n"); - return; - } - pkt = (const struct vmbus_chanpkt_rxbuf *)pkthdr; - - if (__predict_false(pkt->cp_rxbuf_id != HN_NVS_RXBUF_SIG)) { - if_printf(rxr->hn_ifp, "invalid rxbuf_id 0x%08x\n", - pkt->cp_rxbuf_id); - return; - } - - count = pkt->cp_rxbuf_cnt; - if (__predict_false(hlen < - __offsetof(struct vmbus_chanpkt_rxbuf, cp_rxbuf[count]))) { - if_printf(rxr->hn_ifp, "invalid rxbuf_cnt %d\n", count); - return; - } - - /* Each range represents 1 RNDIS pkt that contains 1 Ethernet frame */ - for (i = 0; i < count; ++i) { - int ofs, len; - - ofs = pkt->cp_rxbuf[i].rb_ofs; - len = pkt->cp_rxbuf[i].rb_len; - if (__predict_false(ofs + len > NETVSC_RECEIVE_BUFFER_SIZE)) { - if_printf(rxr->hn_ifp, "%dth RNDIS msg overflow rxbuf, " - "ofs %d, len %d\n", i, ofs, len); - continue; - } - hv_rf_on_receive(sc, rxr, rxr->hn_rxbuf + ofs, len); - } - - /* - * Moved completion call back here so that all received - * messages (not just data messages) will trigger a response - * message back to the host. - */ - hv_nv_on_receive_completion(chan, pkt->cp_hdr.cph_xactid); -} - -/* - * Net VSC on receive completion - * - * Send a receive completion packet to RNDIS device (ie NetVsp) - */ -static void -hv_nv_on_receive_completion(struct vmbus_channel *chan, uint64_t tid) -{ - struct hn_nvs_rndis_ack ack; - int retries = 0; - int ret = 0; - - ack.nvs_type = HN_NVS_TYPE_RNDIS_ACK; - ack.nvs_status = HN_NVS_STATUS_OK; - -retry_send_cmplt: - /* Send the completion */ - ret = vmbus_chan_send(chan, VMBUS_CHANPKT_TYPE_COMP, - VMBUS_CHANPKT_FLAG_NONE, &ack, sizeof(ack), tid); - if (ret == 0) { - /* success */ - /* no-op */ - } else if (ret == EAGAIN) { - /* no more room... wait a bit and attempt to retry 3 times */ - retries++; - - if (retries < 4) { - DELAY(100); - goto retry_send_cmplt; - } - } -} - -static void -hn_proc_notify(struct hn_softc *sc, const struct vmbus_chanpkt_hdr *pkt) -{ - const struct hn_nvs_hdr *hdr; - - if (VMBUS_CHANPKT_DATALEN(pkt) < sizeof(*hdr)) { - if_printf(sc->hn_ifp, "invalid nvs notify\n"); - return; - } - hdr = VMBUS_CHANPKT_CONST_DATA(pkt); - - if (hdr->nvs_type == HN_NVS_TYPE_TXTBL_NOTE) { - /* Useless; ignore */ - return; - } - if_printf(sc->hn_ifp, "got notify, nvs type %u\n", hdr->nvs_type); -} - -/* - * Net VSC on channel callback - */ -static void -hv_nv_on_channel_callback(struct vmbus_channel *chan, void *xrxr) -{ - struct hn_rx_ring *rxr = xrxr; - struct hn_softc *sc = rxr->hn_ifp->if_softc; - void *buffer; - int bufferlen = NETVSC_PACKET_SIZE; - - buffer = rxr->hn_rdbuf; - do { - struct vmbus_chanpkt_hdr *pkt = buffer; - uint32_t bytes_rxed; - int ret; - - bytes_rxed = bufferlen; - ret = vmbus_chan_recv_pkt(chan, pkt, &bytes_rxed); - if (ret == 0) { - if (bytes_rxed > 0) { - switch (pkt->cph_type) { - case VMBUS_CHANPKT_TYPE_COMP: - hv_nv_on_send_completion(sc, chan, pkt); - break; - case VMBUS_CHANPKT_TYPE_RXBUF: - hv_nv_on_receive(sc, rxr, chan, pkt); - break; - case VMBUS_CHANPKT_TYPE_INBAND: - hn_proc_notify(sc, pkt); - break; - default: - if_printf(rxr->hn_ifp, - "unknown chan pkt %u\n", - pkt->cph_type); - break; - } - } - } else if (ret == ENOBUFS) { - /* Handle large packet */ - if (bufferlen > NETVSC_PACKET_SIZE) { - free(buffer, M_NETVSC); - buffer = NULL; - } - - /* alloc new buffer */ - buffer = malloc(bytes_rxed, M_NETVSC, M_NOWAIT); - if (buffer == NULL) { - if_printf(rxr->hn_ifp, - "hv_cb malloc buffer failed, len=%u\n", - bytes_rxed); - bufferlen = 0; - break; - } - bufferlen = bytes_rxed; - } else { - /* No more packets */ - break; - } - } while (1); - - if (bufferlen > NETVSC_PACKET_SIZE) - free(buffer, M_NETVSC); - - hv_rf_channel_rollup(rxr, rxr->hn_txr); -} Modified: stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h Thu Oct 13 07:52:39 2016 (r307199) +++ stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h Thu Oct 13 08:01:38 2016 (r307200) @@ -68,13 +68,6 @@ MALLOC_DECLARE(M_NETVSC); -#define NVSP_INVALID_PROTOCOL_VERSION (0xFFFFFFFF) - -#define NVSP_PROTOCOL_VERSION_1 2 -#define NVSP_PROTOCOL_VERSION_2 0x30002 -#define NVSP_PROTOCOL_VERSION_4 0x40000 -#define NVSP_PROTOCOL_VERSION_5 0x50000 - /* * The following arguably belongs in a separate header file */ @@ -269,12 +262,10 @@ extern int hv_promisc_mode; struct hn_send_ctx; void netvsc_linkstatus_callback(struct hn_softc *sc, uint32_t status); -int hv_nv_on_device_add(struct hn_softc *sc, struct hn_rx_ring *rxr); +int hv_nv_on_device_add(struct hn_softc *sc, int mtu); int hv_nv_on_device_remove(struct hn_softc *sc); int hv_nv_on_send(struct vmbus_channel *chan, uint32_t rndis_mtype, struct hn_send_ctx *sndc, struct vmbus_gpa *gpa, int gpa_cnt); -void hv_nv_subchan_attach(struct vmbus_channel *chan, - struct hn_rx_ring *rxr); #endif /* __HV_NET_VSC_H__ */ Modified: stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Thu Oct 13 07:52:39 2016 (r307199) +++ stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Thu Oct 13 08:01:38 2016 (r307200) @@ -348,9 +348,18 @@ static int hn_encap(struct hn_tx_ring *, static int hn_create_rx_data(struct hn_softc *sc, int); static void hn_destroy_rx_data(struct hn_softc *sc); static void hn_set_chim_size(struct hn_softc *, int); -static void hn_channel_attach(struct hn_softc *, struct vmbus_channel *); -static void hn_subchan_attach(struct hn_softc *, struct vmbus_channel *); -static void hn_subchan_setup(struct hn_softc *); +static int hn_chan_attach(struct hn_softc *, struct vmbus_channel *); +static int hn_attach_subchans(struct hn_softc *); +static void hn_chan_callback(struct vmbus_channel *chan, void *xrxr); + +static void hn_nvs_handle_notify(struct hn_softc *sc, + const struct vmbus_chanpkt_hdr *pkt); +static void hn_nvs_handle_comp(struct hn_softc *sc, struct vmbus_channel *chan, + const struct vmbus_chanpkt_hdr *pkt); +static void hn_nvs_handle_rxbuf(struct hn_softc *sc, struct hn_rx_ring *rxr, + struct vmbus_channel *chan, + const struct vmbus_chanpkt_hdr *pkthdr); +static void hn_nvs_ack_rxbuf(struct vmbus_channel *chan, uint64_t tid); static int hn_transmit(struct ifnet *, struct mbuf *); static void hn_xmit_qflush(struct ifnet *); @@ -528,12 +537,13 @@ netvsc_attach(device_t dev) /* * Associate the first TX/RX ring w/ the primary channel. */ - hn_channel_attach(sc, sc->hn_prichan); + error = hn_chan_attach(sc, sc->hn_prichan); + if (error) + goto failed; ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; ifp->if_ioctl = hn_ioctl; ifp->if_init = hn_ifinit; - /* needed by hv_rf_on_device_add() code */ ifp->if_mtu = ETHERMTU; if (hn_use_if_start) { int qdepth = hn_get_txswq_depth(&sc->hn_tx_ring[0]); @@ -570,8 +580,7 @@ netvsc_attach(device_t dev) if (sc->hn_xact == NULL) goto failed; - error = hv_rf_on_device_add(sc, &device_info, &ring_cnt, - &sc->hn_rx_ring[0]); + error = hv_rf_on_device_add(sc, &device_info, &ring_cnt, ETHERMTU); if (error) goto failed; KASSERT(ring_cnt > 0 && ring_cnt <= sc->hn_rx_ring_inuse, @@ -588,8 +597,11 @@ netvsc_attach(device_t dev) device_printf(dev, "%d TX ring, %d RX ring\n", sc->hn_tx_ring_inuse, sc->hn_rx_ring_inuse); - if (sc->hn_rx_ring_inuse > 1) - hn_subchan_setup(sc); + if (sc->hn_rx_ring_inuse > 1) { + error = hn_attach_subchans(sc); + if (error) + goto failed; + } #if __FreeBSD_version >= 1100099 if (sc->hn_rx_ring_inuse > 1) { @@ -1582,9 +1594,13 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, /* Wait for subchannels to be destroyed */ vmbus_subchan_drain(sc->hn_prichan); + sc->hn_rx_ring[0].hn_rx_flags &= ~HN_RX_FLAG_ATTACHED; + sc->hn_tx_ring[0].hn_tx_flags &= ~HN_TX_FLAG_ATTACHED; + hn_chan_attach(sc, sc->hn_prichan); /* XXX check error */ + ring_cnt = sc->hn_rx_ring_inuse; error = hv_rf_on_device_add(sc, &device_info, &ring_cnt, - &sc->hn_rx_ring[0]); + ifr->ifr_mtu); if (error) { NV_LOCK(sc); sc->temp_unusable = FALSE; @@ -1610,7 +1626,7 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, sc->hn_tx_ring[r].hn_tx_flags &= ~HN_TX_FLAG_ATTACHED; } - hn_subchan_setup(sc); + hn_attach_subchans(sc); /* XXX check error */ } if (sc->hn_tx_ring[0].hn_chim_size > sc->hn_chim_szmax) @@ -3003,14 +3019,18 @@ hn_xmit_txeof_taskfunc(void *xtxr, int p mtx_unlock(&txr->hn_tx_lock); } -static void -hn_channel_attach(struct hn_softc *sc, struct vmbus_channel *chan) +static int +hn_chan_attach(struct hn_softc *sc, struct vmbus_channel *chan) { struct hn_rx_ring *rxr; - int idx; + struct hn_tx_ring *txr = NULL; + int idx, error; idx = vmbus_chan_subidx(chan); + /* + * Link this channel to RX/TX ring. + */ KASSERT(idx >= 0 && idx < sc->hn_rx_ring_inuse, ("invalid channel index %d, should > 0 && < %d", idx, sc->hn_rx_ring_inuse)); @@ -3020,60 +3040,260 @@ hn_channel_attach(struct hn_softc *sc, s rxr->hn_rx_flags |= HN_RX_FLAG_ATTACHED; if (bootverbose) { - if_printf(sc->hn_ifp, "link RX ring %d to channel%u\n", + if_printf(sc->hn_ifp, "link RX ring %d to chan%u\n", idx, vmbus_chan_id(chan)); } if (idx < sc->hn_tx_ring_inuse) { - struct hn_tx_ring *txr = &sc->hn_tx_ring[idx]; - + txr = &sc->hn_tx_ring[idx]; KASSERT((txr->hn_tx_flags & HN_TX_FLAG_ATTACHED) == 0, ("TX ring %d already attached", idx)); txr->hn_tx_flags |= HN_TX_FLAG_ATTACHED; txr->hn_chan = chan; if (bootverbose) { - if_printf(sc->hn_ifp, "link TX ring %d to channel%u\n", + if_printf(sc->hn_ifp, "link TX ring %d to chan%u\n", idx, vmbus_chan_id(chan)); } } - /* Bind channel to a proper CPU */ + /* Bind this channel to a proper CPU. */ vmbus_chan_cpu_set(chan, (sc->hn_cpu + idx) % mp_ncpus); -} - -static void -hn_subchan_attach(struct hn_softc *sc, struct vmbus_channel *chan) -{ - KASSERT(!vmbus_chan_is_primary(chan), - ("subchannel callback on primary channel")); - hn_channel_attach(sc, chan); + /* Open this channel */ + error = vmbus_chan_open(chan, NETVSC_DEVICE_RING_BUFFER_SIZE, + NETVSC_DEVICE_RING_BUFFER_SIZE, NULL, 0, hn_chan_callback, rxr); + if (error) { + if_printf(sc->hn_ifp, "open chan%u failed: %d\n", + vmbus_chan_id(chan), error); + rxr->hn_rx_flags &= ~HN_RX_FLAG_ATTACHED; + if (txr != NULL) + txr->hn_tx_flags &= ~HN_TX_FLAG_ATTACHED; + } + return (error); } -static void -hn_subchan_setup(struct hn_softc *sc) +static int +hn_attach_subchans(struct hn_softc *sc) { struct vmbus_channel **subchans; int subchan_cnt = sc->hn_rx_ring_inuse - 1; - int i; + int i, error = 0; /* Wait for sub-channels setup to complete. */ subchans = vmbus_subchan_get(sc->hn_prichan, subchan_cnt); /* Attach the sub-channels. */ for (i = 0; i < subchan_cnt; ++i) { - struct vmbus_channel *subchan = subchans[i]; - - /* NOTE: Calling order is critical. */ - hn_subchan_attach(sc, subchan); - hv_nv_subchan_attach(subchan, - &sc->hn_rx_ring[vmbus_chan_subidx(subchan)]); + error = hn_chan_attach(sc, subchans[i]); + if (error) + break; } /* Release the sub-channels */ vmbus_subchan_rel(subchans, subchan_cnt); - if_printf(sc->hn_ifp, "%d sub-channels setup done\n", subchan_cnt); + + if (error) { + if_printf(sc->hn_ifp, "sub-channels attach failed: %d\n", error); + } else { + if (bootverbose) { + if_printf(sc->hn_ifp, "%d sub-channels attached\n", + subchan_cnt); + } + } + return (error); +} + +static void +hn_nvs_handle_notify(struct hn_softc *sc, const struct vmbus_chanpkt_hdr *pkt) +{ + const struct hn_nvs_hdr *hdr; + + if (VMBUS_CHANPKT_DATALEN(pkt) < sizeof(*hdr)) { + if_printf(sc->hn_ifp, "invalid nvs notify\n"); + return; + } + hdr = VMBUS_CHANPKT_CONST_DATA(pkt); + + if (hdr->nvs_type == HN_NVS_TYPE_TXTBL_NOTE) { + /* Useless; ignore */ + return; + } + if_printf(sc->hn_ifp, "got notify, nvs type %u\n", hdr->nvs_type); +} + +static void +hn_nvs_handle_comp(struct hn_softc *sc, struct vmbus_channel *chan, + const struct vmbus_chanpkt_hdr *pkt) +{ + struct hn_send_ctx *sndc; + + sndc = (struct hn_send_ctx *)(uintptr_t)pkt->cph_xactid; + sndc->hn_cb(sndc, sc, chan, VMBUS_CHANPKT_CONST_DATA(pkt), + VMBUS_CHANPKT_DATALEN(pkt)); + /* + * NOTE: + * 'sndc' CAN NOT be accessed anymore, since it can be freed by + * its callback. + */ +} + +static void +hn_nvs_handle_rxbuf(struct hn_softc *sc, struct hn_rx_ring *rxr, + struct vmbus_channel *chan, const struct vmbus_chanpkt_hdr *pkthdr) +{ + const struct vmbus_chanpkt_rxbuf *pkt; + const struct hn_nvs_hdr *nvs_hdr; + int count, i, hlen; + + if (__predict_false(VMBUS_CHANPKT_DATALEN(pkthdr) < sizeof(*nvs_hdr))) { + if_printf(rxr->hn_ifp, "invalid nvs RNDIS\n"); + return; + } + nvs_hdr = VMBUS_CHANPKT_CONST_DATA(pkthdr); + + /* Make sure that this is a RNDIS message. */ + if (__predict_false(nvs_hdr->nvs_type != HN_NVS_TYPE_RNDIS)) { + if_printf(rxr->hn_ifp, "nvs type %u, not RNDIS\n", + nvs_hdr->nvs_type); + return; + } + + hlen = VMBUS_CHANPKT_GETLEN(pkthdr->cph_hlen); + if (__predict_false(hlen < sizeof(*pkt))) { + if_printf(rxr->hn_ifp, "invalid rxbuf chanpkt\n"); + return; + } + pkt = (const struct vmbus_chanpkt_rxbuf *)pkthdr; + + if (__predict_false(pkt->cp_rxbuf_id != HN_NVS_RXBUF_SIG)) { + if_printf(rxr->hn_ifp, "invalid rxbuf_id 0x%08x\n", + pkt->cp_rxbuf_id); + return; + } + + count = pkt->cp_rxbuf_cnt; + if (__predict_false(hlen < + __offsetof(struct vmbus_chanpkt_rxbuf, cp_rxbuf[count]))) { + if_printf(rxr->hn_ifp, "invalid rxbuf_cnt %d\n", count); + return; + } + + /* Each range represents 1 RNDIS pkt that contains 1 Ethernet frame */ + for (i = 0; i < count; ++i) { + int ofs, len; + + ofs = pkt->cp_rxbuf[i].rb_ofs; + len = pkt->cp_rxbuf[i].rb_len; + if (__predict_false(ofs + len > NETVSC_RECEIVE_BUFFER_SIZE)) { + if_printf(rxr->hn_ifp, "%dth RNDIS msg overflow rxbuf, " + "ofs %d, len %d\n", i, ofs, len); + continue; + } + hv_rf_on_receive(sc, rxr, rxr->hn_rxbuf + ofs, len); + } + + /* + * Moved completion call back here so that all received + * messages (not just data messages) will trigger a response + * message back to the host. + */ + hn_nvs_ack_rxbuf(chan, pkt->cp_hdr.cph_xactid); +} + +/* + * Net VSC on receive completion + * + * Send a receive completion packet to RNDIS device (ie NetVsp) + */ +static void +hn_nvs_ack_rxbuf(struct vmbus_channel *chan, uint64_t tid) +{ + struct hn_nvs_rndis_ack ack; + int retries = 0; + int ret = 0; + + ack.nvs_type = HN_NVS_TYPE_RNDIS_ACK; + ack.nvs_status = HN_NVS_STATUS_OK; + +retry_send_cmplt: + /* Send the completion */ + ret = vmbus_chan_send(chan, VMBUS_CHANPKT_TYPE_COMP, + VMBUS_CHANPKT_FLAG_NONE, &ack, sizeof(ack), tid); + if (ret == 0) { + /* success */ + /* no-op */ + } else if (ret == EAGAIN) { + /* no more room... wait a bit and attempt to retry 3 times */ + retries++; + + if (retries < 4) { + DELAY(100); + goto retry_send_cmplt; + } + } +} + +static void +hn_chan_callback(struct vmbus_channel *chan, void *xrxr) +{ + struct hn_rx_ring *rxr = xrxr; + struct hn_softc *sc = rxr->hn_ifp->if_softc; + void *buffer; + int bufferlen = NETVSC_PACKET_SIZE; + + buffer = rxr->hn_rdbuf; + do { + struct vmbus_chanpkt_hdr *pkt = buffer; + uint32_t bytes_rxed; + int ret; + + bytes_rxed = bufferlen; + ret = vmbus_chan_recv_pkt(chan, pkt, &bytes_rxed); + if (ret == 0) { + switch (pkt->cph_type) { + case VMBUS_CHANPKT_TYPE_COMP: + hn_nvs_handle_comp(sc, chan, pkt); + break; + case VMBUS_CHANPKT_TYPE_RXBUF: + hn_nvs_handle_rxbuf(sc, rxr, chan, pkt); + break; + case VMBUS_CHANPKT_TYPE_INBAND: + hn_nvs_handle_notify(sc, pkt); + break; + default: + if_printf(rxr->hn_ifp, + "unknown chan pkt %u\n", + pkt->cph_type); + break; + } + } else if (ret == ENOBUFS) { + /* Handle large packet */ + if (bufferlen > NETVSC_PACKET_SIZE) { + free(buffer, M_NETVSC); + buffer = NULL; + } + + /* alloc new buffer */ + buffer = malloc(bytes_rxed, M_NETVSC, M_NOWAIT); + if (buffer == NULL) { + if_printf(rxr->hn_ifp, + "hv_cb malloc buffer failed, len=%u\n", + bytes_rxed); + bufferlen = 0; + break; + } + bufferlen = bytes_rxed; + } else { + /* No more packets */ + break; + } + } while (1); + + if (bufferlen > NETVSC_PACKET_SIZE) + free(buffer, M_NETVSC); + + hv_rf_channel_rollup(rxr, rxr->hn_txr); } static void Modified: stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.c Thu Oct 13 07:52:39 2016 (r307199) +++ stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.c Thu Oct 13 08:01:38 2016 (r307200) @@ -1013,7 +1013,7 @@ hv_rf_halt_device(struct hn_softc *sc) */ int hv_rf_on_device_add(struct hn_softc *sc, void *additl_info, - int *nchan0, struct hn_rx_ring *rxr) + int *nchan0, int mtu) { int ret; netvsc_device_info *dev_info = (netvsc_device_info *)additl_info; @@ -1032,7 +1032,7 @@ hv_rf_on_device_add(struct hn_softc *sc, * (hv_rf_on_receive()) before this call is completed. * Note: Earlier code used a function pointer here. */ - ret = hv_nv_on_device_add(sc, rxr); + ret = hv_nv_on_device_add(sc, mtu); if (ret != 0) return (ret); Modified: stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.h ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.h Thu Oct 13 07:52:39 2016 (r307199) +++ stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.h Thu Oct 13 08:01:38 2016 (r307200) @@ -44,7 +44,7 @@ void hv_rf_on_receive(struct hn_softc *s const void *data, int dlen); void hv_rf_channel_rollup(struct hn_rx_ring *rxr, struct hn_tx_ring *txr); int hv_rf_on_device_add(struct hn_softc *sc, void *additl_info, int *nchan, - struct hn_rx_ring *rxr); + int mtu); int hv_rf_on_device_remove(struct hn_softc *sc); int hv_rf_on_open(struct hn_softc *sc); int hv_rf_on_close(struct hn_softc *sc); Modified: stable/10/sys/dev/hyperv/netvsc/if_hnreg.h ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/if_hnreg.h Thu Oct 13 07:52:39 2016 (r307199) +++ stable/10/sys/dev/hyperv/netvsc/if_hnreg.h Thu Oct 13 08:01:38 2016 (r307200) @@ -40,6 +40,14 @@ #define HN_NDIS_VERSION_MAJOR(ver) (((ver) & 0xffff0000) >> 16) #define HN_NDIS_VERSION_MINOR(ver) ((ver) & 0xffff) +/* + * NVS versions. + */ +#define HN_NVS_VERSION_1 0x00002 +#define HN_NVS_VERSION_2 0x30002 +#define HN_NVS_VERSION_4 0x40000 +#define HN_NVS_VERSION_5 0x50000 + #define HN_NVS_RXBUF_SIG 0xcafe #define HN_NVS_CHIM_SIG 0xface From owner-svn-src-all@freebsd.org Thu Oct 13 08:03:49 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 84045C0F27E; Thu, 13 Oct 2016 08:03:49 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 379F984F; Thu, 13 Oct 2016 08:03:49 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9D83mLp030787; Thu, 13 Oct 2016 08:03:48 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9D83mTI030786; Thu, 13 Oct 2016 08:03:48 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610130803.u9D83mTI030786@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Thu, 13 Oct 2016 08:03:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307201 - stable/10/sys/dev/hyperv/utilities X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Oct 2016 08:03:49 -0000 Author: sephe Date: Thu Oct 13 08:03:48 2016 New Revision: 307201 URL: https://svnweb.freebsd.org/changeset/base/307201 Log: MFC 305585 hyperv/kvp: Fix IPv4/IPv6 address injection support. The GUID string provided by hypervisor has leading and trailing braces, while our GUID string does not have braces at all. Both braces should be ignored, when the GUID strings are compared. Submitted by: Hongjiang Zhang Modified by: sephe Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7809 Modified: stable/10/sys/dev/hyperv/utilities/hv_kvp.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/hyperv/utilities/hv_kvp.c ============================================================================== --- stable/10/sys/dev/hyperv/utilities/hv_kvp.c Thu Oct 13 08:01:38 2016 (r307200) +++ stable/10/sys/dev/hyperv/utilities/hv_kvp.c Thu Oct 13 08:03:48 2016 (r307201) @@ -332,20 +332,23 @@ hv_kvp_convert_utf16_ipinfo_to_utf8(stru if (devclass_get_devices(devclass_find("hn"), &devs, &devcnt) == 0) { for (devcnt = devcnt - 1; devcnt >= 0; devcnt--) { - /* XXX access other driver's softc? are you kidding? */ device_t dev = devs[devcnt]; struct vmbus_channel *chan; char buf[HYPERV_GUID_STRLEN]; + int n; - /* - * Trying to find GUID of Network Device - */ chan = vmbus_get_channel(dev); - hyperv_guid2str(vmbus_chan_guid_inst(chan), - buf, sizeof(buf)); + n = hyperv_guid2str(vmbus_chan_guid_inst(chan), buf, + sizeof(buf)); - if (strncmp(buf, (char *)umsg->body.kvp_ip_val.adapter_id, - HYPERV_GUID_STRLEN - 1) == 0) { + /* + * The string in the 'kvp_ip_val.adapter_id' has + * braces around the GUID; skip the leading brace + * in 'kvp_ip_val.adapter_id'. + */ + if (strncmp(buf, + ((char *)&umsg->body.kvp_ip_val.adapter_id) + 1, + n) == 0) { strlcpy((char *)umsg->body.kvp_ip_val.adapter_id, device_get_nameunit(dev), MAX_ADAPTER_ID_SIZE); break; From owner-svn-src-all@freebsd.org Thu Oct 13 08:06:50 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 90F6BC0F393; Thu, 13 Oct 2016 08:06:50 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 6B8449E6; Thu, 13 Oct 2016 08:06:50 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9D86nQ8031074; Thu, 13 Oct 2016 08:06:49 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9D86njZ031073; Thu, 13 Oct 2016 08:06:49 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610130806.u9D86njZ031073@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Thu, 13 Oct 2016 08:06:49 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307202 - stable/10/sys/dev/hyperv/netvsc X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Oct 2016 08:06:50 -0000 Author: sephe Date: Thu Oct 13 08:06:49 2016 New Revision: 307202 URL: https://svnweb.freebsd.org/changeset/base/307202 Log: MFC 305586,305587 305586 hyperv/hn: Function renaming. While I'm here, remove obvious comment. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7810 305587 hyperv/hn: Factor out NVS NDIS initialization Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7811 Modified: stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.c Thu Oct 13 08:03:48 2016 (r307201) +++ stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.c Thu Oct 13 08:06:49 2016 (r307202) @@ -469,12 +469,10 @@ hn_nvs_doinit(struct hn_softc *sc, uint3 } /* - * Send NDIS version 2 config packet containing MTU. - * - * Not valid for NDIS version 1. + * Configure MTU and enable VLAN. */ static int -hv_nv_send_ndis_config(struct hn_softc *sc, uint32_t mtu) +hn_nvs_conf_ndis(struct hn_softc *sc, int mtu) { struct hn_nvs_ndis_conf conf; int error; @@ -492,6 +490,24 @@ hv_nv_send_ndis_config(struct hn_softc * } static int +hn_nvs_init_ndis(struct hn_softc *sc) +{ + struct hn_nvs_ndis_init ndis; + int error; + + memset(&ndis, 0, sizeof(ndis)); + ndis.nvs_type = HN_NVS_TYPE_NDIS_INIT; + ndis.nvs_ndis_major = HN_NDIS_VERSION_MAJOR(sc->hn_ndis_ver); + ndis.nvs_ndis_minor = HN_NDIS_VERSION_MINOR(sc->hn_ndis_ver); + + /* NOTE: No response. */ + error = hn_nvs_req_send(sc, &ndis, sizeof(ndis)); + if (error) + if_printf(sc->hn_ifp, "send nvs ndis init failed: %d\n", error); + return (error); +} + +static int hn_nvs_init(struct hn_softc *sc) { int i; @@ -521,47 +537,37 @@ hn_nvs_init(struct hn_softc *sc) return (ENXIO); } -/* - * Net VSC connect to VSP - */ static int hv_nv_connect_to_vsp(struct hn_softc *sc, int mtu) { - int ret = 0; - struct hn_nvs_ndis_init ndis; + int ret; + /* + * Initialize NVS. + */ ret = hn_nvs_init(sc); if (ret != 0) return (ret); - /* - * Set the MTU if supported by this NVSP protocol version - * This needs to be right after the NVSP init message per Haiyang - */ - if (sc->hn_nvs_ver >= HN_NVS_VERSION_2) - ret = hv_nv_send_ndis_config(sc, mtu); + if (sc->hn_nvs_ver >= HN_NVS_VERSION_2) { + /* + * Configure NDIS before initializing it. + */ + ret = hn_nvs_conf_ndis(sc, mtu); + if (ret != 0) + return (ret); + } /* * Initialize NDIS. */ - - memset(&ndis, 0, sizeof(ndis)); - ndis.nvs_type = HN_NVS_TYPE_NDIS_INIT; - ndis.nvs_ndis_major = HN_NDIS_VERSION_MAJOR(sc->hn_ndis_ver); - ndis.nvs_ndis_minor = HN_NDIS_VERSION_MINOR(sc->hn_ndis_ver); - - /* NOTE: No response. */ - ret = hn_nvs_req_send(sc, &ndis, sizeof(ndis)); - if (ret != 0) { - if_printf(sc->hn_ifp, "send nvs ndis init failed: %d\n", ret); - goto cleanup; - } + ret = hn_nvs_init_ndis(sc); + if (ret != 0) + return (ret); ret = hv_nv_init_rx_buffer_with_net_vsp(sc); if (ret == 0) ret = hv_nv_init_send_buffer_with_net_vsp(sc); - -cleanup: return (ret); } From owner-svn-src-all@freebsd.org Thu Oct 13 08:09:42 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 04C5FC0F51B; Thu, 13 Oct 2016 08:09:42 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id D5EECD9C; Thu, 13 Oct 2016 08:09:41 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9D89f4g031338; Thu, 13 Oct 2016 08:09:41 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9D89eO8031336; Thu, 13 Oct 2016 08:09:40 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610130809.u9D89eO8031336@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Thu, 13 Oct 2016 08:09:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307203 - in stable/10: lib/libstand sys/boot/i386/pxeldr X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Oct 2016 08:09:42 -0000 Author: sephe Date: Thu Oct 13 08:09:40 2016 New Revision: 307203 URL: https://svnweb.freebsd.org/changeset/base/307203 Log: MFC 305588 pxeboot: Add nfs.read_size tunable. Increase this tunable improves kernel loading speed. Submitted by: Jun Su Reviewed by: rpokala, wblock (previous version) Obtained from: DragonFlyBSD Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7756 Modified: stable/10/lib/libstand/nfs.c stable/10/sys/boot/i386/pxeldr/pxeboot.8 Directory Properties: stable/10/ (props changed) Modified: stable/10/lib/libstand/nfs.c ============================================================================== --- stable/10/lib/libstand/nfs.c Thu Oct 13 08:06:49 2016 (r307202) +++ stable/10/lib/libstand/nfs.c Thu Oct 13 08:09:40 2016 (r307203) @@ -36,6 +36,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -50,7 +51,8 @@ __FBSDID("$FreeBSD$"); #define NFS_DEBUGxx -#define NFSREAD_SIZE 1024 +#define NFSREAD_MIN_SIZE 1024 +#define NFSREAD_MAX_SIZE 4096 /* Define our own NFS attributes without NQNFS stuff. */ #ifdef OLD_NFSV2 @@ -83,7 +85,7 @@ struct nfs_read_repl { n_long errno; struct nfsv2_fattrs fa; n_long count; - u_char data[NFSREAD_SIZE]; + u_char data[NFSREAD_MAX_SIZE]; }; #ifndef NFS_NOSYMLINK @@ -210,6 +212,8 @@ struct fs_ops nfs_fsops = { nfs_readdir }; +static int nfs_read_size = NFSREAD_MIN_SIZE; + #ifdef OLD_NFSV2 /* * Fetch the root file handle (call mount daemon) @@ -264,6 +268,17 @@ nfs_getrootfh(struct iodesc *d, char *pa if (repl->errno) return (ntohl(repl->errno)); bcopy(repl->fh, fhp, sizeof(repl->fh)); + + /* + * Improve boot performance over NFS + */ + if (getenv("nfs.read_size") != NULL) + nfs_read_size = strtol(getenv("nfs.read_size"), NULL, 0); + if (nfs_read_size < NFSREAD_MIN_SIZE) + nfs_read_size = NFSREAD_MIN_SIZE; + if (nfs_read_size > NFSREAD_MAX_SIZE) + nfs_read_size = NFSREAD_MAX_SIZE; + return (0); } @@ -401,11 +416,11 @@ nfs_readdata(struct nfs_iodesc *d, off_t bcopy(d->fh, args->fh, NFS_FHSIZE); args->off = htonl((n_long)off); - if (len > NFSREAD_SIZE) - len = NFSREAD_SIZE; + if (len > nfs_read_size) + len = nfs_read_size; args->len = htonl((n_long)len); args->xxx = htonl((n_long)0); - hlen = sizeof(*repl) - NFSREAD_SIZE; + hlen = offsetof(struct nfs_read_rpl, data[0]); cc = rpc_call(d->iodesc, NFS_PROG, NFS_VER2, NFSPROC_READ, args, sizeof(*args), @@ -1022,7 +1037,7 @@ nfs_readdata(struct nfs_iodesc *d, off_t uint32_t count; uint32_t eof; uint32_t len; - u_char data[NFSREAD_SIZE]; + u_char data[NFSREAD_MAX_SIZE]; } *repl; struct { uint32_t h[RPC_HEADER_WORDS]; @@ -1045,10 +1060,10 @@ nfs_readdata(struct nfs_iodesc *d, off_t pos = roundup(d->fhsize, sizeof(uint32_t)) / sizeof(uint32_t); args->fhoffcnt[pos++] = 0; args->fhoffcnt[pos++] = htonl((uint32_t)off); - if (len > NFSREAD_SIZE) - len = NFSREAD_SIZE; + if (len > nfs_read_size) + len = nfs_read_size; args->fhoffcnt[pos] = htonl((uint32_t)len); - hlen = sizeof(*repl) - NFSREAD_SIZE; + hlen = offsetof(struct repl, data[0]); cc = rpc_call(d->iodesc, NFS_PROG, NFS_VER3, NFSPROCV3_READ, args, 4 * sizeof(uint32_t) + roundup(d->fhsize, sizeof(uint32_t)), Modified: stable/10/sys/boot/i386/pxeldr/pxeboot.8 ============================================================================== --- stable/10/sys/boot/i386/pxeldr/pxeboot.8 Thu Oct 13 08:06:49 2016 (r307202) +++ stable/10/sys/boot/i386/pxeldr/pxeboot.8 Thu Oct 13 08:09:40 2016 (r307203) @@ -85,6 +85,14 @@ expects to fetch .Pa /boot/loader.rc from the specified server before loading any other files. .Pp +.Nm +defaults to a conservative 1024 byte NFS data packet size. +This may be changed by setting the +.Va nfs.read_size +variable in +.Pa /boot/loader.conf . +Valid values range from 1024 to 4096 bytes. +.Pp In all other respects, .Nm acts just like From owner-svn-src-all@freebsd.org Thu Oct 13 08:27:21 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 4DEDAC0FA57; Thu, 13 Oct 2016 08:27:21 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 124ED953; Thu, 13 Oct 2016 08:27:20 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9D8RKGs038895; Thu, 13 Oct 2016 08:27:20 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9D8RK8L038894; Thu, 13 Oct 2016 08:27:20 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201610130827.u9D8RK8L038894@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Ngie Cooper Date: Thu, 13 Oct 2016 08:27:20 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307204 - head/contrib/netbsd-tests/fs/tmpfs X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Oct 2016 08:27:21 -0000 Author: ngie Date: Thu Oct 13 08:27:19 2016 New Revision: 307204 URL: https://svnweb.freebsd.org/changeset/base/307204 Log: Expect :large to fail on FreeBSD FreeBSD doesn't appear to validate large -o size values like NetBSD does MFC after: 2 weeks PR: 212862 Sponsored by: Dell EMC Isilon Modified: head/contrib/netbsd-tests/fs/tmpfs/t_mount.sh Modified: head/contrib/netbsd-tests/fs/tmpfs/t_mount.sh ============================================================================== --- head/contrib/netbsd-tests/fs/tmpfs/t_mount.sh Thu Oct 13 08:09:40 2016 (r307203) +++ head/contrib/netbsd-tests/fs/tmpfs/t_mount.sh Thu Oct 13 08:27:19 2016 (r307204) @@ -93,7 +93,18 @@ negative_body() { test_unmount } +# Begin FreeBSD +if true; then +atf_test_case large cleanup +large_cleanup() { + umount -f tmp 2>/dev/null +} +else +# End FreeBSD atf_test_case large +# Begin FreeBSD +fi +# End FreeBSD large_head() { atf_set "descr" "Tests that extremely long values passed to -s" \ "are handled correctly" @@ -103,6 +114,10 @@ large_body() { test_mount -o -s9223372036854775807 test_unmount + # Begin FreeBSD + atf_expect_fail "-o -s succeeds unexpectedly on FreeBSD - bug 212862" + # End FreeBSD + mkdir tmp atf_check -s eq:1 -o empty -e ignore \ mount -t tmpfs -o -s9223372036854775808 tmpfs tmp From owner-svn-src-all@freebsd.org Thu Oct 13 08:35:10 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 05EC5C0FC49; Thu, 13 Oct 2016 08:35:10 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id CBE06DA2; Thu, 13 Oct 2016 08:35:09 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9D8Z801042695; Thu, 13 Oct 2016 08:35:08 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9D8Z8bS042694; Thu, 13 Oct 2016 08:35:08 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201610130835.u9D8Z8bS042694@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Ngie Cooper Date: Thu, 13 Oct 2016 08:35:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307205 - head/contrib/netbsd-tests/fs/tmpfs X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Oct 2016 08:35:10 -0000 Author: ngie Date: Thu Oct 13 08:35:08 2016 New Revision: 307205 URL: https://svnweb.freebsd.org/changeset/base/307205 Log: Change atf_skip call to atf_expect_fail to make it clear that a failure is expected MFC after: 2 weeks PR: 212861 Suggested by: jmmv Sponsored by: Dell EMC Isilon Modified: head/contrib/netbsd-tests/fs/tmpfs/t_remove.sh Modified: head/contrib/netbsd-tests/fs/tmpfs/t_remove.sh ============================================================================== --- head/contrib/netbsd-tests/fs/tmpfs/t_remove.sh Thu Oct 13 08:27:19 2016 (r307204) +++ head/contrib/netbsd-tests/fs/tmpfs/t_remove.sh Thu Oct 13 08:35:08 2016 (r307205) @@ -46,7 +46,18 @@ single_body() { test_unmount } +# Begin FreeBSD +if true; then +atf_test_case uchg cleanup +uchg_cleanup() { + Mount_Point=$(pwd)/mntpt test_unmount || : +} +else +# End FreeBSD atf_test_case uchg +# Begin FreeBSD +fi +# End FreeBSD uchg_head() { atf_set "descr" "Checks that files with the uchg flag set cannot" \ "be removed" @@ -54,7 +65,7 @@ uchg_head() { } uchg_body() { # Begin FreeBSD - atf_skip "this fails on FreeBSD with root - bug 212861" + atf_expect_fail "this fails on FreeBSD with root - bug 212861" # End FreeBSD test_mount From owner-svn-src-all@freebsd.org Thu Oct 13 08:47:52 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D4F85C10165; Thu, 13 Oct 2016 08:47:52 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 9D2FC83F; Thu, 13 Oct 2016 08:47:52 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9D8lpTa046535; Thu, 13 Oct 2016 08:47:51 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9D8lprY046530; Thu, 13 Oct 2016 08:47:51 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610130847.u9D8lprY046530@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Thu, 13 Oct 2016 08:47:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307206 - stable/10/sys/dev/hyperv/netvsc X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Oct 2016 08:47:52 -0000 Author: sephe Date: Thu Oct 13 08:47:51 2016 New Revision: 307206 URL: https://svnweb.freebsd.org/changeset/base/307206 Log: MFC 305724,305725,305727-305730,305760,305761,305763,305788 305724 hyperv/hn: Rename RXBUF connect/disconnect functions. Minor cleanup and wording in error messages. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7823 305725 hyperv/hn: Rename chimney sending buffer connect/disconnect functions. Minor cleanup and wording in error messages. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7825 305727 hyperv/hn: Function rename. - Minor style changes. - Nuke unnecessary indirection. - Nuke unapplied comment. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7827 305728 hyperv/hn: Reorganize sub-channel allocation. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7829 305729 hyperv/hn: Reorganize RNDIS attach Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7830 305730 hyperv/hn: Pull ether address and link status extraction up. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7831 305760 hyperv/hn: Reorganize channel attach/detach code. This paves the way for further attach/detach code reorganization. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7858 305761 hyperv/hn: Regroup synthetic parts attach code. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7859 305763 hyperv/hn: Reorganize synthetic parts attach code. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7860 305788 hyperv/hn: Pull RSS key and indirect table setup up. This paves the way for the dynamic RSS key and indirect table setting. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7864 Modified: stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.c stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.c stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.h stable/10/sys/dev/hyperv/netvsc/if_hnvar.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.c Thu Oct 13 08:35:08 2016 (r307205) +++ stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.c Thu Oct 13 08:47:51 2016 (r307206) @@ -56,11 +56,10 @@ MALLOC_DEFINE(M_NETVSC, "netvsc", "Hyper /* * Forward declarations */ -static int hv_nv_init_send_buffer_with_net_vsp(struct hn_softc *sc); -static int hv_nv_init_rx_buffer_with_net_vsp(struct hn_softc *); -static int hv_nv_destroy_send_buffer(struct hn_softc *sc); -static int hv_nv_destroy_rx_buffer(struct hn_softc *sc); -static int hv_nv_connect_to_vsp(struct hn_softc *sc, int mtu); +static int hn_nvs_conn_chim(struct hn_softc *sc); +static int hn_nvs_conn_rxbuf(struct hn_softc *); +static int hn_nvs_disconn_chim(struct hn_softc *sc); +static int hn_nvs_disconn_rxbuf(struct hn_softc *sc); static void hn_nvs_sent_none(struct hn_send_ctx *sndc, struct hn_softc *, struct vmbus_channel *chan, const void *, int); @@ -102,7 +101,7 @@ hn_chim_alloc(struct hn_softc *sc) return (ret); } -const void * +static const void * hn_nvs_xact_execute(struct hn_softc *sc, struct vmbus_xact *xact, void *req, int reqlen, size_t *resplen0, uint32_t type) { @@ -153,14 +152,8 @@ hn_nvs_req_send(struct hn_softc *sc, voi req, reqlen, &hn_send_ctx_none)); } -/* - * Net VSC initialize receive buffer with net VSP - * - * Net VSP: Network virtual services client, also known as the - * Hyper-V extensible switch and the synthetic data path. - */ static int -hv_nv_init_rx_buffer_with_net_vsp(struct hn_softc *sc) +hn_nvs_conn_rxbuf(struct hn_softc *sc) { struct vmbus_xact *xact = NULL; struct hn_nvs_rxbuf_conn *conn; @@ -187,7 +180,7 @@ hv_nv_init_rx_buffer_with_net_vsp(struct error = vmbus_chan_gpadl_connect(sc->hn_prichan, sc->hn_rxbuf_dma.hv_paddr, rxbuf_size, &sc->hn_rxbuf_gpadl); if (error) { - if_printf(sc->hn_ifp, "rxbuf gpadl connect failed: %d\n", + if_printf(sc->hn_ifp, "rxbuf gpadl conn failed: %d\n", error); goto cleanup; } @@ -211,7 +204,7 @@ hv_nv_init_rx_buffer_with_net_vsp(struct resp = hn_nvs_xact_execute(sc, xact, conn, sizeof(*conn), &resp_len, HN_NVS_TYPE_RXBUF_CONNRESP); if (resp == NULL) { - if_printf(sc->hn_ifp, "exec rxbuf conn failed\n"); + if_printf(sc->hn_ifp, "exec nvs rxbuf conn failed\n"); error = EIO; goto cleanup; } @@ -221,7 +214,7 @@ hv_nv_init_rx_buffer_with_net_vsp(struct xact = NULL; if (status != HN_NVS_STATUS_OK) { - if_printf(sc->hn_ifp, "rxbuf conn failed: %x\n", status); + if_printf(sc->hn_ifp, "nvs rxbuf conn failed: %x\n", status); error = EIO; goto cleanup; } @@ -232,15 +225,12 @@ hv_nv_init_rx_buffer_with_net_vsp(struct cleanup: if (xact != NULL) vmbus_xact_put(xact); - hv_nv_destroy_rx_buffer(sc); + hn_nvs_disconn_rxbuf(sc); return (error); } -/* - * Net VSC initialize send buffer with net VSP - */ static int -hv_nv_init_send_buffer_with_net_vsp(struct hn_softc *sc) +hn_nvs_conn_chim(struct hn_softc *sc) { struct vmbus_xact *xact = NULL; struct hn_nvs_chim_conn *chim; @@ -260,8 +250,7 @@ hv_nv_init_send_buffer_with_net_vsp(stru sc->hn_chim_dma.hv_paddr, NETVSC_SEND_BUFFER_SIZE, &sc->hn_chim_gpadl); if (error) { - if_printf(sc->hn_ifp, "chimney sending buffer gpadl " - "connect failed: %d\n", error); + if_printf(sc->hn_ifp, "chim gpadl conn failed: %d\n", error); goto cleanup; } @@ -284,7 +273,7 @@ hv_nv_init_send_buffer_with_net_vsp(stru resp = hn_nvs_xact_execute(sc, xact, chim, sizeof(*chim), &resp_len, HN_NVS_TYPE_CHIM_CONNRESP); if (resp == NULL) { - if_printf(sc->hn_ifp, "exec chim conn failed\n"); + if_printf(sc->hn_ifp, "exec nvs chim conn failed\n"); error = EIO; goto cleanup; } @@ -295,14 +284,14 @@ hv_nv_init_send_buffer_with_net_vsp(stru xact = NULL; if (status != HN_NVS_STATUS_OK) { - if_printf(sc->hn_ifp, "chim conn failed: %x\n", status); + if_printf(sc->hn_ifp, "nvs chim conn failed: %x\n", status); error = EIO; goto cleanup; } if (sectsz == 0) { if_printf(sc->hn_ifp, "zero chimney sending buffer " "section size\n"); - return 0; + return (0); } sc->hn_chim_szmax = sectsz; @@ -326,22 +315,19 @@ hv_nv_init_send_buffer_with_net_vsp(stru if_printf(sc->hn_ifp, "chimney sending buffer %d/%d\n", sc->hn_chim_szmax, sc->hn_chim_cnt); } - return 0; + return (0); cleanup: if (xact != NULL) vmbus_xact_put(xact); - hv_nv_destroy_send_buffer(sc); + hn_nvs_disconn_chim(sc); return (error); } -/* - * Net VSC destroy receive buffer - */ static int -hv_nv_destroy_rx_buffer(struct hn_softc *sc) +hn_nvs_disconn_rxbuf(struct hn_softc *sc) { - int ret = 0; + int error; if (sc->hn_flags & HN_FLAG_RXBUF_CONNECTED) { struct hn_nvs_rxbuf_disconn disconn; @@ -354,38 +340,35 @@ hv_nv_destroy_rx_buffer(struct hn_softc disconn.nvs_sig = HN_NVS_RXBUF_SIG; /* NOTE: No response. */ - ret = hn_nvs_req_send(sc, &disconn, sizeof(disconn)); - if (ret != 0) { + error = hn_nvs_req_send(sc, &disconn, sizeof(disconn)); + if (error) { if_printf(sc->hn_ifp, - "send rxbuf disconn failed: %d\n", ret); - return (ret); + "send nvs rxbuf disconn failed: %d\n", error); + return (error); } sc->hn_flags &= ~HN_FLAG_RXBUF_CONNECTED; } - + if (sc->hn_rxbuf_gpadl != 0) { /* * Disconnect RXBUF from primary channel. */ - ret = vmbus_chan_gpadl_disconnect(sc->hn_prichan, + error = vmbus_chan_gpadl_disconnect(sc->hn_prichan, sc->hn_rxbuf_gpadl); - if (ret != 0) { + if (error) { if_printf(sc->hn_ifp, - "rxbuf disconn failed: %d\n", ret); - return (ret); + "rxbuf gpadl disconn failed: %d\n", error); + return (error); } sc->hn_rxbuf_gpadl = 0; } - return (ret); + return (0); } -/* - * Net VSC destroy send buffer - */ static int -hv_nv_destroy_send_buffer(struct hn_softc *sc) +hn_nvs_disconn_chim(struct hn_softc *sc) { - int ret = 0; + int error; if (sc->hn_flags & HN_FLAG_CHIM_CONNECTED) { struct hn_nvs_chim_disconn disconn; @@ -398,25 +381,25 @@ hv_nv_destroy_send_buffer(struct hn_soft disconn.nvs_sig = HN_NVS_CHIM_SIG; /* NOTE: No response. */ - ret = hn_nvs_req_send(sc, &disconn, sizeof(disconn)); - if (ret != 0) { + error = hn_nvs_req_send(sc, &disconn, sizeof(disconn)); + if (error) { if_printf(sc->hn_ifp, - "send chim disconn failed: %d\n", ret); - return (ret); + "send nvs chim disconn failed: %d\n", error); + return (error); } sc->hn_flags &= ~HN_FLAG_CHIM_CONNECTED; } - + if (sc->hn_chim_gpadl != 0) { /* * Disconnect chimney sending buffer from primary channel. */ - ret = vmbus_chan_gpadl_disconnect(sc->hn_prichan, + error = vmbus_chan_gpadl_disconnect(sc->hn_prichan, sc->hn_chim_gpadl); - if (ret != 0) { + if (error) { if_printf(sc->hn_ifp, - "chim disconn failed: %d\n", ret); - return (ret); + "chim gpadl disconn failed: %d\n", error); + return (error); } sc->hn_chim_gpadl = 0; } @@ -425,8 +408,7 @@ hv_nv_destroy_send_buffer(struct hn_soft free(sc->hn_chim_bmap, M_NETVSC); sc->hn_chim_bmap = NULL; } - - return (ret); + return (0); } static int @@ -537,38 +519,48 @@ hn_nvs_init(struct hn_softc *sc) return (ENXIO); } -static int -hv_nv_connect_to_vsp(struct hn_softc *sc, int mtu) +int +hn_nvs_attach(struct hn_softc *sc, int mtu) { - int ret; + int error; /* * Initialize NVS. */ - ret = hn_nvs_init(sc); - if (ret != 0) - return (ret); + error = hn_nvs_init(sc); + if (error) + return (error); if (sc->hn_nvs_ver >= HN_NVS_VERSION_2) { /* * Configure NDIS before initializing it. */ - ret = hn_nvs_conf_ndis(sc, mtu); - if (ret != 0) - return (ret); + error = hn_nvs_conf_ndis(sc, mtu); + if (error) + return (error); } /* * Initialize NDIS. */ - ret = hn_nvs_init_ndis(sc); - if (ret != 0) - return (ret); - - ret = hv_nv_init_rx_buffer_with_net_vsp(sc); - if (ret == 0) - ret = hv_nv_init_send_buffer_with_net_vsp(sc); - return (ret); + error = hn_nvs_init_ndis(sc); + if (error) + return (error); + + /* + * Connect RXBUF. + */ + error = hn_nvs_conn_rxbuf(sc); + if (error) + return (error); + + /* + * Connect chimney sending buffer. + */ + error = hn_nvs_conn_chim(sc); + if (error) + return (error); + return (0); } /* @@ -577,23 +569,8 @@ hv_nv_connect_to_vsp(struct hn_softc *sc static void hv_nv_disconnect_from_vsp(struct hn_softc *sc) { - hv_nv_destroy_rx_buffer(sc); - hv_nv_destroy_send_buffer(sc); -} - -/* - * Net VSC on device add - * - * Callback when the device belonging to this driver is added - */ -int -hv_nv_on_device_add(struct hn_softc *sc, int mtu) -{ - - /* - * Connect with the NetVsp - */ - return (hv_nv_connect_to_vsp(sc, mtu)); + hn_nvs_disconn_rxbuf(sc); + hn_nvs_disconn_chim(sc); } /* @@ -604,11 +581,6 @@ hv_nv_on_device_remove(struct hn_softc * { hv_nv_disconnect_from_vsp(sc); - - /* Now, we can close the channel safely */ - - vmbus_chan_close(sc->hn_prichan); - return (0); } @@ -675,3 +647,54 @@ hv_nv_on_send(struct vmbus_channel *chan return (ret); } + +int +hn_nvs_alloc_subchans(struct hn_softc *sc, int *nsubch0) +{ + struct vmbus_xact *xact; + struct hn_nvs_subch_req *req; + const struct hn_nvs_subch_resp *resp; + int error, nsubch_req; + uint32_t nsubch; + size_t resp_len; + + nsubch_req = *nsubch0; + KASSERT(nsubch_req > 0, ("invalid # of sub-channels %d", nsubch_req)); + + xact = vmbus_xact_get(sc->hn_xact, sizeof(*req)); + if (xact == NULL) { + if_printf(sc->hn_ifp, "no xact for nvs subch alloc\n"); + return (ENXIO); + } + req = vmbus_xact_req_data(xact); + req->nvs_type = HN_NVS_TYPE_SUBCH_REQ; + req->nvs_op = HN_NVS_SUBCH_OP_ALLOC; + req->nvs_nsubch = nsubch_req; + + resp_len = sizeof(*resp); + resp = hn_nvs_xact_execute(sc, xact, req, sizeof(*req), &resp_len, + HN_NVS_TYPE_SUBCH_RESP); + if (resp == NULL) { + if_printf(sc->hn_ifp, "exec nvs subch alloc failed\n"); + error = EIO; + goto done; + } + if (resp->nvs_status != HN_NVS_STATUS_OK) { + if_printf(sc->hn_ifp, "nvs subch alloc failed: %x\n", + resp->nvs_status); + error = EIO; + goto done; + } + + nsubch = resp->nvs_nsubch; + if (nsubch > nsubch_req) { + if_printf(sc->hn_ifp, "%u subchans are allocated, " + "requested %d\n", nsubch, nsubch_req); + nsubch = nsubch_req; + } + *nsubch0 = nsubch; + error = 0; +done: + vmbus_xact_put(xact); + return (error); +} Modified: stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h Thu Oct 13 08:35:08 2016 (r307205) +++ stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h Thu Oct 13 08:47:51 2016 (r307206) @@ -99,11 +99,6 @@ struct vmbus_channel; #define NETVSC_DEVICE_RING_BUFFER_SIZE (128 * PAGE_SIZE) #define NETVSC_PACKET_MAXPAGE 32 -typedef struct { - uint8_t mac_addr[ETHER_ADDR_LEN]; - uint32_t link_state; -} netvsc_device_info; - #define HN_XACT_REQ_PGCNT 2 #define HN_XACT_RESP_PGCNT 2 #define HN_XACT_REQ_SIZE (HN_XACT_REQ_PGCNT * PAGE_SIZE) @@ -262,7 +257,7 @@ extern int hv_promisc_mode; struct hn_send_ctx; void netvsc_linkstatus_callback(struct hn_softc *sc, uint32_t status); -int hv_nv_on_device_add(struct hn_softc *sc, int mtu); +int hn_nvs_attach(struct hn_softc *sc, int mtu); int hv_nv_on_device_remove(struct hn_softc *sc); int hv_nv_on_send(struct vmbus_channel *chan, uint32_t rndis_mtype, struct hn_send_ctx *sndc, struct vmbus_gpa *gpa, int gpa_cnt); Modified: stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Thu Oct 13 08:35:08 2016 (r307205) +++ stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Thu Oct 13 08:47:51 2016 (r307206) @@ -349,8 +349,12 @@ static int hn_create_rx_data(struct hn_s static void hn_destroy_rx_data(struct hn_softc *sc); static void hn_set_chim_size(struct hn_softc *, int); static int hn_chan_attach(struct hn_softc *, struct vmbus_channel *); +static void hn_chan_detach(struct hn_softc *, struct vmbus_channel *); static int hn_attach_subchans(struct hn_softc *); +static void hn_detach_allchans(struct hn_softc *); static void hn_chan_callback(struct vmbus_channel *chan, void *xrxr); +static void hn_set_ring_inuse(struct hn_softc *, int); +static int hn_synth_attach(struct hn_softc *, int); static void hn_nvs_handle_notify(struct hn_softc *sc, const struct vmbus_chanpkt_hdr *pkt); @@ -368,6 +372,14 @@ static void hn_xmit_txeof(struct hn_tx_r static void hn_xmit_taskfunc(void *, int); static void hn_xmit_txeof_taskfunc(void *, int); +static const uint8_t hn_rss_key_default[NDIS_HASH_KEYSIZE_TOEPLITZ] = { + 0x6d, 0x5a, 0x56, 0xda, 0x25, 0x5b, 0x0e, 0xc2, + 0x41, 0x67, 0x25, 0x3d, 0x43, 0xa3, 0x8f, 0xb0, + 0xd0, 0xca, 0x2b, 0xcb, 0xae, 0x7b, 0x30, 0xb4, + 0x77, 0xcb, 0x2d, 0xa3, 0x80, 0x30, 0xf2, 0x0c, + 0x6a, 0x42, 0xb7, 0x3b, 0xbe, 0xac, 0x01, 0xfa +}; + #if __FreeBSD_version >= 1100099 static void hn_set_lro_lenlim(struct hn_softc *sc, int lenlim) @@ -457,7 +469,8 @@ netvsc_attach(device_t dev) { struct sysctl_oid_list *child; struct sysctl_ctx_list *ctx; - netvsc_device_info device_info; + uint8_t eaddr[ETHER_ADDR_LEN]; + uint32_t link_status; hn_softc_t *sc; int unit = device_get_unit(dev); struct ifnet *ifp = NULL; @@ -535,9 +548,17 @@ netvsc_attach(device_t dev) goto failed; /* - * Associate the first TX/RX ring w/ the primary channel. + * Create transaction context for NVS and RNDIS transactions. */ - error = hn_chan_attach(sc, sc->hn_prichan); + sc->hn_xact = vmbus_xact_ctx_create(bus_get_dma_tag(dev), + HN_XACT_REQ_SIZE, HN_XACT_RESP_SIZE, 0); + if (sc->hn_xact == NULL) + goto failed; + + /* + * Attach the synthetic parts, i.e. NVS and RNDIS. + */ + error = hn_synth_attach(sc, ETHERMTU); if (error) goto failed; @@ -575,34 +596,6 @@ netvsc_attach(device_t dev) IFCAP_LRO; ifp->if_hwassist = sc->hn_tx_ring[0].hn_csum_assist | CSUM_TSO; - sc->hn_xact = vmbus_xact_ctx_create(bus_get_dma_tag(dev), - HN_XACT_REQ_SIZE, HN_XACT_RESP_SIZE, 0); - if (sc->hn_xact == NULL) - goto failed; - - error = hv_rf_on_device_add(sc, &device_info, &ring_cnt, ETHERMTU); - if (error) - goto failed; - KASSERT(ring_cnt > 0 && ring_cnt <= sc->hn_rx_ring_inuse, - ("invalid channel count %d, should be less than %d", - ring_cnt, sc->hn_rx_ring_inuse)); - - /* - * Set the # of TX/RX rings that could be used according to - * the # of channels that host offered. - */ - if (sc->hn_tx_ring_inuse > ring_cnt) - sc->hn_tx_ring_inuse = ring_cnt; - sc->hn_rx_ring_inuse = ring_cnt; - device_printf(dev, "%d TX ring, %d RX ring\n", - sc->hn_tx_ring_inuse, sc->hn_rx_ring_inuse); - - if (sc->hn_rx_ring_inuse > 1) { - error = hn_attach_subchans(sc); - if (error) - goto failed; - } - #if __FreeBSD_version >= 1100099 if (sc->hn_rx_ring_inuse > 1) { /* @@ -613,9 +606,11 @@ netvsc_attach(device_t dev) } #endif - if (device_info.link_state == NDIS_MEDIA_STATE_CONNECTED) { + error = hn_rndis_get_linkstatus(sc, &link_status); + if (error) + goto failed; + if (link_status == NDIS_MEDIA_STATE_CONNECTED) sc->hn_carrier = 1; - } tso_maxlen = hn_tso_maxlen; if (tso_maxlen <= 0 || tso_maxlen > IP_MAXPACKET) @@ -626,7 +621,10 @@ netvsc_attach(device_t dev) ifp->if_hw_tsomax = tso_maxlen - (ETHER_HDR_LEN + ETHER_VLAN_ENCAP_LEN); - ether_ifattach(ifp, device_info.mac_addr); + error = hn_rndis_get_eaddr(sc, eaddr); + if (error) + goto failed; + ether_ifattach(ifp, eaddr); if_printf(ifp, "TSO: %u/%u/%u\n", ifp->if_hw_tsomax, ifp->if_hw_tsomaxsegcount, ifp->if_hw_tsomaxsegsize); @@ -675,6 +673,7 @@ netvsc_detach(device_t dev) */ hv_rf_on_device_remove(sc); + hn_detach_allchans(sc); hn_stop_tx_tasks(sc); @@ -1519,8 +1518,7 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, #ifdef INET struct ifaddr *ifa = (struct ifaddr *)data; #endif - netvsc_device_info device_info; - int mask, error = 0, ring_cnt; + int mask, error = 0; int retry_cnt = 500; switch(cmd) { @@ -1591,43 +1589,16 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, break; } - /* Wait for subchannels to be destroyed */ - vmbus_subchan_drain(sc->hn_prichan); - - sc->hn_rx_ring[0].hn_rx_flags &= ~HN_RX_FLAG_ATTACHED; - sc->hn_tx_ring[0].hn_tx_flags &= ~HN_TX_FLAG_ATTACHED; - hn_chan_attach(sc, sc->hn_prichan); /* XXX check error */ - - ring_cnt = sc->hn_rx_ring_inuse; - error = hv_rf_on_device_add(sc, &device_info, &ring_cnt, - ifr->ifr_mtu); - if (error) { - NV_LOCK(sc); - sc->temp_unusable = FALSE; - NV_UNLOCK(sc); - break; - } - /* # of channels can _not_ be changed */ - KASSERT(sc->hn_rx_ring_inuse == ring_cnt, - ("RX ring count %d and channel count %u mismatch", - sc->hn_rx_ring_cnt, ring_cnt)); - if (sc->hn_rx_ring_inuse > 1) { - int r; + /* + * Detach all of the channels. + */ + hn_detach_allchans(sc); - /* - * Skip the rings on primary channel; they are - * handled by the hv_rf_on_device_add() above. - */ - for (r = 1; r < sc->hn_rx_ring_cnt; ++r) { - sc->hn_rx_ring[r].hn_rx_flags &= - ~HN_RX_FLAG_ATTACHED; - } - for (r = 1; r < sc->hn_tx_ring_cnt; ++r) { - sc->hn_tx_ring[r].hn_tx_flags &= - ~HN_TX_FLAG_ATTACHED; - } - hn_attach_subchans(sc); /* XXX check error */ - } + /* + * Attach the synthetic parts, i.e. NVS and RNDIS. + * XXX check error. + */ + hn_synth_attach(sc, ifr->ifr_mtu); if (sc->hn_tx_ring[0].hn_chim_size > sc->hn_chim_szmax) hn_set_chim_size(sc, sc->hn_chim_szmax); @@ -3073,6 +3044,42 @@ hn_chan_attach(struct hn_softc *sc, stru return (error); } +static void +hn_chan_detach(struct hn_softc *sc, struct vmbus_channel *chan) +{ + struct hn_rx_ring *rxr; + int idx; + + idx = vmbus_chan_subidx(chan); + + /* + * Link this channel to RX/TX ring. + */ + KASSERT(idx >= 0 && idx < sc->hn_rx_ring_inuse, + ("invalid channel index %d, should > 0 && < %d", + idx, sc->hn_rx_ring_inuse)); + rxr = &sc->hn_rx_ring[idx]; + KASSERT((rxr->hn_rx_flags & HN_RX_FLAG_ATTACHED), + ("RX ring %d is not attached", idx)); + rxr->hn_rx_flags &= ~HN_RX_FLAG_ATTACHED; + + if (idx < sc->hn_tx_ring_inuse) { + struct hn_tx_ring *txr = &sc->hn_tx_ring[idx]; + + KASSERT((txr->hn_tx_flags & HN_TX_FLAG_ATTACHED), + ("TX ring %d is not attached attached", idx)); + txr->hn_tx_flags &= ~HN_TX_FLAG_ATTACHED; + } + + /* + * Close this channel. + * + * NOTE: + * Channel closing does _not_ destroy the target channel. + */ + vmbus_chan_close(chan); +} + static int hn_attach_subchans(struct hn_softc *sc) { @@ -3080,17 +3087,16 @@ hn_attach_subchans(struct hn_softc *sc) int subchan_cnt = sc->hn_rx_ring_inuse - 1; int i, error = 0; - /* Wait for sub-channels setup to complete. */ - subchans = vmbus_subchan_get(sc->hn_prichan, subchan_cnt); + if (subchan_cnt == 0) + return (0); /* Attach the sub-channels. */ + subchans = vmbus_subchan_get(sc->hn_prichan, subchan_cnt); for (i = 0; i < subchan_cnt; ++i) { error = hn_chan_attach(sc, subchans[i]); if (error) break; } - - /* Release the sub-channels */ vmbus_subchan_rel(subchans, subchan_cnt); if (error) { @@ -3105,6 +3111,202 @@ hn_attach_subchans(struct hn_softc *sc) } static void +hn_detach_allchans(struct hn_softc *sc) +{ + struct vmbus_channel **subchans; + int subchan_cnt = sc->hn_rx_ring_inuse - 1; + int i; + + if (subchan_cnt == 0) + goto back; + + /* Detach the sub-channels. */ + subchans = vmbus_subchan_get(sc->hn_prichan, subchan_cnt); + for (i = 0; i < subchan_cnt; ++i) + hn_chan_detach(sc, subchans[i]); + vmbus_subchan_rel(subchans, subchan_cnt); + +back: + /* + * Detach the primary channel, _after_ all sub-channels + * are detached. + */ + hn_chan_detach(sc, sc->hn_prichan); + + /* Wait for sub-channels to be destroyed, if any. */ + vmbus_subchan_drain(sc->hn_prichan); + +#ifdef INVARIANTS + for (i = 0; i < sc->hn_rx_ring_cnt; ++i) { + KASSERT((sc->hn_rx_ring[i].hn_rx_flags & + HN_RX_FLAG_ATTACHED) == 0, + ("%dth RX ring is still attached", i)); + } + for (i = 0; i < sc->hn_tx_ring_cnt; ++i) { + KASSERT((sc->hn_tx_ring[i].hn_tx_flags & + HN_TX_FLAG_ATTACHED) == 0, + ("%dth TX ring is still attached", i)); + } +#endif +} + +static int +hn_synth_alloc_subchans(struct hn_softc *sc, int *nsubch) +{ + struct vmbus_channel **subchans; + int nchan, rxr_cnt, error; + + nchan = *nsubch + 1; + if (sc->hn_ndis_ver < HN_NDIS_VERSION_6_30 || nchan == 1) { + /* + * Either RSS is not supported, or multiple RX/TX rings + * are not requested. + */ + *nsubch = 0; + return (0); + } + + /* + * Get RSS capabilities, e.g. # of RX rings, and # of indirect + * table entries. + */ + error = hn_rndis_get_rsscaps(sc, &rxr_cnt); + if (error) { + /* No RSS; this is benign. */ + *nsubch = 0; + return (0); + } + if_printf(sc->hn_ifp, "RX rings offered %u, requested %d\n", + rxr_cnt, nchan); + + if (nchan > rxr_cnt) + nchan = rxr_cnt; + if (nchan == 1) { + if_printf(sc->hn_ifp, "only 1 channel is supported, no vRSS\n"); + *nsubch = 0; + return (0); + } + + /* + * Allocate sub-channels from NVS. + */ + *nsubch = nchan - 1; + error = hn_nvs_alloc_subchans(sc, nsubch); + if (error || *nsubch == 0) { + /* Failed to allocate sub-channels. */ + *nsubch = 0; + return (0); + } + + /* + * Wait for all sub-channels to become ready before moving on. + */ + subchans = vmbus_subchan_get(sc->hn_prichan, *nsubch); + vmbus_subchan_rel(subchans, *nsubch); + return (0); +} + +static int +hn_synth_attach(struct hn_softc *sc, int mtu) +{ + struct ndis_rssprm_toeplitz *rss = &sc->hn_rss; + int error, nsubch, nchan, i; + + /* + * Attach the primary channel _before_ attaching NVS and RNDIS. + */ + error = hn_chan_attach(sc, sc->hn_prichan); + if (error) + return (error); + + /* + * Attach NVS. + */ + error = hn_nvs_attach(sc, mtu); + if (error) + return (error); + + /* + * Attach RNDIS _after_ NVS is attached. + */ + error = hn_rndis_attach(sc); + if (error) + return (error); + + /* + * Allocate sub-channels for multi-TX/RX rings. + * + * NOTE: + * The # of RX rings that can be used is equivalent to the # of + * channels to be requested. + */ + nsubch = sc->hn_rx_ring_cnt - 1; + error = hn_synth_alloc_subchans(sc, &nsubch); + if (error) + return (error); + + nchan = nsubch + 1; + if (nchan == 1) { + /* Only the primary channel can be used; done */ + goto back; + } + + /* + * Configure RSS key and indirect table _after_ all sub-channels + * are allocated. + */ + + /* Setup default RSS key. */ + memcpy(rss->rss_key, hn_rss_key_default, sizeof(rss->rss_key)); + + /* Setup default RSS indirect table. */ + /* TODO: Take ndis_rss_caps.ndis_nind into account. */ + for (i = 0; i < NDIS_HASH_INDCNT; ++i) + rss->rss_ind[i] = i % nchan; + + error = hn_rndis_conf_rss(sc); + if (error) { + /* + * Failed to configure RSS key or indirect table; only + * the primary channel can be used. + */ + nchan = 1; + } +back: + /* + * Set the # of TX/RX rings that could be used according to + * the # of channels that NVS offered. + */ + hn_set_ring_inuse(sc, nchan); + + /* + * Attach the sub-channels, if any. + */ + error = hn_attach_subchans(sc); + if (error) + return (error); + return (0); +} + +static void +hn_set_ring_inuse(struct hn_softc *sc, int ring_cnt) +{ + KASSERT(ring_cnt > 0 && ring_cnt <= sc->hn_rx_ring_cnt, + ("invalid ring count %d", ring_cnt)); + + if (sc->hn_tx_ring_cnt > ring_cnt) + sc->hn_tx_ring_inuse = ring_cnt; + else + sc->hn_tx_ring_inuse = sc->hn_tx_ring_cnt; + sc->hn_rx_ring_inuse = ring_cnt; + + if (bootverbose) { + if_printf(sc->hn_ifp, "%d TX ring, %d RX ring\n", + sc->hn_tx_ring_inuse, sc->hn_rx_ring_inuse); + } +} + +static void hn_nvs_handle_notify(struct hn_softc *sc, const struct vmbus_chanpkt_hdr *pkt) { const struct hn_nvs_hdr *hdr; Modified: stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.c Thu Oct 13 08:35:08 2016 (r307205) +++ stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.c Thu Oct 13 08:47:51 2016 (r307206) @@ -76,18 +76,12 @@ static void hv_rf_receive_indicate_statu const void *data, int dlen); static void hv_rf_receive_data(struct hn_rx_ring *rxr, const void *data, int dlen); -static int hv_rf_query_device_mac(struct hn_softc *sc, uint8_t *eaddr); -static int hv_rf_query_device_link_status(struct hn_softc *sc, - uint32_t *link_status); -static int hv_rf_init_device(struct hn_softc *sc); static int hn_rndis_query(struct hn_softc *sc, uint32_t oid, const void *idata, size_t idlen, void *odata, size_t *odlen0); static int hn_rndis_set(struct hn_softc *sc, uint32_t oid, const void *data, size_t dlen); static int hn_rndis_conf_offload(struct hn_softc *sc); -static int hn_rndis_get_rsscaps(struct hn_softc *sc, int *rxr_cnt); -static int hn_rndis_conf_rss(struct hn_softc *sc, int nchan); static __inline uint32_t hn_rndis_rid(struct hn_softc *sc) @@ -481,11 +475,8 @@ hv_rf_on_receive(struct hn_softc *sc, st } } -/* - * RNDIS filter query device MAC address - */ -static int -hv_rf_query_device_mac(struct hn_softc *sc, uint8_t *eaddr) +int +hn_rndis_get_eaddr(struct hn_softc *sc, uint8_t *eaddr) { size_t eaddr_len; int error; @@ -502,11 +493,8 @@ hv_rf_query_device_mac(struct hn_softc * return (0); } -/* - * RNDIS filter query device link status - */ -static int -hv_rf_query_device_link_status(struct hn_softc *sc, uint32_t *link_status) +int +hn_rndis_get_linkstatus(struct hn_softc *sc, uint32_t *link_status) { size_t size; int error; @@ -523,14 +511,6 @@ hv_rf_query_device_link_status(struct hn return (0); } -static uint8_t netvsc_hash_key[NDIS_HASH_KEYSIZE_TOEPLITZ] = { - 0x6d, 0x5a, 0x56, 0xda, 0x25, 0x5b, 0x0e, 0xc2, - 0x41, 0x67, 0x25, 0x3d, 0x43, 0xa3, 0x8f, 0xb0, - 0xd0, 0xca, 0x2b, 0xcb, 0xae, 0x7b, 0x30, 0xb4, - 0x77, 0xcb, 0x2d, 0xa3, 0x80, 0x30, 0xf2, 0x0c, - 0x6a, 0x42, 0xb7, 0x3b, 0xbe, 0xac, 0x01, 0xfa -}; - static const void * hn_rndis_xact_exec1(struct hn_softc *sc, struct vmbus_xact *xact, size_t reqlen, struct hn_send_ctx *sndc, size_t *comp_len) @@ -722,7 +702,7 @@ done: return (error); } -static int +int hn_rndis_get_rsscaps(struct hn_softc *sc, int *rxr_cnt) { struct ndis_rss_caps in, caps; @@ -857,12 +837,12 @@ hn_rndis_conf_offload(struct hn_softc *s return (error); } -static int -hn_rndis_conf_rss(struct hn_softc *sc, int nchan) +int +hn_rndis_conf_rss(struct hn_softc *sc) { struct ndis_rssprm_toeplitz *rss = &sc->hn_rss; struct ndis_rss_params *prm = &rss->rss_params; - int i, error; + int error; /* * Only NDIS 6.30+ is supported. @@ -870,7 +850,12 @@ hn_rndis_conf_rss(struct hn_softc *sc, i KASSERT(sc->hn_ndis_ver >= HN_NDIS_VERSION_6_30, ("NDIS 6.30+ is required, NDIS version 0x%08x", sc->hn_ndis_ver)); - memset(rss, 0, sizeof(*rss)); + /* + * NOTE: + * DO NOT whack rss_key and rss_ind, which are setup by the caller. + */ + memset(prm, 0, sizeof(*prm)); + prm->ndis_hdr.ndis_type = NDIS_OBJTYPE_RSS_PARAMS; prm->ndis_hdr.ndis_rev = NDIS_RSS_PARAMS_REV_2; prm->ndis_hdr.ndis_size = sizeof(*rss); @@ -885,14 +870,6 @@ hn_rndis_conf_rss(struct hn_softc *sc, i prm->ndis_keyoffset = __offsetof(struct ndis_rssprm_toeplitz, rss_key[0]); - /* Setup RSS key */ - memcpy(rss->rss_key, netvsc_hash_key, sizeof(rss->rss_key)); - - /* Setup RSS indirect table */ - /* TODO: Take ndis_rss_caps.ndis_nind into account */ *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-all@freebsd.org Thu Oct 13 08:50:20 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 865A0C10342; Thu, 13 Oct 2016 08:50:20 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 50E72B34; Thu, 13 Oct 2016 08:50:20 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9D8oI20046688; Thu, 13 Oct 2016 08:50:18 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9D8oIgZ046687; Thu, 13 Oct 2016 08:50:18 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610130850.u9D8oIgZ046687@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Thu, 13 Oct 2016 08:50:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307207 - stable/10/sys/dev/hyperv/vmbus X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Oct 2016 08:50:20 -0000 Author: sephe Date: Thu Oct 13 08:50:18 2016 New Revision: 307207 URL: https://svnweb.freebsd.org/changeset/base/307207 Log: MFC 305789 hyperv/vmbus: Make sure that the sub-channel count is valid. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7865 Modified: stable/10/sys/dev/hyperv/vmbus/vmbus_chan.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/hyperv/vmbus/vmbus_chan.c ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/vmbus_chan.c Thu Oct 13 08:47:51 2016 (r307206) +++ stable/10/sys/dev/hyperv/vmbus/vmbus_chan.c Thu Oct 13 08:50:18 2016 (r307207) @@ -1346,6 +1346,8 @@ vmbus_subchan_get(struct vmbus_channel * struct vmbus_channel **ret, *chan; int i; + KASSERT(subchan_cnt > 0, ("invalid sub-channel count %d", subchan_cnt)); + ret = malloc(subchan_cnt * sizeof(struct vmbus_channel *), M_TEMP, M_WAITOK); From owner-svn-src-all@freebsd.org Thu Oct 13 08:56:54 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 3A921C105C9; Thu, 13 Oct 2016 08:56:54 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 1409AEC; Thu, 13 Oct 2016 08:56:54 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9D8urOQ050363; Thu, 13 Oct 2016 08:56:53 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9D8urVR050361; Thu, 13 Oct 2016 08:56:53 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610130856.u9D8urVR050361@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Thu, 13 Oct 2016 08:56:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307208 - stable/10/sys/dev/hyperv/netvsc X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Oct 2016 08:56:54 -0000 Author: sephe Date: Thu Oct 13 08:56:52 2016 New Revision: 307208 URL: https://svnweb.freebsd.org/changeset/base/307208 Log: MFC 305790-305793 305790 hyperv/hn: Remove unused softc field Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7866 305791 hyperv/hn: Deprecate hn_softc_t Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7867 305792 hyperv/hn: Function renaming: hn_ifinit -> hn_init No functional changes. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7868 305793 hyperv/hn: Cleanup hn_ioctl. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7869 Modified: stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h Thu Oct 13 08:50:18 2016 (r307207) +++ stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h Thu Oct 13 08:56:52 2016 (r307208) @@ -198,12 +198,11 @@ struct hn_tx_ring { /* * Device-specific softc structure */ -typedef struct hn_softc { +struct hn_softc { struct ifnet *hn_ifp; struct arpcom arpcom; struct ifmedia hn_media; device_t hn_dev; - uint8_t hn_unit; int hn_carrier; int hn_if_flags; struct mtx hn_lock; @@ -245,7 +244,7 @@ typedef struct hn_softc { uint32_t hn_ndis_ver; struct ndis_rssprm_toeplitz hn_rss; -} hn_softc_t; +}; #define HN_FLAG_RXBUF_CONNECTED 0x0001 #define HN_FLAG_CHIM_CONNECTED 0x0002 Modified: stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Thu Oct 13 08:50:18 2016 (r307207) +++ stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Thu Oct 13 08:56:52 2016 (r307208) @@ -312,9 +312,9 @@ static u_int hn_cpu_index; /* * Forward declarations */ -static void hn_stop(hn_softc_t *sc); -static void hn_ifinit_locked(hn_softc_t *sc); -static void hn_ifinit(void *xsc); +static void hn_stop(struct hn_softc *sc); +static void hn_init_locked(struct hn_softc *sc); +static void hn_init(void *xsc); static int hn_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data); static int hn_start_locked(struct hn_tx_ring *txr, int len); static void hn_start(struct ifnet *ifp); @@ -467,19 +467,15 @@ hn_cpuset_setthread_task(void *xmask, in static int netvsc_attach(device_t dev) { + struct hn_softc *sc = device_get_softc(dev); struct sysctl_oid_list *child; struct sysctl_ctx_list *ctx; uint8_t eaddr[ETHER_ADDR_LEN]; uint32_t link_status; - hn_softc_t *sc; - int unit = device_get_unit(dev); struct ifnet *ifp = NULL; int error, ring_cnt, tx_ring_cnt; int tso_maxlen; - sc = device_get_softc(dev); - - sc->hn_unit = unit; sc->hn_dev = dev; sc->hn_prichan = vmbus_get_channel(dev); @@ -564,7 +560,7 @@ netvsc_attach(device_t dev) ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; ifp->if_ioctl = hn_ioctl; - ifp->if_init = hn_ifinit; + ifp->if_init = hn_init; ifp->if_mtu = ETHERMTU; if (hn_use_if_start) { int qdepth = hn_get_txswq_depth(&sc->hn_tx_ring[0]); @@ -1513,29 +1509,13 @@ skip: static int hn_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) { - hn_softc_t *sc = ifp->if_softc; + struct hn_softc *sc = ifp->if_softc; struct ifreq *ifr = (struct ifreq *)data; -#ifdef INET - struct ifaddr *ifa = (struct ifaddr *)data; -#endif int mask, error = 0; int retry_cnt = 500; - switch(cmd) { - - case SIOCSIFADDR: -#ifdef INET - if (ifa->ifa_addr->sa_family == AF_INET) { - ifp->if_flags |= IFF_UP; - if (!(ifp->if_drv_flags & IFF_DRV_RUNNING)) - hn_ifinit(sc); - arp_ifinit(ifp, ifa); - } else -#endif - error = ether_ioctl(ifp, cmd, data); - break; + switch (cmd) { case SIOCSIFMTU: - /* Check MTU value change */ if (ifp->if_mtu == ifr->ifr_mtu) break; @@ -1603,12 +1583,13 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, if (sc->hn_tx_ring[0].hn_chim_size > sc->hn_chim_szmax) hn_set_chim_size(sc, sc->hn_chim_szmax); - hn_ifinit_locked(sc); + hn_init_locked(sc); NV_LOCK(sc); sc->temp_unusable = FALSE; NV_UNLOCK(sc); break; + case SIOCSIFFLAGS: do { NV_LOCK(sc); @@ -1649,7 +1630,7 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, /* do something here for Hyper-V */ } else #endif - hn_ifinit_locked(sc); + hn_init_locked(sc); } else { if (ifp->if_drv_flags & IFF_DRV_RUNNING) { hn_stop(sc); @@ -1659,8 +1640,8 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, sc->temp_unusable = FALSE; NV_UNLOCK(sc); sc->hn_if_flags = ifp->if_flags; - error = 0; break; + case SIOCSIFCAP: NV_LOCK(sc); @@ -1699,38 +1680,32 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, } NV_UNLOCK(sc); - error = 0; break; + case SIOCADDMULTI: case SIOCDELMULTI: -#ifdef notyet - /* Fixme: Multicast mode? */ - if (ifp->if_drv_flags & IFF_DRV_RUNNING) { - NV_LOCK(sc); - netvsc_setmulti(sc); - NV_UNLOCK(sc); - error = 0; - } -#endif - error = EINVAL; + /* Always all-multi */ + /* + * TODO: + * Enable/disable all-multi according to the emptiness of + * the mcast address list. + */ break; + case SIOCSIFMEDIA: case SIOCGIFMEDIA: error = ifmedia_ioctl(ifp, ifr, &sc->hn_media, cmd); break; + default: error = ether_ioctl(ifp, cmd, data); break; } - return (error); } -/* - * - */ static void -hn_stop(hn_softc_t *sc) +hn_stop(struct hn_softc *sc) { struct ifnet *ifp; int ret, i; @@ -1809,11 +1784,8 @@ do_sched: } } -/* - * - */ static void -hn_ifinit_locked(hn_softc_t *sc) +hn_init_locked(struct hn_softc *sc) { struct ifnet *ifp; int ret, i; @@ -1845,9 +1817,9 @@ hn_ifinit_locked(hn_softc_t *sc) * */ static void -hn_ifinit(void *xsc) +hn_init(void *xsc) { - hn_softc_t *sc = xsc; + struct hn_softc *sc = xsc; NV_LOCK(sc); if (sc->temp_unusable) { @@ -1857,7 +1829,7 @@ hn_ifinit(void *xsc) sc->temp_unusable = TRUE; NV_UNLOCK(sc); - hn_ifinit_locked(sc); + hn_init_locked(sc); NV_LOCK(sc); sc->temp_unusable = FALSE; @@ -1871,11 +1843,9 @@ hn_ifinit(void *xsc) static void hn_watchdog(struct ifnet *ifp) { - hn_softc_t *sc; - sc = ifp->if_softc; - printf("hn%d: watchdog timeout -- resetting\n", sc->hn_unit); - hn_ifinit(sc); /*???*/ + if_printf(ifp, "watchdog timeout -- resetting\n"); + hn_init(ifp->if_softc); /* XXX */ ifp->if_oerrors++; } #endif @@ -3545,7 +3515,7 @@ static device_method_t netvsc_methods[] static driver_t netvsc_driver = { NETVSC_DEVNAME, netvsc_methods, - sizeof(hn_softc_t) + sizeof(struct hn_softc) }; static devclass_t netvsc_devclass; From owner-svn-src-all@freebsd.org Thu Oct 13 09:00:45 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A1276C10806; Thu, 13 Oct 2016 09:00:45 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 7C5972F1; Thu, 13 Oct 2016 09:00:45 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9D90iCj050592; Thu, 13 Oct 2016 09:00:44 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9D90i3Y050590; Thu, 13 Oct 2016 09:00:44 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610130900.u9D90i3Y050590@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Thu, 13 Oct 2016 09:00:44 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307209 - stable/10/sys/dev/hyperv/netvsc X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Oct 2016 09:00:45 -0000 Author: sephe Date: Thu Oct 13 09:00:44 2016 New Revision: 307209 URL: https://svnweb.freebsd.org/changeset/base/307209 Log: MFC 305794 hyperv/hn: Use sx for the main lock. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7870 Modified: stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h Thu Oct 13 08:56:52 2016 (r307208) +++ stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h Thu Oct 13 09:00:44 2016 (r307209) @@ -205,10 +205,7 @@ struct hn_softc { device_t hn_dev; int hn_carrier; int hn_if_flags; - struct mtx hn_lock; - int hn_initdone; - /* See hv_netvsc_drv_freebsd.c for rules on how to use */ - int temp_unusable; + struct sx hn_lock; struct vmbus_channel *hn_prichan; int hn_rx_ring_cnt; Modified: stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Thu Oct 13 08:56:52 2016 (r307208) +++ stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Thu Oct 13 09:00:44 2016 (r307209) @@ -197,21 +197,12 @@ struct hn_txdesc { #define HN_LRO_ACKCNT_DEF 1 -/* - * Be aware that this sleepable mutex will exhibit WITNESS errors when - * certain TCP and ARP code paths are taken. This appears to be a - * well-known condition, as all other drivers checked use a sleeping - * mutex to protect their transmit paths. - * Also Be aware that mutexes do not play well with semaphores, and there - * is a conflicting semaphore in a certain channel code path. - */ -#define NV_LOCK_INIT(_sc, _name) \ - mtx_init(&(_sc)->hn_lock, _name, MTX_NETWORK_LOCK, MTX_DEF) -#define NV_LOCK(_sc) mtx_lock(&(_sc)->hn_lock) -#define NV_LOCK_ASSERT(_sc) mtx_assert(&(_sc)->hn_lock, MA_OWNED) -#define NV_UNLOCK(_sc) mtx_unlock(&(_sc)->hn_lock) -#define NV_LOCK_DESTROY(_sc) mtx_destroy(&(_sc)->hn_lock) - +#define HN_LOCK_INIT(sc) \ + sx_init(&(sc)->hn_lock, device_get_nameunit((sc)->hn_dev)) +#define HN_LOCK_ASSERT(sc) sx_assert(&(sc)->hn_lock, SA_XLOCKED) +#define HN_LOCK_DESTROY(sc) sx_destroy(&(sc)->hn_lock) +#define HN_LOCK(sc) sx_xlock(&(sc)->hn_lock) +#define HN_UNLOCK(sc) sx_xunlock(&(sc)->hn_lock) /* * Globals @@ -478,6 +469,7 @@ netvsc_attach(device_t dev) sc->hn_dev = dev; sc->hn_prichan = vmbus_get_channel(dev); + HN_LOCK_INIT(sc); if (hn_tx_taskq == NULL) { sc->hn_tx_taskq = taskqueue_create("hn_tx", M_WAITOK, @@ -500,7 +492,6 @@ netvsc_attach(device_t dev) } else { sc->hn_tx_taskq = hn_tx_taskq; } - NV_LOCK_INIT(sc, "NetVSCLock"); ifp = sc->hn_ifp = sc->arpcom.ac_ifp = if_alloc(IFT_ETHER); ifp->if_softc = sc; @@ -681,6 +672,7 @@ netvsc_detach(device_t dev) taskqueue_free(sc->hn_tx_taskq); vmbus_xact_ctx_destroy(sc->hn_xact); + HN_LOCK_DESTROY(sc); return (0); } @@ -1491,39 +1483,27 @@ skip: return (0); } -/* - * Rules for using sc->temp_unusable: - * 1. sc->temp_unusable can only be read or written while holding NV_LOCK() - * 2. code reading sc->temp_unusable under NV_LOCK(), and finding - * sc->temp_unusable set, must release NV_LOCK() and exit - * 3. to retain exclusive control of the interface, - * sc->temp_unusable must be set by code before releasing NV_LOCK() - * 4. only code setting sc->temp_unusable can clear sc->temp_unusable - * 5. code setting sc->temp_unusable must eventually clear sc->temp_unusable - */ - -/* - * Standard ioctl entry point. Called when the user wants to configure - * the interface. - */ static int hn_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) { struct hn_softc *sc = ifp->if_softc; struct ifreq *ifr = (struct ifreq *)data; int mask, error = 0; - int retry_cnt = 500; - + switch (cmd) { case SIOCSIFMTU: - if (ifp->if_mtu == ifr->ifr_mtu) - break; - if (ifr->ifr_mtu > NETVSC_MAX_CONFIGURABLE_MTU) { error = EINVAL; break; } + HN_LOCK(sc); + + if (ifp->if_mtu == ifr->ifr_mtu) { + HN_UNLOCK(sc); + break; + } + /* Obtain and record requested MTU */ ifp->if_mtu = ifr->ifr_mtu; @@ -1532,40 +1512,18 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, * Make sure that LRO aggregation length limit is still * valid, after the MTU change. */ - NV_LOCK(sc); if (sc->hn_rx_ring[0].hn_lro.lro_length_lim < HN_LRO_LENLIM_MIN(ifp)) hn_set_lro_lenlim(sc, HN_LRO_LENLIM_MIN(ifp)); - NV_UNLOCK(sc); #endif - do { - NV_LOCK(sc); - if (!sc->temp_unusable) { - sc->temp_unusable = TRUE; - retry_cnt = -1; - } - NV_UNLOCK(sc); - if (retry_cnt > 0) { - retry_cnt--; - DELAY(5 * 1000); - } - } while (retry_cnt > 0); - - if (retry_cnt == 0) { - error = EINVAL; - break; - } - /* We must remove and add back the device to cause the new * MTU to take effect. This includes tearing down, but not * deleting the channel, then bringing it back up. */ error = hv_rf_on_device_remove(sc); if (error) { - NV_LOCK(sc); - sc->temp_unusable = FALSE; - NV_UNLOCK(sc); + HN_UNLOCK(sc); break; } @@ -1585,29 +1543,11 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, hn_init_locked(sc); - NV_LOCK(sc); - sc->temp_unusable = FALSE; - NV_UNLOCK(sc); + HN_UNLOCK(sc); break; case SIOCSIFFLAGS: - do { - NV_LOCK(sc); - if (!sc->temp_unusable) { - sc->temp_unusable = TRUE; - retry_cnt = -1; - } - NV_UNLOCK(sc); - if (retry_cnt > 0) { - retry_cnt--; - DELAY(5 * 1000); - } - } while (retry_cnt > 0); - - if (retry_cnt == 0) { - error = EINVAL; - break; - } + HN_LOCK(sc); if (ifp->if_flags & IFF_UP) { /* @@ -1636,14 +1576,13 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, hn_stop(sc); } } - NV_LOCK(sc); - sc->temp_unusable = FALSE; - NV_UNLOCK(sc); sc->hn_if_flags = ifp->if_flags; + + HN_UNLOCK(sc); break; case SIOCSIFCAP: - NV_LOCK(sc); + HN_LOCK(sc); mask = ifr->ifr_reqcap ^ ifp->if_capenable; if (mask & IFCAP_TXCSUM) { @@ -1679,7 +1618,7 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, ifp->if_hwassist &= ~CSUM_IP6_TSO; } - NV_UNLOCK(sc); + HN_UNLOCK(sc); break; case SIOCADDMULTI: @@ -1710,6 +1649,8 @@ hn_stop(struct hn_softc *sc) struct ifnet *ifp; int ret, i; + HN_LOCK_ASSERT(sc); + ifp = sc->hn_ifp; if (bootverbose) @@ -1721,7 +1662,6 @@ hn_stop(struct hn_softc *sc) sc->hn_tx_ring[i].hn_oactive = 0; if_link_state_change(ifp, LINK_STATE_DOWN); - sc->hn_initdone = 0; ret = hv_rf_on_close(sc); } @@ -1790,6 +1730,8 @@ hn_init_locked(struct hn_softc *sc) struct ifnet *ifp; int ret, i; + HN_LOCK_ASSERT(sc); + ifp = sc->hn_ifp; if (ifp->if_drv_flags & IFF_DRV_RUNNING) { @@ -1799,11 +1741,8 @@ hn_init_locked(struct hn_softc *sc) hv_promisc_mode = 1; ret = hv_rf_on_open(sc); - if (ret != 0) { + if (ret != 0) return; - } else { - sc->hn_initdone = 1; - } atomic_clear_int(&ifp->if_drv_flags, IFF_DRV_OACTIVE); for (i = 0; i < sc->hn_tx_ring_inuse; ++i) @@ -1813,27 +1752,14 @@ hn_init_locked(struct hn_softc *sc) if_link_state_change(ifp, LINK_STATE_UP); } -/* - * - */ static void hn_init(void *xsc) { struct hn_softc *sc = xsc; - NV_LOCK(sc); - if (sc->temp_unusable) { - NV_UNLOCK(sc); - return; - } - sc->temp_unusable = TRUE; - NV_UNLOCK(sc); - + HN_LOCK(sc); hn_init_locked(sc); - - NV_LOCK(sc); - sc->temp_unusable = FALSE; - NV_UNLOCK(sc); + HN_UNLOCK(sc); } #ifdef LATER @@ -1864,13 +1790,15 @@ hn_lro_lenlim_sysctl(SYSCTL_HANDLER_ARGS if (error || req->newptr == NULL) return error; + HN_LOCK(sc); if (lenlim < HN_LRO_LENLIM_MIN(sc->hn_ifp) || - lenlim > TCP_LRO_LENGTH_MAX) + lenlim > TCP_LRO_LENGTH_MAX) { + HN_UNLOCK(sc); return EINVAL; - - NV_LOCK(sc); + } hn_set_lro_lenlim(sc, lenlim); - NV_UNLOCK(sc); + HN_UNLOCK(sc); + return 0; } @@ -1897,10 +1825,10 @@ hn_lro_ackcnt_sysctl(SYSCTL_HANDLER_ARGS * count limit. */ --ackcnt; - NV_LOCK(sc); + HN_LOCK(sc); for (i = 0; i < sc->hn_rx_ring_inuse; ++i) sc->hn_rx_ring[i].hn_lro.lro_ackcnt_lim = ackcnt; - NV_UNLOCK(sc); + HN_UNLOCK(sc); return 0; } @@ -1921,7 +1849,7 @@ hn_trust_hcsum_sysctl(SYSCTL_HANDLER_ARG if (error || req->newptr == NULL) return error; - NV_LOCK(sc); + HN_LOCK(sc); for (i = 0; i < sc->hn_rx_ring_inuse; ++i) { struct hn_rx_ring *rxr = &sc->hn_rx_ring[i]; @@ -1930,7 +1858,7 @@ hn_trust_hcsum_sysctl(SYSCTL_HANDLER_ARG else rxr->hn_trust_hcsum &= ~hcsum; } - NV_UNLOCK(sc); + HN_UNLOCK(sc); return 0; } @@ -1948,7 +1876,9 @@ hn_chim_size_sysctl(SYSCTL_HANDLER_ARGS) if (chim_size > sc->hn_chim_szmax || chim_size <= 0) return EINVAL; + HN_LOCK(sc); hn_set_chim_size(sc, chim_size); + HN_UNLOCK(sc); return 0; } @@ -2073,12 +2003,12 @@ hn_tx_conf_int_sysctl(SYSCTL_HANDLER_ARG if (error || req->newptr == NULL) return error; - NV_LOCK(sc); + HN_LOCK(sc); for (i = 0; i < sc->hn_tx_ring_inuse; ++i) { txr = &sc->hn_tx_ring[i]; *((int *)((uint8_t *)txr + ofs)) = conf; } - NV_UNLOCK(sc); + HN_UNLOCK(sc); return 0; } @@ -2732,10 +2662,8 @@ hn_set_chim_size(struct hn_softc *sc, in { int i; - NV_LOCK(sc); for (i = 0; i < sc->hn_tx_ring_inuse; ++i) sc->hn_tx_ring[i].hn_chim_size = chim_size; - NV_UNLOCK(sc); } static void From owner-svn-src-all@freebsd.org Thu Oct 13 09:06:31 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 1690FC109ED; Thu, 13 Oct 2016 09:06:31 +0000 (UTC) (envelope-from andrew@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id BC877A73; Thu, 13 Oct 2016 09:06:30 +0000 (UTC) (envelope-from andrew@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9D96TJk054235; Thu, 13 Oct 2016 09:06:29 GMT (envelope-from andrew@FreeBSD.org) Received: (from andrew@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9D96T5I054233; Thu, 13 Oct 2016 09:06:29 GMT (envelope-from andrew@FreeBSD.org) Message-Id: <201610130906.u9D96T5I054233@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: andrew set sender to andrew@FreeBSD.org using -f From: Andrew Turner Date: Thu, 13 Oct 2016 09:06:29 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307210 - head/sys/arm64/arm64 X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Oct 2016 09:06:31 -0000 Author: andrew Date: Thu Oct 13 09:06:29 2016 New Revision: 307210 URL: https://svnweb.freebsd.org/changeset/base/307210 Log: Move printing the AArch64 ID registers to a new SYSINIT, the previous location only prints them when booting on SMP with multiple cores. MFC after: 1 week Sponsored by: DARPA, AFRL Modified: head/sys/arm64/arm64/identcpu.c head/sys/arm64/arm64/mp_machdep.c Modified: head/sys/arm64/arm64/identcpu.c ============================================================================== --- head/sys/arm64/arm64/identcpu.c Thu Oct 13 09:00:44 2016 (r307209) +++ head/sys/arm64/arm64/identcpu.c Thu Oct 13 09:06:29 2016 (r307210) @@ -33,7 +33,9 @@ __FBSDID("$FreeBSD$"); #include +#include #include +#include #include #include @@ -151,6 +153,17 @@ const struct cpu_implementers cpu_implem CPU_IMPLEMENTER_NONE, }; +static void +identify_cpu_sysinit(void *dummy __unused) +{ + int cpu; + + CPU_FOREACH(cpu) { + print_cpu_features(cpu); + } +} +SYSINIT(idenrity_cpu, SI_SUB_SMP, SI_ORDER_ANY, identify_cpu_sysinit, NULL); + void print_cpu_features(u_int cpu) { Modified: head/sys/arm64/arm64/mp_machdep.c ============================================================================== --- head/sys/arm64/arm64/mp_machdep.c Thu Oct 13 09:00:44 2016 (r307209) +++ head/sys/arm64/arm64/mp_machdep.c Thu Oct 13 09:06:29 2016 (r307210) @@ -201,7 +201,7 @@ arm64_cpu_attach(device_t dev) static void release_aps(void *dummy __unused) { - int cpu, i; + int i; intr_pic_ipi_setup(IPI_AST, "ast", ipi_ast, NULL); intr_pic_ipi_setup(IPI_PREEMPT, "preempt", ipi_preempt, NULL); @@ -217,14 +217,8 @@ release_aps(void *dummy __unused) printf("Release APs\n"); for (i = 0; i < 2000; i++) { - if (smp_started) { - for (cpu = 0; cpu <= mp_maxid; cpu++) { - if (CPU_ABSENT(cpu)) - continue; - print_cpu_features(cpu); - } + if (smp_started) return; - } DELAY(1000); } From owner-svn-src-all@freebsd.org Thu Oct 13 09:18:57 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 5B8A8C10D1F; Thu, 13 Oct 2016 09:18:57 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 331BA235; Thu, 13 Oct 2016 09:18:57 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9D9IuvI058321; Thu, 13 Oct 2016 09:18:56 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9D9Iuui058320; Thu, 13 Oct 2016 09:18:56 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610130918.u9D9Iuui058320@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Thu, 13 Oct 2016 09:18:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307211 - stable/10/sys/dev/hyperv/netvsc X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Oct 2016 09:18:57 -0000 Author: sephe Date: Thu Oct 13 09:18:56 2016 New Revision: 307211 URL: https://svnweb.freebsd.org/changeset/base/307211 Log: MFC 305801,305923,305924 305801 hyperv/hn: Fix some ifnet settings - ifnet.if_mtu does not require explicit setting. - ifnet.if_hdrlen must be set after ether_ifattach(). Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7873 305923 hyperv/hn: Regroup ifnet setup code. While I'm here, add comment along the attach DEVMETHOD. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7874 305924 hyperv/hn: Put debug message under bootverbose Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7875 Modified: stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Thu Oct 13 09:06:29 2016 (r307210) +++ stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Thu Oct 13 09:18:56 2016 (r307211) @@ -471,6 +471,9 @@ netvsc_attach(device_t dev) sc->hn_prichan = vmbus_get_channel(dev); HN_LOCK_INIT(sc); + /* + * Setup taskqueue for transmission. + */ if (hn_tx_taskq == NULL) { sc->hn_tx_taskq = taskqueue_create("hn_tx", M_WAITOK, taskqueue_thread_enqueue, &sc->hn_tx_taskq); @@ -493,11 +496,22 @@ netvsc_attach(device_t dev) sc->hn_tx_taskq = hn_tx_taskq; } + /* + * Allocate ifnet and setup its name earlier, so that if_printf + * can be used by functions, which will be called after + * ether_ifattach(). + */ ifp = sc->hn_ifp = sc->arpcom.ac_ifp = if_alloc(IFT_ETHER); ifp->if_softc = sc; if_initname(ifp, device_get_name(dev), device_get_unit(dev)); /* + * Initialize ifmedia earlier so that it can be unconditionally + * destroyed, if error happened later on. + */ + ifmedia_init(&sc->hn_media, 0, hn_ifmedia_upd, hn_ifmedia_sts); + + /* * Figure out the # of RX rings (ring_cnt) and the # of TX rings * to use (tx_ring_cnt). * @@ -527,6 +541,10 @@ netvsc_attach(device_t dev) */ sc->hn_cpu = atomic_fetchadd_int(&hn_cpu_index, ring_cnt) % mp_ncpus; + /* + * Create enough TX/RX rings, even if only limited number of + * channels can be allocated. + */ error = hn_create_tx_data(sc, tx_ring_cnt); if (error) goto failed; @@ -549,10 +567,54 @@ netvsc_attach(device_t dev) if (error) goto failed; + error = hn_rndis_get_linkstatus(sc, &link_status); + if (error) + goto failed; + if (link_status == NDIS_MEDIA_STATE_CONNECTED) + sc->hn_carrier = 1; + + error = hn_rndis_get_eaddr(sc, eaddr); + if (error) + goto failed; + +#if __FreeBSD_version >= 1100099 + if (sc->hn_rx_ring_inuse > 1) { + /* + * Reduce TCP segment aggregation limit for multiple + * RX rings to increase ACK timeliness. + */ + hn_set_lro_lenlim(sc, HN_LRO_LENLIM_MULTIRX_DEF); + } +#endif + + hn_set_chim_size(sc, sc->hn_chim_szmax); + if (hn_tx_chimney_size > 0 && + hn_tx_chimney_size < sc->hn_chim_szmax) + hn_set_chim_size(sc, hn_tx_chimney_size); + + ctx = device_get_sysctl_ctx(dev); + child = SYSCTL_CHILDREN(device_get_sysctl_tree(dev)); + SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "nvs_version", CTLFLAG_RD, + &sc->hn_nvs_ver, 0, "NVS version"); + SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "ndis_version", + CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, sc, 0, + hn_ndis_version_sysctl, "A", "NDIS version"); + + /* + * Setup the ifmedia, which has been initialized earlier. + */ + ifmedia_add(&sc->hn_media, IFM_ETHER | IFM_AUTO, 0, NULL); + ifmedia_set(&sc->hn_media, IFM_ETHER | IFM_AUTO); + /* XXX ifmedia_set really should do this for us */ + sc->hn_media.ifm_media = sc->hn_media.ifm_cur->ifm_media; + + /* + * Setup the ifnet for this interface. + */ + ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; ifp->if_ioctl = hn_ioctl; ifp->if_init = hn_init; - ifp->if_mtu = ETHERMTU; if (hn_use_if_start) { int qdepth = hn_get_txswq_depth(&sc->hn_tx_ring[0]); @@ -565,16 +627,6 @@ netvsc_attach(device_t dev) ifp->if_qflush = hn_xmit_qflush; } - ifmedia_init(&sc->hn_media, 0, hn_ifmedia_upd, hn_ifmedia_sts); - ifmedia_add(&sc->hn_media, IFM_ETHER | IFM_AUTO, 0, NULL); - ifmedia_set(&sc->hn_media, IFM_ETHER | IFM_AUTO); - /* XXX ifmedia_set really should do this for us */ - sc->hn_media.ifm_media = sc->hn_media.ifm_cur->ifm_media; - - /* - * Tell upper layers that we support full VLAN capability. - */ - ifp->if_data.ifi_hdrlen = sizeof(struct ether_vlan_header); ifp->if_capabilities |= IFCAP_VLAN_HWTAGGING | IFCAP_VLAN_MTU | IFCAP_HWCSUM | IFCAP_TSO | IFCAP_LRO; @@ -583,54 +635,27 @@ netvsc_attach(device_t dev) IFCAP_LRO; ifp->if_hwassist = sc->hn_tx_ring[0].hn_csum_assist | CSUM_TSO; -#if __FreeBSD_version >= 1100099 - if (sc->hn_rx_ring_inuse > 1) { - /* - * Reduce TCP segment aggregation limit for multiple - * RX rings to increase ACK timeliness. - */ - hn_set_lro_lenlim(sc, HN_LRO_LENLIM_MULTIRX_DEF); - } -#endif - - error = hn_rndis_get_linkstatus(sc, &link_status); - if (error) - goto failed; - if (link_status == NDIS_MEDIA_STATE_CONNECTED) - sc->hn_carrier = 1; - tso_maxlen = hn_tso_maxlen; if (tso_maxlen <= 0 || tso_maxlen > IP_MAXPACKET) tso_maxlen = IP_MAXPACKET; - ifp->if_hw_tsomaxsegcount = HN_TX_DATA_SEGCNT_MAX; ifp->if_hw_tsomaxsegsize = PAGE_SIZE; ifp->if_hw_tsomax = tso_maxlen - (ETHER_HDR_LEN + ETHER_VLAN_ENCAP_LEN); - error = hn_rndis_get_eaddr(sc, eaddr); - if (error) - goto failed; ether_ifattach(ifp, eaddr); - if_printf(ifp, "TSO: %u/%u/%u\n", ifp->if_hw_tsomax, - ifp->if_hw_tsomaxsegcount, ifp->if_hw_tsomaxsegsize); - - hn_set_chim_size(sc, sc->hn_chim_szmax); - if (hn_tx_chimney_size > 0 && - hn_tx_chimney_size < sc->hn_chim_szmax) - hn_set_chim_size(sc, hn_tx_chimney_size); + if (bootverbose) { + if_printf(ifp, "TSO: %u/%u/%u\n", ifp->if_hw_tsomax, + ifp->if_hw_tsomaxsegcount, ifp->if_hw_tsomaxsegsize); + } - ctx = device_get_sysctl_ctx(dev); - child = SYSCTL_CHILDREN(device_get_sysctl_tree(dev)); - SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "nvs_version", CTLFLAG_RD, - &sc->hn_nvs_ver, 0, "NVS version"); - SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "ndis_version", - CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, sc, 0, - hn_ndis_version_sysctl, "A", "NDIS version"); + /* Inform the upper layer about the long frame support. */ + ifp->if_hdrlen = sizeof(struct ether_vlan_header); return (0); failed: + /* TODO: reuse netvsc_detach() */ hn_destroy_tx_data(sc); if (ifp != NULL) if_free(ifp); From owner-svn-src-all@freebsd.org Thu Oct 13 09:27:10 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 29509C10FAA; Thu, 13 Oct 2016 09:27:10 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id DB6EDA84; Thu, 13 Oct 2016 09:27:09 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9D9R8Rn062269; Thu, 13 Oct 2016 09:27:08 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9D9R8hW062265; Thu, 13 Oct 2016 09:27:08 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610130927.u9D9R8hW062265@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Thu, 13 Oct 2016 09:27:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307212 - stable/10/sys/dev/hyperv/netvsc X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Oct 2016 09:27:10 -0000 Author: sephe Date: Thu Oct 13 09:27:08 2016 New Revision: 307212 URL: https://svnweb.freebsd.org/changeset/base/307212 Log: MFC 305925,305926,305960 305925 hyperv/hn: Don't mess up RSS key and indirect table after attachment. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7889 305926 hyperv/hn: Add sysctls to dynamic adjust RSS key and indirect table Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7890 305960 hyperv/hn: Apply RSS indirect table fixup before configure RNDIS RSS. MFC after: 1 week Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7916 Modified: stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.c stable/10/sys/dev/hyperv/netvsc/if_hnvar.h stable/10/sys/dev/hyperv/netvsc/ndis.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Thu Oct 13 09:18:56 2016 (r307211) +++ stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Thu Oct 13 09:27:08 2016 (r307212) @@ -327,6 +327,8 @@ static int hn_rx_stat_ulong_sysctl(SYSCT static int hn_tx_stat_ulong_sysctl(SYSCTL_HANDLER_ARGS); static int hn_tx_conf_int_sysctl(SYSCTL_HANDLER_ARGS); static int hn_ndis_version_sysctl(SYSCTL_HANDLER_ARGS); +static int hn_rss_key_sysctl(SYSCTL_HANDLER_ARGS); +static int hn_rss_ind_sysctl(SYSCTL_HANDLER_ARGS); static int hn_check_iplen(const struct mbuf *, int); static int hn_create_tx_ring(struct hn_softc *, int); static void hn_destroy_tx_ring(struct hn_tx_ring *); @@ -393,6 +395,62 @@ hn_get_txswq_depth(const struct hn_tx_ri } static int +hn_rss_reconfig(struct hn_softc *sc) +{ + int error; + + HN_LOCK_ASSERT(sc); + + /* + * Disable RSS first. + * + * NOTE: + * Direct reconfiguration by setting the UNCHG flags does + * _not_ work properly. + */ + if (bootverbose) + if_printf(sc->hn_ifp, "disable RSS\n"); + error = hn_rndis_conf_rss(sc, NDIS_RSS_FLAG_DISABLE); + if (error) { + if_printf(sc->hn_ifp, "RSS disable failed\n"); + return (error); + } + + /* + * Reenable the RSS w/ the updated RSS key or indirect + * table. + */ + if (bootverbose) + if_printf(sc->hn_ifp, "reconfig RSS\n"); + error = hn_rndis_conf_rss(sc, NDIS_RSS_FLAG_NONE); + if (error) { + if_printf(sc->hn_ifp, "RSS reconfig failed\n"); + return (error); + } + return (0); +} + +static void +hn_rss_ind_fixup(struct hn_softc *sc, int nchan) +{ + struct ndis_rssprm_toeplitz *rss = &sc->hn_rss; + int i; + + /* + * Check indirect table to make sure that all channels in it + * can be used. + */ + for (i = 0; i < NDIS_HASH_INDCNT; ++i) { + if (rss->rss_ind[i] >= nchan) { + if_printf(sc->hn_ifp, + "RSS indirect table %d fixup: %u -> %d\n", + i, rss->rss_ind[i], nchan - 1); + rss->rss_ind[i] = nchan - 1; + } + } +} + +static int hn_ifmedia_upd(struct ifnet *ifp __unused) { @@ -599,6 +657,12 @@ netvsc_attach(device_t dev) SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "ndis_version", CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, sc, 0, hn_ndis_version_sysctl, "A", "NDIS version"); + SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "rss_key", + CTLTYPE_OPAQUE | CTLFLAG_RW | CTLFLAG_MPSAFE, sc, 0, + hn_rss_key_sysctl, "IU", "RSS key"); + SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "rss_ind", + CTLTYPE_OPAQUE | CTLFLAG_RW | CTLFLAG_MPSAFE, sc, 0, + hn_rss_ind_sysctl, "IU", "RSS indirect table"); /* * Setup the ifmedia, which has been initialized earlier. @@ -2051,6 +2115,51 @@ hn_ndis_version_sysctl(SYSCTL_HANDLER_AR } static int +hn_rss_key_sysctl(SYSCTL_HANDLER_ARGS) +{ + struct hn_softc *sc = arg1; + int error; + + HN_LOCK(sc); + + error = SYSCTL_OUT(req, sc->hn_rss.rss_key, sizeof(sc->hn_rss.rss_key)); + if (error || req->newptr == NULL) + goto back; + + error = SYSCTL_IN(req, sc->hn_rss.rss_key, sizeof(sc->hn_rss.rss_key)); + if (error) + goto back; + + error = hn_rss_reconfig(sc); +back: + HN_UNLOCK(sc); + return (error); +} + +static int +hn_rss_ind_sysctl(SYSCTL_HANDLER_ARGS) +{ + struct hn_softc *sc = arg1; + int error; + + HN_LOCK(sc); + + error = SYSCTL_OUT(req, sc->hn_rss.rss_ind, sizeof(sc->hn_rss.rss_ind)); + if (error || req->newptr == NULL) + goto back; + + error = SYSCTL_IN(req, sc->hn_rss.rss_ind, sizeof(sc->hn_rss.rss_ind)); + if (error) + goto back; + + hn_rss_ind_fixup(sc, sc->hn_rx_ring_inuse); + error = hn_rss_reconfig(sc); +back: + HN_UNLOCK(sc); + return (error); +} + +static int hn_check_iplen(const struct mbuf *m, int hoff) { const struct ip *ip; @@ -3179,15 +3288,34 @@ hn_synth_attach(struct hn_softc *sc, int * are allocated. */ - /* Setup default RSS key. */ - memcpy(rss->rss_key, hn_rss_key_default, sizeof(rss->rss_key)); + if (!device_is_attached(sc->hn_dev)) { + /* + * Setup default RSS key and indirect table for the + * attach DEVMETHOD. They can be altered later on, + * so don't mess them up once this interface is attached. + */ + if (bootverbose) { + if_printf(sc->hn_ifp, "setup default RSS key and " + "indirect table\n"); + } + + /* Setup default RSS key. */ + memcpy(rss->rss_key, hn_rss_key_default, sizeof(rss->rss_key)); - /* Setup default RSS indirect table. */ - /* TODO: Take ndis_rss_caps.ndis_nind into account. */ - for (i = 0; i < NDIS_HASH_INDCNT; ++i) - rss->rss_ind[i] = i % nchan; + /* Setup default RSS indirect table. */ + /* TODO: Take ndis_rss_caps.ndis_nind into account. */ + for (i = 0; i < NDIS_HASH_INDCNT; ++i) + rss->rss_ind[i] = i % nchan; + } else { + /* + * # of usable channels may be changed, so we have to + * make sure that all entries in RSS indirect table + * are valid. + */ + hn_rss_ind_fixup(sc, nchan); + } - error = hn_rndis_conf_rss(sc); + error = hn_rndis_conf_rss(sc, NDIS_RSS_FLAG_NONE); if (error) { /* * Failed to configure RSS key or indirect table; only Modified: stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.c Thu Oct 13 09:18:56 2016 (r307211) +++ stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.c Thu Oct 13 09:27:08 2016 (r307212) @@ -838,7 +838,7 @@ hn_rndis_conf_offload(struct hn_softc *s } int -hn_rndis_conf_rss(struct hn_softc *sc) +hn_rndis_conf_rss(struct hn_softc *sc, uint16_t flags) { struct ndis_rssprm_toeplitz *rss = &sc->hn_rss; struct ndis_rss_params *prm = &rss->rss_params; @@ -859,6 +859,7 @@ hn_rndis_conf_rss(struct hn_softc *sc) prm->ndis_hdr.ndis_type = NDIS_OBJTYPE_RSS_PARAMS; prm->ndis_hdr.ndis_rev = NDIS_RSS_PARAMS_REV_2; prm->ndis_hdr.ndis_size = sizeof(*rss); + prm->ndis_flags = flags; prm->ndis_hash = NDIS_HASH_FUNCTION_TOEPLITZ | NDIS_HASH_IPV4 | NDIS_HASH_TCP_IPV4 | NDIS_HASH_IPV6 | NDIS_HASH_TCP_IPV6; Modified: stable/10/sys/dev/hyperv/netvsc/if_hnvar.h ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/if_hnvar.h Thu Oct 13 09:18:56 2016 (r307211) +++ stable/10/sys/dev/hyperv/netvsc/if_hnvar.h Thu Oct 13 09:27:08 2016 (r307212) @@ -118,7 +118,7 @@ uint32_t hn_chim_alloc(struct hn_softc * void hn_chim_free(struct hn_softc *sc, uint32_t chim_idx); int hn_rndis_attach(struct hn_softc *sc); -int hn_rndis_conf_rss(struct hn_softc *sc); +int hn_rndis_conf_rss(struct hn_softc *sc, uint16_t flags); void *hn_rndis_pktinfo_append(struct rndis_packet_msg *, size_t pktsize, size_t pi_dlen, uint32_t pi_type); int hn_rndis_get_rsscaps(struct hn_softc *sc, int *rxr_cnt); Modified: stable/10/sys/dev/hyperv/netvsc/ndis.h ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/ndis.h Thu Oct 13 09:18:56 2016 (r307211) +++ stable/10/sys/dev/hyperv/netvsc/ndis.h Thu Oct 13 09:27:08 2016 (r307212) @@ -188,6 +188,7 @@ struct ndis_rss_params { #define NDIS_RSS_PARAMS_REV_1 1 /* NDIS 6.0 */ #define NDIS_RSS_PARAMS_REV_2 2 /* NDIS 6.20 */ +#define NDIS_RSS_FLAG_NONE 0x0000 #define NDIS_RSS_FLAG_BCPU_UNCHG 0x0001 #define NDIS_RSS_FLAG_HASH_UNCHG 0x0002 #define NDIS_RSS_FLAG_IND_UNCHG 0x0004 From owner-svn-src-all@freebsd.org Thu Oct 13 09:37:22 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 46E58C0E55E; Thu, 13 Oct 2016 09:37:22 +0000 (UTC) (envelope-from royger@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 1823E21B; Thu, 13 Oct 2016 09:37:22 +0000 (UTC) (envelope-from royger@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9D9bLdX065947; Thu, 13 Oct 2016 09:37:21 GMT (envelope-from royger@FreeBSD.org) Received: (from royger@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9D9bL0v065946; Thu, 13 Oct 2016 09:37:21 GMT (envelope-from royger@FreeBSD.org) Message-Id: <201610130937.u9D9bL0v065946@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: royger set sender to royger@FreeBSD.org using -f From: =?UTF-8?Q?Roger_Pau_Monn=c3=a9?= Date: Thu, 13 Oct 2016 09:37:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307213 - stable/10/sys/x86/x86 X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Oct 2016 09:37:22 -0000 Author: royger Date: Thu Oct 13 09:37:21 2016 New Revision: 307213 URL: https://svnweb.freebsd.org/changeset/base/307213 Log: MFC r303491: Revert r291022: x86/intr: allow mutex recursion in intr_remove_handler Sponsored by: Citrix Systems R&D Modified: stable/10/sys/x86/x86/intr_machdep.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/x86/x86/intr_machdep.c ============================================================================== --- stable/10/sys/x86/x86/intr_machdep.c Thu Oct 13 09:27:08 2016 (r307212) +++ stable/10/sys/x86/x86/intr_machdep.c Thu Oct 13 09:37:21 2016 (r307213) @@ -197,28 +197,19 @@ int intr_remove_handler(void *cookie) { struct intsrc *isrc; - int error, mtx_owned; + int error; isrc = intr_handler_source(cookie); error = intr_event_remove_handler(cookie); if (error == 0) { - /* - * Recursion is needed here so PICs can remove interrupts - * while resuming. It was previously not possible due to - * intr_resume holding the intr_table_lock and - * intr_remove_handler recursing on it. - */ - mtx_owned = mtx_owned(&intr_table_lock); - if (mtx_owned == 0) - mtx_lock(&intr_table_lock); + mtx_lock(&intr_table_lock); isrc->is_handlers--; if (isrc->is_handlers == 0) { isrc->is_pic->pic_disable_source(isrc, PIC_NO_EOI); isrc->is_pic->pic_disable_intr(isrc); } intrcnt_updatename(isrc); - if (mtx_owned == 0) - mtx_unlock(&intr_table_lock); + mtx_unlock(&intr_table_lock); } return (error); } From owner-svn-src-all@freebsd.org Thu Oct 13 09:43:05 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 44317C0E720; Thu, 13 Oct 2016 09:43:05 +0000 (UTC) (envelope-from sepherosa@gmail.com) Received: from mail-vk0-x235.google.com (mail-vk0-x235.google.com [IPv6:2607:f8b0:400c:c05::235]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id F249FF5; Thu, 13 Oct 2016 09:43:04 +0000 (UTC) (envelope-from sepherosa@gmail.com) Received: by mail-vk0-x235.google.com with SMTP id 83so48215797vkd.0; Thu, 13 Oct 2016 02:43:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=ClnhcjVSrMJlUpQit60S3251UubEniZAoDvPetQ7nQY=; b=TuF5msw4WntcMyY60VL4FLE05SHKHRSYTUNt/l16e6z+Qg8L7DW0BF4ifC31C2JnKn CJX+CSU6MCrV7k20XlKwfpI/ng6W7sUA3D7y7iBnmxy6QB5zuX4VjaySlNcDiXR0L6kZ Hp24N+phh7iDbzxNhSFzrswek3U3i3dxzqIOV+aH5CLOqdnq137CoDp3kchYkF78h1Zx i/ff4TZq1j6MP55NeeQ76OJrZAhttV8ZaupnxLaeY8V5qcOezzO9LLUQYUSOT5P/8PAu yN6UT8ySUSStmo4sq0t33lwNTni1UDiGKE3uhzoe5/pGHhz/VGVrWj7r2xvfhfqRHt0t Irkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=ClnhcjVSrMJlUpQit60S3251UubEniZAoDvPetQ7nQY=; b=In/GP/E50/DsxJBjs/7FM/BIT430RlumsbYDL3c5FswzB27gJmjAG5JSdkmuVyczIm BCffyvHwFY00dGPA9x63YGZEJBicjbEta041ITfKKM2xdQfoq4gC7vM8fA5fLYioEVtk 4TgMaMNRndq+k3ok7k5VF5l4dDm4xVyi2pDhCmZAD+NBzYzaV0tR2mRpUHwrPQEULMrS N0GltwjL302E3YQlOxR9inL77DF+/wZN0mXE8TJfIIrFg+bCskLtmO5vbLQCkKR6Gmb3 b8cU5iSh4iDg9heSrGIOf/YF2msPiAUZYHhRUc465/KgAXOedcgHEx1rcC+CGlRAMriM NXvA== X-Gm-Message-State: AA6/9RnazG5aCf5tuhzRlsRsCB1ELr2HF3YdsrXJQkSo4NO0rxZOlQFSq1slDi4S/8hH6p7qAOKrZrO8HhNiAQ== X-Received: by 10.31.120.14 with SMTP id t14mr3716006vkc.55.1476351783737; Thu, 13 Oct 2016 02:43:03 -0700 (PDT) MIME-Version: 1.0 Received: by 10.176.81.121 with HTTP; Thu, 13 Oct 2016 02:43:03 -0700 (PDT) In-Reply-To: <201610130937.u9D9bL0v065946@repo.freebsd.org> References: <201610130937.u9D9bL0v065946@repo.freebsd.org> From: Sepherosa Ziehau Date: Thu, 13 Oct 2016 17:43:03 +0800 Message-ID: Subject: Re: svn commit: r307213 - stable/10/sys/x86/x86 To: =?UTF-8?Q?Roger_Pau_Monn=C3=A9?= Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Oct 2016 09:43:05 -0000 On Thu, Oct 13, 2016 at 5:37 PM, Roger Pau Monn=C3=A9 = wrote: > Author: royger > Date: Thu Oct 13 09:37:21 2016 > New Revision: 307213 > URL: https://svnweb.freebsd.org/changeset/base/307213 > > Log: > MFC r303491: > > Revert r291022: x86/intr: allow mutex recursion in intr_remove_handler > > Sponsored by: Citrix Systems R&D Thank you very much! From owner-svn-src-all@freebsd.org Thu Oct 13 11:34:25 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A70CFC0EB38; Thu, 13 Oct 2016 11:34:25 +0000 (UTC) (envelope-from mm@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 7315F178; Thu, 13 Oct 2016 11:34:25 +0000 (UTC) (envelope-from mm@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9DBYOQa010546; Thu, 13 Oct 2016 11:34:24 GMT (envelope-from mm@FreeBSD.org) Received: (from mm@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9DBYNgs010536; Thu, 13 Oct 2016 11:34:23 GMT (envelope-from mm@FreeBSD.org) Message-Id: <201610131134.u9DBYNgs010536@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mm set sender to mm@FreeBSD.org using -f From: Martin Matuska Date: Thu, 13 Oct 2016 11:34:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-vendor@freebsd.org Subject: svn commit: r307214 - in vendor/libarchive/dist: cpio/test libarchive libarchive/test tar/test X-SVN-Group: vendor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Oct 2016 11:34:25 -0000 Author: mm Date: Thu Oct 13 11:34:23 2016 New Revision: 307214 URL: https://svnweb.freebsd.org/changeset/base/307214 Log: Update vendor/libarchive to git e3bdbbf3475c3abf264e563c753a20972095665e Important vendor bugfixes (relevant to FreeBSD): #801: FreeBSD Coverity report: resource leak in libarchive/tar/test/main.c Modified: vendor/libarchive/dist/cpio/test/main.c vendor/libarchive/dist/cpio/test/test.h vendor/libarchive/dist/libarchive/archive_read_disk_entry_from_file.c vendor/libarchive/dist/libarchive/archive_read_disk_set_standard_lookup.c vendor/libarchive/dist/libarchive/test/main.c vendor/libarchive/dist/libarchive/test/test.h vendor/libarchive/dist/libarchive/test/test_read_set_format.c vendor/libarchive/dist/tar/test/main.c vendor/libarchive/dist/tar/test/test.h vendor/libarchive/dist/tar/test/test_missing_file.c Modified: vendor/libarchive/dist/cpio/test/main.c ============================================================================== --- vendor/libarchive/dist/cpio/test/main.c Thu Oct 13 09:37:21 2016 (r307213) +++ vendor/libarchive/dist/cpio/test/main.c Thu Oct 13 11:34:23 2016 (r307214) @@ -130,6 +130,13 @@ __FBSDID("$FreeBSD: src/usr.bin/cpio/tes # include #endif +mode_t umasked(mode_t expected_mode) +{ + mode_t mode = umask(0); + umask(mode); + return expected_mode & ~mode; +} + /* Path to working directory for current test */ const char *testworkdir; #ifdef PROGRAM @@ -1294,6 +1301,11 @@ assertion_file_time(const char *file, in switch (type) { case 'a': filet_nsec = st.st_atimespec.tv_nsec; break; case 'b': filet = st.st_birthtime; + /* FreeBSD filesystems that don't support birthtime + * (e.g., UFS1) always return -1 here. */ + if (filet == -1) { + return (1); + } filet_nsec = st.st_birthtimespec.tv_nsec; break; case 'm': filet_nsec = st.st_mtimespec.tv_nsec; break; default: fprintf(stderr, "INTERNAL: Bad type %c for file time", type); @@ -1425,7 +1437,7 @@ assertion_file_nlinks(const char *file, assertion_count(file, line); r = lstat(pathname, &st); if (r == 0 && (int)st.st_nlink == nlinks) - return (1); + return (1); failure_start(file, line, "File %s has %d links, expected %d", pathname, st.st_nlink, nlinks); failure_finish(NULL); @@ -1661,6 +1673,7 @@ assertion_make_file(const char *file, in if (0 != chmod(path, mode)) { failure_start(file, line, "Could not chmod %s", path); failure_finish(NULL); + close(fd); return (0); } if (contents != NULL) { @@ -1675,6 +1688,7 @@ assertion_make_file(const char *file, in failure_start(file, line, "Could not write to %s", path); failure_finish(NULL); + close(fd); return (0); } } Modified: vendor/libarchive/dist/cpio/test/test.h ============================================================================== --- vendor/libarchive/dist/cpio/test/test.h Thu Oct 13 09:37:21 2016 (r307213) +++ vendor/libarchive/dist/cpio/test/test.h Thu Oct 13 11:34:23 2016 (r307214) @@ -182,6 +182,8 @@ assertion_file_nlinks(__FILE__, __LINE__, pathname, nlinks) #define assertFileSize(pathname, size) \ assertion_file_size(__FILE__, __LINE__, pathname, size) +#define assertFileMode(pathname, mode) \ + assertion_file_mode(__FILE__, __LINE__, pathname, mode) #define assertTextFileContents(text, pathname) \ assertion_text_file_contents(__FILE__, __LINE__, text, pathname) #define assertFileContainsLinesAnyOrder(pathname, lines) \ @@ -327,6 +329,9 @@ void copy_reference_file(const char *); */ void extract_reference_files(const char **); +/* Subtract umask from mode */ +mode_t umasked(mode_t expected_mode); + /* Path to working directory for current test */ extern const char *testworkdir; Modified: vendor/libarchive/dist/libarchive/archive_read_disk_entry_from_file.c ============================================================================== --- vendor/libarchive/dist/libarchive/archive_read_disk_entry_from_file.c Thu Oct 13 09:37:21 2016 (r307213) +++ vendor/libarchive/dist/libarchive/archive_read_disk_entry_from_file.c Thu Oct 13 11:34:23 2016 (r307214) @@ -628,7 +628,6 @@ translate_acl(struct archive_read_disk * archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC, "Unknown ACL brand"); return (ARCHIVE_WARN); - break; } #endif Modified: vendor/libarchive/dist/libarchive/archive_read_disk_set_standard_lookup.c ============================================================================== --- vendor/libarchive/dist/libarchive/archive_read_disk_set_standard_lookup.c Thu Oct 13 09:37:21 2016 (r307213) +++ vendor/libarchive/dist/libarchive/archive_read_disk_set_standard_lookup.c Thu Oct 13 11:34:23 2016 (r307214) @@ -232,6 +232,7 @@ static const char * lookup_uname_helper(struct name_cache *cache, id_t id) { struct passwd *result; + (void)cache; /* UNUSED */ result = getpwuid((uid_t)id); @@ -298,6 +299,7 @@ static const char * lookup_gname_helper(struct name_cache *cache, id_t id) { struct group *result; + (void)cache; /* UNUSED */ result = getgrgid((gid_t)id); Modified: vendor/libarchive/dist/libarchive/test/main.c ============================================================================== --- vendor/libarchive/dist/libarchive/test/main.c Thu Oct 13 09:37:21 2016 (r307213) +++ vendor/libarchive/dist/libarchive/test/main.c Thu Oct 13 11:34:23 2016 (r307214) @@ -128,6 +128,13 @@ __FBSDID("$FreeBSD: head/lib/libarchive/ # include #endif +mode_t umasked(mode_t expected_mode) +{ + mode_t mode = umask(0); + umask(mode); + return expected_mode & ~mode; +} + /* Path to working directory for current test */ const char *testworkdir; #ifdef PROGRAM @@ -1364,6 +1371,31 @@ assertion_file_birthtime_recent(const ch return assertion_file_time(file, line, pathname, 0, 0, 'b', 1); } +/* Verify mode of 'pathname'. */ +int +assertion_file_mode(const char *file, int line, const char *pathname, int expected_mode) +{ + int mode; + int r; + + assertion_count(file, line); +#if defined(_WIN32) && !defined(__CYGWIN__) + failure_start(file, line, "assertFileMode not yet implemented for Windows"); +#else + { + struct stat st; + r = lstat(pathname, &st); + mode = (int)(st.st_mode & 0777); + } + if (r == 0 && mode == expected_mode) + return (1); + failure_start(file, line, "File %s has mode %o, expected %o", + pathname, mode, expected_mode); +#endif + failure_finish(NULL); + return (0); +} + /* Verify mtime of 'pathname'. */ int assertion_file_mtime(const char *file, int line, @@ -1403,7 +1435,7 @@ assertion_file_nlinks(const char *file, assertion_count(file, line); r = lstat(pathname, &st); if (r == 0 && (int)st.st_nlink == nlinks) - return (1); + return (1); failure_start(file, line, "File %s has %d links, expected %d", pathname, st.st_nlink, nlinks); failure_finish(NULL); @@ -1440,31 +1472,6 @@ assertion_file_size(const char *file, in return (0); } -/* Verify mode of 'pathname'. */ -int -assertion_file_mode(const char *file, int line, const char *pathname, int expected_mode) -{ - int mode; - int r; - - assertion_count(file, line); -#if defined(_WIN32) && !defined(__CYGWIN__) - failure_start(file, line, "assertFileMode not yet implemented for Windows"); -#else - { - struct stat st; - r = lstat(pathname, &st); - mode = (int)(st.st_mode & 0777); - } - if (r == 0 && mode == expected_mode) - return (1); - failure_start(file, line, "File %s has mode %o, expected %o", - pathname, mode, expected_mode); -#endif - failure_finish(NULL); - return (0); -} - /* Assert that 'pathname' is a dir. If mode >= 0, verify that too. */ int assertion_is_dir(const char *file, int line, const char *pathname, int mode) @@ -1664,6 +1671,7 @@ assertion_make_file(const char *file, in if (0 != chmod(path, mode)) { failure_start(file, line, "Could not chmod %s", path); failure_finish(NULL); + close(fd); return (0); } if (contents != NULL) { @@ -1678,6 +1686,7 @@ assertion_make_file(const char *file, in failure_start(file, line, "Could not write to %s", path); failure_finish(NULL); + close(fd); return (0); } } Modified: vendor/libarchive/dist/libarchive/test/test.h ============================================================================== --- vendor/libarchive/dist/libarchive/test/test.h Thu Oct 13 09:37:21 2016 (r307213) +++ vendor/libarchive/dist/libarchive/test/test.h Thu Oct 13 11:34:23 2016 (r307214) @@ -243,12 +243,12 @@ int assertion_file_birthtime_recent(cons int assertion_file_contains_lines_any_order(const char *, int, const char *, const char **); int assertion_file_contents(const char *, int, const void *, int, const char *); int assertion_file_exists(const char *, int, const char *); +int assertion_file_mode(const char *, int, const char *, int); int assertion_file_mtime(const char *, int, const char *, long, long); int assertion_file_mtime_recent(const char *, int, const char *); int assertion_file_nlinks(const char *, int, const char *, int); int assertion_file_not_exists(const char *, int, const char *); int assertion_file_size(const char *, int, const char *, long); -int assertion_file_mode(const char *, int, const char *, int); int assertion_is_dir(const char *, int, const char *, int); int assertion_is_hardlink(const char *, int, const char *, const char *); int assertion_is_not_hardlink(const char *, int, const char *, const char *); @@ -329,6 +329,9 @@ void copy_reference_file(const char *); */ void extract_reference_files(const char **); +/* Subtract umask from mode */ +mode_t umasked(mode_t expected_mode); + /* Path to working directory for current test */ extern const char *testworkdir; Modified: vendor/libarchive/dist/libarchive/test/test_read_set_format.c ============================================================================== --- vendor/libarchive/dist/libarchive/test/test_read_set_format.c Thu Oct 13 09:37:21 2016 (r307213) +++ vendor/libarchive/dist/libarchive/test/test_read_set_format.c Thu Oct 13 11:34:23 2016 (r307214) @@ -200,6 +200,8 @@ DEFINE_TEST(test_read_append_filter_wron { struct archive_entry *ae; struct archive *a; + int fd; + fpos_t pos; /* * If we have "bunzip2 -q", try using that. @@ -208,6 +210,13 @@ DEFINE_TEST(test_read_append_filter_wron skipping("Can't run bunzip2 program on this platform"); return; } + + /* bunzip2 will write to stderr, redirect it to a file */ + fflush(stderr); + fgetpos(stderr, &pos); + fd = dup(fileno(stderr)); + freopen("stderr1", "w", stderr); + assert((a = archive_read_new()) != NULL); assertA(0 == archive_read_set_format(a, ARCHIVE_FORMAT_TAR)); assertEqualIntA(a, ARCHIVE_OK, @@ -217,4 +226,13 @@ DEFINE_TEST(test_read_append_filter_wron assertA(archive_read_next_header(a, &ae) < (ARCHIVE_WARN)); assertEqualIntA(a, ARCHIVE_WARN, archive_read_close(a)); assertEqualInt(ARCHIVE_OK, archive_read_free(a)); + + /* restore stderr */ + fflush(stderr); + dup2(fd, fileno(stderr)); + close(fd); + clearerr(stderr); + fsetpos(stderr, &pos); + + assertTextFileContents("bunzip2: (stdin) is not a bzip2 file.\n", "stderr1"); } Modified: vendor/libarchive/dist/tar/test/main.c ============================================================================== --- vendor/libarchive/dist/tar/test/main.c Thu Oct 13 09:37:21 2016 (r307213) +++ vendor/libarchive/dist/tar/test/main.c Thu Oct 13 11:34:23 2016 (r307214) @@ -1164,6 +1164,35 @@ assertion_file_contains_lines_any_order( return (0); } +/* Verify that a text file does not contains the specified strings */ +int +assertion_file_contains_no_invalid_strings(const char *file, int line, + const char *pathname, const char *strings[]) +{ + char *buff; + int i; + + buff = slurpfile(NULL, "%s", pathname); + if (buff == NULL) { + failure_start(file, line, "Can't read file: %s", pathname); + failure_finish(NULL); + return (0); + } + + for (i = 0; strings[i] != NULL; ++i) { + if (strstr(buff, strings[i]) != NULL) { + failure_start(file, line, "Invalid string in %s: %s", pathname, + strings[i]); + failure_finish(NULL); + free(buff); + return(0); + } + } + + free(buff); + return (0); +} + /* Test that two paths point to the same file. */ /* As a side-effect, asserts that both files exist. */ static int @@ -1301,6 +1330,11 @@ assertion_file_time(const char *file, in switch (type) { case 'a': filet_nsec = st.st_atimespec.tv_nsec; break; case 'b': filet = st.st_birthtime; + /* FreeBSD filesystems that don't support birthtime + * (e.g., UFS1) always return -1 here. */ + if (filet == -1) { + return (1); + } filet_nsec = st.st_birthtimespec.tv_nsec; break; case 'm': filet_nsec = st.st_mtimespec.tv_nsec; break; default: fprintf(stderr, "INTERNAL: Bad type %c for file time", type); @@ -1432,7 +1466,7 @@ assertion_file_nlinks(const char *file, assertion_count(file, line); r = lstat(pathname, &st); if (r == 0 && (int)st.st_nlink == nlinks) - return (1); + return (1); failure_start(file, line, "File %s has %d links, expected %d", pathname, st.st_nlink, nlinks); failure_finish(NULL); @@ -1668,6 +1702,7 @@ assertion_make_file(const char *file, in if (0 != chmod(path, mode)) { failure_start(file, line, "Could not chmod %s", path); failure_finish(NULL); + close(fd); return (0); } if (contents != NULL) { @@ -1682,6 +1717,7 @@ assertion_make_file(const char *file, in failure_start(file, line, "Could not write to %s", path); failure_finish(NULL); + close(fd); return (0); } } Modified: vendor/libarchive/dist/tar/test/test.h ============================================================================== --- vendor/libarchive/dist/tar/test/test.h Thu Oct 13 09:37:21 2016 (r307213) +++ vendor/libarchive/dist/tar/test/test.h Thu Oct 13 11:34:23 2016 (r307214) @@ -174,6 +174,9 @@ /* Assert that file contents match a string. */ #define assertFileContents(data, data_size, pathname) \ assertion_file_contents(__FILE__, __LINE__, data, data_size, pathname) +/* Verify that a file does not contain invalid strings */ +#define assertFileContainsNoInvalidStrings(pathname, strings) \ + assertion_file_contains_no_invalid_strings(__FILE__, __LINE__, pathname, strings) #define assertFileMtime(pathname, sec, nsec) \ assertion_file_mtime(__FILE__, __LINE__, pathname, sec, nsec) #define assertFileMtimeRecent(pathname) \ @@ -182,6 +185,8 @@ assertion_file_nlinks(__FILE__, __LINE__, pathname, nlinks) #define assertFileSize(pathname, size) \ assertion_file_size(__FILE__, __LINE__, pathname, size) +#define assertFileMode(pathname, mode) \ + assertion_file_mode(__FILE__, __LINE__, pathname, mode) #define assertTextFileContents(text, pathname) \ assertion_text_file_contents(__FILE__, __LINE__, text, pathname) #define assertFileContainsLinesAnyOrder(pathname, lines) \ @@ -239,6 +244,7 @@ int assertion_file_atime_recent(const ch int assertion_file_birthtime(const char *, int, const char *, long, long); int assertion_file_birthtime_recent(const char *, int, const char *); int assertion_file_contains_lines_any_order(const char *, int, const char *, const char **); +int assertion_file_contains_no_invalid_strings(const char *, int, const char *, const char **); int assertion_file_contents(const char *, int, const void *, int, const char *); int assertion_file_exists(const char *, int, const char *); int assertion_file_mode(const char *, int, const char *, int); Modified: vendor/libarchive/dist/tar/test/test_missing_file.c ============================================================================== --- vendor/libarchive/dist/tar/test/test_missing_file.c Thu Oct 13 09:37:21 2016 (r307213) +++ vendor/libarchive/dist/tar/test/test_missing_file.c Thu Oct 13 11:34:23 2016 (r307214) @@ -27,11 +27,15 @@ __FBSDID("$FreeBSD$"); DEFINE_TEST(test_missing_file) { + const char * invalid_stderr[] = { "INTERNAL ERROR", NULL }; assertMakeFile("file1", 0644, "file1"); assertMakeFile("file2", 0644, "file2"); assert(0 == systemf("%s -cf archive.tar file1 file2 2>stderr1", testprog)); assertEmptyFile("stderr1"); assert(0 != systemf("%s -cf archive.tar file1 file2 file3 2>stderr2", testprog)); + assertFileContainsNoInvalidStrings("stderr2", invalid_stderr); assert(0 != systemf("%s -cf archive.tar 2>stderr3", testprog)); - assert(0 != systemf("%s -cf archive.tar file3 2>stderr4", testprog)); + assertFileContainsNoInvalidStrings("stderr3", invalid_stderr); + assert(0 != systemf("%s -cf archive.tar file3 file4 2>stderr4", testprog)); + assertFileContainsNoInvalidStrings("stderr4", invalid_stderr); } From owner-svn-src-all@freebsd.org Thu Oct 13 11:40:37 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 0B8E5C0EC70; Thu, 13 Oct 2016 11:40:37 +0000 (UTC) (envelope-from mm@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id C92AC3D2; Thu, 13 Oct 2016 11:40:36 +0000 (UTC) (envelope-from mm@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9DBeaEQ010855; Thu, 13 Oct 2016 11:40:36 GMT (envelope-from mm@FreeBSD.org) Received: (from mm@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9DBeZ4o010845; Thu, 13 Oct 2016 11:40:35 GMT (envelope-from mm@FreeBSD.org) Message-Id: <201610131140.u9DBeZ4o010845@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mm set sender to mm@FreeBSD.org using -f From: Martin Matuska Date: Thu, 13 Oct 2016 11:40:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307215 - in head/contrib/libarchive: cpio/test libarchive libarchive/test tar/test X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Oct 2016 11:40:37 -0000 Author: mm Date: Thu Oct 13 11:40:34 2016 New Revision: 307215 URL: https://svnweb.freebsd.org/changeset/base/307215 Log: MFV r307214: Sync libarchive with vendor. Style and tests fixes. Important vendor bugfixes (relevant to FreeBSD): #801: FreeBSD Coverity report: resource leak in libarchive/tar/test/main.c MFC after: 1 week Modified: head/contrib/libarchive/cpio/test/main.c head/contrib/libarchive/cpio/test/test.h head/contrib/libarchive/libarchive/archive_read_disk_entry_from_file.c head/contrib/libarchive/libarchive/archive_read_disk_set_standard_lookup.c head/contrib/libarchive/libarchive/test/main.c head/contrib/libarchive/libarchive/test/test.h head/contrib/libarchive/libarchive/test/test_read_set_format.c head/contrib/libarchive/tar/test/main.c head/contrib/libarchive/tar/test/test.h head/contrib/libarchive/tar/test/test_missing_file.c Directory Properties: head/contrib/libarchive/ (props changed) Modified: head/contrib/libarchive/cpio/test/main.c ============================================================================== --- head/contrib/libarchive/cpio/test/main.c Thu Oct 13 11:34:23 2016 (r307214) +++ head/contrib/libarchive/cpio/test/main.c Thu Oct 13 11:40:34 2016 (r307215) @@ -130,6 +130,13 @@ __FBSDID("$FreeBSD$"); # include #endif +mode_t umasked(mode_t expected_mode) +{ + mode_t mode = umask(0); + umask(mode); + return expected_mode & ~mode; +} + /* Path to working directory for current test */ const char *testworkdir; #ifdef PROGRAM @@ -1294,6 +1301,11 @@ assertion_file_time(const char *file, in switch (type) { case 'a': filet_nsec = st.st_atimespec.tv_nsec; break; case 'b': filet = st.st_birthtime; + /* FreeBSD filesystems that don't support birthtime + * (e.g., UFS1) always return -1 here. */ + if (filet == -1) { + return (1); + } filet_nsec = st.st_birthtimespec.tv_nsec; break; case 'm': filet_nsec = st.st_mtimespec.tv_nsec; break; default: fprintf(stderr, "INTERNAL: Bad type %c for file time", type); @@ -1425,7 +1437,7 @@ assertion_file_nlinks(const char *file, assertion_count(file, line); r = lstat(pathname, &st); if (r == 0 && (int)st.st_nlink == nlinks) - return (1); + return (1); failure_start(file, line, "File %s has %d links, expected %d", pathname, st.st_nlink, nlinks); failure_finish(NULL); @@ -1661,6 +1673,7 @@ assertion_make_file(const char *file, in if (0 != chmod(path, mode)) { failure_start(file, line, "Could not chmod %s", path); failure_finish(NULL); + close(fd); return (0); } if (contents != NULL) { @@ -1675,6 +1688,7 @@ assertion_make_file(const char *file, in failure_start(file, line, "Could not write to %s", path); failure_finish(NULL); + close(fd); return (0); } } Modified: head/contrib/libarchive/cpio/test/test.h ============================================================================== --- head/contrib/libarchive/cpio/test/test.h Thu Oct 13 11:34:23 2016 (r307214) +++ head/contrib/libarchive/cpio/test/test.h Thu Oct 13 11:40:34 2016 (r307215) @@ -182,6 +182,8 @@ assertion_file_nlinks(__FILE__, __LINE__, pathname, nlinks) #define assertFileSize(pathname, size) \ assertion_file_size(__FILE__, __LINE__, pathname, size) +#define assertFileMode(pathname, mode) \ + assertion_file_mode(__FILE__, __LINE__, pathname, mode) #define assertTextFileContents(text, pathname) \ assertion_text_file_contents(__FILE__, __LINE__, text, pathname) #define assertFileContainsLinesAnyOrder(pathname, lines) \ @@ -327,6 +329,9 @@ void copy_reference_file(const char *); */ void extract_reference_files(const char **); +/* Subtract umask from mode */ +mode_t umasked(mode_t expected_mode); + /* Path to working directory for current test */ extern const char *testworkdir; Modified: head/contrib/libarchive/libarchive/archive_read_disk_entry_from_file.c ============================================================================== --- head/contrib/libarchive/libarchive/archive_read_disk_entry_from_file.c Thu Oct 13 11:34:23 2016 (r307214) +++ head/contrib/libarchive/libarchive/archive_read_disk_entry_from_file.c Thu Oct 13 11:40:34 2016 (r307215) @@ -627,7 +627,6 @@ translate_acl(struct archive_read_disk * archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC, "Unknown ACL brand"); return (ARCHIVE_WARN); - break; } #endif Modified: head/contrib/libarchive/libarchive/archive_read_disk_set_standard_lookup.c ============================================================================== --- head/contrib/libarchive/libarchive/archive_read_disk_set_standard_lookup.c Thu Oct 13 11:34:23 2016 (r307214) +++ head/contrib/libarchive/libarchive/archive_read_disk_set_standard_lookup.c Thu Oct 13 11:40:34 2016 (r307215) @@ -232,6 +232,7 @@ static const char * lookup_uname_helper(struct name_cache *cache, id_t id) { struct passwd *result; + (void)cache; /* UNUSED */ result = getpwuid((uid_t)id); @@ -298,6 +299,7 @@ static const char * lookup_gname_helper(struct name_cache *cache, id_t id) { struct group *result; + (void)cache; /* UNUSED */ result = getgrgid((gid_t)id); Modified: head/contrib/libarchive/libarchive/test/main.c ============================================================================== --- head/contrib/libarchive/libarchive/test/main.c Thu Oct 13 11:34:23 2016 (r307214) +++ head/contrib/libarchive/libarchive/test/main.c Thu Oct 13 11:40:34 2016 (r307215) @@ -128,6 +128,13 @@ __FBSDID("$FreeBSD$"); # include #endif +mode_t umasked(mode_t expected_mode) +{ + mode_t mode = umask(0); + umask(mode); + return expected_mode & ~mode; +} + /* Path to working directory for current test */ const char *testworkdir; #ifdef PROGRAM @@ -1364,6 +1371,31 @@ assertion_file_birthtime_recent(const ch return assertion_file_time(file, line, pathname, 0, 0, 'b', 1); } +/* Verify mode of 'pathname'. */ +int +assertion_file_mode(const char *file, int line, const char *pathname, int expected_mode) +{ + int mode; + int r; + + assertion_count(file, line); +#if defined(_WIN32) && !defined(__CYGWIN__) + failure_start(file, line, "assertFileMode not yet implemented for Windows"); +#else + { + struct stat st; + r = lstat(pathname, &st); + mode = (int)(st.st_mode & 0777); + } + if (r == 0 && mode == expected_mode) + return (1); + failure_start(file, line, "File %s has mode %o, expected %o", + pathname, mode, expected_mode); +#endif + failure_finish(NULL); + return (0); +} + /* Verify mtime of 'pathname'. */ int assertion_file_mtime(const char *file, int line, @@ -1403,7 +1435,7 @@ assertion_file_nlinks(const char *file, assertion_count(file, line); r = lstat(pathname, &st); if (r == 0 && (int)st.st_nlink == nlinks) - return (1); + return (1); failure_start(file, line, "File %s has %d links, expected %d", pathname, st.st_nlink, nlinks); failure_finish(NULL); @@ -1440,31 +1472,6 @@ assertion_file_size(const char *file, in return (0); } -/* Verify mode of 'pathname'. */ -int -assertion_file_mode(const char *file, int line, const char *pathname, int expected_mode) -{ - int mode; - int r; - - assertion_count(file, line); -#if defined(_WIN32) && !defined(__CYGWIN__) - failure_start(file, line, "assertFileMode not yet implemented for Windows"); -#else - { - struct stat st; - r = lstat(pathname, &st); - mode = (int)(st.st_mode & 0777); - } - if (r == 0 && mode == expected_mode) - return (1); - failure_start(file, line, "File %s has mode %o, expected %o", - pathname, mode, expected_mode); -#endif - failure_finish(NULL); - return (0); -} - /* Assert that 'pathname' is a dir. If mode >= 0, verify that too. */ int assertion_is_dir(const char *file, int line, const char *pathname, int mode) @@ -1664,6 +1671,7 @@ assertion_make_file(const char *file, in if (0 != chmod(path, mode)) { failure_start(file, line, "Could not chmod %s", path); failure_finish(NULL); + close(fd); return (0); } if (contents != NULL) { @@ -1678,6 +1686,7 @@ assertion_make_file(const char *file, in failure_start(file, line, "Could not write to %s", path); failure_finish(NULL); + close(fd); return (0); } } Modified: head/contrib/libarchive/libarchive/test/test.h ============================================================================== --- head/contrib/libarchive/libarchive/test/test.h Thu Oct 13 11:34:23 2016 (r307214) +++ head/contrib/libarchive/libarchive/test/test.h Thu Oct 13 11:40:34 2016 (r307215) @@ -243,12 +243,12 @@ int assertion_file_birthtime_recent(cons int assertion_file_contains_lines_any_order(const char *, int, const char *, const char **); int assertion_file_contents(const char *, int, const void *, int, const char *); int assertion_file_exists(const char *, int, const char *); +int assertion_file_mode(const char *, int, const char *, int); int assertion_file_mtime(const char *, int, const char *, long, long); int assertion_file_mtime_recent(const char *, int, const char *); int assertion_file_nlinks(const char *, int, const char *, int); int assertion_file_not_exists(const char *, int, const char *); int assertion_file_size(const char *, int, const char *, long); -int assertion_file_mode(const char *, int, const char *, int); int assertion_is_dir(const char *, int, const char *, int); int assertion_is_hardlink(const char *, int, const char *, const char *); int assertion_is_not_hardlink(const char *, int, const char *, const char *); @@ -329,6 +329,9 @@ void copy_reference_file(const char *); */ void extract_reference_files(const char **); +/* Subtract umask from mode */ +mode_t umasked(mode_t expected_mode); + /* Path to working directory for current test */ extern const char *testworkdir; Modified: head/contrib/libarchive/libarchive/test/test_read_set_format.c ============================================================================== --- head/contrib/libarchive/libarchive/test/test_read_set_format.c Thu Oct 13 11:34:23 2016 (r307214) +++ head/contrib/libarchive/libarchive/test/test_read_set_format.c Thu Oct 13 11:40:34 2016 (r307215) @@ -200,6 +200,8 @@ DEFINE_TEST(test_read_append_filter_wron { struct archive_entry *ae; struct archive *a; + int fd; + fpos_t pos; /* * If we have "bunzip2 -q", try using that. @@ -208,6 +210,13 @@ DEFINE_TEST(test_read_append_filter_wron skipping("Can't run bunzip2 program on this platform"); return; } + + /* bunzip2 will write to stderr, redirect it to a file */ + fflush(stderr); + fgetpos(stderr, &pos); + fd = dup(fileno(stderr)); + freopen("stderr1", "w", stderr); + assert((a = archive_read_new()) != NULL); assertA(0 == archive_read_set_format(a, ARCHIVE_FORMAT_TAR)); assertEqualIntA(a, ARCHIVE_OK, @@ -217,4 +226,13 @@ DEFINE_TEST(test_read_append_filter_wron assertA(archive_read_next_header(a, &ae) < (ARCHIVE_WARN)); assertEqualIntA(a, ARCHIVE_WARN, archive_read_close(a)); assertEqualInt(ARCHIVE_OK, archive_read_free(a)); + + /* restore stderr */ + fflush(stderr); + dup2(fd, fileno(stderr)); + close(fd); + clearerr(stderr); + fsetpos(stderr, &pos); + + assertTextFileContents("bunzip2: (stdin) is not a bzip2 file.\n", "stderr1"); } Modified: head/contrib/libarchive/tar/test/main.c ============================================================================== --- head/contrib/libarchive/tar/test/main.c Thu Oct 13 11:34:23 2016 (r307214) +++ head/contrib/libarchive/tar/test/main.c Thu Oct 13 11:40:34 2016 (r307215) @@ -1164,6 +1164,35 @@ assertion_file_contains_lines_any_order( return (0); } +/* Verify that a text file does not contains the specified strings */ +int +assertion_file_contains_no_invalid_strings(const char *file, int line, + const char *pathname, const char *strings[]) +{ + char *buff; + int i; + + buff = slurpfile(NULL, "%s", pathname); + if (buff == NULL) { + failure_start(file, line, "Can't read file: %s", pathname); + failure_finish(NULL); + return (0); + } + + for (i = 0; strings[i] != NULL; ++i) { + if (strstr(buff, strings[i]) != NULL) { + failure_start(file, line, "Invalid string in %s: %s", pathname, + strings[i]); + failure_finish(NULL); + free(buff); + return(0); + } + } + + free(buff); + return (0); +} + /* Test that two paths point to the same file. */ /* As a side-effect, asserts that both files exist. */ static int @@ -1301,6 +1330,11 @@ assertion_file_time(const char *file, in switch (type) { case 'a': filet_nsec = st.st_atimespec.tv_nsec; break; case 'b': filet = st.st_birthtime; + /* FreeBSD filesystems that don't support birthtime + * (e.g., UFS1) always return -1 here. */ + if (filet == -1) { + return (1); + } filet_nsec = st.st_birthtimespec.tv_nsec; break; case 'm': filet_nsec = st.st_mtimespec.tv_nsec; break; default: fprintf(stderr, "INTERNAL: Bad type %c for file time", type); @@ -1432,7 +1466,7 @@ assertion_file_nlinks(const char *file, assertion_count(file, line); r = lstat(pathname, &st); if (r == 0 && (int)st.st_nlink == nlinks) - return (1); + return (1); failure_start(file, line, "File %s has %d links, expected %d", pathname, st.st_nlink, nlinks); failure_finish(NULL); @@ -1668,6 +1702,7 @@ assertion_make_file(const char *file, in if (0 != chmod(path, mode)) { failure_start(file, line, "Could not chmod %s", path); failure_finish(NULL); + close(fd); return (0); } if (contents != NULL) { @@ -1682,6 +1717,7 @@ assertion_make_file(const char *file, in failure_start(file, line, "Could not write to %s", path); failure_finish(NULL); + close(fd); return (0); } } Modified: head/contrib/libarchive/tar/test/test.h ============================================================================== --- head/contrib/libarchive/tar/test/test.h Thu Oct 13 11:34:23 2016 (r307214) +++ head/contrib/libarchive/tar/test/test.h Thu Oct 13 11:40:34 2016 (r307215) @@ -174,6 +174,9 @@ /* Assert that file contents match a string. */ #define assertFileContents(data, data_size, pathname) \ assertion_file_contents(__FILE__, __LINE__, data, data_size, pathname) +/* Verify that a file does not contain invalid strings */ +#define assertFileContainsNoInvalidStrings(pathname, strings) \ + assertion_file_contains_no_invalid_strings(__FILE__, __LINE__, pathname, strings) #define assertFileMtime(pathname, sec, nsec) \ assertion_file_mtime(__FILE__, __LINE__, pathname, sec, nsec) #define assertFileMtimeRecent(pathname) \ @@ -182,6 +185,8 @@ assertion_file_nlinks(__FILE__, __LINE__, pathname, nlinks) #define assertFileSize(pathname, size) \ assertion_file_size(__FILE__, __LINE__, pathname, size) +#define assertFileMode(pathname, mode) \ + assertion_file_mode(__FILE__, __LINE__, pathname, mode) #define assertTextFileContents(text, pathname) \ assertion_text_file_contents(__FILE__, __LINE__, text, pathname) #define assertFileContainsLinesAnyOrder(pathname, lines) \ @@ -239,6 +244,7 @@ int assertion_file_atime_recent(const ch int assertion_file_birthtime(const char *, int, const char *, long, long); int assertion_file_birthtime_recent(const char *, int, const char *); int assertion_file_contains_lines_any_order(const char *, int, const char *, const char **); +int assertion_file_contains_no_invalid_strings(const char *, int, const char *, const char **); int assertion_file_contents(const char *, int, const void *, int, const char *); int assertion_file_exists(const char *, int, const char *); int assertion_file_mode(const char *, int, const char *, int); Modified: head/contrib/libarchive/tar/test/test_missing_file.c ============================================================================== --- head/contrib/libarchive/tar/test/test_missing_file.c Thu Oct 13 11:34:23 2016 (r307214) +++ head/contrib/libarchive/tar/test/test_missing_file.c Thu Oct 13 11:40:34 2016 (r307215) @@ -27,11 +27,15 @@ __FBSDID("$FreeBSD$"); DEFINE_TEST(test_missing_file) { + const char * invalid_stderr[] = { "INTERNAL ERROR", NULL }; assertMakeFile("file1", 0644, "file1"); assertMakeFile("file2", 0644, "file2"); assert(0 == systemf("%s -cf archive.tar file1 file2 2>stderr1", testprog)); assertEmptyFile("stderr1"); assert(0 != systemf("%s -cf archive.tar file1 file2 file3 2>stderr2", testprog)); + assertFileContainsNoInvalidStrings("stderr2", invalid_stderr); assert(0 != systemf("%s -cf archive.tar 2>stderr3", testprog)); - assert(0 != systemf("%s -cf archive.tar file3 2>stderr4", testprog)); + assertFileContainsNoInvalidStrings("stderr3", invalid_stderr); + assert(0 != systemf("%s -cf archive.tar file3 file4 2>stderr4", testprog)); + assertFileContainsNoInvalidStrings("stderr4", invalid_stderr); } From owner-svn-src-all@freebsd.org Thu Oct 13 13:06:35 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D401FC1016D; Thu, 13 Oct 2016 13:06:35 +0000 (UTC) (envelope-from carpeddiem@gmail.com) Received: from mail-it0-x244.google.com (mail-it0-x244.google.com [IPv6:2607:f8b0:4001:c0b::244]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 9DAF0A3D; Thu, 13 Oct 2016 13:06:35 +0000 (UTC) (envelope-from carpeddiem@gmail.com) Received: by mail-it0-x244.google.com with SMTP id o19so5787277ito.3; Thu, 13 Oct 2016 06:06:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=/YjwrfpmfG12F7YMKy7TDAmqy43cb4AhDnVs3ixAyKM=; b=udoO7PPq4v0sY1Mbx6zUPsxKsem6KxefIgCp8eSunspf9aHGL8FQoR7/SohS0eVTXQ D3p/Rkt8suUpebt/IMId+u566e2rczg2uFV6doBoJrmAkCHqJgv4gSQna9h08M5yEQOw cEKGW2/mpjemueM8gLrTsSLFSl+7IFhG0PhqX4Z2eWDfGWbLW+C0saYi0YX4k9OkHjPg QDtRQLNk8glcLJs0OdMV4TknqffSRQOGqKFitRIAHJ5yazirheW4KMojggW0kxuTdEcw b4xYkTsJ4Z08aFDn4Tdt3NVKRdPREvcatnTR4XxLdRPMMfLQlpq4TttXe4wGUvjMuMJp 4zHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=/YjwrfpmfG12F7YMKy7TDAmqy43cb4AhDnVs3ixAyKM=; b=f/Cn72P4KUYA3yu6sOwYiXVeURd/2BVAoomLU1omkKst/np5yyYdlbbHhsTpmKOvD8 cUbnpHbXmVr/VjxlYuHjmKWsLopnmM9MofMTRBLYUVn2dKEM4bpcGuiFEV8m4DMXE52U WL79s+lPqNrv6KhGlWa+mEddOZXmeOODf15/ALXh0YNB1oVQpvKLC3daXBEPfyAL9XQG wdqrN717+ZwCfDzdhPoxRf+erD2+pnJaNwbtZP/wRMZlfaGgDXnrdlcQPfPncDrvtxBP daab9vN788VCBSCFtOABVT4BkDwbWkmZDpmjqyJqd2MlvER+72mSH1vipHLN1moqyuiU c8aA== X-Gm-Message-State: AA6/9RmD+rsCDyaRatjTijnnQ7/+z9FnzuWxhEj+C1oDwgIguddtlFOq5NecrGtcLrBLll2t26PX0z7nh/Su0A== X-Received: by 10.36.108.8 with SMTP id w8mr7740375itb.83.1476363994722; Thu, 13 Oct 2016 06:06:34 -0700 (PDT) MIME-Version: 1.0 Sender: carpeddiem@gmail.com Received: by 10.107.180.211 with HTTP; Thu, 13 Oct 2016 06:06:14 -0700 (PDT) In-Reply-To: <20161013110013.W925@besplex.bde.org> References: <201610121356.u9CDuF1q013531@repo.freebsd.org> <20161013110013.W925@besplex.bde.org> From: Ed Maste Date: Thu, 13 Oct 2016 13:06:14 +0000 X-Google-Sender-Auth: goFlwxKYw2g47otjol7CJAXm7ps Message-ID: Subject: Re: svn commit: r307148 - in head/lib/libc: gen stdlib To: Bruce Evans Cc: "src-committers@freebsd.org" , "svn-src-all@freebsd.org" , "svn-src-head@freebsd.org" Content-Type: text/plain; charset=UTF-8 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Oct 2016 13:06:35 -0000 On 13 October 2016 at 02:05, Bruce Evans wrote: > On Wed, 12 Oct 2016, Ed Maste wrote: > > The comment starts by being just wrong: > > 1. "The" sysctl is not used here. Instead, a wrapper arc4_sysctl() is used. > The wrapper handles some but not all errors. Fixed in my WIP tree. > 2. The sysctl can and does fail. It fails on: > - all old kernels mixed with new userlands We don't support new userlands on very old kernels, and I think there are many other things in libc that will fail on kernels old enough to lack kern.arandom. > - with new kernels, at boot time, before the random device is seeded. If that is indeed still possible it's a bug we need to fix before 12.0. > 3. The sysctl can, or at least used to, return short reads with nonzero > counts. That was addressed in markm's 2015 random work, I think. Presumably random() was silently broken for the rand_type != TYPE_0 case prior to that. > The documentation for this is well hidden, but the > arc4_sysctl() wrapper exists to support short reads, or perhaps just > the special case of short reads of 0, which it handles poorly by > possibly spinning forever. I suspect we can just remove the arc4_sysctl wrapper too. > Then the excuse is wrong. abort() never makes sense in library functions. arc4random must not return without good quality random data. The other option would be for it to loop indefinitely. > Here it gives very confusing errors for the delicate boot-time fandago > case. The "delicate boot-time fandango case" was a bug. > Style bugs: > - sentence breaks are 2 spaces in KNF, and all old code in this file follows > that rule. Fixed in my WIP tree. > - 'abort' is not marked up Fixed in my WIP tree. > This is even more broken, since it doesn't have the wrapper. This and the other issues predate my changes; I'll take a look at the history soon. From owner-svn-src-all@freebsd.org Thu Oct 13 13:38:15 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E4CF9C10D42; Thu, 13 Oct 2016 13:38:15 +0000 (UTC) (envelope-from tuexen@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id C1534378; Thu, 13 Oct 2016 13:38:15 +0000 (UTC) (envelope-from tuexen@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9DDcEoa056705; Thu, 13 Oct 2016 13:38:14 GMT (envelope-from tuexen@FreeBSD.org) Received: (from tuexen@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9DDcE8X056704; Thu, 13 Oct 2016 13:38:14 GMT (envelope-from tuexen@FreeBSD.org) Message-Id: <201610131338.u9DDcE8X056704@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: tuexen set sender to tuexen@FreeBSD.org using -f From: Michael Tuexen Date: Thu, 13 Oct 2016 13:38:14 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307216 - head/sys/netinet X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Oct 2016 13:38:16 -0000 Author: tuexen Date: Thu Oct 13 13:38:14 2016 New Revision: 307216 URL: https://svnweb.freebsd.org/changeset/base/307216 Log: Whitespace changes. MFC after: 1 month Modified: head/sys/netinet/sctp_pcb.c Modified: head/sys/netinet/sctp_pcb.c ============================================================================== --- head/sys/netinet/sctp_pcb.c Thu Oct 13 11:40:34 2016 (r307215) +++ head/sys/netinet/sctp_pcb.c Thu Oct 13 13:38:14 2016 (r307216) @@ -77,7 +77,6 @@ SCTP6_ARE_ADDR_EQUAL(struct sockaddr_in6 } return (IN6_ARE_ADDR_EQUAL(&tmp_a.sin6_addr, &tmp_b.sin6_addr)); } - #endif void @@ -837,14 +836,11 @@ static int sctp_does_stcb_own_this_addr(struct sctp_tcb *stcb, struct sockaddr *to) { int loopback_scope; - #if defined(INET) int ipv4_local_scope, ipv4_addr_legal; - #endif #if defined(INET6) int local_scope, site_scope, ipv6_addr_legal; - #endif struct sctp_vrf *vrf; struct sctp_ifn *sctp_ifn; @@ -1216,10 +1212,8 @@ sctp_tcb_special_locate(struct sctp_inpc if (netp != NULL) { *netp = net; } - /* - * Update the endpoint - * pointer - */ + /* Update the endpoint + * pointer */ *inp_p = inp; SCTP_INP_RUNLOCK(inp); return (stcb); @@ -1240,10 +1234,8 @@ sctp_tcb_special_locate(struct sctp_inpc if (netp != NULL) { *netp = net; } - /* - * Update the endpoint - * pointer - */ + /* Update the endpoint + * pointer */ *inp_p = inp; SCTP_INP_RUNLOCK(inp); return (stcb); @@ -1622,15 +1614,12 @@ sctp_endpoint_probe(struct sockaddr *nam { struct sctp_inpcb *inp; struct sctp_laddr *laddr; - #ifdef INET struct sockaddr_in *sin; - #endif #ifdef INET6 struct sockaddr_in6 *sin6; struct sockaddr_in6 *intf_addr6; - #endif int fnd; @@ -1673,10 +1662,8 @@ sctp_endpoint_probe(struct sockaddr *nam case AF_INET: if ((inp->sctp_flags & SCTP_PCB_FLAGS_BOUND_V6) && SCTP_IPV6_V6ONLY(inp)) { - /* - * IPv4 on a IPv6 socket with ONLY - * IPv6 set - */ + /* IPv4 on a IPv6 socket with ONLY + * IPv6 set */ SCTP_INP_RUNLOCK(inp); continue; } @@ -1689,10 +1676,8 @@ sctp_endpoint_probe(struct sockaddr *nam #endif #ifdef INET6 case AF_INET6: - /* - * A V6 address and the endpoint is NOT - * bound V6 - */ + /* A V6 address and the endpoint is NOT + * bound V6 */ if ((inp->sctp_flags & SCTP_PCB_FLAGS_BOUND_V6) == 0) { SCTP_INP_RUNLOCK(inp); continue; @@ -1926,14 +1911,11 @@ sctp_pcb_findep(struct sockaddr *nam, in struct sctppcbhead *head; int lport; unsigned int i; - #ifdef INET struct sockaddr_in *sin; - #endif #ifdef INET6 struct sockaddr_in6 *sin6; - #endif switch (nam->sa_family) { @@ -2057,21 +2039,16 @@ sctp_findassociation_special_addr(struct struct sockaddr *dst) { struct sctp_paramhdr *phdr, parm_buf; - #if defined(INET) || defined(INET6) struct sctp_tcb *stcb; uint16_t ptype; - #endif uint16_t plen; - #ifdef INET struct sockaddr_in sin4; - #endif #ifdef INET6 struct sockaddr_in6 sin6; - #endif #ifdef INET @@ -2198,10 +2175,8 @@ sctp_findassoc_by_vtag(struct sockaddr * continue; } if (remote_tag) { - /* - * If we have both vtags that's all we match - * on - */ + /* If we have both vtags that's all we match + * on */ if (stcb->asoc.peer_vtag == remote_tag) { /* * If both tags match we consider it @@ -2319,14 +2294,11 @@ sctp_findassociation_ep_asconf(struct mb struct sctp_paramhdr parm_buf, *phdr; int ptype; int zero_address = 0; - #ifdef INET struct sockaddr_in *sin; - #endif #ifdef INET6 struct sockaddr_in6 *sin6; - #endif memset(&remote_store, 0, sizeof(remote_store)); @@ -2897,10 +2869,8 @@ sctp_inpcb_bind(struct socket *so, struc #ifdef INET6 case AF_INET6: { - /* - * Only for pure IPv6 Address. (No IPv4 - * Mapped!) - */ + /* Only for pure IPv6 Address. (No IPv4 + * Mapped!) */ struct sockaddr_in6 *sin6; sin6 = (struct sockaddr_in6 *)addr; @@ -2977,10 +2947,8 @@ sctp_inpcb_bind(struct socket *so, struc /* unlock info */ if ((sctp_is_feature_on(inp, SCTP_PCB_FLAGS_PORTREUSE)) && (sctp_is_feature_on(inp_tmp, SCTP_PCB_FLAGS_PORTREUSE))) { - /* - * Ok, must be one-2-one and - * allowing port re-use - */ + /* Ok, must be one-2-one and + * allowing port re-use */ port_reuse_active = 1; goto continue_anyway; } @@ -3003,10 +2971,8 @@ sctp_inpcb_bind(struct socket *so, struc /* unlock info */ if ((sctp_is_feature_on(inp, SCTP_PCB_FLAGS_PORTREUSE)) && (sctp_is_feature_on(inp_tmp, SCTP_PCB_FLAGS_PORTREUSE))) { - /* - * Ok, must be one-2-one and - * allowing port re-use - */ + /* Ok, must be one-2-one and + * allowing port re-use */ port_reuse_active = 1; goto continue_anyway; } @@ -3146,11 +3112,11 @@ continue_anyway: * bind specific, make sure flags is off and add a new * address structure to the sctp_addr_list inside the ep * structure. - * - * We will need to allocate one and insert it at the head. The - * socketopt call can just insert new addresses in there as - * well. It will also have to do the embed scope kame hack - * too (before adding). + * + * We will need to allocate one and insert it at the head. + * The socketopt call can just insert new addresses in there + * as well. It will also have to do the embed scope kame + * hack too (before adding). */ struct sctp_ifa *ifa; union sctp_sockstore store; @@ -3268,11 +3234,11 @@ sctp_iterator_inp_being_freed(struct sct * from happening. But of course the iterator has a * reference on the stcb and inp. We can mark it and it will * stop. - * - * If its a single iterator situation, we set the end iterator - * flag. Otherwise we set the iterator to go to the next - * inp. - * + * + * If its a single iterator situation, we set the end + * iterator flag. Otherwise we set the iterator to go to the + * next inp. + * */ if (it->iterator_flags & SCTP_ITERATOR_DO_SINGLE_INP) { sctp_it_ctl.iterator_flags |= SCTP_ITERATOR_STOP_CUR_IT; @@ -3305,10 +3271,8 @@ sctp_iterator_inp_being_freed(struct sct SCTP_INP_INCR_REF(it->inp); } } - /* - * When its put in the refcnt is incremented so decr - * it - */ + /* When its put in the refcnt is incremented so decr + * it */ SCTP_INP_DECR_REF(inp); } } @@ -3991,10 +3955,8 @@ sctp_add_remote_addr(struct sctp_tcb *st rmtu = SCTP_GATHER_MTU_FROM_ROUTE(net->ro._s_addr, &net->ro._l_addr.sa, net->ro.ro_rt); if (rmtu == 0) { - /* - * Start things off to match mtu of - * interface please. - */ + /* Start things off to match mtu of + * interface please. */ SCTP_SET_MTU_OF_ROUTE(&net->ro._l_addr.sa, net->ro.ro_rt, net->mtu); } else { @@ -5484,10 +5446,8 @@ sctp_del_local_addr_ep(struct sctp_inpcb if (stcb->asoc.last_used_address == laddr) /* delete this address */ stcb->asoc.last_used_address = NULL; - /* - * Now spin through all the nets and purge any ref - * to laddr - */ + /* Now spin through all the nets and purge any ref + * to laddr */ TAILQ_FOREACH(net, &stcb->asoc.nets, sctp_next) { if (net->ro._s_addr == laddr->ifa) { /* Yep, purge src address selected */ @@ -5755,7 +5715,6 @@ sctp_startup_mcore_threads(void) } } - #endif void @@ -6097,14 +6056,11 @@ sctp_load_addresses_from_init(struct sct uint8_t peer_supports_nrsack; uint8_t peer_supports_pktdrop; uint8_t peer_supports_idata; - #ifdef INET struct sockaddr_in sin; - #endif #ifdef INET6 struct sockaddr_in6 sin6; - #endif /* First get the destination address setup too. */ @@ -6267,10 +6223,8 @@ sctp_load_addresses_from_init(struct sct struct mbuf *op_err; char msg[SCTP_DIAG_INFO_LEN]; - /* - * in setup state we - * abort this guy - */ + /* in setup state we + * abort this guy */ snprintf(msg, sizeof(msg), "%s:%d at %s", __FILE__, __LINE__, __func__); op_err = sctp_generate_cause(SCTP_BASE_SYSCTL(sctp_diag_info_code), @@ -6312,10 +6266,8 @@ sctp_load_addresses_from_init(struct sct goto next_param; } if (IN6_IS_ADDR_LINKLOCAL(&sin6.sin6_addr)) { - /* - * Link local make no sense without - * scope - */ + /* Link local make no sense without + * scope */ goto next_param; } sa = (struct sockaddr *)&sin6; @@ -6366,10 +6318,8 @@ sctp_load_addresses_from_init(struct sct struct mbuf *op_err; char msg[SCTP_DIAG_INFO_LEN]; - /* - * in setup state we - * abort this guy - */ + /* in setup state we + * abort this guy */ snprintf(msg, sizeof(msg), "%s:%d at %s", __FILE__, __LINE__, __func__); op_err = sctp_generate_cause(SCTP_BASE_SYSCTL(sctp_diag_info_code), @@ -6409,10 +6359,8 @@ sctp_load_addresses_from_init(struct sct struct sctp_asconf_addr_param lstore, *fee; int lptype; struct sockaddr *lsa = NULL; - #ifdef INET struct sctp_asconf_addrv4_param *fii; - #endif if (stcb->asoc.asconf_supported == 0) { From owner-svn-src-all@freebsd.org Thu Oct 13 13:53:02 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 5E657C1012C; Thu, 13 Oct 2016 13:53:02 +0000 (UTC) (envelope-from tuexen@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 2947AEB5; Thu, 13 Oct 2016 13:53:02 +0000 (UTC) (envelope-from tuexen@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9DDr1oG064044; Thu, 13 Oct 2016 13:53:01 GMT (envelope-from tuexen@FreeBSD.org) Received: (from tuexen@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9DDr1Le064043; Thu, 13 Oct 2016 13:53:01 GMT (envelope-from tuexen@FreeBSD.org) Message-Id: <201610131353.u9DDr1Le064043@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: tuexen set sender to tuexen@FreeBSD.org using -f From: Michael Tuexen Date: Thu, 13 Oct 2016 13:53:01 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307217 - head/sys/netinet X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Oct 2016 13:53:02 -0000 Author: tuexen Date: Thu Oct 13 13:53:01 2016 New Revision: 307217 URL: https://svnweb.freebsd.org/changeset/base/307217 Log: Mark the socket as un-writable when it is 1-to-1 and the SCTP association is freed. MFC after: 1 month Modified: head/sys/netinet/sctp_pcb.c Modified: head/sys/netinet/sctp_pcb.c ============================================================================== --- head/sys/netinet/sctp_pcb.c Thu Oct 13 13:38:14 2016 (r307216) +++ head/sys/netinet/sctp_pcb.c Thu Oct 13 13:53:01 2016 (r307217) @@ -4870,6 +4870,7 @@ sctp_free_assoc(struct sctp_inpcb *inp, SS_ISCONNECTED); } socantrcvmore_locked(so); + socantsendmore(so); sctp_sowwakeup(inp, so); sctp_sorwakeup(inp, so); SCTP_SOWAKEUP(so); From owner-svn-src-all@freebsd.org Thu Oct 13 14:41:06 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E6B98C10EAA; Thu, 13 Oct 2016 14:41:06 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id C3965ACF; Thu, 13 Oct 2016 14:41:06 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9DEf5jY079962; Thu, 13 Oct 2016 14:41:05 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9DEf5Gg079955; Thu, 13 Oct 2016 14:41:05 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201610131441.u9DEf5Gg079955@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Thu, 13 Oct 2016 14:41:05 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307218 - in head/sys: cddl/contrib/opensolaris/uts/common/fs/zfs dev/drm2/i915 dev/drm2/ttm kern vm X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Oct 2016 14:41:07 -0000 Author: kib Date: Thu Oct 13 14:41:05 2016 New Revision: 307218 URL: https://svnweb.freebsd.org/changeset/base/307218 Log: Fix a race in vm_page_busy_sleep(9). Suppose that we have an exclusively busy page, and a thread which can accept shared-busy page. In this case, typical code waiting for the page xbusy state to pass is again: VM_OBJECT_WLOCK(object); ... if (vm_page_xbusied(m)) { vm_page_lock(m); VM_OBJECT_WUNLOCK(object); <---1 vm_page_busy_sleep(p, "vmopax"); goto again; } Suppose that the xbusy state owner locked the object, unbusied the page and unlocked the object after we are at the line [1], but before we executed the load of the busy_lock word in vm_page_busy_sleep(). If it happens that there is still no waiters recorded for the busy state, the xbusy owner did not acquired the page lock, so it proceeded. More, suppose that some other thread happen to share-busy the page after xbusy state was relinquished but before the m->busy_lock is read in vm_page_busy_sleep(). Again, that thread only needs vm_object lock to proceed. Then, vm_page_busy_sleep() reads busy_lock value equal to the VPB_SHARERS_WORD(1). In this case, all tests in vm_page_busy_sleep(9) pass and we are going to sleep, despite the page being share-busied. Update check for m->busy_lock == VPB_UNBUSIED in vm_page_busy_sleep(9) to also accept shared-busy state if we only wait for the xbusy state to pass. Merge sequential if()s with the same 'then' clause in vm_page_busy_sleep(). Note that the current code does not share-busy pages from parallel threads, the only way to have more that one sbusy owner is right now is to recurse. Reported and tested by: pho (previous version) Reviewed by: alc, markj Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D8196 Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c head/sys/dev/drm2/i915/i915_gem.c head/sys/dev/drm2/ttm/ttm_bo_vm.c head/sys/kern/vfs_bio.c head/sys/vm/vm_object.c head/sys/vm/vm_page.c head/sys/vm/vm_page.h Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c ============================================================================== --- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c Thu Oct 13 13:53:01 2016 (r307217) +++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c Thu Oct 13 14:41:05 2016 (r307218) @@ -421,7 +421,7 @@ page_busy(vnode_t *vp, int64_t start, in vm_page_reference(pp); vm_page_lock(pp); zfs_vmobject_wunlock(obj); - vm_page_busy_sleep(pp, "zfsmwb"); + vm_page_busy_sleep(pp, "zfsmwb", true); zfs_vmobject_wlock(obj); continue; } @@ -476,7 +476,7 @@ page_hold(vnode_t *vp, int64_t start) vm_page_reference(pp); vm_page_lock(pp); zfs_vmobject_wunlock(obj); - vm_page_busy_sleep(pp, "zfsmwb"); + vm_page_busy_sleep(pp, "zfsmwb", true); zfs_vmobject_wlock(obj); continue; } Modified: head/sys/dev/drm2/i915/i915_gem.c ============================================================================== --- head/sys/dev/drm2/i915/i915_gem.c Thu Oct 13 13:53:01 2016 (r307217) +++ head/sys/dev/drm2/i915/i915_gem.c Thu Oct 13 14:41:05 2016 (r307218) @@ -1533,7 +1533,7 @@ retry: DRM_UNLOCK(dev); vm_page_lock(page); VM_OBJECT_WUNLOCK(vm_obj); - vm_page_busy_sleep(page, "915pee"); + vm_page_busy_sleep(page, "915pee", false); goto retry; } goto have_page; @@ -1575,7 +1575,7 @@ retry: DRM_UNLOCK(dev); vm_page_lock(page); VM_OBJECT_WUNLOCK(vm_obj); - vm_page_busy_sleep(page, "915pbs"); + vm_page_busy_sleep(page, "915pbs", false); goto retry; } if (vm_page_insert(page, vm_obj, OFF_TO_IDX(offset))) { Modified: head/sys/dev/drm2/ttm/ttm_bo_vm.c ============================================================================== --- head/sys/dev/drm2/ttm/ttm_bo_vm.c Thu Oct 13 13:53:01 2016 (r307217) +++ head/sys/dev/drm2/ttm/ttm_bo_vm.c Thu Oct 13 14:41:05 2016 (r307218) @@ -236,7 +236,7 @@ reserve: if (vm_page_busied(m)) { vm_page_lock(m); VM_OBJECT_WUNLOCK(vm_obj); - vm_page_busy_sleep(m, "ttmpbs"); + vm_page_busy_sleep(m, "ttmpbs", false); VM_OBJECT_WLOCK(vm_obj); ttm_mem_io_unlock(man); ttm_bo_unreserve(bo); Modified: head/sys/kern/vfs_bio.c ============================================================================== --- head/sys/kern/vfs_bio.c Thu Oct 13 13:53:01 2016 (r307217) +++ head/sys/kern/vfs_bio.c Thu Oct 13 14:41:05 2016 (r307218) @@ -2633,7 +2633,7 @@ vfs_vmio_invalidate(struct buf *bp) while (vm_page_xbusied(m)) { vm_page_lock(m); VM_OBJECT_WUNLOCK(obj); - vm_page_busy_sleep(m, "mbncsh"); + vm_page_busy_sleep(m, "mbncsh", true); VM_OBJECT_WLOCK(obj); } if (pmap_page_wired_mappings(m) == 0) @@ -4182,7 +4182,7 @@ vfs_drain_busy_pages(struct buf *bp) while (vm_page_xbusied(m)) { vm_page_lock(m); VM_OBJECT_WUNLOCK(bp->b_bufobj->bo_object); - vm_page_busy_sleep(m, "vbpage"); + vm_page_busy_sleep(m, "vbpage", true); VM_OBJECT_WLOCK(bp->b_bufobj->bo_object); } } Modified: head/sys/vm/vm_object.c ============================================================================== --- head/sys/vm/vm_object.c Thu Oct 13 13:53:01 2016 (r307217) +++ head/sys/vm/vm_object.c Thu Oct 13 14:41:05 2016 (r307218) @@ -1186,7 +1186,7 @@ shadowlookup: if (object != tobject) VM_OBJECT_WUNLOCK(object); VM_OBJECT_WUNLOCK(tobject); - vm_page_busy_sleep(m, "madvpo"); + vm_page_busy_sleep(m, "madvpo", false); VM_OBJECT_WLOCK(object); goto relookup; } @@ -1365,7 +1365,7 @@ retry: VM_OBJECT_WUNLOCK(new_object); vm_page_lock(m); VM_OBJECT_WUNLOCK(orig_object); - vm_page_busy_sleep(m, "spltwt"); + vm_page_busy_sleep(m, "spltwt", false); VM_OBJECT_WLOCK(orig_object); VM_OBJECT_WLOCK(new_object); goto retry; @@ -1453,7 +1453,7 @@ vm_object_collapse_scan_wait(vm_object_t if (p == NULL) VM_WAIT; else - vm_page_busy_sleep(p, "vmocol"); + vm_page_busy_sleep(p, "vmocol", false); VM_OBJECT_WLOCK(object); VM_OBJECT_WLOCK(backing_object); return (TAILQ_FIRST(&backing_object->memq)); @@ -1912,7 +1912,7 @@ again: vm_page_lock(p); if (vm_page_xbusied(p)) { VM_OBJECT_WUNLOCK(object); - vm_page_busy_sleep(p, "vmopax"); + vm_page_busy_sleep(p, "vmopax", true); VM_OBJECT_WLOCK(object); goto again; } @@ -1927,7 +1927,7 @@ again: } if (vm_page_busied(p)) { VM_OBJECT_WUNLOCK(object); - vm_page_busy_sleep(p, "vmopar"); + vm_page_busy_sleep(p, "vmopar", false); VM_OBJECT_WLOCK(object); goto again; } Modified: head/sys/vm/vm_page.c ============================================================================== --- head/sys/vm/vm_page.c Thu Oct 13 13:53:01 2016 (r307217) +++ head/sys/vm/vm_page.c Thu Oct 13 14:41:05 2016 (r307218) @@ -741,21 +741,20 @@ vm_page_sunbusy(vm_page_t m) * This is used to implement the hard-path of busying mechanism. * * The given page must be locked. + * + * If nonshared is true, sleep only if the page is xbusy. */ void -vm_page_busy_sleep(vm_page_t m, const char *wmesg) +vm_page_busy_sleep(vm_page_t m, const char *wmesg, bool nonshared) { u_int x; - vm_page_lock_assert(m, MA_OWNED); + vm_page_assert_locked(m); x = m->busy_lock; - if (x == VPB_UNBUSIED) { - vm_page_unlock(m); - return; - } - if ((x & VPB_BIT_WAITERS) == 0 && - !atomic_cmpset_int(&m->busy_lock, x, x | VPB_BIT_WAITERS)) { + if (x == VPB_UNBUSIED || (nonshared && (x & VPB_BIT_SHARED) != 0) || + ((x & VPB_BIT_WAITERS) == 0 && + !atomic_cmpset_int(&m->busy_lock, x, x | VPB_BIT_WAITERS))) { vm_page_unlock(m); return; } @@ -1092,7 +1091,7 @@ vm_page_sleep_if_busy(vm_page_t m, const obj = m->object; vm_page_lock(m); VM_OBJECT_WUNLOCK(obj); - vm_page_busy_sleep(m, msg); + vm_page_busy_sleep(m, msg, false); VM_OBJECT_WLOCK(obj); return (TRUE); } @@ -3455,7 +3454,8 @@ retrylookup: vm_page_aflag_set(m, PGA_REFERENCED); vm_page_lock(m); VM_OBJECT_WUNLOCK(object); - vm_page_busy_sleep(m, "pgrbwt"); + vm_page_busy_sleep(m, "pgrbwt", (allocflags & + VM_ALLOC_IGN_SBUSY) != 0); VM_OBJECT_WLOCK(object); goto retrylookup; } else { Modified: head/sys/vm/vm_page.h ============================================================================== --- head/sys/vm/vm_page.h Thu Oct 13 13:53:01 2016 (r307217) +++ head/sys/vm/vm_page.h Thu Oct 13 14:41:05 2016 (r307218) @@ -436,7 +436,7 @@ malloc2vm_flags(int malloc_flags) #endif void vm_page_busy_downgrade(vm_page_t m); -void vm_page_busy_sleep(vm_page_t m, const char *msg); +void vm_page_busy_sleep(vm_page_t m, const char *msg, bool nonshared); void vm_page_flash(vm_page_t m); void vm_page_hold(vm_page_t mem); void vm_page_unhold(vm_page_t mem); From owner-svn-src-all@freebsd.org Thu Oct 13 15:23:54 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 7355EC0C6F2; Thu, 13 Oct 2016 15:23:54 +0000 (UTC) (envelope-from br@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4296BCD2; Thu, 13 Oct 2016 15:23:54 +0000 (UTC) (envelope-from br@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9DFNrH2098528; Thu, 13 Oct 2016 15:23:53 GMT (envelope-from br@FreeBSD.org) Received: (from br@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9DFNr8N098526; Thu, 13 Oct 2016 15:23:53 GMT (envelope-from br@FreeBSD.org) Message-Id: <201610131523.u9DFNr8N098526@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: br set sender to br@FreeBSD.org using -f From: Ruslan Bukin Date: Thu, 13 Oct 2016 15:23:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307219 - head/lib/libc/mips/string X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Oct 2016 15:23:54 -0000 Author: br Date: Thu Oct 13 15:23:53 2016 New Revision: 307219 URL: https://svnweb.freebsd.org/changeset/base/307219 Log: Fix strchr, strrchr implementation: convert c to char (according to standard). Discussed with: andrew Reviewed by: emaste Sponsored by: DARPA, AFRL Sponsored by: HEIF5 Differential Revision: https://reviews.freebsd.org/D8239 Modified: head/lib/libc/mips/string/strchr.S head/lib/libc/mips/string/strrchr.S Modified: head/lib/libc/mips/string/strchr.S ============================================================================== --- head/lib/libc/mips/string/strchr.S Thu Oct 13 14:41:05 2016 (r307218) +++ head/lib/libc/mips/string/strchr.S Thu Oct 13 15:23:53 2016 (r307219) @@ -44,7 +44,12 @@ __FBSDID("$FreeBSD$"); .abicalls #endif +/* + * char * + * strchr(const char *s, int c); + */ LEAF(strchr) + and a1, a1, 0xff 1: lbu a2, 0(a0) # get a byte PTR_ADDU a0, a0, 1 Modified: head/lib/libc/mips/string/strrchr.S ============================================================================== --- head/lib/libc/mips/string/strrchr.S Thu Oct 13 14:41:05 2016 (r307218) +++ head/lib/libc/mips/string/strrchr.S Thu Oct 13 15:23:53 2016 (r307219) @@ -44,8 +44,13 @@ __FBSDID("$FreeBSD$"); .abicalls #endif +/* + * char * + * strrchr(const char *s, int c); + */ LEAF(strrchr) move v0, zero # default if not found + and a1, a1, 0xff 1: lbu a3, 0(a0) # get a byte PTR_ADDU a0, a0, 1 From owner-svn-src-all@freebsd.org Thu Oct 13 15:26:52 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id EF8F0C0C902; Thu, 13 Oct 2016 15:26:52 +0000 (UTC) (envelope-from br@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id BE334F93; Thu, 13 Oct 2016 15:26:52 +0000 (UTC) (envelope-from br@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9DFQpu4098669; Thu, 13 Oct 2016 15:26:51 GMT (envelope-from br@FreeBSD.org) Received: (from br@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9DFQp1Q098668; Thu, 13 Oct 2016 15:26:51 GMT (envelope-from br@FreeBSD.org) Message-Id: <201610131526.u9DFQp1Q098668@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: br set sender to br@FreeBSD.org using -f From: Ruslan Bukin Date: Thu, 13 Oct 2016 15:26:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307220 - head/lib/libc/tests/stdio X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Oct 2016 15:26:53 -0000 Author: br Date: Thu Oct 13 15:26:51 2016 New Revision: 307220 URL: https://svnweb.freebsd.org/changeset/base/307220 Log: Fix typos: use correct string format and value to compare. Sponsored by: DARPA, AFRL Sponsored by: HEIF5 Differential Revision: https://reviews.freebsd.org/D8226 Modified: head/lib/libc/tests/stdio/printbasic_test.c Modified: head/lib/libc/tests/stdio/printbasic_test.c ============================================================================== --- head/lib/libc/tests/stdio/printbasic_test.c Thu Oct 13 15:23:53 2016 (r307219) +++ head/lib/libc/tests/stdio/printbasic_test.c Thu Oct 13 15:26:51 2016 (r307220) @@ -124,10 +124,10 @@ ATF_TC_BODY(int_within_limits, tc) testfmt(S_ULONGMAX, "%lu", ULONG_MAX); testfmt("-1", "%lld", (long long)-1); - testfmt(S_ULONGMAX, "%lu", ULLONG_MAX); + testfmt(S_ULLONGMAX, "%llu", ULLONG_MAX); testfmt("-1", "%d", -1); - testfmt(S_UINT32MAX, "%lu", UINT32_MAX); + testfmt(S_UINT32MAX, "%u", UINT32_MAX); testfmt("-1", "%hd", -1); testfmt("65535", "%hu", USHRT_MAX); From owner-svn-src-all@freebsd.org Thu Oct 13 16:41:35 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 43E07C10AA0; Thu, 13 Oct 2016 16:41:35 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 15E1684B; Thu, 13 Oct 2016 16:41:35 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9DGfYBL027946; Thu, 13 Oct 2016 16:41:34 GMT (envelope-from adrian@FreeBSD.org) Received: (from adrian@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9DGfYXZ027945; Thu, 13 Oct 2016 16:41:34 GMT (envelope-from adrian@FreeBSD.org) Message-Id: <201610131641.u9DGfYXZ027945@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: adrian set sender to adrian@FreeBSD.org using -f From: Adrian Chadd Date: Thu, 13 Oct 2016 16:41:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307221 - head/sys/net80211 X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Oct 2016 16:41:35 -0000 Author: adrian Date: Thu Oct 13 16:41:34 2016 New Revision: 307221 URL: https://svnweb.freebsd.org/changeset/base/307221 Log: [net80211] add some more QoS frame subtypes. Modified: head/sys/net80211/ieee80211.h Modified: head/sys/net80211/ieee80211.h ============================================================================== --- head/sys/net80211/ieee80211.h Thu Oct 13 15:26:51 2016 (r307220) +++ head/sys/net80211/ieee80211.h Thu Oct 13 16:41:34 2016 (r307221) @@ -157,8 +157,17 @@ struct ieee80211_qosframe_addr4 { #define IEEE80211_FC0_SUBTYPE_CFPOLL 0x60 #define IEEE80211_FC0_SUBTYPE_CF_ACK_CF_ACK 0x70 #define IEEE80211_FC0_SUBTYPE_QOS 0x80 +#define IEEE80211_FC0_SUBTYPE_QOS_CFACK 0x90 +#define IEEE80211_FC0_SUBTYPE_QOS_CFPOLL 0xa0 +#define IEEE80211_FC0_SUBTYPE_QOS_CFACKPOLL 0xb0 #define IEEE80211_FC0_SUBTYPE_QOS_NULL 0xc0 +#define IEEE80211_FC0_QOSDATA \ + (IEEE80211_FC0_TYPE_DATA|IEEE80211_FC0_SUBTYPE_QOS|IEEE80211_FC0_VERSION_0) + +#define IEEE80211_IS_QOSDATA(wh) \ + ((wh)->i_fc[0] == IEEE80211_FC0_QOSDATA) + #define IEEE80211_FC1_DIR_MASK 0x03 #define IEEE80211_FC1_DIR_NODS 0x00 /* STA->STA */ #define IEEE80211_FC1_DIR_TODS 0x01 /* STA->AP */ @@ -199,6 +208,8 @@ struct ieee80211_qosframe_addr4 { #define IEEE80211_NWID_LEN 32 #define IEEE80211_MESHID_LEN 32 +#define IEEE80211_QOS_CTL_LEN 2 + #define IEEE80211_QOS_TXOP 0x00ff /* bit 8 is reserved */ #define IEEE80211_QOS_AMSDU 0x80 From owner-svn-src-all@freebsd.org Thu Oct 13 16:45:03 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 0E3C1C10B72; Thu, 13 Oct 2016 16:45:03 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id CF4B9BA0; Thu, 13 Oct 2016 16:45:02 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9DGj1xq028926; Thu, 13 Oct 2016 16:45:01 GMT (envelope-from adrian@FreeBSD.org) Received: (from adrian@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9DGj1rS028925; Thu, 13 Oct 2016 16:45:01 GMT (envelope-from adrian@FreeBSD.org) Message-Id: <201610131645.u9DGj1rS028925@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: adrian set sender to adrian@FreeBSD.org using -f From: Adrian Chadd Date: Thu, 13 Oct 2016 16:45:01 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307222 - head/sys/net80211 X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Oct 2016 16:45:03 -0000 Author: adrian Date: Thu Oct 13 16:45:01 2016 New Revision: 307222 URL: https://svnweb.freebsd.org/changeset/base/307222 Log: [net80211] remove now duplicate copy of the QOSDATA check macro. Modified: head/sys/net80211/ieee80211_ht.c Modified: head/sys/net80211/ieee80211_ht.c ============================================================================== --- head/sys/net80211/ieee80211_ht.c Thu Oct 13 16:41:34 2016 (r307221) +++ head/sys/net80211/ieee80211_ht.c Thu Oct 13 16:45:01 2016 (r307222) @@ -779,8 +779,6 @@ ampdu_rx_flush_upto(struct ieee80211_nod int ieee80211_ampdu_reorder(struct ieee80211_node *ni, struct mbuf *m) { -#define IEEE80211_FC0_QOSDATA \ - (IEEE80211_FC0_TYPE_DATA|IEEE80211_FC0_SUBTYPE_QOS|IEEE80211_FC0_VERSION_0) #define PROCESS 0 /* caller should process frame */ #define CONSUMED 1 /* frame consumed, caller does nothing */ struct ieee80211vap *vap = ni->ni_vap; @@ -966,7 +964,6 @@ again: } #undef CONSUMED #undef PROCESS -#undef IEEE80211_FC0_QOSDATA } /* From owner-svn-src-all@freebsd.org Thu Oct 13 16:57:20 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id AD839C10E88; Thu, 13 Oct 2016 16:57:20 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 7954C15F; Thu, 13 Oct 2016 16:57:20 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9DGvJhC032667; Thu, 13 Oct 2016 16:57:19 GMT (envelope-from emaste@FreeBSD.org) Received: (from emaste@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9DGvJFA032663; Thu, 13 Oct 2016 16:57:19 GMT (envelope-from emaste@FreeBSD.org) Message-Id: <201610131657.u9DGvJFA032663@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: emaste set sender to emaste@FreeBSD.org using -f From: Ed Maste Date: Thu, 13 Oct 2016 16:57:19 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307223 - head/sys/contrib/octeon-sdk X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Oct 2016 16:57:20 -0000 Author: emaste Date: Thu Oct 13 16:57:19 2016 New Revision: 307223 URL: https://svnweb.freebsd.org/changeset/base/307223 Log: Convert ­ U+00AD soft hyphen to - in Cavium Octeon SDK Linux's copy of the Cavium SDK does not have these non-ASCII characters and this reduces noise in diffs when comparing the two. Sponsored by: The FreeBSD Foundation Modified: head/sys/contrib/octeon-sdk/cvmx-dma-engine.h head/sys/contrib/octeon-sdk/cvmx-higig.h head/sys/contrib/octeon-sdk/cvmx-pcie.c head/sys/contrib/octeon-sdk/cvmx-raid.h Modified: head/sys/contrib/octeon-sdk/cvmx-dma-engine.h ============================================================================== --- head/sys/contrib/octeon-sdk/cvmx-dma-engine.h Thu Oct 13 16:45:01 2016 (r307222) +++ head/sys/contrib/octeon-sdk/cvmx-dma-engine.h Thu Oct 13 16:57:19 2016 (r307223) @@ -87,7 +87,7 @@ typedef union PCIe memory space pointers in the LAST POINTERS block in the OUTBOUND, INBOUND, and EXTERNAL-ONLY cases. Must be zero in the INTERNAL-ONLY case. Must be zero on chips with PCI */ - cvmx_dma_engine_transfer_t type : 2; /**< Type ­ A given PCI DMA transfer is either OUTBOUND (read from L2/DRAM, + cvmx_dma_engine_transfer_t type : 2; /**< Type - A given PCI DMA transfer is either OUTBOUND (read from L2/DRAM, write into PCI / PCIe memory space), INBOUND (read from PCI / PCIe memory space, write into L2/DRAM), INTERNAL-ONLY (read from L2/DRAM, write into L2/DRAM), or EXTERNAL-ONLY (read from PCIe memory space, write into PCIe memory space). */ @@ -95,14 +95,14 @@ typedef union work-queue entry that is submitted by the hardware after completing the DMA; when WQP = 0, PTR (if non-zero) is a pointer to a byte in local memory that is written to 0 by the hardware after completing the DMA. */ - uint64_t c : 1; /**< C ­ Counter. 1 = use counter 1, 0 = use counter 0. + uint64_t c : 1; /**< C - Counter. 1 = use counter 1, 0 = use counter 0. The C bit selects between the two counters (NPEI_DMA_CNTS[DMA0,DMA1]) that can optionally be updated after an OUTBOUND or EXTERNAL-ONLY transfer, and also selects between the two forced-interrupt bits (NPEI_INT_SUMn[DMA0_FI, DMA1_FI]) that can optionally be set after an OUTBOUND or EXTERNAL-ONLY transfer. C must be zero for INBOUND or INTERNAL-ONLY transfers. */ - uint64_t ca : 1; /**< CA ­ Counter add. + uint64_t ca : 1; /**< CA - Counter add. When CA = 1, the hardware updates the selected counter after it completes the PCI DMA OUTBOUND or EXTERNAL-ONLY Instruction. - If C = 0, PCIE_DMA_CNT0 is updated @@ -117,13 +117,13 @@ typedef union When CA = 0, the hardware does not update any counters. For an INBOUND or INTERNAL-ONLY PCI DMA transfer, CA must never be set, and the hardware never adds to the counters. */ - uint64_t fi : 1; /**< FI ­ Force interrupt. + uint64_t fi : 1; /**< FI - Force interrupt. When FI is set for an OUTBOUND or EXTERNAL-ONLY transfer, the hardware sets a forced interrupt bit after it completes the PCI DMA Instruction. If C = 0, NPEI_INT_SUMn[DMA0_FI] is set, else NPEI_INT_SUMn[DMA1_FI] is set. For an INBOUND or INTERNAL-ONLY PCI DMA operation, FI must never be set, and the hardware never generates interrupts. */ - uint64_t ii : 1; /**< II­ Ignore the I bit (i.e. the I bit of the PCI DMA instruction local pointer). + uint64_t ii : 1; /**< II- Ignore the I bit (i.e. the I bit of the PCI DMA instruction local pointer). For OUTBOUND transfers when II = 1, ignore the I bit and the FL bit in the DMA HDR alone determines whether the hardware frees any/all of the local buffers in the FIRST POINTERS area: @@ -134,7 +134,7 @@ typedef union - when (FL I) is true, the hardware frees the local buffer when II=0. For INBOUND, INTERNAL-ONLY, and EXTERNAL-ONLY PCI DMA transfers, II must never be set, and local buffers are never freed. */ - uint64_t fl : 1; /**< FL ­ Free local buffer. + uint64_t fl : 1; /**< FL - Free local buffer. When FL = 1, for an OUTBOUND operation, it indicates that the local buffers in the FIRST BUFFERS area should be freed. If II = 1, the FL bit alone indicates whether the local buffer should be freed: @@ -145,7 +145,7 @@ typedef union - when (FL I) is true, the hardware frees the local buffer when II=0. For an INBOUND, INTERNAL-ONLY, or EXTERNAL-ONLY PCI DMA transfer, FL must never be set, and local buffers are never freed. */ - uint64_t nlst : 4; /**< NLST ­ Number Last pointers. + uint64_t nlst : 4; /**< NLST - Number Last pointers. The number of pointers in the LAST POINTERS area. In the INBOUND, OUTBOUND, and EXTERNAL-ONLY cases, the LAST POINTERS area contains PCI components, and the number of 64-bit words @@ -156,7 +156,7 @@ typedef union - HDR.NLST Note that the sum of the number of 64-bit words in the LAST POINTERS and FIRST POINTERS area must never exceed 31. */ - uint64_t nfst : 4; /**< NFST ­ Number First pointers. + uint64_t nfst : 4; /**< NFST - Number First pointers. The number of pointers in the FIRST POINTERS area. In the INBOUND, OUTBOUND, and INTERNAL-ONLY cases, the FIRST POINTERS area contains local pointers, and the number of 64-bit words required @@ -166,7 +166,7 @@ typedef union components, and the number of 64-bit words required in the FIRST POINTERS area is: - HDR.NFST + ((HDR.NFST + 3)/4) where the division removes the fraction. */ - uint64_t addr : 40; /**< PTR ­ Pointer, either a work-queue-entry pointer (when WQP = 1) or a local + uint64_t addr : 40; /**< PTR - Pointer, either a work-queue-entry pointer (when WQP = 1) or a local memory pointer (WQP = 0). When WQP = 1 and PTR 0x0, the hardware inserts the work-queue entry indicated by PTR into a POW input queue after the PCI DMA operation is @@ -186,12 +186,12 @@ typedef union uint64_t u64; struct { - uint64_t i : 1; /**< I ­ Invert free. + uint64_t i : 1; /**< I - Invert free. This bit gives the software the ability to free buffers independently for an OUTBOUND PCI DMA transfer. I is not used by the hardware when II is set. I must not be set, and buffers are never freed, for INBOUND, INTERNAL-ONLY, and EXTERNAL-ONLY PCI DMA transfers. */ - uint64_t back : 4; /**< Back ­ Backup amount. + uint64_t back : 4; /**< Back - Backup amount. Allows the start of a buffer that is to be freed during an OUTBOUND transfer to be different from the ptr value. Back specifies the amount to subtract from the pointer to reach the start when freeing a buffer. @@ -200,13 +200,13 @@ typedef union Back is only used by the hardware when the buffer corresponding to ptr is freed. Back must be 0x0, and buffers are never freed, for INBOUND, INTERNAL-ONLY, and EXTERNAL-ONLY PCI DMA transfers. */ - uint64_t pool : 3; /**< Pool ­ Free pool. + uint64_t pool : 3; /**< Pool - Free pool. Specifies which pool (of the eight hardware-managed FPA free pools) receives the buffer associated with ptr when freed during an OUTBOUND transfer. Pool is only used when the buffer corresponding to ptr is freed. Pool must be 0x0, and buffers are never freed, for INBOUND, INTERNAL-ONLY, and EXTERNAL-ONLY PCI DMA transfers. */ - uint64_t f : 1; /**< F ­ Full-block writes are allowed. + uint64_t f : 1; /**< F - Full-block writes are allowed. When set, the hardware is permitted to write all the bytes in the cache blocks covered by ptr, ptr + Size - 1. This can improve memory system performance when the write misses in the L2 cache. @@ -218,12 +218,12 @@ typedef union F must not be set for local pointers that are not written to: - The local pointers in the FIRST POINTERS area for OUTBOUND and INTERNAL-ONLY transfers. */ - uint64_t a : 1; /**< A ­ Allocate L2. + uint64_t a : 1; /**< A - Allocate L2. This is a hint to the hardware that the cache blocks should be allocated in the L2 cache (if they were not already). */ - uint64_t l : 1; /**< L ­ Little-endian. + uint64_t l : 1; /**< L - Little-endian. When L is set, the data at ptr is in little-endian format rather than big-endian. */ - uint64_t size : 13; /**< Size ­ Size in bytes of the contiguous space specified by ptr. A Size value of 0 is + uint64_t size : 13; /**< Size - Size in bytes of the contiguous space specified by ptr. A Size value of 0 is illegal. Note that the sum of the sizes in the FIRST POINTERS area must always exactly equal the sum of the sizes/lengths in the LAST POINTERS area: - In the OUTBOUND and INBOUND cases, the HDR.NFST size fields in the Modified: head/sys/contrib/octeon-sdk/cvmx-higig.h ============================================================================== --- head/sys/contrib/octeon-sdk/cvmx-higig.h Thu Oct 13 16:45:01 2016 (r307222) +++ head/sys/contrib/octeon-sdk/cvmx-higig.h Thu Oct 13 16:57:19 2016 (r307223) @@ -120,11 +120,11 @@ typedef struct multicast (unknown L2 multicast and IPMC) packets. This field is used when OPCODE is 011 or 100 Semantics of PFM bits are as follows; For registered L2 multicast packets: - PFM= 0 ­ Flood to VLAN - PFM= 1 or 2 ­ Send to group members in the L2MC table + PFM= 0 - Flood to VLAN + PFM= 1 or 2 - Send to group members in the L2MC table For unregistered L2 multicast packets: - PFM= 0 or 1 ­ Flood to VLAN - PFM= 2 ­ Drop the packet */ + PFM= 0 or 1 - Flood to VLAN + PFM= 2 - Drop the packet */ uint32_t src_port_tgid : 6; /**< If the MSB of this field is set, then it indicates the LAG the packet ingressed on, else it represents the physical port the packet ingressed on. */ uint32_t dst_port : 5; /**< Port number of destination port on which the packet needs to egress. */ @@ -138,10 +138,10 @@ typedef struct uint32_t cng_low : 1; /**< Semantics of CNG_HIGH and CNG_LOW are as follows: The following encodings are to make it backward compatible: [CNG_HIGH, CNG_LOW] - COLOR - [0, 0] ­ Packet is green - [0, 1] ­ Packet is red - [1, 1] ­ Packet is yellow - [1, 0] ­ Undefined */ + [0, 0] - Packet is green + [0, 1] - Packet is red + [1, 1] - Packet is yellow + [1, 0] - Undefined */ uint32_t dst_modid_low : 5; /**< Bits [4-: 0] of Module ID of the destination port on which the packet needs to egress. */ } s; } dw1; @@ -273,11 +273,11 @@ typedef struct multicast (unknown L2 multicast and IPMC) packets. This field is used when OPCODE is 011 or 100 Semantics of PFM bits are as follows; For registered L2 multicast packets: - PFM= 0 ­ Flood to VLAN - PFM= 1 or 2 ­ Send to group members in the L2MC table + PFM= 0 - Flood to VLAN + PFM= 1 or 2 - Send to group members in the L2MC table For unregistered L2 multicast packets: - PFM= 0 or 1 ­ Flood to VLAN - PFM= 2 ­ Drop the packet */ + PFM= 0 or 1 - Flood to VLAN + PFM= 2 - Drop the packet */ uint32_t src_t : 1; /**< If the MSB of this field is set, then it indicates the LAG the packet ingressed on, else it represents the physical port the packet ingressed on. */ uint32_t reserved_11_12 : 2; Modified: head/sys/contrib/octeon-sdk/cvmx-pcie.c ============================================================================== --- head/sys/contrib/octeon-sdk/cvmx-pcie.c Thu Oct 13 16:45:01 2016 (r307222) +++ head/sys/contrib/octeon-sdk/cvmx-pcie.c Thu Oct 13 16:57:19 2016 (r307223) @@ -722,8 +722,8 @@ retry: /* Setup BAR2 attributes */ /* Relaxed Ordering (NPEI_CTL_PORTn[PTLP_RO,CTLP_RO, WAIT_COM]) */ - /* ­ PTLP_RO,CTLP_RO should normally be set (except for debug). */ - /* ­ WAIT_COM=0 will likely work for all applications. */ + /* - PTLP_RO,CTLP_RO should normally be set (except for debug). */ + /* - WAIT_COM=0 will likely work for all applications. */ /* Load completion relaxed ordering (NPEI_CTL_PORTn[WAITL_COM]) */ if (pcie_port) { @@ -1139,8 +1139,8 @@ static int __cvmx_pcie_rc_initialize_gen /* Setup BAR2 attributes */ /* Relaxed Ordering (NPEI_CTL_PORTn[PTLP_RO,CTLP_RO, WAIT_COM]) */ - /* ­ PTLP_RO,CTLP_RO should normally be set (except for debug). */ - /* ­ WAIT_COM=0 will likely work for all applications. */ + /* - PTLP_RO,CTLP_RO should normally be set (except for debug). */ + /* - WAIT_COM=0 will likely work for all applications. */ /* Load completion relaxed ordering (NPEI_CTL_PORTn[WAITL_COM]) */ pemx_bar_ctl.u64 = cvmx_read_csr(CVMX_PEMX_BAR_CTL(pcie_port)); pemx_bar_ctl.s.bar1_siz = 3; /* 256MB BAR1*/ Modified: head/sys/contrib/octeon-sdk/cvmx-raid.h ============================================================================== --- head/sys/contrib/octeon-sdk/cvmx-raid.h Thu Oct 13 16:45:01 2016 (r307222) +++ head/sys/contrib/octeon-sdk/cvmx-raid.h Thu Oct 13 16:57:19 2016 (r307223) @@ -125,7 +125,7 @@ typedef union { uint64_t reserved_58_63 : 6; /**< Must be zero */ uint64_t fw : 1; /**< When set, indicates that RAD can modify any byte in any (128B) cache line touched - by L2/DRAM addresses OWORD[PTR] through OWORD[PTR]+CWORD[SIZE]­1. + by L2/DRAM addresses OWORD[PTR] through OWORD[PTR]+CWORD[SIZE]-1. Setting OWORD[FW] can improve hardware performance, as some DRAM loads can be avoided on L2 cache misses. The Q OWORD[FW] must not be set when CWORD[Q_CMP] is set, and the P OWORD[FW] must not be set when From owner-svn-src-all@freebsd.org Thu Oct 13 17:03:56 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 0CC71C1037A; Thu, 13 Oct 2016 17:03:56 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id D1160A17; Thu, 13 Oct 2016 17:03:55 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9DH3sP8036275; Thu, 13 Oct 2016 17:03:54 GMT (envelope-from imp@FreeBSD.org) Received: (from imp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9DH3smi036274; Thu, 13 Oct 2016 17:03:54 GMT (envelope-from imp@FreeBSD.org) Message-Id: <201610131703.u9DH3smi036274@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: imp set sender to imp@FreeBSD.org using -f From: Warner Losh Date: Thu, 13 Oct 2016 17:03:54 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307224 - head/usr.sbin/efivar X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Oct 2016 17:03:56 -0000 Author: imp Date: Thu Oct 13 17:03:54 2016 New Revision: 307224 URL: https://svnweb.freebsd.org/changeset/base/307224 Log: 'b' is short for --binary, it isn't 'a'. PR: 213437 Submitted by: Ganael LAPLANCHE Modified: head/usr.sbin/efivar/efivar.8 Modified: head/usr.sbin/efivar/efivar.8 ============================================================================== --- head/usr.sbin/efivar/efivar.8 Thu Oct 13 16:57:19 2016 (r307223) +++ head/usr.sbin/efivar/efivar.8 Thu Oct 13 17:03:54 2016 (r307224) @@ -98,7 +98,7 @@ UEFI Specification for hex values to use Display the variable data as modified ascii: All printable characters are printed, while unprintable characters are rendered as a two-digit hexadecimal number preceeded by a % character. -.It Fl A Fl -binary +.It Fl b Fl -binary Display the variable data as binary data. Usually will be used with the .Fl N From owner-svn-src-all@freebsd.org Thu Oct 13 17:16:33 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 52FA6C106BC; Thu, 13 Oct 2016 17:16:33 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 248D1FFC; Thu, 13 Oct 2016 17:16:33 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9DHGWKK040074; Thu, 13 Oct 2016 17:16:32 GMT (envelope-from emaste@FreeBSD.org) Received: (from emaste@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9DHGWKi040073; Thu, 13 Oct 2016 17:16:32 GMT (envelope-from emaste@FreeBSD.org) Message-Id: <201610131716.u9DHGWKi040073@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: emaste set sender to emaste@FreeBSD.org using -f From: Ed Maste Date: Thu, 13 Oct 2016 17:16:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307225 - head/sys/contrib/octeon-sdk X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Oct 2016 17:16:33 -0000 Author: emaste Date: Thu Oct 13 17:16:32 2016 New Revision: 307225 URL: https://svnweb.freebsd.org/changeset/base/307225 Log: Fix octeon model comparison in Cavium SDK buildkernel failed with GCC 5.3 with error: comparison of constant '852736' with boolean expression is always true Sponsored by: The FreeBSD Foundation Modified: head/sys/contrib/octeon-sdk/cvmx-pcie.c Modified: head/sys/contrib/octeon-sdk/cvmx-pcie.c ============================================================================== --- head/sys/contrib/octeon-sdk/cvmx-pcie.c Thu Oct 13 17:03:54 2016 (r307224) +++ head/sys/contrib/octeon-sdk/cvmx-pcie.c Thu Oct 13 17:16:32 2016 (r307225) @@ -981,7 +981,7 @@ static int __cvmx_pcie_rc_initialize_gen /* Make sure we aren't trying to setup a target mode interface in host mode */ mio_rst_ctl.u64 = cvmx_read_csr(CVMX_MIO_RST_CTLX(pcie_port)); - ep_mode = (OCTEON_IS_MODEL(OCTEON_CN61XX || OCTEON_IS_MODEL(OCTEON_CNF71XX)) ? (mio_rst_ctl.s.prtmode != 1) : (!mio_rst_ctl.s.host_mode)); + ep_mode = ((OCTEON_IS_MODEL(OCTEON_CN61XX) || OCTEON_IS_MODEL(OCTEON_CNF71XX)) ? (mio_rst_ctl.s.prtmode != 1) : (!mio_rst_ctl.s.host_mode)); if (ep_mode) { cvmx_dprintf("PCIe: Port %d in endpoint mode.\n", pcie_port); From owner-svn-src-all@freebsd.org Thu Oct 13 18:02:31 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 3F4DCC1010F; Thu, 13 Oct 2016 18:02:31 +0000 (UTC) (envelope-from glebius@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 0A904AA6; Thu, 13 Oct 2016 18:02:30 +0000 (UTC) (envelope-from glebius@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9DI2U8U058840; Thu, 13 Oct 2016 18:02:30 GMT (envelope-from glebius@FreeBSD.org) Received: (from glebius@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9DI2UQi058839; Thu, 13 Oct 2016 18:02:30 GMT (envelope-from glebius@FreeBSD.org) Message-Id: <201610131802.u9DI2UQi058839@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: glebius set sender to glebius@FreeBSD.org using -f From: Gleb Smirnoff Date: Thu, 13 Oct 2016 18:02:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307226 - head/sys/netinet/tcp_stacks X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Oct 2016 18:02:31 -0000 Author: glebius Date: Thu Oct 13 18:02:29 2016 New Revision: 307226 URL: https://svnweb.freebsd.org/changeset/base/307226 Log: With build without TCP_HHOOK and with INVARIANTS. Before mutex.h came via sys/hhook.h -> sys/rmlock.h -> sys/mutex.h. Modified: head/sys/netinet/tcp_stacks/fastpath.c Modified: head/sys/netinet/tcp_stacks/fastpath.c ============================================================================== --- head/sys/netinet/tcp_stacks/fastpath.c Thu Oct 13 17:16:32 2016 (r307225) +++ head/sys/netinet/tcp_stacks/fastpath.c Thu Oct 13 18:02:29 2016 (r307226) @@ -60,7 +60,9 @@ __FBSDID("$FreeBSD$"); #include "opt_tcpdebug.h" #include +#include #include +#include #include #ifdef TCP_HHOOK #include From owner-svn-src-all@freebsd.org Thu Oct 13 18:25:42 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A0110C10809; Thu, 13 Oct 2016 18:25:42 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 6E570820; Thu, 13 Oct 2016 18:25:42 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9DIPfgW066710; Thu, 13 Oct 2016 18:25:41 GMT (envelope-from ed@FreeBSD.org) Received: (from ed@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9DIPeXH066703; Thu, 13 Oct 2016 18:25:40 GMT (envelope-from ed@FreeBSD.org) Message-Id: <201610131825.u9DIPeXH066703@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ed set sender to ed@FreeBSD.org using -f From: Ed Schouten Date: Thu, 13 Oct 2016 18:25:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307227 - in head: include lib/libc/stdlib lib/libc/tests/stdlib X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Oct 2016 18:25:42 -0000 Author: ed Date: Thu Oct 13 18:25:40 2016 New Revision: 307227 URL: https://svnweb.freebsd.org/changeset/base/307227 Log: Improve typing of POSIX search tree functions. Back in 2015 when I reimplemented these functions to use an AVL tree, I was annoyed by the weakness of the typing of these functions. Both tree nodes and keys are represented by 'void *', meaning that things like the documentation for these functions are an absolute train wreck. To make things worse, users of these functions need to cast the return value of tfind()/tsearch() from 'void *' to 'type_of_key **' in order to access the key. Technically speaking such casts violate aliasing rules. I've observed actual breakages as a result of this by enabling features like LTO. I've filed a bug report at the Austin Group. Looking at the way the bug got resolved, they made a pretty good step in the right direction. A new type 'posix_tnode' has been added to correspond to tree nodes. It is still defined as 'void' for source-level compatibility, but in the very far future it could be replaced by a proper structure type containing a key pointer. MFC after: 1 month Differential Revision: https://reviews.freebsd.org/D8205 Modified: head/include/search.h head/lib/libc/stdlib/tdelete.c head/lib/libc/stdlib/tfind.c head/lib/libc/stdlib/tsearch.3 head/lib/libc/stdlib/tsearch.c head/lib/libc/stdlib/twalk.c head/lib/libc/tests/stdlib/tsearch_test.c Modified: head/include/search.h ============================================================================== --- head/include/search.h Thu Oct 13 18:02:29 2016 (r307226) +++ head/include/search.h Thu Oct 13 18:25:40 2016 (r307227) @@ -34,16 +34,18 @@ typedef enum { } VISIT; #ifdef _SEARCH_PRIVATE -typedef struct node { - void *key; - struct node *llink, *rlink; - signed char balance; -} node_t; +typedef struct __posix_tnode { + void *key; + struct __posix_tnode *llink, *rlink; + signed char balance; +} posix_tnode; struct que_elem { struct que_elem *next; struct que_elem *prev; }; +#else +typedef void posix_tnode; #endif #if __BSD_VISIBLE @@ -62,12 +64,15 @@ void *lfind(const void *, const void *, void *lsearch(const void *, void *, size_t *, size_t, int (*)(const void *, const void *)); void remque(void *); -void *tdelete(const void * __restrict, void ** __restrict, +void *tdelete(const void * __restrict, posix_tnode ** __restrict, int (*)(const void *, const void *)); -void *tfind(const void *, void * const *, +posix_tnode * + tfind(const void *, posix_tnode * const *, int (*)(const void *, const void *)); -void *tsearch(const void *, void **, int (*)(const void *, const void *)); -void twalk(const void *, void (*)(const void *, VISIT, int)); +posix_tnode * + tsearch(const void *, posix_tnode **, + int (*)(const void *, const void *)); +void twalk(const posix_tnode *, void (*)(const posix_tnode *, VISIT, int)); #if __BSD_VISIBLE int hcreate_r(size_t, struct hsearch_data *); Modified: head/lib/libc/stdlib/tdelete.c ============================================================================== --- head/lib/libc/stdlib/tdelete.c Thu Oct 13 18:02:29 2016 (r307226) +++ head/lib/libc/stdlib/tdelete.c Thu Oct 13 18:25:40 2016 (r307227) @@ -46,9 +46,9 @@ __FBSDID("$FreeBSD$"); * that we won't need to perform any rotations above \ * this point. In this case rotations are always \ * capable of keeping the subtree in balance. Make \ - * this the base node and reset the path. \ + * this the root node and reset the path. \ */ \ - base = leaf; \ + rootp = leaf; \ path_init(&path); \ } \ path_taking_left(&path); \ @@ -59,7 +59,7 @@ __FBSDID("$FreeBSD$"); #define GO_RIGHT() do { \ if ((*leaf)->balance == 0 || \ ((*leaf)->balance > 0 && (*leaf)->llink->balance == 0)) { \ - base = leaf; \ + rootp = leaf; \ path_init(&path); \ } \ path_taking_right(&path); \ @@ -67,18 +67,16 @@ __FBSDID("$FreeBSD$"); } while (0) void * -tdelete(const void *restrict key, void **restrict rootp, +tdelete(const void *restrict key, posix_tnode **restrict rootp, int (*compar)(const void *, const void *)) { struct path path; - node_t *root, **base, **leaf, *old, **n, *x, *y, *z; - void *result; + posix_tnode **leaf, *old, **n, *x, *y, *z, *result; int cmp; /* POSIX requires that tdelete() returns NULL if rootp is NULL. */ if (rootp == NULL) return (NULL); - root = *rootp; /* * Find the leaf that needs to be removed. Return if we cannot @@ -86,19 +84,18 @@ tdelete(const void *restrict key, void * * to get to the node, as we will need it to adjust the * balances. */ - result = (void *)1; + result = (posix_tnode *)1; path_init(&path); - base = &root; - leaf = &root; + leaf = rootp; for (;;) { if (*leaf == NULL) return (NULL); cmp = compar(key, (*leaf)->key); if (cmp < 0) { - result = &(*leaf)->key; + result = *leaf; GO_LEFT(); } else if (cmp > 0) { - result = &(*leaf)->key; + result = *leaf; GO_RIGHT(); } else { break; @@ -134,7 +131,7 @@ tdelete(const void *restrict key, void * * and left-left case that only exists when deleting. Hence the * duplication of code. */ - for (n = base; n != leaf;) { + for (n = rootp; n != leaf;) { if (path_took_left(&path)) { x = *n; if (x->balance < 0) { @@ -207,6 +204,5 @@ tdelete(const void *restrict key, void * } /* Return the parent of the old entry. */ - *rootp = root; return (result); } Modified: head/lib/libc/stdlib/tfind.c ============================================================================== --- head/lib/libc/stdlib/tfind.c Thu Oct 13 18:02:29 2016 (r307226) +++ head/lib/libc/stdlib/tfind.c Thu Oct 13 18:25:40 2016 (r307227) @@ -4,8 +4,6 @@ * Tree search generalized from Knuth (6.2.2) Algorithm T just like * the AT&T man page says. * - * The node_t structure is for internal use only, lint doesn't grok it. - * * Written by reading the System V Interface Definition, not the code. * * Totally public domain. @@ -29,11 +27,10 @@ __FBSDID("$FreeBSD$"); * vkey - key to be found * vrootp - address of the tree root */ -void * -tfind(const void *vkey, void * const *vrootp, +posix_tnode * +tfind(const void *vkey, posix_tnode * const *rootp, int (*compar)(const void *, const void *)) { - node_t **rootp = (node_t **)vrootp; if (rootp == NULL) return NULL; Modified: head/lib/libc/stdlib/tsearch.3 ============================================================================== --- head/lib/libc/stdlib/tsearch.3 Thu Oct 13 18:02:29 2016 (r307226) +++ head/lib/libc/stdlib/tsearch.3 Thu Oct 13 18:25:40 2016 (r307227) @@ -27,7 +27,7 @@ .\" OpenBSD: tsearch.3,v 1.2 1998/06/21 22:13:49 millert Exp .\" $FreeBSD$ .\" -.Dd December 6, 2015 +.Dd October 9, 2016 .Dt TSEARCH 3 .Os .Sh NAME @@ -36,13 +36,13 @@ .Sh SYNOPSIS .In search.h .Ft void * -.Fn tdelete "const void * restrict key" "void ** restrict rootp" "int (*compar) (const void *, const void *)" -.Ft void * -.Fn tfind "const void *key" "void * const *rootp" "int (*compar) (const void *, const void *)" -.Ft void * -.Fn tsearch "const void *key" "void **rootp" "int (*compar) (const void *, const void *)" +.Fn tdelete "const void * restrict key" "posix_tnode ** restrict rootp" "int (*compar) (const void *, const void *)" +.Ft posix_tnode * +.Fn tfind "const void *key" "posix_tnode * const *rootp" "int (*compar) (const void *, const void *)" +.Ft posix_tnode * +.Fn tsearch "const void *key" "posix_tnode **rootp" "int (*compar) (const void *, const void *)" .Ft void -.Fn twalk "const void *root" "void (*action) (const void *, VISIT, int)" +.Fn twalk "const posix_tnode *root" "void (*action) (const posix_tnode *, VISIT, int)" .Sh DESCRIPTION The .Fn tdelete , @@ -134,3 +134,18 @@ function returns no value. .Xr bsearch 3 , .Xr hsearch 3 , .Xr lsearch 3 +.Sh STANDARDS +These functions conform to +.St -p1003.1-2008 . +.Pp +The +.Fa posix_tnode +type is not part of +.St -p1003.1-2008 , +but it is expected to be standardized by future versions of the standard. +It is defined as +.Fa void +for source-level compatibility. +Using +.Fa posix_tnode +makes it easier to distinguish between nodes and keys. Modified: head/lib/libc/stdlib/tsearch.c ============================================================================== --- head/lib/libc/stdlib/tsearch.c Thu Oct 13 18:02:29 2016 (r307226) +++ head/lib/libc/stdlib/tsearch.c Thu Oct 13 18:25:40 2016 (r307227) @@ -32,18 +32,17 @@ __FBSDID("$FreeBSD$"); #include "tsearch_path.h" -void * -tsearch(const void *key, void **rootp, +posix_tnode * +tsearch(const void *key, posix_tnode **rootp, int (*compar)(const void *, const void *)) { struct path path; - node_t *root, **base, **leaf, *result, *n, *x, *y, *z; + posix_tnode **leaf, *result, *n, *x, *y, *z; int cmp; /* POSIX requires that tsearch() returns NULL if rootp is NULL. */ if (rootp == NULL) - return (NULL); - root = *rootp; + return (NULL); /* * Find the leaf where the new key needs to be inserted. Return @@ -52,8 +51,7 @@ tsearch(const void *key, void **rootp, * balances. */ path_init(&path); - base = &root; - leaf = &root; + leaf = rootp; while (*leaf != NULL) { if ((*leaf)->balance != 0) { /* @@ -62,9 +60,9 @@ tsearch(const void *key, void **rootp, * need to perform any rotations above this * point. In this case rotations are always * capable of keeping the subtree in balance. - * Make this the base node and reset the path. + * Make this the root node and reset the path. */ - base = leaf; + rootp = leaf; path_init(&path); } cmp = compar(key, (*leaf)->key); @@ -75,7 +73,7 @@ tsearch(const void *key, void **rootp, path_taking_right(&path); leaf = &(*leaf)->rlink; } else { - return (&(*leaf)->key); + return (*leaf); } } @@ -94,7 +92,7 @@ tsearch(const void *key, void **rootp, * have a balance of zero, meaning that these nodes will not get * out of balance. */ - for (n = *base; n != *leaf;) { + for (n = *rootp; n != *leaf;) { if (path_took_left(&path)) { n->balance += 1; n = n->llink; @@ -106,10 +104,10 @@ tsearch(const void *key, void **rootp, /* * Adjusting the balances may have pushed the balance of the - * base node out of range. Perform a rotation to bring the + * root node out of range. Perform a rotation to bring the * balance back in range. */ - x = *base; + x = *rootp; if (x->balance > 1) { y = x->llink; if (y->balance < 0) { @@ -129,7 +127,7 @@ tsearch(const void *key, void **rootp, z->llink = y; x->llink = z->rlink; z->rlink = x; - *base = z; + *rootp = z; x->balance = z->balance > 0 ? -1 : 0; y->balance = z->balance < 0 ? 1 : 0; @@ -146,7 +144,7 @@ tsearch(const void *key, void **rootp, */ x->llink = y->rlink; y->rlink = x; - *base = y; + *rootp = y; x->balance = 0; y->balance = 0; @@ -165,12 +163,12 @@ tsearch(const void *key, void **rootp, * / \ A B C D * B C */ - node_t *z = y->llink; + posix_tnode *z = y->llink; x->rlink = z->llink; z->llink = x; y->llink = z->rlink; z->rlink = y; - *base = z; + *rootp = z; x->balance = z->balance < 0 ? 1 : 0; y->balance = z->balance > 0 ? -1 : 0; @@ -187,7 +185,7 @@ tsearch(const void *key, void **rootp, */ x->rlink = y->llink; y->llink = x; - *base = y; + *rootp = y; x->balance = 0; y->balance = 0; @@ -195,6 +193,5 @@ tsearch(const void *key, void **rootp, } /* Return the new entry. */ - *rootp = root; - return (&result->key); + return (result); } Modified: head/lib/libc/stdlib/twalk.c ============================================================================== --- head/lib/libc/stdlib/twalk.c Thu Oct 13 18:02:29 2016 (r307226) +++ head/lib/libc/stdlib/twalk.c Thu Oct 13 18:25:40 2016 (r307227) @@ -4,8 +4,6 @@ * Tree search generalized from Knuth (6.2.2) Algorithm T just like * the AT&T man page says. * - * The node_t structure is for internal use only, lint doesn't grok it. - * * Written by reading the System V Interface Definition, not the code. * * Totally public domain. @@ -23,12 +21,11 @@ __FBSDID("$FreeBSD$"); #include #include -typedef void (*cmp_fn_t)(const void *, VISIT, int); +typedef void (*cmp_fn_t)(const posix_tnode *, VISIT, int); /* Walk the nodes of a tree */ static void -trecurse(const node_t *root, /* Root of the tree to be walked */ - cmp_fn_t action, int level) +trecurse(const posix_tnode *root, cmp_fn_t action, int level) { if (root->llink == NULL && root->rlink == NULL) @@ -46,7 +43,7 @@ trecurse(const node_t *root, /* Root of /* Walk the nodes of a tree */ void -twalk(const void *vroot, cmp_fn_t action) /* Root of the tree to be walked */ +twalk(const posix_tnode *vroot, cmp_fn_t action) { if (vroot != NULL && action != NULL) trecurse(vroot, action, 0); Modified: head/lib/libc/tests/stdlib/tsearch_test.c ============================================================================== --- head/lib/libc/tests/stdlib/tsearch_test.c Thu Oct 13 18:02:29 2016 (r307226) +++ head/lib/libc/tests/stdlib/tsearch_test.c Thu Oct 13 18:25:40 2016 (r307227) @@ -34,7 +34,7 @@ __FBSDID("$FreeBSD$"); /* Validates the integrity of an AVL tree. */ static inline unsigned int -tnode_assert(const node_t *n) +tnode_assert(const posix_tnode *n) { unsigned int height_left, height_right; int balance; @@ -79,7 +79,7 @@ ATF_TC_BODY(tsearch_test, tc) keys[i] = i; /* Apply random operations on a binary tree and check the results. */ - void *root = NULL; + posix_tnode *root = NULL; bool present[NKEYS] = {}; for (int i = 0; i < NKEYS * 10; ++i) { int key = nrand48(random_state) % NKEYS; From owner-svn-src-all@freebsd.org Thu Oct 13 18:57:20 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 2F8C6C10FAC; Thu, 13 Oct 2016 18:57:20 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id E6C8319D8; Thu, 13 Oct 2016 18:57:19 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9DIvJwW078084; Thu, 13 Oct 2016 18:57:19 GMT (envelope-from emaste@FreeBSD.org) Received: (from emaste@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9DIvIQa078080; Thu, 13 Oct 2016 18:57:18 GMT (envelope-from emaste@FreeBSD.org) Message-Id: <201610131857.u9DIvIQa078080@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: emaste set sender to emaste@FreeBSD.org using -f From: Ed Maste Date: Thu, 13 Oct 2016 18:57:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307230 - in head/lib: libgcc_eh libgcc_s X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Oct 2016 18:57:20 -0000 Author: emaste Date: Thu Oct 13 18:57:18 2016 New Revision: 307230 URL: https://svnweb.freebsd.org/changeset/base/307230 Log: Introduce lib/libgcc_eh and lib/libgcc_s for LLVM's implementation They are not yet connected to the build, but I am adding them to allow for easier testing, ports exp-runs, etc. Reviewed by: ed Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D8188 Added: head/lib/libgcc_eh/ head/lib/libgcc_eh/Makefile (contents, props changed) head/lib/libgcc_eh/Makefile.inc (contents, props changed) head/lib/libgcc_s/ head/lib/libgcc_s/Makefile (contents, props changed) head/lib/libgcc_s/Version.map (contents, props changed) Added: head/lib/libgcc_eh/Makefile ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/lib/libgcc_eh/Makefile Thu Oct 13 18:57:18 2016 (r307230) @@ -0,0 +1,12 @@ +# $FreeBSD$ + +.include + +PACKAGE= clibs +LIB= gcc_eh +NO_PIC= +WARNS?= 2 + +.include "Makefile.inc" + +.include Added: head/lib/libgcc_eh/Makefile.inc ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/lib/libgcc_eh/Makefile.inc Thu Oct 13 18:57:18 2016 (r307230) @@ -0,0 +1,30 @@ +# $FreeBSD$ + +COMPILERRTDIR= ${SRCTOP}/contrib/compiler-rt +UNWINDINCDIR= ${SRCTOP}/contrib/llvm/projects/libunwind/include +UNWINDSRCDIR= ${SRCTOP}/contrib/llvm/projects/libunwind/src + +CFLAGS+=${PICFLAG} -fvisibility=hidden -DVISIBILITY_HIDDEN + +.PATH: ${COMPILERRTDIR}/lib/builtins +.PATH: ${UNWINDSRCDIR} +SRCS+= gcc_personality_v0.c +SRCS+= int_util.c +SRCS+= Unwind-EHABI.cpp +SRCS+= Unwind-sjlj.c +SRCS+= UnwindLevel1-gcc-ext.c +SRCS+= UnwindLevel1.c +SRCS+= UnwindRegistersRestore.S +SRCS+= UnwindRegistersSave.S +SRCS+= libunwind.cpp + +CFLAGS+= -I${UNWINDINCDIR} -I${.CURDIR} -D_LIBUNWIND_IS_NATIVE_ONLY +.if empty(CXXFLAGS:M-std=*) +CXXFLAGS+= -std=c++11 +.endif +CXXFLAGS+= -fno-rtti +STATIC_CXXFLAGS+= -fvisibility=hidden -fPIC +.if ${MK_DIRDEPS_BUILD} == "yes" +# Avoid dependency on lib/libc++ +CFLAGS+= -I${SRCTOP}/contrib/libc++/include +.endif Added: head/lib/libgcc_s/Makefile ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/lib/libgcc_s/Makefile Thu Oct 13 18:57:18 2016 (r307230) @@ -0,0 +1,14 @@ +# $FreeBSD$ + +PKG= clibs +SHLIB_NAME= libgcc_s.so.1 + +WARNS?= 2 + +LDFLAGS+= -nodefaultlibs +VERSION_MAP= ${.CURDIR}/Version.map + +.include "../libcompiler_rt/Makefile.inc" +.include "../libgcc_eh/Makefile.inc" + +.include Added: head/lib/libgcc_s/Version.map ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/lib/libgcc_s/Version.map Thu Oct 13 18:57:18 2016 (r307230) @@ -0,0 +1,123 @@ +/* + * $FreeBSD$ + */ + +GCC_3.0 { + __absvdi2; + __absvsi2; + __addvdi3; + __addvsi3; + __ashlti3; + __ashrti3; + __clear_cache; + __cmpti2; + __deregister_frame; + __deregister_frame_info; + __deregister_frame_info_bases; + __divti3; + __ffsdi2; + __ffsti2; + __fixdfti; + __fixsfti; + __fixunsdfdi; + __fixunsdfti; + __fixunssfdi; + __fixunssfti; + __fixunsxfdi; + __fixunsxfti; + __fixxfti; + __floattidf; + __floattisf; + __floattixf; + __lshrti3; + __modti3; + __mulvdi3; + __mulvsi3; + __multi3; + __negti2; + __negvdi2; + __negvsi2; + __register_frame; + __register_frame_info; + __register_frame_info_bases; + __register_frame_info_table; + __register_frame_info_table_bases; + __register_frame_table; + __subvdi3; + __subvsi3; + __ucmpti2; + __udivmodti4; + __udivti3; + __umodti3; + _Unwind_DeleteException; + _Unwind_Find_FDE; + _Unwind_ForcedUnwind; + _Unwind_GetDataRelBase; + _Unwind_GetGR; + _Unwind_GetIP; + _Unwind_GetLanguageSpecificData; + _Unwind_GetRegionStart; + _Unwind_GetTextRelBase; + _Unwind_RaiseException; + _Unwind_Resume; + _Unwind_SetGR; + _Unwind_SetIP; +}; + +GCC_3.3 { + _Unwind_Backtrace; + _Unwind_FindEnclosingFunction; + _Unwind_GetCFA; + _Unwind_Resume_or_Rethrow; +} GCC_3.0; + +GCC_3.3.1 { + __gcc_personality_v0; +} GCC_3.3; + +GCC_3.4 { + __clzdi2; + __clzti2; + __ctzdi2; + __ctzti2; + __paritydi2; + __parityti2; + __popcountdi2; + __popcountti2; +} GCC_3.3.1; + +GCC_3.4.2 { + __enable_execute_stack; +} GCC_3.4; + +GCC_3.4.4 { + __absvti2; + __addvti3; + __mulvti3; + __negvti2; + __subvti3; +} GCC_3.4.2; + +GCC_4.0.0 { + __divdc3; + __divsc3; + __divxc3; + __muldc3; + __mulsc3; + __mulxc3; + __powidf2; + __powisf2; + __powixf2; +} GCC_3.4.4; + +GCC_4.2.0 { + __floatuntidf; + __floatuntisf; + __floatuntixf; + _Unwind_GetIPInfo; +} GCC_4.0.0; + +GCC_4.3.0 { + __bswapdi2; + __bswapsi2; +} GCC_4.2.0; From owner-svn-src-all@freebsd.org Thu Oct 13 19:18:01 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id DA981C1054B; Thu, 13 Oct 2016 19:18:01 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id A9EFD771; Thu, 13 Oct 2016 19:18:01 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9DJI08d085696; Thu, 13 Oct 2016 19:18:00 GMT (envelope-from emaste@FreeBSD.org) Received: (from emaste@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9DJI0bX085695; Thu, 13 Oct 2016 19:18:00 GMT (envelope-from emaste@FreeBSD.org) Message-Id: <201610131918.u9DJI0bX085695@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: emaste set sender to emaste@FreeBSD.org using -f From: Ed Maste Date: Thu, 13 Oct 2016 19:18:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307231 - head/lib/libgcc_s X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Oct 2016 19:18:02 -0000 Author: emaste Date: Thu Oct 13 19:18:00 2016 New Revision: 307231 URL: https://svnweb.freebsd.org/changeset/base/307231 Log: libgcc_s: add libm dependencies from div{d,s,x}c3 compiler-rt's complex division support routines contain calls to compiler builtins such as `__builtin_scalbnl`. Unfortunately Clang turns these back into a call to `scalbnl`. For now link libm's C version of the required support routines. Reviewed by: ed Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D8190 Modified: head/lib/libgcc_s/Makefile Modified: head/lib/libgcc_s/Makefile ============================================================================== --- head/lib/libgcc_s/Makefile Thu Oct 13 18:57:18 2016 (r307230) +++ head/lib/libgcc_s/Makefile Thu Oct 13 19:18:00 2016 (r307231) @@ -11,4 +11,22 @@ VERSION_MAP= ${.CURDIR}/Version.map .include "../libcompiler_rt/Makefile.inc" .include "../libgcc_eh/Makefile.inc" +LIBCSRCDIR= ${SRCTOP}/lib/libc +LIBMSRCDIR= ${SRCTOP}/lib/msun/src +CFLAGS+= -I${LIBCSRCDIR}/include -I${LIBCSRCDIR}/${MACHINE_CPUARCH} +CFLAGS+= -I${LIBMSRCDIR} +.PATH: ${LIBMSRCDIR} +SRCS+= s_fabs.c +SRCS+= s_fabsf.c +SRCS+= s_fabsl.c +SRCS+= s_fmax.c +SRCS+= s_fmaxf.c +SRCS+= s_fmaxl.c +SRCS+= s_logb.c +SRCS+= s_logbf.c +SRCS+= s_logbl.c +SRCS+= s_scalbn.c +SRCS+= s_scalbnf.c +SRCS+= s_scalbnl.c + .include From owner-svn-src-all@freebsd.org Thu Oct 13 19:33:09 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 16CDAC10CAC; Thu, 13 Oct 2016 19:33:09 +0000 (UTC) (envelope-from martymac@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id DCC0738A; Thu, 13 Oct 2016 19:33:08 +0000 (UTC) (envelope-from martymac@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9DJX8iY093065; Thu, 13 Oct 2016 19:33:08 GMT (envelope-from martymac@FreeBSD.org) Received: (from martymac@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9DJX8q8093064; Thu, 13 Oct 2016 19:33:08 GMT (envelope-from martymac@FreeBSD.org) Message-Id: <201610131933.u9DJX8q8093064@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: martymac set sender to martymac@FreeBSD.org using -f From: Ganael LAPLANCHE Date: Thu, 13 Oct 2016 19:33:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307232 - head/sys/fs/nandfs X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Oct 2016 19:33:09 -0000 Author: martymac (ports committer) Date: Thu Oct 13 19:33:07 2016 New Revision: 307232 URL: https://svnweb.freebsd.org/changeset/base/307232 Log: Fix panic() message reporting ufs instead of nandfs PR: 213438 Approved by: kib Modified: head/sys/fs/nandfs/nandfs_vnops.c Modified: head/sys/fs/nandfs/nandfs_vnops.c ============================================================================== --- head/sys/fs/nandfs/nandfs_vnops.c Thu Oct 13 19:18:00 2016 (r307231) +++ head/sys/fs/nandfs/nandfs_vnops.c Thu Oct 13 19:33:07 2016 (r307232) @@ -2211,7 +2211,7 @@ nandfs_whiteout(struct vop_whiteout_args /* Create a new directory whiteout */ #ifdef INVARIANTS if ((cnp->cn_flags & SAVENAME) == 0) - panic("ufs_whiteout: missing name"); + panic("nandfs_whiteout: missing name"); #endif error = nandfs_add_dirent(dvp, NANDFS_WHT_INO, cnp->cn_nameptr, cnp->cn_namelen, DT_WHT); From owner-svn-src-all@freebsd.org Thu Oct 13 19:40:22 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 73AA7C10F6F; Thu, 13 Oct 2016 19:40:22 +0000 (UTC) (envelope-from np@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 43ED9A35; Thu, 13 Oct 2016 19:40:22 +0000 (UTC) (envelope-from np@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9DJeLCl093500; Thu, 13 Oct 2016 19:40:21 GMT (envelope-from np@FreeBSD.org) Received: (from np@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9DJeLNg093498; Thu, 13 Oct 2016 19:40:21 GMT (envelope-from np@FreeBSD.org) Message-Id: <201610131940.u9DJeLNg093498@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: np set sender to np@FreeBSD.org using -f From: Navdeep Parhar Date: Thu, 13 Oct 2016 19:40:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307233 - head/sys/dev/cxgbe X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Oct 2016 19:40:22 -0000 Author: np Date: Thu Oct 13 19:40:21 2016 New Revision: 307233 URL: https://svnweb.freebsd.org/changeset/base/307233 Log: cxgbe(4): Allow the interface MTU to be set as high as the actual hardware limit. Submitted by: jpaetzel@ Differential Revision: https://reviews.freebsd.org/D8237 Modified: head/sys/dev/cxgbe/t4_main.c Modified: head/sys/dev/cxgbe/t4_main.c ============================================================================== --- head/sys/dev/cxgbe/t4_main.c Thu Oct 13 19:33:07 2016 (r307232) +++ head/sys/dev/cxgbe/t4_main.c Thu Oct 13 19:40:21 2016 (r307233) @@ -1567,7 +1567,7 @@ cxgbe_ioctl(struct ifnet *ifp, unsigned switch (cmd) { case SIOCSIFMTU: mtu = ifr->ifr_mtu; - if ((mtu < ETHERMIN) || (mtu > ETHERMTU_JUMBO)) + if (mtu < ETHERMIN || mtu > MAX_MTU) return (EINVAL); rc = begin_synchronized_op(sc, vi, SLEEP_OK | INTR_OK, "t4mtu"); From owner-svn-src-all@freebsd.org Thu Oct 13 20:15:48 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B203EC107D1; Thu, 13 Oct 2016 20:15:48 +0000 (UTC) (envelope-from glebius@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 69C2BCFE; Thu, 13 Oct 2016 20:15:48 +0000 (UTC) (envelope-from glebius@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9DKFlB9008543; Thu, 13 Oct 2016 20:15:47 GMT (envelope-from glebius@FreeBSD.org) Received: (from glebius@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9DKFlhV008540; Thu, 13 Oct 2016 20:15:47 GMT (envelope-from glebius@FreeBSD.org) Message-Id: <201610132015.u9DKFlhV008540@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: glebius set sender to glebius@FreeBSD.org using -f From: Gleb Smirnoff Date: Thu, 13 Oct 2016 20:15:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307234 - in head/sys: netinet netinet6 X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Oct 2016 20:15:48 -0000 Author: glebius Date: Thu Oct 13 20:15:47 2016 New Revision: 307234 URL: https://svnweb.freebsd.org/changeset/base/307234 Log: - Revert r300854, r303657 which tried to fix regression from r297225. - Fix the regression proper way using RO_RTFREE(). Submitted by: ae Modified: head/sys/netinet/in_pcb.c head/sys/netinet/ip_output.c head/sys/netinet6/ip6_output.c Modified: head/sys/netinet/in_pcb.c ============================================================================== --- head/sys/netinet/in_pcb.c Thu Oct 13 19:40:21 2016 (r307233) +++ head/sys/netinet/in_pcb.c Thu Oct 13 20:15:47 2016 (r307234) @@ -1299,10 +1299,7 @@ in_pcbfree(struct inpcb *inp) if (inp->inp_moptions != NULL) inp_freemoptions(inp->inp_moptions); #endif - if (inp->inp_route.ro_rt) { - RTFREE(inp->inp_route.ro_rt); - inp->inp_route.ro_rt = (struct rtentry *)NULL; - } + RO_RTFREE(&inp->inp_route); if (inp->inp_route.ro_lle) LLE_FREE(inp->inp_route.ro_lle); /* zeros ro_lle */ @@ -2242,10 +2239,7 @@ void in_losing(struct inpcb *inp) { - if (inp->inp_route.ro_rt) { - RTFREE(inp->inp_route.ro_rt); - inp->inp_route.ro_rt = (struct rtentry *)NULL; - } + RO_RTFREE(&inp->inp_route); if (inp->inp_route.ro_lle) LLE_FREE(inp->inp_route.ro_lle); /* zeros ro_lle */ return; Modified: head/sys/netinet/ip_output.c ============================================================================== --- head/sys/netinet/ip_output.c Thu Oct 13 19:40:21 2016 (r307233) +++ head/sys/netinet/ip_output.c Thu Oct 13 20:15:47 2016 (r307234) @@ -704,11 +704,7 @@ sendit: IPSTAT_INC(ips_fragmented); done: - /* - * Release the route if using our private route, or if - * (with flowtable) we don't have our own reference. - */ - if (ro == &iproute || ro->ro_flags & RT_NORTREF) + if (ro == &iproute) RO_RTFREE(ro); else if (rte == NULL) /* Modified: head/sys/netinet6/ip6_output.c ============================================================================== --- head/sys/netinet6/ip6_output.c Thu Oct 13 19:40:21 2016 (r307233) +++ head/sys/netinet6/ip6_output.c Thu Oct 13 20:15:47 2016 (r307234) @@ -1064,12 +1064,7 @@ sendorfree: IP6STAT_INC(ip6s_fragmented); done: - /* - * Release the route if using our private route, or if - * (with flowtable) we don't have our own reference. - */ - if (ro == &ip6route || - (ro != NULL && ro->ro_flags & RT_NORTREF)) + if (ro == &ip6route) RO_RTFREE(ro); return (error); From owner-svn-src-all@freebsd.org Thu Oct 13 20:34:45 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B705AC10E00; Thu, 13 Oct 2016 20:34:45 +0000 (UTC) (envelope-from kp@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 72A09B5D; Thu, 13 Oct 2016 20:34:45 +0000 (UTC) (envelope-from kp@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9DKYiIK016280; Thu, 13 Oct 2016 20:34:44 GMT (envelope-from kp@FreeBSD.org) Received: (from kp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9DKYi07016276; Thu, 13 Oct 2016 20:34:44 GMT (envelope-from kp@FreeBSD.org) Message-Id: <201610132034.u9DKYi07016276@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kp set sender to kp@FreeBSD.org using -f From: Kristof Provost Date: Thu, 13 Oct 2016 20:34:44 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307235 - in head: sbin/pfctl share/man/man5 sys/netpfil/pf X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Oct 2016 20:34:45 -0000 Author: kp Date: Thu Oct 13 20:34:44 2016 New Revision: 307235 URL: https://svnweb.freebsd.org/changeset/base/307235 Log: pf: port extended DSCP support from OpenBSD Ignore the ECN bits on 'tos' and 'set-tos' and allow to use DCSP names instead of having to embed their TOS equivalents as plain numbers. Obtained from: OpenBSD Sponsored by: OPNsense Differential Revision: https://reviews.freebsd.org/D8165 Modified: head/sbin/pfctl/parse.y head/share/man/man5/pf.conf.5 head/sys/netpfil/pf/pf.c head/sys/netpfil/pf/pf_norm.c Modified: head/sbin/pfctl/parse.y ============================================================================== --- head/sbin/pfctl/parse.y Thu Oct 13 20:15:47 2016 (r307234) +++ head/sbin/pfctl/parse.y Thu Oct 13 20:34:44 2016 (r307235) @@ -351,6 +351,8 @@ void decide_address_family(struct node_ void remove_invalid_hosts(struct node_host **, sa_family_t *); int invalid_redirect(struct node_host *, sa_family_t); u_int16_t parseicmpspec(char *, sa_family_t); +int kw_casecmp(const void *, const void *); +int map_tos(char *string, int *); static TAILQ_HEAD(loadanchorshead, loadanchors) loadanchorshead = TAILQ_HEAD_INITIALIZER(loadanchorshead); @@ -3584,15 +3586,17 @@ icmp6type : STRING { ; tos : STRING { - if (!strcmp($1, "lowdelay")) - $$ = IPTOS_LOWDELAY; - else if (!strcmp($1, "throughput")) - $$ = IPTOS_THROUGHPUT; - else if (!strcmp($1, "reliability")) - $$ = IPTOS_RELIABILITY; - else if ($1[0] == '0' && $1[1] == 'x') - $$ = strtoul($1, NULL, 16); - else + int val; + char *end; + + if (map_tos($1, &val)) + $$ = val; + else if ($1[0] == '0' && $1[1] == 'x') { + errno = 0; + $$ = strtoul($1, &end, 16); + if (errno || *end != '\0') + $$ = 256; + } else $$ = 256; /* flag bad argument */ if ($$ < 0 || $$ > 255) { yyerror("illegal tos value %s", $1); @@ -6250,6 +6254,57 @@ pfctl_load_anchors(int dev, struct pfctl } int +kw_casecmp(const void *k, const void *e) +{ + return (strcasecmp(k, ((const struct keywords *)e)->k_name)); +} + +int +map_tos(char *s, int *val) +{ + /* DiffServ Codepoints and other TOS mappings */ + const struct keywords toswords[] = { + { "af11", IPTOS_DSCP_AF11 }, + { "af12", IPTOS_DSCP_AF12 }, + { "af13", IPTOS_DSCP_AF13 }, + { "af21", IPTOS_DSCP_AF21 }, + { "af22", IPTOS_DSCP_AF22 }, + { "af23", IPTOS_DSCP_AF23 }, + { "af31", IPTOS_DSCP_AF31 }, + { "af32", IPTOS_DSCP_AF32 }, + { "af33", IPTOS_DSCP_AF33 }, + { "af41", IPTOS_DSCP_AF41 }, + { "af42", IPTOS_DSCP_AF42 }, + { "af43", IPTOS_DSCP_AF43 }, + { "critical", IPTOS_PREC_CRITIC_ECP }, + { "cs0", IPTOS_DSCP_CS0 }, + { "cs1", IPTOS_DSCP_CS1 }, + { "cs2", IPTOS_DSCP_CS2 }, + { "cs3", IPTOS_DSCP_CS3 }, + { "cs4", IPTOS_DSCP_CS4 }, + { "cs5", IPTOS_DSCP_CS5 }, + { "cs6", IPTOS_DSCP_CS6 }, + { "cs7", IPTOS_DSCP_CS7 }, + { "ef", IPTOS_DSCP_EF }, + { "inetcontrol", IPTOS_PREC_INTERNETCONTROL }, + { "lowdelay", IPTOS_LOWDELAY }, + { "netcontrol", IPTOS_PREC_NETCONTROL }, + { "reliability", IPTOS_RELIABILITY }, + { "throughput", IPTOS_THROUGHPUT } + }; + const struct keywords *p; + + p = bsearch(s, toswords, sizeof(toswords)/sizeof(toswords[0]), + sizeof(toswords[0]), kw_casecmp); + + if (p) { + *val = p->k_val; + return (1); + } + return (0); +} + +int rt_tableid_max(void) { #ifdef __FreeBSD__ Modified: head/share/man/man5/pf.conf.5 ============================================================================== --- head/share/man/man5/pf.conf.5 Thu Oct 13 20:15:47 2016 (r307234) +++ head/share/man/man5/pf.conf.5 Thu Oct 13 20:34:44 2016 (r307235) @@ -28,7 +28,7 @@ .\" ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" POSSIBILITY OF SUCH DAMAGE. .\" -.Dd September 28, 2016 +.Dd October 6, 2016 .Dt PF.CONF 5 .Os .Sh NAME @@ -648,9 +648,16 @@ for matching IP packets. .Em TOS may be given as one of +.Ar critical , +.Ar inetcontrol , .Ar lowdelay , +.Ar netcontrol , .Ar throughput , .Ar reliability , +or one of the DiffServ Code Points: +.Ar ef , +.Ar af11 No ... Ar af43 , +.Ar cs0 No ... Ar cs7 ; or as either hex or decimal. .It Ar random-id Replaces the IP identification field with random values to compensate @@ -1697,9 +1704,16 @@ bits set. .Em TOS may be given as one of +.Ar critical , +.Ar inetcontrol , .Ar lowdelay , +.Ar netcontrol , .Ar throughput , .Ar reliability , +or one of the DiffServ Code Points: +.Ar ef , +.Ar af11 No ... Ar af43 , +.Ar cs0 No ... Ar cs7 ; or as either hex or decimal. .Pp For example, the following rules are identical: @@ -1803,7 +1817,6 @@ pass in proto tcp to port 25 set prio 2 pass in proto tcp to port 22 set prio (2, 5) .Ed .Pp - .It Ar tag Aq Ar string Packets matching this rule will be tagged with the specified string. Modified: head/sys/netpfil/pf/pf.c ============================================================================== --- head/sys/netpfil/pf/pf.c Thu Oct 13 20:15:47 2016 (r307234) +++ head/sys/netpfil/pf/pf.c Thu Oct 13 20:34:44 2016 (r307235) @@ -5893,7 +5893,7 @@ pf_test(int dir, struct ifnet *ifp, stru pd.sidx = (dir == PF_IN) ? 0 : 1; pd.didx = (dir == PF_IN) ? 1 : 0; pd.af = AF_INET; - pd.tos = h->ip_tos; + pd.tos = h->ip_tos & ~IPTOS_ECN_MASK; pd.tot_len = ntohs(h->ip_len); /* handle fragments that didn't get reassembled by normalization */ Modified: head/sys/netpfil/pf/pf_norm.c ============================================================================== --- head/sys/netpfil/pf/pf_norm.c Thu Oct 13 20:15:47 2016 (r307234) +++ head/sys/netpfil/pf/pf_norm.c Thu Oct 13 20:34:44 2016 (r307235) @@ -1811,7 +1811,7 @@ pf_scrub_ip(struct mbuf **m0, u_int32_t u_int16_t ov, nv; ov = *(u_int16_t *)h; - h->ip_tos = tos; + h->ip_tos = tos | (h->ip_tos & IPTOS_ECN_MASK); nv = *(u_int16_t *)h; h->ip_sum = pf_cksum_fixup(h->ip_sum, ov, nv, 0); From owner-svn-src-all@freebsd.org Thu Oct 13 20:39:35 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id DDB92C10EE1; Thu, 13 Oct 2016 20:39:35 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id AFC1BD5C; Thu, 13 Oct 2016 20:39:35 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9DKdYTj016481; Thu, 13 Oct 2016 20:39:34 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9DKdY0u016480; Thu, 13 Oct 2016 20:39:34 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201610132039.u9DKdY0u016480@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Thu, 13 Oct 2016 20:39:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307236 - head/sys/vm X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Oct 2016 20:39:36 -0000 Author: markj Date: Thu Oct 13 20:39:34 2016 New Revision: 307236 URL: https://svnweb.freebsd.org/changeset/base/307236 Log: Plug a potential vnode lock leak in vm_fault_hold(). Reviewed by: alc, kib MFC after: 1 week Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D8242 Modified: head/sys/vm/vm_fault.c Modified: head/sys/vm/vm_fault.c ============================================================================== --- head/sys/vm/vm_fault.c Thu Oct 13 20:34:44 2016 (r307235) +++ head/sys/vm/vm_fault.c Thu Oct 13 20:39:34 2016 (r307236) @@ -321,6 +321,8 @@ RetryFault:; growstack = FALSE; goto RetryFault; } + if (fs.vp != NULL) + vput(fs.vp); return (result); } From owner-svn-src-all@freebsd.org Thu Oct 13 20:55:42 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 22587C10339; Thu, 13 Oct 2016 20:55:42 +0000 (UTC) (envelope-from cse.cem@gmail.com) Received: from mail-io0-f175.google.com (mail-io0-f175.google.com [209.85.223.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id EAB509B9; Thu, 13 Oct 2016 20:55:41 +0000 (UTC) (envelope-from cse.cem@gmail.com) Received: by mail-io0-f175.google.com with SMTP id q192so99825372iod.0; Thu, 13 Oct 2016 13:55:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:reply-to:in-reply-to:references :from:date:message-id:subject:to:cc; bh=nyr+sicDdkzm6xaJStm8+oKBG3ClxzT0iS/UlgAhNJA=; b=L2C7wLqDYOdQ1EufcV/ctUF1DeKjvHZiNyczPWupOc5G0UHQaI7VaDiViyLwbQAz3H p8E5NfT+HLFDphQVUiTWlKSj15nycMAvho/m7lxQltn2JaG0+LoBTA4Y0BJkmQH00SWp RV1cgARfYqzmro3MZ9LVjbigKshRfJvASwE0Hm58PfhIkBLF5+ImZ7UuPcgHY4VGWiK3 5vdWe3uvZY/ySS/s1G3yXBYG+4an+77DMYvqSwp0oFfF6VvJowaY/FUXaSjhX9kqOuVP SP6mwgOyDm3sTlnlTf3Q/TPtlxrB6jhBIIV4vWhl8RWbPqnE66bEMEZFBT6OFrk35zni bjug== X-Gm-Message-State: AA6/9Rlt58cb9ChyEI9KrX3hMn/+daf5ShrIhJl83XvanXV24ceTHYqbaMsn5HYDD3PZMA== X-Received: by 10.107.26.79 with SMTP id a76mr8771652ioa.54.1476391770015; Thu, 13 Oct 2016 13:49:30 -0700 (PDT) Received: from mail-it0-f52.google.com (mail-it0-f52.google.com. [209.85.214.52]) by smtp.gmail.com with ESMTPSA id g11sm6447361ioi.12.2016.10.13.13.49.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Oct 2016 13:49:29 -0700 (PDT) Received: by mail-it0-f52.google.com with SMTP id e203so137504259itc.0; Thu, 13 Oct 2016 13:49:29 -0700 (PDT) X-Received: by 10.36.250.131 with SMTP id v125mr9447797ith.104.1476391769655; Thu, 13 Oct 2016 13:49:29 -0700 (PDT) MIME-Version: 1.0 Reply-To: cem@freebsd.org Received: by 10.36.220.199 with HTTP; Thu, 13 Oct 2016 13:49:29 -0700 (PDT) In-Reply-To: <201610132039.u9DKdY0u016480@repo.freebsd.org> References: <201610132039.u9DKdY0u016480@repo.freebsd.org> From: Conrad Meyer Date: Thu, 13 Oct 2016 13:49:29 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: svn commit: r307236 - head/sys/vm To: Mark Johnston Cc: src-committers , svn-src-all@freebsd.org, svn-src-head@freebsd.org Content-Type: text/plain; charset=UTF-8 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Oct 2016 20:55:42 -0000 On Thu, Oct 13, 2016 at 1:39 PM, Mark Johnston wrote: > Author: markj > Date: Thu Oct 13 20:39:34 2016 > New Revision: 307236 > URL: https://svnweb.freebsd.org/changeset/base/307236 > > Log: > Plug a potential vnode lock leak in vm_fault_hold(). This isn't just potential, right? I believe we hit this one empirically with an assert in place of this if/vput. Best, Conrad From owner-svn-src-all@freebsd.org Thu Oct 13 21:02:45 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B7062C10623; Thu, 13 Oct 2016 21:02:45 +0000 (UTC) (envelope-from markjdb@gmail.com) Received: from mail-pa0-x229.google.com (mail-pa0-x229.google.com [IPv6:2607:f8b0:400e:c03::229]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 864D7EAB; Thu, 13 Oct 2016 21:02:45 +0000 (UTC) (envelope-from markjdb@gmail.com) Received: by mail-pa0-x229.google.com with SMTP id qn10so41316558pac.2; Thu, 13 Oct 2016 14:02:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=ucBigxgbI5wM/r2MEsptF6mwUMQzHQcPi892P84Ydwk=; b=0xmnyfx02fKuy7hUfuFiFC8yEzxAbsnMIFGmfVo5cCH1RT2ZVWic4lPwg/SNAlY17N o6Vly/Xl9GuHH9odXVuVLKPZ3NzbqVhhX2tcV8g2efFLKyirLmp+7d1jLnVKgJF8q1B9 vDVFYLurP+COkk1HPF+igeVSMW2VSXQTxy2FGgVCnFzgxuik4XiRVRX4ZhDEfqM46ezz zAtoLxY46w8wp64FyOeFMnuz7dIyLiNc4pna4bpgILJV7v7De1+NAjbxpZNyC7CzjPSN TuZZOiMsbvffk2IGO0Sue0170mNIie1E4SWvH0Lk+dRT2qgA3TIulvvNAcjCyDWfLQX+ eenA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to:user-agent; bh=ucBigxgbI5wM/r2MEsptF6mwUMQzHQcPi892P84Ydwk=; b=EAZvO2lye3RyRXHTdJj419CyxcC8urPF3TkzN1PvF+2rw0Dqbezy80JdgUIdYoXww3 nKINcb2WykfbwJXPvyCEEYIuu1XISKWb1CBh8fMsoRy8BLLGylOEHoAypa4792O+wUTx OeNE73Mk0/PCEgP23YXa/NgU5isaSrtELPjyTBwTAjwhhAo9h8iFCGVpTd1lsWpKW9wh Hfj9EA9RBPQrG4j6Npf1XjSZReCw+qt3yYuxX9U/vNE3if073UCShsieWIgiGNXYZXhj m1i+ZvAVYBpY6lnzoCQJHUZhbQV26rYPgIy00yr9MTl0kD25aBGLuiPuQiX3qvXE1hxM hALQ== X-Gm-Message-State: AA6/9Rl5B102hKVkH7h3SzT/mgXZhbaWcWtu4n1UXCZtR2cVpm/H/s005+6i3UTrF+8huQ== X-Received: by 10.66.254.10 with SMTP id ae10mr10824834pad.26.1476392564888; Thu, 13 Oct 2016 14:02:44 -0700 (PDT) Received: from wkstn-mjohnston.west.isilon.com (c-76-104-201-218.hsd1.wa.comcast.net. [76.104.201.218]) by smtp.gmail.com with ESMTPSA id 3sm21767567pfo.31.2016.10.13.14.02.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Oct 2016 14:02:44 -0700 (PDT) Sender: Mark Johnston Date: Thu, 13 Oct 2016 14:08:41 -0700 From: Mark Johnston To: Conrad Meyer Cc: src-committers , svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r307236 - head/sys/vm Message-ID: <20161013210841.GB52539@wkstn-mjohnston.west.isilon.com> References: <201610132039.u9DKdY0u016480@repo.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.7.0 (2016-08-17) X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Oct 2016 21:02:45 -0000 On Thu, Oct 13, 2016 at 01:49:29PM -0700, Conrad Meyer wrote: > On Thu, Oct 13, 2016 at 1:39 PM, Mark Johnston wrote: > > Author: markj > > Date: Thu Oct 13 20:39:34 2016 > > New Revision: 307236 > > URL: https://svnweb.freebsd.org/changeset/base/307236 > > > > Log: > > Plug a potential vnode lock leak in vm_fault_hold(). > > This isn't just potential, right? I believe we hit this one > empirically with an assert in place of this if/vput. Sorry, right, that was bad wording. I meant that the lock is not always leaked in this error path - the map lookup needs to succeed initially, after which we need to block for the vnode lock, restart the fault handler, and then get an error from vm_map_lookup(). If the initial lookup fails, there's no leak. From owner-svn-src-all@freebsd.org Thu Oct 13 21:35:50 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 29E72C10D12; Thu, 13 Oct 2016 21:35:50 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id ED97EE6D; Thu, 13 Oct 2016 21:35:49 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9DLZnis038744; Thu, 13 Oct 2016 21:35:49 GMT (envelope-from emaste@FreeBSD.org) Received: (from emaste@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9DLZnmT038743; Thu, 13 Oct 2016 21:35:49 GMT (envelope-from emaste@FreeBSD.org) Message-Id: <201610132135.u9DLZnmT038743@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: emaste set sender to emaste@FreeBSD.org using -f From: Ed Maste Date: Thu, 13 Oct 2016 21:35:49 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307237 - head/lib X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Oct 2016 21:35:50 -0000 Author: emaste Date: Thu Oct 13 21:35:48 2016 New Revision: 307237 URL: https://svnweb.freebsd.org/changeset/base/307237 Log: garbage collect _libatm, missed in r179308 Modified: head/lib/Makefile Modified: head/lib/Makefile ============================================================================== --- head/lib/Makefile Thu Oct 13 20:39:34 2016 (r307236) +++ head/lib/Makefile Thu Oct 13 21:35:48 2016 (r307237) @@ -26,7 +26,6 @@ SUBDIR= ${SUBDIR_BOOTSTRAP} \ .WAIT \ libalias \ libarchive \ - ${_libatm} \ libauditd \ libbegemot \ ${_libblacklist} \ @@ -134,7 +133,6 @@ SUBDIR= ${SUBDIR_BOOTSTRAP} \ # libraries, those libraries should be listed as build order dependencies here. SUBDIR_DEPEND_libarchive= libz libbz2 libexpat liblzma libmd -SUBDIR_DEPEND_libatm= libmd SUBDIR_DEPEND_libauditdm= libbsm SUBDIR_DEPEND_libbsnmp= ${_libnetgraph} SUBDIR_DEPEND_libc++:= libcxxrt From owner-svn-src-all@freebsd.org Thu Oct 13 21:42:32 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id DD5F9C10F75; Thu, 13 Oct 2016 21:42:32 +0000 (UTC) (envelope-from asomers@gmail.com) Received: from mail-qk0-x22c.google.com (mail-qk0-x22c.google.com [IPv6:2607:f8b0:400d:c09::22c]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id A3E4533D; Thu, 13 Oct 2016 21:42:32 +0000 (UTC) (envelope-from asomers@gmail.com) Received: by mail-qk0-x22c.google.com with SMTP id f128so110741020qkb.1; Thu, 13 Oct 2016 14:42:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=eqPNMl7awoy8ADNBfv6wfK42vX3Ji7yPHPvBfq5T4t8=; b=IFf47xw5j3HVFYqqsgimGXu69ahOmu4AV5lAZQVVnkSqOSplsplUGMUg0BRX0lXBPV tfCoGL7enPMPO23CR69kA6GKxdzzKMzxxXdnVAGU9w4FMM1WtOr+qVTKg4pBqs5Vmo58 dM7g/NICl4eHIrBRKddiYDLZ9V4AD1fZxc2GJpvrFT/47LkW/IrVjtoVBrviGm7WGhjp UeDERfoIUGmORqgmTolHTMbWHLR22Jaetqw2pYu+gVStV8zOpbbBhnr1PHEeCLwG/ING abZaD8bARdEJ8E2CaTo/gA8HslktWOKM6WYAUAxR7sFX/szEGTwu7qQ7D7CDa4RpzNZk Lvow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=eqPNMl7awoy8ADNBfv6wfK42vX3Ji7yPHPvBfq5T4t8=; b=lx/OYtAYk34bylQnsDtxl2GOqMUISCWT861UfZGDm+XB32o8fByJCFBMGu06dYc0/h RnC9voWLRIUe2NeYG5eFS9Nm8vdcXc5KxROWCQDlJUqsgD4FIbgJcIz8+oq14esGEy5T bocNywTy9U93blRqAClRj+8wk68YNeYIsi+lGDQozQqsIFR9f3nZj0txmgvjDsLjpJ4M dwCD4RwvdHDWqVlOhckACe6BDkeKL4kXHnrCXyECjTtD4oxPSEPlG3LqDbRTHGNYlMqd IkkI6Ped6PG3yacdecco/riYcNzrrCOD/VaIo7WdW2py+pkB7nKQPR0RwuXReoYx+09g GMDw== X-Gm-Message-State: AA6/9RmZg+NWOKv3HMrFFIUt1p/nYCz0dEKqW3GObDRS1qMdaGK3rskRZV7M9bfDNosocjbq5ZXHNm0qLQQhZw== X-Received: by 10.55.80.136 with SMTP id e130mr8396419qkb.119.1476394951700; Thu, 13 Oct 2016 14:42:31 -0700 (PDT) MIME-Version: 1.0 Sender: asomers@gmail.com Received: by 10.12.138.251 with HTTP; Thu, 13 Oct 2016 14:42:31 -0700 (PDT) In-Reply-To: <201507021731.t62HV074085188@repo.freebsd.org> References: <201507021731.t62HV074085188@repo.freebsd.org> From: Alan Somers Date: Thu, 13 Oct 2016 15:42:31 -0600 X-Google-Sender-Auth: Zi29YmTRfK1BpHLcf0OjKwSW8iQ Message-ID: Subject: Re: svn commit: r285050 - in head: lib/libutil usr.sbin/pwd_mkdb To: Renato Botelho Cc: "src-committers@freebsd.org" , "svn-src-all@freebsd.org" , "svn-src-head@freebsd.org" Content-Type: text/plain; charset=UTF-8 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Oct 2016 21:42:33 -0000 On Thu, Jul 2, 2015 at 11:31 AM, Renato Botelho wrote: > Author: garga (ports committer) > Date: Thu Jul 2 17:30:59 2015 > New Revision: 285050 > URL: https://svnweb.freebsd.org/changeset/base/285050 > > Log: > When passwd or group information is changed (by pw, vipw, chpass, ...) > temporary file is created and then a rename() call move it to official file. > This operation didn't have any check to make sure data was written to disk > and if a power cycle happens system could end up with a 0 length passwd > or group database. > > There is a pfSense bug with more infor about it: > > https://redmine.pfsense.org/issues/4523 > > The following changes were made to protect passwd and group operations: > > * lib/libutil/gr_util.c: > - Replace mkstemp() by mkostemp() with O_SYNC flag to create temp file > - After rename(), fsync() call on directory for faster result > > * lib/libutil/pw_util.c > - Replace mkstemp() by mkostemp() with O_SYNC flag to create temp file > > * usr.sbin/pwd_mkdb/pwd_mkdb.c > - Added O_SYNC flag on dbopen() calls > - After rename(), fsync() call on directory for faster result > > * lib/libutil/pw_util.3 > - pw_lock() returns a file descriptor to master password file on success > > Differential Revision: https://reviews.freebsd.org/D2978 > Approved by: bapt > Sponsored by: Netgate > > Modified: > head/lib/libutil/gr_util.c > head/lib/libutil/pw_util.3 > head/lib/libutil/pw_util.c > head/usr.sbin/pwd_mkdb/pwd_mkdb.c This change is making certain pw operations very slow on ZFS root systems. The problem is that when you open a file with O_SYNC, every single write(2) call turns into a zil_commit on ZFS, which is fairly expensive. Did you consider using fsync(2) on the temporary files instead of opening them with O_SYNC? I just tried that now, and I see a considerable speedup when running the tests in /usr/tests/usr.sbin/pw: Using O_SYNC, as CURRENT does: 4 minutes 5.2 seconds No synchronous operations at all: 49.5 seconds Using fsync(2): 56.0 seconds -Alan From owner-svn-src-all@freebsd.org Thu Oct 13 22:43:51 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 3CED5C10B07; Thu, 13 Oct 2016 22:43:51 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 17039EB5; Thu, 13 Oct 2016 22:43:51 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9DMhoXE064830; Thu, 13 Oct 2016 22:43:50 GMT (envelope-from bapt@FreeBSD.org) Received: (from bapt@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9DMhnVH064823; Thu, 13 Oct 2016 22:43:49 GMT (envelope-from bapt@FreeBSD.org) Message-Id: <201610132243.u9DMhnVH064823@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bapt set sender to bapt@FreeBSD.org using -f From: Baptiste Daroussin Date: Thu, 13 Oct 2016 22:43:49 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307238 - in head/sys/boot: arm/uboot common mips/uboot powerpc/kboot powerpc/ofw powerpc/ps3 sparc64/loader X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Oct 2016 22:43:51 -0000 Author: bapt Date: Thu Oct 13 22:43:49 2016 New Revision: 307238 URL: https://svnweb.freebsd.org/changeset/base/307238 Log: Stop closing the network device when netbooting for loaders using the common dev_net.c code. The NETIF_OPEN_CLOSE_ONCE flag was added in r201932 to prevent that behaviour on some architectures (sparc64 and powerpc64) the default was left to always open and close the device for each open and close of a file by the loader because it was necessary for u-boot on arm. Since it has been added, the flag was turned on for every arches including the u-boot loader for arm. This also fixes netbooting on RPi3 (tested by gonzo@) For the loader.efi it greatly speeds up netbooting Reviewed by: emaste, gonzo, tsoome Approved by: gonzo MFC after: 1 month Sponsored by: Gandi.net Differential Revision: https://reviews.freebsd.org/D8230 Modified: head/sys/boot/arm/uboot/Makefile head/sys/boot/common/dev_net.c head/sys/boot/mips/uboot/Makefile head/sys/boot/powerpc/kboot/Makefile head/sys/boot/powerpc/ofw/Makefile head/sys/boot/powerpc/ps3/Makefile head/sys/boot/sparc64/loader/Makefile Modified: head/sys/boot/arm/uboot/Makefile ============================================================================== --- head/sys/boot/arm/uboot/Makefile Thu Oct 13 21:35:48 2016 (r307237) +++ head/sys/boot/arm/uboot/Makefile Thu Oct 13 22:43:49 2016 (r307238) @@ -77,8 +77,6 @@ LIBUBOOT_FDT= ${.OBJDIR}/../../uboot/fdt LIBFDT= ${.OBJDIR}/../../fdt/libfdt.a .endif -CFLAGS+= -DNETIF_OPEN_CLOSE_ONCE - .if ${MK_FORTH} != "no" # Enable BootForth BOOT_FORTH= yes Modified: head/sys/boot/common/dev_net.c ============================================================================== --- head/sys/boot/common/dev_net.c Thu Oct 13 21:35:48 2016 (r307237) +++ head/sys/boot/common/dev_net.c Thu Oct 13 22:43:49 2016 (r307238) @@ -120,11 +120,9 @@ net_open(struct open_file *f, ...) devname = va_arg(args, char*); va_end(args); -#ifdef NETIF_OPEN_CLOSE_ONCE /* Before opening another interface, close the previous one first. */ if (netdev_sock >= 0 && strcmp(devname, netdev_name) != 0) net_cleanup(); -#endif /* On first open, do netif open, mount, etc. */ if (netdev_opens == 0) { @@ -198,21 +196,6 @@ net_close(struct open_file *f) f->f_devdata = NULL; -#ifndef NETIF_OPEN_CLOSE_ONCE - /* Extra close call? */ - if (netdev_opens <= 0) - return (0); - netdev_opens--; - /* Not last close? */ - if (netdev_opens > 0) - return (0); - /* On last close, do netif close, etc. */ -#ifdef NETIF_DEBUG - if (debug) - printf("net_close: calling net_cleanup()\n"); -#endif - net_cleanup(); -#endif return (0); } Modified: head/sys/boot/mips/uboot/Makefile ============================================================================== --- head/sys/boot/mips/uboot/Makefile Thu Oct 13 21:35:48 2016 (r307237) +++ head/sys/boot/mips/uboot/Makefile Thu Oct 13 22:43:49 2016 (r307238) @@ -81,8 +81,6 @@ LIBUBOOT_FDT= ${.OBJDIR}/../../uboot/fdt LIBFDT= ${.OBJDIR}/../../fdt/libfdt.a .endif -CFLAGS+= -DNETIF_OPEN_CLOSE_ONCE - .if ${MK_FORTH} != "no" # Enable BootForth BOOT_FORTH= yes Modified: head/sys/boot/powerpc/kboot/Makefile ============================================================================== --- head/sys/boot/powerpc/kboot/Makefile Thu Oct 13 21:35:48 2016 (r307237) +++ head/sys/boot/powerpc/kboot/Makefile Thu Oct 13 22:43:49 2016 (r307238) @@ -68,10 +68,7 @@ CFLAGS+= -DBOOT_FORTH -I${.CURDIR}/../.. LIBFICL= ${.OBJDIR}/../../ficl/libficl.a .endif -# Avoid the open-close-dance for every file access as some firmwares perform -# an auto-negotiation on every open of the network interface and thus causes -# netbooting to take horribly long. -CFLAGS+= -DNETIF_OPEN_CLOSE_ONCE -mcpu=powerpc64 +CFLAGS+= -mcpu=powerpc64 # Always add MI sources .PATH: ${.CURDIR}/../../common ${.CURDIR}/../../../libkern Modified: head/sys/boot/powerpc/ofw/Makefile ============================================================================== --- head/sys/boot/powerpc/ofw/Makefile Thu Oct 13 21:35:48 2016 (r307237) +++ head/sys/boot/powerpc/ofw/Makefile Thu Oct 13 22:43:49 2016 (r307238) @@ -67,11 +67,6 @@ CFLAGS+= -DBOOT_FORTH -I${.CURDIR}/../.. LIBFICL= ${.OBJDIR}/../../ficl/libficl.a .endif -# Avoid the open-close-dance for every file access as some firmwares perform -# an auto-negotiation on every open of the network interface and thus causes -# netbooting to take horribly long. -CFLAGS+= -DNETIF_OPEN_CLOSE_ONCE - # Always add MI sources .PATH: ${.CURDIR}/../../common ${.CURDIR}/../../../libkern .include "${.CURDIR}/../../common/Makefile.inc" Modified: head/sys/boot/powerpc/ps3/Makefile ============================================================================== --- head/sys/boot/powerpc/ps3/Makefile Thu Oct 13 21:35:48 2016 (r307237) +++ head/sys/boot/powerpc/ps3/Makefile Thu Oct 13 22:43:49 2016 (r307238) @@ -68,10 +68,7 @@ CFLAGS+= -DBOOT_FORTH -I${.CURDIR}/../.. LIBFICL= ${.OBJDIR}/../../ficl/libficl.a .endif -# Avoid the open-close-dance for every file access as some firmwares perform -# an auto-negotiation on every open of the network interface and thus causes -# netbooting to take horribly long. -CFLAGS+= -DNETIF_OPEN_CLOSE_ONCE -mcpu=powerpc64 +CFLAGS+= -mcpu=powerpc64 # Always add MI sources .PATH: ${.CURDIR}/../../common ${.CURDIR}/../../../libkern Modified: head/sys/boot/sparc64/loader/Makefile ============================================================================== --- head/sys/boot/sparc64/loader/Makefile Thu Oct 13 21:35:48 2016 (r307237) +++ head/sys/boot/sparc64/loader/Makefile Thu Oct 13 22:43:49 2016 (r307238) @@ -69,10 +69,6 @@ LIBFICL= ${.OBJDIR}/../../ficl/libficl.a .include "${.CURDIR}/../../common/Makefile.inc" CFLAGS+= -I${.CURDIR}/../../common CFLAGS+= -I. -# Avoid the open-close-dance for every file access as some firmwares perform -# an auto-negotiation on every open of the network interface and thus causes -# netbooting to take horribly long. -CFLAGS+= -DNETIF_OPEN_CLOSE_ONCE CLEANFILES+= vers.c loader.help From owner-svn-src-all@freebsd.org Thu Oct 13 23:06:21 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 1EE5CC1014B; Thu, 13 Oct 2016 23:06:21 +0000 (UTC) (envelope-from truckman@FreeBSD.org) Received: from gw.catspoiler.org (unknown [IPv6:2602:304:b010:ef20::f2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "gw.catspoiler.org", Issuer "gw.catspoiler.org" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id D484F1890; Thu, 13 Oct 2016 23:06:20 +0000 (UTC) (envelope-from truckman@FreeBSD.org) Received: from FreeBSD.org (mousie.catspoiler.org [192.168.101.2]) by gw.catspoiler.org (8.15.2/8.15.2) with ESMTP id u9DN6Aod023917; Thu, 13 Oct 2016 16:06:14 -0700 (PDT) (envelope-from truckman@FreeBSD.org) Message-Id: <201610132306.u9DN6Aod023917@gw.catspoiler.org> Date: Thu, 13 Oct 2016 16:06:10 -0700 (PDT) From: Don Lewis Subject: Re: svn commit: r285050 - in head: lib/libutil usr.sbin/pwd_mkdb To: asomers@freebsd.org cc: garga@freebsd.org, src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org In-Reply-To: MIME-Version: 1.0 Content-Type: TEXT/plain; charset=us-ascii X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Oct 2016 23:06:21 -0000 On 13 Oct, Alan Somers wrote: > On Thu, Jul 2, 2015 at 11:31 AM, Renato Botelho wrote: >> Author: garga (ports committer) >> Date: Thu Jul 2 17:30:59 2015 >> New Revision: 285050 >> URL: https://svnweb.freebsd.org/changeset/base/285050 >> >> Log: >> When passwd or group information is changed (by pw, vipw, chpass, ...) >> temporary file is created and then a rename() call move it to official file. >> This operation didn't have any check to make sure data was written to disk >> and if a power cycle happens system could end up with a 0 length passwd >> or group database. >> >> There is a pfSense bug with more infor about it: >> >> https://redmine.pfsense.org/issues/4523 >> >> The following changes were made to protect passwd and group operations: >> >> * lib/libutil/gr_util.c: >> - Replace mkstemp() by mkostemp() with O_SYNC flag to create temp file >> - After rename(), fsync() call on directory for faster result >> >> * lib/libutil/pw_util.c >> - Replace mkstemp() by mkostemp() with O_SYNC flag to create temp file >> >> * usr.sbin/pwd_mkdb/pwd_mkdb.c >> - Added O_SYNC flag on dbopen() calls >> - After rename(), fsync() call on directory for faster result >> >> * lib/libutil/pw_util.3 >> - pw_lock() returns a file descriptor to master password file on success >> >> Differential Revision: https://reviews.freebsd.org/D2978 >> Approved by: bapt >> Sponsored by: Netgate >> >> Modified: >> head/lib/libutil/gr_util.c >> head/lib/libutil/pw_util.3 >> head/lib/libutil/pw_util.c >> head/usr.sbin/pwd_mkdb/pwd_mkdb.c > > This change is making certain pw operations very slow on ZFS root > systems. The problem is that when you open a file with O_SYNC, every > single write(2) call turns into a zil_commit on ZFS, which is fairly > expensive. Did you consider using fsync(2) on the temporary files > instead of opening them with O_SYNC? I just tried that now, and I see > a considerable speedup when running the tests in > /usr/tests/usr.sbin/pw: > > Using O_SYNC, as CURRENT does: 4 minutes 5.2 seconds > No synchronous operations at all: 49.5 seconds > Using fsync(2): 56.0 seconds pwd_mkdb was fixed back in February with by switching to fsync() in r295925. It looks like libutil was not fixed, though. From owner-svn-src-all@freebsd.org Thu Oct 13 23:29:26 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 46CF2C105B7; Thu, 13 Oct 2016 23:29:26 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id E5728AF; Thu, 13 Oct 2016 23:29:25 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9DNTPqK080084; Thu, 13 Oct 2016 23:29:25 GMT (envelope-from gonzo@FreeBSD.org) Received: (from gonzo@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9DNTPtv080083; Thu, 13 Oct 2016 23:29:25 GMT (envelope-from gonzo@FreeBSD.org) Message-Id: <201610132329.u9DNTPtv080083@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: gonzo set sender to gonzo@FreeBSD.org using -f From: Oleksandr Tymoshenko Date: Thu, 13 Oct 2016 23:29:25 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307239 - head/sys/arm/broadcom/bcm2835 X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Oct 2016 23:29:26 -0000 Author: gonzo Date: Thu Oct 13 23:29:24 2016 New Revision: 307239 URL: https://svnweb.freebsd.org/changeset/base/307239 Log: Fix BCM283x(Raspberry Pi) SDHCI driver for ARM64 build - Revert BUS_SPACE_PHYSADDR back to rman_get_start. BUS_SPACE_PHYSADDR was introduced in 2013 as temporary wrapper until proper solution appears. It's ARM only and since we need this file for ARM64 build and no proper API has been introduced - just revert the change and make sure it's going to appear when people grep for BUS_SPACE_PHYSADDR in sources. - Fix printf format for size_t variables Modified: head/sys/arm/broadcom/bcm2835/bcm2835_sdhci.c Modified: head/sys/arm/broadcom/bcm2835/bcm2835_sdhci.c ============================================================================== --- head/sys/arm/broadcom/bcm2835/bcm2835_sdhci.c Thu Oct 13 22:43:49 2016 (r307238) +++ head/sys/arm/broadcom/bcm2835/bcm2835_sdhci.c Thu Oct 13 23:29:24 2016 (r307239) @@ -246,8 +246,9 @@ bcm_sdhci_attach(device_t dev) goto fail; } - sc->sc_sdhci_buffer_phys = BUS_SPACE_PHYSADDR(sc->sc_mem_res, - SDHCI_BUFFER); + /* FIXME: Fix along with other BUS_SPACE_PHYSADDR instances */ + sc->sc_sdhci_buffer_phys = rman_get_start(sc->sc_mem_res) + + SDHCI_BUFFER; bus_generic_probe(dev); bus_generic_attach(dev); @@ -552,7 +553,7 @@ bcm_sdhci_read_dma(device_t dev, struct slot->curcmd->data->len - slot->offset); KASSERT((left & 3) == 0, - ("%s: len = %d, not word-aligned", __func__, left)); + ("%s: len = %zu, not word-aligned", __func__, left)); if (bus_dmamap_load(sc->sc_dma_tag, sc->sc_dma_map, (uint8_t *)slot->curcmd->data->data + slot->offset, left, @@ -581,7 +582,7 @@ bcm_sdhci_write_dma(device_t dev, struct slot->curcmd->data->len - slot->offset); KASSERT((left & 3) == 0, - ("%s: len = %d, not word-aligned", __func__, left)); + ("%s: len = %zu, not word-aligned", __func__, left)); if (bus_dmamap_load(sc->sc_dma_tag, sc->sc_dma_map, (uint8_t *)slot->curcmd->data->data + slot->offset, left, From owner-svn-src-all@freebsd.org Fri Oct 14 00:42:09 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E7D68AC699C; Fri, 14 Oct 2016 00:42:09 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id AF0B87B0; Fri, 14 Oct 2016 00:42:09 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9E0g81U009740; Fri, 14 Oct 2016 00:42:08 GMT (envelope-from gonzo@FreeBSD.org) Received: (from gonzo@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9E0g8u9009739; Fri, 14 Oct 2016 00:42:08 GMT (envelope-from gonzo@FreeBSD.org) Message-Id: <201610140042.u9E0g8u9009739@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: gonzo set sender to gonzo@FreeBSD.org using -f From: Oleksandr Tymoshenko Date: Fri, 14 Oct 2016 00:42:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307240 - head/sys/arm/broadcom/bcm2835 X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Oct 2016 00:42:10 -0000 Author: gonzo Date: Fri Oct 14 00:42:08 2016 New Revision: 307240 URL: https://svnweb.freebsd.org/changeset/base/307240 Log: Fix BCM238x framebuffer driver build for ARM64 VM_MEMATTR_WRITE_COMBINING can be undefined for some platforms, use it only if it's defined Modified: head/sys/arm/broadcom/bcm2835/bcm2835_fbd.c Modified: head/sys/arm/broadcom/bcm2835/bcm2835_fbd.c ============================================================================== --- head/sys/arm/broadcom/bcm2835/bcm2835_fbd.c Thu Oct 13 23:29:24 2016 (r307239) +++ head/sys/arm/broadcom/bcm2835/bcm2835_fbd.c Fri Oct 14 00:42:08 2016 (r307240) @@ -120,7 +120,9 @@ bcm_fb_setup_fbd(struct bcmsc_softc *sc) sc->info.fb_width = fb.xres; sc->info.fb_height = fb.yres; sc->info.fb_flags = FB_FLAG_MEMATTR; +#ifdef VM_MEMATTR_WRITE_COMBINING sc->info.fb_memattr = VM_MEMATTR_WRITE_COMBINING; +#endif if (sc->fbswap) { switch (sc->info.fb_bpp) { From owner-svn-src-all@freebsd.org Fri Oct 14 01:23:22 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 4F7CFC10353; Fri, 14 Oct 2016 01:23:22 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 21622B3F; Fri, 14 Oct 2016 01:23:22 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9E1NL3C025754; Fri, 14 Oct 2016 01:23:21 GMT (envelope-from gonzo@FreeBSD.org) Received: (from gonzo@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9E1NLrp025753; Fri, 14 Oct 2016 01:23:21 GMT (envelope-from gonzo@FreeBSD.org) Message-Id: <201610140123.u9E1NLrp025753@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: gonzo set sender to gonzo@FreeBSD.org using -f From: Oleksandr Tymoshenko Date: Fri, 14 Oct 2016 01:23:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307241 - head/sys/arm/broadcom/bcm2835 X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Oct 2016 01:23:22 -0000 Author: gonzo Date: Fri Oct 14 01:23:21 2016 New Revision: 307241 URL: https://svnweb.freebsd.org/changeset/base/307241 Log: Do not set FB_FLAG_MEMATTR if VM_MEMATTR_WRITE_COMBINING is not available Pintyhat to: gonzo Spotted by: jmallett Modified: head/sys/arm/broadcom/bcm2835/bcm2835_fbd.c Modified: head/sys/arm/broadcom/bcm2835/bcm2835_fbd.c ============================================================================== --- head/sys/arm/broadcom/bcm2835/bcm2835_fbd.c Fri Oct 14 00:42:08 2016 (r307240) +++ head/sys/arm/broadcom/bcm2835/bcm2835_fbd.c Fri Oct 14 01:23:21 2016 (r307241) @@ -119,8 +119,8 @@ bcm_fb_setup_fbd(struct bcmsc_softc *sc) sc->info.fb_stride = fb.pitch; sc->info.fb_width = fb.xres; sc->info.fb_height = fb.yres; - sc->info.fb_flags = FB_FLAG_MEMATTR; #ifdef VM_MEMATTR_WRITE_COMBINING + sc->info.fb_flags = FB_FLAG_MEMATTR; sc->info.fb_memattr = VM_MEMATTR_WRITE_COMBINING; #endif From owner-svn-src-all@freebsd.org Fri Oct 14 01:38:30 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 6AC3DC106DE; Fri, 14 Oct 2016 01:38:30 +0000 (UTC) (envelope-from hiren@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 2EEA91B2; Fri, 14 Oct 2016 01:38:30 +0000 (UTC) (envelope-from hiren@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9E1cTx7030090; Fri, 14 Oct 2016 01:38:29 GMT (envelope-from hiren@FreeBSD.org) Received: (from hiren@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9E1cTR5030089; Fri, 14 Oct 2016 01:38:29 GMT (envelope-from hiren@FreeBSD.org) Message-Id: <201610140138.u9E1cTR5030089@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hiren set sender to hiren@FreeBSD.org using -f From: Hiren Panchasara Date: Fri, 14 Oct 2016 01:38:29 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307242 - stable/11/sys/netinet X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Oct 2016 01:38:30 -0000 Author: hiren Date: Fri Oct 14 01:38:29 2016 New Revision: 307242 URL: https://svnweb.freebsd.org/changeset/base/307242 Log: MFC r306464 This adds a sysctl which allows you to disable the TCP hostcache. This is handy during testing of network related changes where cached entries may pollute your results, or during known congestion events where you don't want to unfairly penalize hosts. Prior to r232346 this would have meant you would break any connection with a sub 1500 MTU, as the hostcache was authoritative. All entries as they stand today should simply be used to pre populate values for efficiency. Modified: stable/11/sys/netinet/tcp_hostcache.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/netinet/tcp_hostcache.c ============================================================================== --- stable/11/sys/netinet/tcp_hostcache.c Fri Oct 14 01:23:21 2016 (r307241) +++ stable/11/sys/netinet/tcp_hostcache.c Fri Oct 14 01:38:29 2016 (r307242) @@ -124,6 +124,12 @@ static void tcp_hc_purge(void *); static SYSCTL_NODE(_net_inet_tcp, OID_AUTO, hostcache, CTLFLAG_RW, 0, "TCP Host cache"); +VNET_DEFINE(int, tcp_use_hostcache) = 1; +#define V_tcp_use_hostcache VNET(tcp_use_hostcache) +SYSCTL_INT(_net_inet_tcp_hostcache, OID_AUTO, enable, CTLFLAG_VNET | CTLFLAG_RW, + &VNET_NAME(tcp_use_hostcache), 0, + "Enable the TCP hostcache"); + SYSCTL_UINT(_net_inet_tcp_hostcache, OID_AUTO, cachelimit, CTLFLAG_VNET | CTLFLAG_RDTUN, &VNET_NAME(tcp_hostcache.cache_limit), 0, "Overall entry limit for hostcache"); @@ -276,6 +282,9 @@ tcp_hc_lookup(struct in_conninfo *inc) struct hc_head *hc_head; struct hc_metrics *hc_entry; + if (!V_tcp_use_hostcache) + return NULL; + KASSERT(inc != NULL, ("tcp_hc_lookup with NULL in_conninfo pointer")); /* @@ -332,6 +341,9 @@ tcp_hc_insert(struct in_conninfo *inc) struct hc_head *hc_head; struct hc_metrics *hc_entry; + if (!V_tcp_use_hostcache) + return NULL; + KASSERT(inc != NULL, ("tcp_hc_insert with NULL in_conninfo pointer")); /* @@ -421,6 +433,9 @@ tcp_hc_get(struct in_conninfo *inc, stru { struct hc_metrics *hc_entry; + if (!V_tcp_use_hostcache) + return; + /* * Find the right bucket. */ @@ -452,7 +467,7 @@ tcp_hc_get(struct in_conninfo *inc, stru /* * External function: look up an entry in the hostcache and return the - * discovered path MTU. Returns NULL if no entry is found or value is not + * discovered path MTU. Returns 0 if no entry is found or value is not * set. */ u_long @@ -461,6 +476,9 @@ tcp_hc_getmtu(struct in_conninfo *inc) struct hc_metrics *hc_entry; u_long mtu; + if (!V_tcp_use_hostcache) + return 0; + hc_entry = tcp_hc_lookup(inc); if (hc_entry == NULL) { return 0; @@ -482,6 +500,9 @@ tcp_hc_updatemtu(struct in_conninfo *inc { struct hc_metrics *hc_entry; + if (!V_tcp_use_hostcache) + return; + /* * Find the right bucket. */ @@ -521,6 +542,9 @@ tcp_hc_update(struct in_conninfo *inc, s { struct hc_metrics *hc_entry; + if (!V_tcp_use_hostcache) + return; + hc_entry = tcp_hc_lookup(inc); if (hc_entry == NULL) { hc_entry = tcp_hc_insert(inc); From owner-svn-src-all@freebsd.org Fri Oct 14 01:53:17 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 03AF6C109F1; Fri, 14 Oct 2016 01:53:17 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id C8C98A46; Fri, 14 Oct 2016 01:53:16 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9E1rFjg037508; Fri, 14 Oct 2016 01:53:15 GMT (envelope-from emaste@FreeBSD.org) Received: (from emaste@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9E1rFi6037507; Fri, 14 Oct 2016 01:53:15 GMT (envelope-from emaste@FreeBSD.org) Message-Id: <201610140153.u9E1rFi6037507@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: emaste set sender to emaste@FreeBSD.org using -f From: Ed Maste Date: Fri, 14 Oct 2016 01:53:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307243 - head/lib X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Oct 2016 01:53:17 -0000 Author: emaste Date: Fri Oct 14 01:53:15 2016 New Revision: 307243 URL: https://svnweb.freebsd.org/changeset/base/307243 Log: partially convert lib/Makefile to SUBDIR.${MK_FOO} style Cases other than MK_* (e.g. ${MACHINE_CPUARCH} == "i386") have been left as is. Reviewed by: imp Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D8246 Modified: head/lib/Makefile Modified: head/lib/Makefile ============================================================================== --- head/lib/Makefile Fri Oct 14 01:38:29 2016 (r307242) +++ head/lib/Makefile Fri Oct 14 01:53:15 2016 (r307243) @@ -28,106 +28,69 @@ SUBDIR= ${SUBDIR_BOOTSTRAP} \ libarchive \ libauditd \ libbegemot \ - ${_libblacklist} \ libblocksruntime \ - ${_libbluetooth} \ - ${_libbsnmp} \ libbsdstat \ libbsm \ libbz2 \ libcalendar \ libcam \ libcapsicum \ - ${_libcasper} \ - ${_libcom_err} \ libcompat \ libcrypt \ libdevctl \ - ${_libdevdctl} \ libdevinfo \ libdevstat \ libdwarf \ libedit \ - ${_libefivar} \ - ${_libelftc} \ libevent \ libexecinfo \ libexpat \ libfetch \ libfigpar \ libgeom \ - ${_libgpio} \ - ${_libgssapi} \ - ${_librpcsec_gss} \ - ${_libiconv_modules} \ libifconfig \ libipsec \ libjail \ libkiconv \ libkvm \ - ${_libldns} \ liblzma \ - ${_libmagic} \ libmemstat \ libmd \ - ${_libmilter} \ - ${_libmp} \ libmt \ - ${_libnandfs} \ lib80211 \ libnetbsd \ - ${_libnetgraph} \ - ${_libngatm} \ libnv \ libopenbsd \ libopie \ libpam \ libpcap \ - ${_libpe} \ libpjdlog \ - ${_libpmc} \ ${_libproc} \ libprocstat \ - ${_libradius} \ librpcsvc \ librss \ librt \ ${_librtld_db} \ libsbuf \ - ${_libsdp} \ - ${_libsm} \ libsmb \ - ${_libsmdb} \ - ${_libsmutil} \ libsqlite3 \ libstand \ libstdbuf \ libstdthreads \ libsysdecode \ libtacplus \ - ${_libtelnet} \ - ${_libthr} \ libthread_db \ libucl \ libufs \ libugidfw \ libulog \ - ${_libunbound} \ - ${_libusbhid} \ - ${_libusb} \ libutil \ ${_libvgl} \ - ${_libvmmapi} \ libwrap \ libxo \ liby \ - ${_libypclnt} \ libz \ - ncurses \ - ${_atf} \ - ${_clang} \ - ${_cuse} \ - ${_tests} + ncurses # Inter-library dependencies. When the makefile for a library contains LDADD # libraries, those libraries should be listed as build order dependencies here. @@ -159,70 +122,26 @@ SUBDIR_DEPEND_liblzma= ${_libthr} # NB: keep these sorted by MK_* knobs -.if ${MK_ATM} != "no" -_libngatm= libngatm -.endif - -.if ${MK_BLACKLIST} != "no" -_libblacklist= libblacklist -.endif - -.if ${MK_BLUETOOTH} != "no" -_libbluetooth= libbluetooth -_libsdp= libsdp -.endif - -.if ${MK_BSNMP} != "no" -_libbsnmp= libbsnmp -.endif - -.if ${MK_CASPER} != "no" -_libcasper= libcasper -.endif - -.if ${MK_CLANG} != "no" && !defined(COMPAT_32BIT) && !defined(COMPAT_SOFTFP) -_clang= clang -.endif - -.if ${MK_CUSE} != "no" -_cuse= libcuse -.endif - -.if ${MK_CXX} != "no" -_libdevdctl= libdevdctl -.endif - -.if ${MK_TOOLCHAIN} != "no" -_libelftc= libelftc -_libpe= libpe +SUBDIR.${MK_ATM}+= libngatm +SUBDIR.${MK_BLACKLIST}+=libblacklist +SUBDIR.${MK_BLUETOOTH}+=libbluetooth libsdp +SUBDIR.${MK_BSNMP}+= libbsnmp +SUBDIR.${MK_CASPER}+= libcasper + +.if !defined(COMPAT_32BIT) && !defined(COMPAT_SOFTFP) +SUBDIR.${MK_CLANG}+= clang .endif +SUBDIR.${MK_CUSE}+= libcuse +SUBDIR.${MK_CXX}+= libdevdctl +SUBDIR.${MK_TOOLCHAIN}+=libelftc libpe SUBDIR.${MK_DIALOG}+= libdpv - -.if ${MK_FILE} != "no" -_libmagic= libmagic -.endif - -.if ${MK_GPIO} != "no" -_libgpio= libgpio -.endif - -.if ${MK_GSSAPI} != "no" -_libgssapi= libgssapi -_librpcsec_gss= librpcsec_gss -.endif - -.if ${MK_ICONV} != "no" -_libiconv_modules= libiconv_modules -.endif - -.if ${MK_KERBEROS_SUPPORT} != "no" -_libcom_err= libcom_err -.endif - -.if ${MK_LDNS} != "no" -_libldns= libldns -.endif +SUBDIR.${MK_FILE}+= libmagic +SUBDIR.${MK_GPIO}+= libgpio +SUBDIR.${MK_GSSAPI}+= libgssapi librpcsec_gss +SUBDIR.${MK_ICONV}+= libiconv_modules +SUBDIR.${MK_KERBEROS_SUPPORT}+= libcom_err +SUBDIR.${MK_LDNS}+= libldns # The libraries under libclang_rt can only be built by clang, and only make # sense to build when clang is enabled at all. Furthermore, they can only be @@ -239,25 +158,11 @@ _libcxxrt= libcxxrt _libcplusplus= libc++ .endif -.if ${MK_EFI} != "no" -_libefivar= libefivar -.endif - -.if ${MK_LIBTHR} != "no" -_libthr= libthr -.endif - -.if ${MK_NAND} != "no" -_libnandfs= libnandfs -.endif - -.if ${MK_NETGRAPH} != "no" -_libnetgraph= libnetgraph -.endif - -.if ${MK_NIS} != "no" -_libypclnt= libypclnt -.endif +SUBDIR.${MK_EFI}+= libefivar +SUBDIR.${MK_LIBTHR}+= libthr +SUBDIR.${MK_NAND}+= libnandfs +SUBDIR.${MK_NETGRAPH}+= libnetgraph +SUBDIR.${MK_NIS}+= libypclnt .if ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "amd64" _libvgl= libvgl @@ -266,9 +171,7 @@ _librtld_db= librtld_db .endif .if ${MACHINE_CPUARCH} == "amd64" -.if ${MK_BHYVE} != "no" -_libvmmapi= libvmmapi -.endif +SUBDIR.${MK_BHYVE}+= libvmmapi .endif .if ${MACHINE_CPUARCH} == "mips" @@ -287,44 +190,15 @@ _libproc= libproc _librtld_db= librtld_db .endif -.if ${MK_OPENSSL} != "no" -_libmp= libmp -.endif - -.if ${MK_PMC} != "no" -_libpmc= libpmc -.endif - -.if ${MK_RADIUS_SUPPORT} != "no" -_libradius= libradius -.endif - -.if ${MK_SENDMAIL} != "no" -_libmilter= libmilter -_libsm= libsm -_libsmdb= libsmdb -_libsmutil= libsmutil -.endif - -.if ${MK_TELNET} != "no" -_libtelnet= libtelnet -.endif - -.if ${MK_TESTS_SUPPORT} != "no" -_atf= atf -.endif -.if ${MK_TESTS} != "no" -_tests= tests -.endif - -.if ${MK_UNBOUND} != "no" -_libunbound= libunbound -.endif - -.if ${MK_USB} != "no" -_libusbhid= libusbhid -_libusb= libusb -.endif +SUBDIR.${MK_OPENSSL}+= libmp +SUBDIR.${MK_PMC}+= libpmc +SUBDIR.${MK_RADIUS_SUPPORT}+= libradius +SUBDIR.${MK_SENDMAIL}+= libmilter libsm libsmdb libsmutil +SUBDIR.${MK_TELNET}+= libtelnet +SUBDIR.${MK_TESTS_SUPPORT}+= atf +SUBDIR.${MK_TESTS}+= tests +SUBDIR.${MK_UNBOUND}+= libunbound +SUBDIR.${MK_USB}+= libusbhid libusb .if !make(install) SUBDIR_PARALLEL= From owner-svn-src-all@freebsd.org Fri Oct 14 01:53:42 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C3313C10A43; Fri, 14 Oct 2016 01:53:42 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mail108.syd.optusnet.com.au (mail108.syd.optusnet.com.au [211.29.132.59]) by mx1.freebsd.org (Postfix) with ESMTP id 6F597BBD; Fri, 14 Oct 2016 01:53:41 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from besplex.bde.org (c110-21-100-78.carlnfd1.nsw.optusnet.com.au [110.21.100.78]) by mail108.syd.optusnet.com.au (Postfix) with ESMTPS id DCAF11A1B32; Fri, 14 Oct 2016 12:53:29 +1100 (AEDT) Date: Fri, 14 Oct 2016 12:53:25 +1100 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: Ed Maste cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r307231 - head/lib/libgcc_s In-Reply-To: <201610131918.u9DJI0bX085695@repo.freebsd.org> Message-ID: <20161014113603.F1039@besplex.bde.org> References: <201610131918.u9DJI0bX085695@repo.freebsd.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.1 cv=VIkg5I7X c=1 sm=1 tr=0 a=uGjuzT6u7JdBDS7kH8taPg==:117 a=uGjuzT6u7JdBDS7kH8taPg==:17 a=L9H7d07YOLsA:10 a=9cW_t1CCXrUA:10 a=s5jvgZ67dGcA:10 a=kj9zAlcOel0A:10 a=6I5d2MoRAAAA:8 a=BuHqgrkV7Vy3e-t3-m8A:9 a=CjuIK1q_8ugA:10 a=IjZwj45LgO3ly-622nXo:22 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Oct 2016 01:53:42 -0000 On Thu, 13 Oct 2016, Ed Maste wrote: > Log: > libgcc_s: add libm dependencies from div{d,s,x}c3 > > compiler-rt's complex division support routines contain calls to > compiler builtins such as `__builtin_scalbnl`. Unfortunately Clang > turns these back into a call to `scalbnl`. gcc-4.2 has the same bug. This causes problems in the implementation of libm (and other libraries). The implementation can never (but sometimes does) use __builtin_foo() to get a possibly-better optimized or MD or CFLAGS-dependent version, because when the compiler doesn't have a better version it usually has the bug if of calling the library version which calls just itself when it is misimplemented as the builtin. The __has_builtin() macro is worse than useless for determining if the builtin is better. First, it doesn't really exist so is a dummy version with value 0 on some compilers that have have some better builtins. clang has the opposite problem -- it has squillions of builtins, but most of them just call the standard function. Next, even if the compiler has a real builtin, there is no way except a benchmark to tell if it is worth using. The ones that are always worth using are usually used automatically, but -ffreestanding and -fno-builtin often turns this off. In libm, the most interesting builtin is __builtin_fma[fl](), but this is unusable and not used. fma*() even has a standard macro FP_FAST_FMA[FL] to tell you if it is any good. It is only any good if it is in pure hardware, but libm hard-codes FP_FAST_FMAF = true and has special a not-very-fast implementation for the float case. On x86, it takes later SSE and/or AVX to give fma*() in hardware, and unportable CFLGS to use this hardware, and a compiler that supports this and the __builtin_fma*() spelling to use the instruction (even clang is excessively IEEE/C conformant on x86 -- it never turns x*y+z into fma(x,y,z)). So *fma*() is unusuable for efficiency in practice. It gives extra accuracy in some cases and is specified to do that, but implementing this in software makes using it just a pessimization in most cases. > For now link libm's C version of the required support routines. Even libm doesn't use these in some cases. i386 mostly uses asm versions. Hopefully the rt division routines don't need to be efficient because they are rarely called. > Reviewed by: ed > Sponsored by: The FreeBSD Foundation > Differential Revision: https://reviews.freebsd.org/D8190 > > Modified: > head/lib/libgcc_s/Makefile > > Modified: head/lib/libgcc_s/Makefile > ============================================================================== > --- head/lib/libgcc_s/Makefile Thu Oct 13 18:57:18 2016 (r307230) > +++ head/lib/libgcc_s/Makefile Thu Oct 13 19:18:00 2016 (r307231) > @@ -11,4 +11,22 @@ VERSION_MAP= ${.CURDIR}/Version.map > .include "../libcompiler_rt/Makefile.inc" > .include "../libgcc_eh/Makefile.inc" > > +LIBCSRCDIR= ${SRCTOP}/lib/libc > +LIBMSRCDIR= ${SRCTOP}/lib/msun/src > +CFLAGS+= -I${LIBCSRCDIR}/include -I${LIBCSRCDIR}/${MACHINE_CPUARCH} > +CFLAGS+= -I${LIBMSRCDIR} > +.PATH: ${LIBMSRCDIR} > +SRCS+= s_fabs.c > +SRCS+= s_fabsf.c > +SRCS+= s_fabsl.c The fabs functions cause a smaller set of problems for builtins: - normally they are automatically inlined as a builtin if they are spelled fabs*() - -ffreestanding turns this off, so rt might need to spell them __builtin_fabs*(), but on arches where they aren't real builtins the above is still needed - i386 doesn't bother implementing these in asm since they are usually builtins - the C implementations are good, but are often very badly optimized by compilers, due to problems with compilers not understanding load/store penalties for the current arch or the compile-time arch not matching the runtime arch - the builtins have the same problem with arch mismatches. > +SRCS+= s_fmax.c > +SRCS+= s_fmaxf.c > +SRCS+= s_fmaxl.c These are exotic functions which should rarely be used, especially in portable code that doesn't need to be efficient. They just give subtle behaviour for NaNs. I checked recently that the special builtins for comparing possible NaNs are insignificantly faster than the generic code which starts with isnan(), on x86 (this depends on isnan() being a fast builtin). The implementation of these functions is basically to start with an inline C implementation of isnan(). This is likely to be just slower than the natural max(x, y) code using a comparison, after adding some isnan()s to the latter. Division code should have classified NaNs up front and never use these functions. i386 doesn't bother to optimize these functions. I think it can't do any better than the C code using a builtin relop (x86 has special relops that behave differently for NaNs, but IIRC these functions treat NaNs too unusually for either the normal relop or a special relop to work directly). > +SRCS+= s_logb.c > +SRCS+= s_logbf.c > +SRCS+= s_logbl.c i386 does these in asm. amd64 does only logbl() in asm. These optimizations are barely worth it, though they map directly to an x87 instruction and this instruction is not slow. > +SRCS+= s_scalbn.c > +SRCS+= s_scalbnf.c > +SRCS+= s_scalbnl.c Both i386 and amd64 do all of these in asm. This is a dubious optimization. The C versions are quite complicated and not very good. libm knows this and uses lots of inline expansions of core parts of these functions. This is much faster than calling the x86 MD versions too. > + > .include I think there are still namespace bugs. scalbnl() is in the application namespace for -ffreestanding. There are similar bugs from calling mem*() for struct copying. libcompiler_rt.a now on amd64 now has the following namespace bugs: U compilerrt_abort_impl U fflush U fprintf U mprotect U sysconf U fmaxl U logbl U scalbnl U logbf U scalbnf U logb U scalbn U abort These are bugs since division must be available with -ffreestanding and the freestanding library shouldn't have to reimplement it. Bruce From owner-svn-src-all@freebsd.org Fri Oct 14 02:03:55 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 2A1C1C10EA8; Fri, 14 Oct 2016 02:03:55 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id DB6F21BC; Fri, 14 Oct 2016 02:03:54 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9E23rud041271; Fri, 14 Oct 2016 02:03:53 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9E23rUU041270; Fri, 14 Oct 2016 02:03:53 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610140203.u9E23rUU041270@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Fri, 14 Oct 2016 02:03:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307244 - stable/10/sys/x86/x86 X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Oct 2016 02:03:55 -0000 Author: sephe Date: Fri Oct 14 02:03:53 2016 New Revision: 307244 URL: https://svnweb.freebsd.org/changeset/base/307244 Log: MFC 305722 x86: Use sx lock for interrupt sources. - Certain pic_assign_cpu, e.g. msi_assign_cpu can have quite a long call chain. For msi_assign_cpu, mutex makes complex PCI bridge drivers more tricky, e.g. sleep can note be called, etc, it will be pretty tricky for upcoming Hyper-V PCI bridge driver for PCI pass-through. - It is not used on any hot code path nor non-sleepable context, so sx should have the same effect as mutex. PIC list is still protected by mutex to keep suspend/resume work. Discussed with: jhb Reviewed by: jhb Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7784 Modified: stable/10/sys/x86/x86/intr_machdep.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/x86/x86/intr_machdep.c ============================================================================== --- stable/10/sys/x86/x86/intr_machdep.c Fri Oct 14 01:53:15 2016 (r307243) +++ stable/10/sys/x86/x86/intr_machdep.c Fri Oct 14 02:03:53 2016 (r307244) @@ -46,6 +46,7 @@ #include #include #include +#include #include #include #include @@ -73,7 +74,8 @@ typedef void (*mask_fn)(void *); static int intrcnt_index; static struct intsrc *interrupt_sources[NUM_IO_INTS]; -static struct mtx intr_table_lock; +static struct sx intrsrc_lock; +static struct mtx intrpic_lock; static struct mtx intrcnt_lock; static TAILQ_HEAD(pics_head, pic) pics; @@ -117,14 +119,14 @@ intr_register_pic(struct pic *pic) { int error; - mtx_lock(&intr_table_lock); + mtx_lock(&intrpic_lock); if (intr_pic_registered(pic)) error = EBUSY; else { TAILQ_INSERT_TAIL(&pics, pic, pics); error = 0; } - mtx_unlock(&intr_table_lock); + mtx_unlock(&intrpic_lock); return (error); } @@ -148,16 +150,16 @@ intr_register_source(struct intsrc *isrc vector); if (error) return (error); - mtx_lock(&intr_table_lock); + sx_xlock(&intrsrc_lock); if (interrupt_sources[vector] != NULL) { - mtx_unlock(&intr_table_lock); + sx_xunlock(&intrsrc_lock); intr_event_destroy(isrc->is_event); return (EEXIST); } intrcnt_register(isrc); interrupt_sources[vector] = isrc; isrc->is_handlers = 0; - mtx_unlock(&intr_table_lock); + sx_xunlock(&intrsrc_lock); return (0); } @@ -181,14 +183,14 @@ intr_add_handler(const char *name, int v error = intr_event_add_handler(isrc->is_event, name, filter, handler, arg, intr_priority(flags), flags, cookiep); if (error == 0) { - mtx_lock(&intr_table_lock); + sx_xlock(&intrsrc_lock); intrcnt_updatename(isrc); isrc->is_handlers++; if (isrc->is_handlers == 1) { isrc->is_pic->pic_enable_intr(isrc); isrc->is_pic->pic_enable_source(isrc); } - mtx_unlock(&intr_table_lock); + sx_xunlock(&intrsrc_lock); } return (error); } @@ -202,14 +204,14 @@ intr_remove_handler(void *cookie) isrc = intr_handler_source(cookie); error = intr_event_remove_handler(cookie); if (error == 0) { - mtx_lock(&intr_table_lock); + sx_xlock(&intrsrc_lock); isrc->is_handlers--; if (isrc->is_handlers == 0) { isrc->is_pic->pic_disable_source(isrc, PIC_NO_EOI); isrc->is_pic->pic_disable_intr(isrc); } intrcnt_updatename(isrc); - mtx_unlock(&intr_table_lock); + sx_xunlock(&intrsrc_lock); } return (error); } @@ -283,12 +285,12 @@ intr_resume(bool suspend_cancelled) #ifndef DEV_ATPIC atpic_reset(); #endif - mtx_lock(&intr_table_lock); + mtx_lock(&intrpic_lock); TAILQ_FOREACH(pic, &pics, pics) { if (pic->pic_resume != NULL) pic->pic_resume(pic, suspend_cancelled); } - mtx_unlock(&intr_table_lock); + mtx_unlock(&intrpic_lock); } void @@ -296,12 +298,12 @@ intr_suspend(void) { struct pic *pic; - mtx_lock(&intr_table_lock); + mtx_lock(&intrpic_lock); TAILQ_FOREACH_REVERSE(pic, &pics, pics_head, pics) { if (pic->pic_suspend != NULL) pic->pic_suspend(pic); } - mtx_unlock(&intr_table_lock); + mtx_unlock(&intrpic_lock); } static int @@ -317,9 +319,9 @@ intr_assign_cpu(void *arg, u_char cpu) */ if (assign_cpu && cpu != NOCPU) { isrc = arg; - mtx_lock(&intr_table_lock); + sx_xlock(&intrsrc_lock); error = isrc->is_pic->pic_assign_cpu(isrc, cpu_apic_ids[cpu]); - mtx_unlock(&intr_table_lock); + sx_xunlock(&intrsrc_lock); } else error = 0; return (error); @@ -379,7 +381,8 @@ intr_init(void *dummy __unused) intrcnt_setname("???", 0); intrcnt_index = 1; TAILQ_INIT(&pics); - mtx_init(&intr_table_lock, "intr sources", NULL, MTX_DEF); + mtx_init(&intrpic_lock, "intrpic", NULL, MTX_DEF); + sx_init(&intrsrc_lock, "intrsrc"); mtx_init(&intrcnt_lock, "intrcnt", NULL, MTX_SPIN); } SYSINIT(intr_init, SI_SUB_INTR, SI_ORDER_FIRST, intr_init, NULL); @@ -527,7 +530,7 @@ intr_shuffle_irqs(void *arg __unused) return; /* Round-robin assign a CPU to each enabled source. */ - mtx_lock(&intr_table_lock); + sx_xlock(&intrsrc_lock); assign_cpu = 1; for (i = 0; i < NUM_IO_INTS; i++) { isrc = interrupt_sources[i]; @@ -548,7 +551,7 @@ intr_shuffle_irqs(void *arg __unused) } } - mtx_unlock(&intr_table_lock); + sx_xunlock(&intrsrc_lock); } SYSINIT(intr_shuffle_irqs, SI_SUB_SMP, SI_ORDER_SECOND, intr_shuffle_irqs, NULL); From owner-svn-src-all@freebsd.org Fri Oct 14 02:06:30 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 22534C10F3F; Fri, 14 Oct 2016 02:06:30 +0000 (UTC) (envelope-from carpeddiem@gmail.com) Received: from mail-io0-x243.google.com (mail-io0-x243.google.com [IPv6:2607:f8b0:4001:c06::243]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id E05D53D3; Fri, 14 Oct 2016 02:06:29 +0000 (UTC) (envelope-from carpeddiem@gmail.com) Received: by mail-io0-x243.google.com with SMTP id p26so6004657ioo.2; Thu, 13 Oct 2016 19:06:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=eZ3B0uTAEe3iwyjQ/gV8PiYyQ4D2rOOPw0ZgO5y98jY=; b=uVESCNk/s3O8XVjngI4v8j7w6ilCrqpeUT2W2soMPoCPh/j7cLYecT/l8TgVuDW2yn wg3yZuqoiySzg7NR3yIkLF4iMxbD5Bglu0CCmL8Q81Ph/2ghlrYL5OzVWPAZIrmCDq5M WAxg/XIlGReh6GcXVqQmxBo2jEYx8HLlZLYZ7BwugI+zfX2HloVqHUjAYdbBrC7Y7Ebl +FwrR93ePXDd0x7c+DtnmHt48MMccU8llZIFNn/A5eAxUnMJ97RIu142B+tdLS83TXZI 4uN5Zsp7QpPRoKtM9JZ3OUgF6o+wbkGg8dC8RZHNNmOoTRhCcSieLHIX+3psx5Fri+rg IecA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=eZ3B0uTAEe3iwyjQ/gV8PiYyQ4D2rOOPw0ZgO5y98jY=; b=dYp7dqvjcN5l0N8O5q3lxIpeukF8AQura0cxZ2zbUArsJDxkfSGBTkzAT/UF02a8sy Jf50Cg/eaVfwLV3xn7QMm2jXFgQGt24ob9wfcFLi+t9J6xn3WNhGV0lSFvO5BXHcnHRd M3d6Y6EDLZe/g+nOONZIz1gvy0Lgu4QMeMa9zoiw4Z+40v471fC++eEYUkkGWgjqwJJc YNO0hbzpU9AHPHqhFOzEV5q/ZxoAA/1U09J3GEmSKAoAgIOavdfQ2d0ZYhB2u+Z/+pqQ d6IOArmz15xkEXMtqMyXXzz6qlP9z8sBv4dREm0gbkbYGkMNSf86Vi0o8NSIKEO3BWHD Rozw== X-Gm-Message-State: AA6/9RkZEsD4ytCTBwM6iLCHWBfcVI+jITpxEic8z3C1Fw5yD2s1f//sKYbPSQrqCigwjY+gnnKkWOhGFUByjQ== X-Received: by 10.107.23.197 with SMTP id 188mr8912338iox.162.1476410789183; Thu, 13 Oct 2016 19:06:29 -0700 (PDT) MIME-Version: 1.0 Sender: carpeddiem@gmail.com Received: by 10.107.180.211 with HTTP; Thu, 13 Oct 2016 19:06:08 -0700 (PDT) In-Reply-To: <20161014113603.F1039@besplex.bde.org> References: <201610131918.u9DJI0bX085695@repo.freebsd.org> <20161014113603.F1039@besplex.bde.org> From: Ed Maste Date: Fri, 14 Oct 2016 02:06:08 +0000 X-Google-Sender-Auth: cyw6T_vxGvrmzv8bpfzAI9dhUpw Message-ID: Subject: Re: svn commit: r307231 - head/lib/libgcc_s To: Bruce Evans Cc: "src-committers@freebsd.org" , "svn-src-all@freebsd.org" , "svn-src-head@freebsd.org" Content-Type: text/plain; charset=UTF-8 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Oct 2016 02:06:30 -0000 Hi Bruce, thank you for the detailed response. On 14 October 2016 at 01:53, Bruce Evans wrote: >> compiler-rt's complex division support routines contain calls to >> compiler builtins such as `__builtin_scalbnl`. Unfortunately Clang >> turns these back into a call to `scalbnl`. > > gcc-4.2 has the same bug. Oh, interesting. Do you know off hand if it's resolved in later GCC? It seems particularly unfortunate for the compiler to report (by whatever mechanism) that a builtin exists, and then just turn that builtin into a library call. >> For now link libm's C version of the required support routines. > > Even libm doesn't use these in some cases. i386 mostly uses asm > versions. Hopefully the rt division routines don't need to be efficient > because they are rarely called. Most likely I'll switch to the asm versions across suitable architectures in a subsequent change, mirroring the choices made in libm. I just wanted to get a version in, to enable further testing (ports exp-runs, etc.) of this libunwind / compiler-rt combination. [Details about specific groups of functions omitted -- I'll try to take a look at these later.] > libcompiler_rt.a now on amd64 now has the following namespace bugs: > > U compilerrt_abort_impl > U fflush > U fprintf > U mprotect > U sysconf > U fmaxl > U logbl > U scalbnl > U logbf > U scalbnf > U logb > U scalbn > U abort > > These are bugs since division must be available with -ffreestanding and > the freestanding library shouldn't have to reimplement it. Yes, these libcompiler_rt.a issues seem rather surprising to me, but presumably they aren't causing much of an issue in practice in the static lib. In any case, my hope is that once I try disentangling these libraries I can take a look at these issues across the set of libraries (libcompiler_rt.a aka libgcc.a, libgcc_eh.a, libgcc_s.so). From owner-svn-src-all@freebsd.org Fri Oct 14 02:19:48 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A0DB9C1117F; Fri, 14 Oct 2016 02:19:48 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 62879B67; Fri, 14 Oct 2016 02:19:48 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9E2JlJs045484; Fri, 14 Oct 2016 02:19:47 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9E2Jlxh045480; Fri, 14 Oct 2016 02:19:47 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610140219.u9E2Jlxh045480@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Fri, 14 Oct 2016 02:19:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307245 - stable/10/sys/dev/hyperv/netvsc X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Oct 2016 02:19:48 -0000 Author: sephe Date: Fri Oct 14 02:19:47 2016 New Revision: 307245 URL: https://svnweb.freebsd.org/changeset/base/307245 Log: MFC 305962,305964-305967 305962 hyperv/hn: Don't allow NVS and NDIS version change upon reinitailization NVS and NDIS version change would break too much assumption and static configuration. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7919 305964 hyperv/hn: Save capabilities for later use. And don't allow capability changes during reinitialization, which breaks too much static configuration. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7922 305965 hyperv/hn: Don't allow MTU change, if it is not supported by the NVS. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7923 305966 hyperv/hn: Stringent RSS sysctl checks - Don't change RNDIS RSS configuration for RSS key sysctl, if the interface is not capable of RSS yet. - Don't change RSS indirect table (both cached one and RNDIS RSS configuration), if the interface is not capable of RSS yet. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7924 305967 hyperv/hn: Allow RSS capability flipping upon attach/reinit. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7927 Modified: stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.c stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.c Fri Oct 14 02:03:53 2016 (r307244) +++ stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.c Fri Oct 14 02:19:47 2016 (r307245) @@ -466,9 +466,15 @@ hn_nvs_conf_ndis(struct hn_softc *sc, in /* NOTE: No response. */ error = hn_nvs_req_send(sc, &conf, sizeof(conf)); - if (error) + if (error) { if_printf(sc->hn_ifp, "send nvs ndis conf failed: %d\n", error); - return (error); + return (error); + } + + if (bootverbose) + if_printf(sc->hn_ifp, "nvs ndis conf done\n"); + sc->hn_caps |= HN_CAP_MTU | HN_CAP_VLAN; + return (0); } static int @@ -494,6 +500,22 @@ hn_nvs_init(struct hn_softc *sc) { int i; + if (device_is_attached(sc->hn_dev)) { + /* + * NVS version and NDIS version MUST NOT be changed. + */ + if (bootverbose) { + if_printf(sc->hn_ifp, "reinit NVS version 0x%x, " + "NDIS version %u.%u\n", sc->hn_nvs_ver, + HN_NDIS_VERSION_MAJOR(sc->hn_ndis_ver), + HN_NDIS_VERSION_MINOR(sc->hn_ndis_ver)); + } + return (hn_nvs_doinit(sc, sc->hn_nvs_ver)); + } + + /* + * Find the supported NVS version and set NDIS version accordingly. + */ for (i = 0; i < nitems(hn_nvs_version); ++i) { int error; Modified: stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h Fri Oct 14 02:03:53 2016 (r307244) +++ stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h Fri Oct 14 02:19:47 2016 (r307245) @@ -229,7 +229,8 @@ struct hn_softc { struct vmbus_xact_ctx *hn_xact; uint32_t hn_nvs_ver; - uint32_t hn_flags; + uint32_t hn_caps; /* HN_CAP_ */ + uint32_t hn_flags; /* HN_FLAG_ */ void *hn_rxbuf; uint32_t hn_rxbuf_gpadl; struct hyperv_dma hn_rxbuf_dma; @@ -245,6 +246,18 @@ struct hn_softc { #define HN_FLAG_RXBUF_CONNECTED 0x0001 #define HN_FLAG_CHIM_CONNECTED 0x0002 +#define HN_FLAG_HAS_RSSKEY 0x0004 +#define HN_FLAG_HAS_RSSIND 0x0008 + +#define HN_CAP_VLAN 0x0001 +#define HN_CAP_MTU 0x0002 +#define HN_CAP_IPCS 0x0004 +#define HN_CAP_TCP4CS 0x0008 +#define HN_CAP_TCP6CS 0x0010 +#define HN_CAP_UDP4CS 0x0020 +#define HN_CAP_UDP6CS 0x0040 +#define HN_CAP_TSO4 0x0080 +#define HN_CAP_TSO6 0x0100 /* * Externs Modified: stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Fri Oct 14 02:03:53 2016 (r307244) +++ stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Fri Oct 14 02:19:47 2016 (r307245) @@ -327,6 +327,7 @@ static int hn_rx_stat_ulong_sysctl(SYSCT static int hn_tx_stat_ulong_sysctl(SYSCTL_HANDLER_ARGS); static int hn_tx_conf_int_sysctl(SYSCTL_HANDLER_ARGS); static int hn_ndis_version_sysctl(SYSCTL_HANDLER_ARGS); +static int hn_caps_sysctl(SYSCTL_HANDLER_ARGS); static int hn_rss_key_sysctl(SYSCTL_HANDLER_ARGS); static int hn_rss_ind_sysctl(SYSCTL_HANDLER_ARGS); static int hn_check_iplen(const struct mbuf *, int); @@ -436,6 +437,8 @@ hn_rss_ind_fixup(struct hn_softc *sc, in struct ndis_rssprm_toeplitz *rss = &sc->hn_rss; int i; + KASSERT(nchan > 1, ("invalid # of channels %d", nchan)); + /* * Check indirect table to make sure that all channels in it * can be used. @@ -657,6 +660,9 @@ netvsc_attach(device_t dev) SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "ndis_version", CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, sc, 0, hn_ndis_version_sysctl, "A", "NDIS version"); + SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "caps", + CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, sc, 0, + hn_caps_sysctl, "A", "capabilities"); SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "rss_key", CTLTYPE_OPAQUE | CTLFLAG_RW | CTLFLAG_MPSAFE, sc, 0, hn_rss_key_sysctl, "IU", "RSS key"); @@ -1588,6 +1594,13 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, HN_LOCK(sc); + if ((sc->hn_caps & HN_CAP_MTU) == 0) { + /* Can't change MTU */ + HN_UNLOCK(sc); + error = EOPNOTSUPP; + break; + } + if (ifp->if_mtu == ifr->ifr_mtu) { HN_UNLOCK(sc); break; @@ -2115,6 +2128,30 @@ hn_ndis_version_sysctl(SYSCTL_HANDLER_AR } static int +hn_caps_sysctl(SYSCTL_HANDLER_ARGS) +{ + struct hn_softc *sc = arg1; + char caps_str[128]; + uint32_t caps; + + HN_LOCK(sc); + caps = sc->hn_caps; + HN_UNLOCK(sc); + snprintf(caps_str, sizeof(caps_str), "%b", caps, + "\020" + "\001VLAN" + "\002MTU" + "\003IPCS" + "\004TCP4CS" + "\005TCP6CS" + "\006UDP4CS" + "\007UDP6CS" + "\010TSO4" + "\011TSO6"); + return sysctl_handle_string(oidp, caps_str, sizeof(caps_str), req); +} + +static int hn_rss_key_sysctl(SYSCTL_HANDLER_ARGS) { struct hn_softc *sc = arg1; @@ -2129,8 +2166,14 @@ hn_rss_key_sysctl(SYSCTL_HANDLER_ARGS) error = SYSCTL_IN(req, sc->hn_rss.rss_key, sizeof(sc->hn_rss.rss_key)); if (error) goto back; + sc->hn_flags |= HN_FLAG_HAS_RSSKEY; - error = hn_rss_reconfig(sc); + if (sc->hn_rx_ring_inuse > 1) { + error = hn_rss_reconfig(sc); + } else { + /* Not RSS capable, at least for now; just save the RSS key. */ + error = 0; + } back: HN_UNLOCK(sc); return (error); @@ -2148,9 +2191,19 @@ hn_rss_ind_sysctl(SYSCTL_HANDLER_ARGS) if (error || req->newptr == NULL) goto back; + /* + * Don't allow RSS indirect table change, if this interface is not + * RSS capable currently. + */ + if (sc->hn_rx_ring_inuse == 1) { + error = EOPNOTSUPP; + goto back; + } + error = SYSCTL_IN(req, sc->hn_rss.rss_ind, sizeof(sc->hn_rss.rss_ind)); if (error) goto back; + sc->hn_flags |= HN_FLAG_HAS_RSSIND; hn_rss_ind_fixup(sc, sc->hn_rx_ring_inuse); error = hn_rss_reconfig(sc); @@ -3243,6 +3296,11 @@ hn_synth_attach(struct hn_softc *sc, int { struct ndis_rssprm_toeplitz *rss = &sc->hn_rss; int error, nsubch, nchan, i; + uint32_t old_caps; + + /* Save capabilities for later verification. */ + old_caps = sc->hn_caps; + sc->hn_caps = 0; /* * Attach the primary channel _before_ attaching NVS and RNDIS. @@ -3266,6 +3324,17 @@ hn_synth_attach(struct hn_softc *sc, int return (error); /* + * Make sure capabilities are not changed. + */ + if (device_is_attached(sc->hn_dev) && old_caps != sc->hn_caps) { + if_printf(sc->hn_ifp, "caps mismatch old 0x%08x, new 0x%08x\n", + old_caps, sc->hn_caps); + /* Restore old capabilities and abort. */ + sc->hn_caps = old_caps; + return ENXIO; + } + + /* * Allocate sub-channels for multi-TX/RX rings. * * NOTE: @@ -3288,24 +3357,29 @@ hn_synth_attach(struct hn_softc *sc, int * are allocated. */ - if (!device_is_attached(sc->hn_dev)) { + if ((sc->hn_flags & HN_FLAG_HAS_RSSKEY) == 0) { /* - * Setup default RSS key and indirect table for the - * attach DEVMETHOD. They can be altered later on, - * so don't mess them up once this interface is attached. + * RSS key is not set yet; set it to the default RSS key. */ - if (bootverbose) { - if_printf(sc->hn_ifp, "setup default RSS key and " - "indirect table\n"); - } - - /* Setup default RSS key. */ + if (bootverbose) + if_printf(sc->hn_ifp, "setup default RSS key\n"); memcpy(rss->rss_key, hn_rss_key_default, sizeof(rss->rss_key)); + sc->hn_flags |= HN_FLAG_HAS_RSSKEY; + } - /* Setup default RSS indirect table. */ + if ((sc->hn_flags & HN_FLAG_HAS_RSSIND) == 0) { + /* + * RSS indirect table is not set yet; set it up in round- + * robin fashion. + */ + if (bootverbose) { + if_printf(sc->hn_ifp, "setup default RSS indirect " + "table\n"); + } /* TODO: Take ndis_rss_caps.ndis_nind into account. */ for (i = 0; i < NDIS_HASH_INDCNT; ++i) rss->rss_ind[i] = i % nchan; + sc->hn_flags |= HN_FLAG_HAS_RSSIND; } else { /* * # of usable channels may be changed, so we have to Modified: stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.c Fri Oct 14 02:03:53 2016 (r307244) +++ stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.c Fri Oct 14 02:19:47 2016 (r307245) @@ -801,6 +801,7 @@ static int hn_rndis_conf_offload(struct hn_softc *sc) { struct ndis_offload_params params; + uint32_t caps; size_t paramsz; int error; @@ -817,24 +818,29 @@ hn_rndis_conf_offload(struct hn_softc *s } params.ndis_hdr.ndis_size = paramsz; + caps = HN_CAP_IPCS | HN_CAP_TCP4CS | HN_CAP_TCP6CS; params.ndis_ip4csum = NDIS_OFFLOAD_PARAM_TXRX; params.ndis_tcp4csum = NDIS_OFFLOAD_PARAM_TXRX; params.ndis_tcp6csum = NDIS_OFFLOAD_PARAM_TXRX; if (sc->hn_ndis_ver >= HN_NDIS_VERSION_6_30) { + caps |= HN_CAP_UDP4CS | HN_CAP_UDP6CS; params.ndis_udp4csum = NDIS_OFFLOAD_PARAM_TXRX; params.ndis_udp6csum = NDIS_OFFLOAD_PARAM_TXRX; } + caps |= HN_CAP_TSO4; params.ndis_lsov2_ip4 = NDIS_OFFLOAD_LSOV2_ON; /* XXX ndis_lsov2_ip6 = NDIS_OFFLOAD_LSOV2_ON */ error = hn_rndis_set(sc, OID_TCP_OFFLOAD_PARAMETERS, ¶ms, paramsz); if (error) { if_printf(sc->hn_ifp, "offload config failed: %d\n", error); - } else { - if (bootverbose) - if_printf(sc->hn_ifp, "offload config done\n"); + return (error); } - return (error); + + if (bootverbose) + if_printf(sc->hn_ifp, "offload config done\n"); + sc->hn_caps |= caps; + return (0); } int From owner-svn-src-all@freebsd.org Fri Oct 14 02:27:20 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A7A76C11399; Fri, 14 Oct 2016 02:27:20 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 6A997F5D; Fri, 14 Oct 2016 02:27:20 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9E2RJBX049290; Fri, 14 Oct 2016 02:27:19 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9E2RJ10049288; Fri, 14 Oct 2016 02:27:19 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610140227.u9E2RJ10049288@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Fri, 14 Oct 2016 02:27:19 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307246 - stable/10/sys/dev/hyperv/netvsc X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Oct 2016 02:27:20 -0000 Author: sephe Date: Fri Oct 14 02:27:19 2016 New Revision: 307246 URL: https://svnweb.freebsd.org/changeset/base/307246 Log: MFC 306013,306014 306013 hyperv/hn: Fix ifnet hwassist setup. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7948 306014 hyperv/hn: Let the caller of hn_nvs_doinit() do the error logging. So that NVS version probing failure does not look too scary. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7950 Modified: stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.c stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.c Fri Oct 14 02:19:47 2016 (r307245) +++ stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.c Fri Oct 14 02:27:19 2016 (r307246) @@ -443,8 +443,15 @@ hn_nvs_doinit(struct hn_softc *sc, uint3 vmbus_xact_put(xact); if (status != HN_NVS_STATUS_OK) { - if_printf(sc->hn_ifp, "nvs init failed for ver 0x%x\n", - nvs_ver); + if (bootverbose) { + /* + * Caller may try another NVS version, and will log + * error if there are no more NVS versions to try, + * so don't bark out loud here. + */ + if_printf(sc->hn_ifp, "nvs init failed for ver 0x%x\n", + nvs_ver); + } return (EINVAL); } return (0); @@ -498,7 +505,7 @@ hn_nvs_init_ndis(struct hn_softc *sc) static int hn_nvs_init(struct hn_softc *sc) { - int i; + int i, error; if (device_is_attached(sc->hn_dev)) { /* @@ -510,15 +517,19 @@ hn_nvs_init(struct hn_softc *sc) HN_NDIS_VERSION_MAJOR(sc->hn_ndis_ver), HN_NDIS_VERSION_MINOR(sc->hn_ndis_ver)); } - return (hn_nvs_doinit(sc, sc->hn_nvs_ver)); + + error = hn_nvs_doinit(sc, sc->hn_nvs_ver); + if (error) { + if_printf(sc->hn_ifp, "reinit NVS version 0x%x " + "failed: %d\n", sc->hn_nvs_ver, error); + } + return (error); } /* * Find the supported NVS version and set NDIS version accordingly. */ for (i = 0; i < nitems(hn_nvs_version); ++i) { - int error; - error = hn_nvs_doinit(sc, hn_nvs_version[i]); if (!error) { sc->hn_nvs_ver = hn_nvs_version[i]; Modified: stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Fri Oct 14 02:19:47 2016 (r307245) +++ stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Fri Oct 14 02:27:19 2016 (r307246) @@ -182,14 +182,6 @@ struct hn_txdesc { #define HN_TXD_FLAG_ONLIST 0x1 #define HN_TXD_FLAG_DMAMAP 0x2 -/* - * Only enable UDP checksum offloading when it is on 2012R2 or - * later. UDP checksum offloading doesn't work on earlier - * Windows releases. - */ -#define HN_CSUM_ASSIST_WIN8 (CSUM_IP | CSUM_TCP) -#define HN_CSUM_ASSIST (CSUM_IP | CSUM_UDP | CSUM_TCP) - #define HN_LRO_LENLIM_MULTIRX_DEF (12 * ETHERMTU) #define HN_LRO_LENLIM_DEF (25 * ETHERMTU) /* YYY 2*MTU is a bit rough, but should be good enough. */ @@ -204,6 +196,13 @@ struct hn_txdesc { #define HN_LOCK(sc) sx_xlock(&(sc)->hn_lock) #define HN_UNLOCK(sc) sx_xunlock(&(sc)->hn_lock) +#define HN_CSUM_IP_MASK (CSUM_IP | CSUM_IP_TCP | CSUM_IP_UDP) +#define HN_CSUM_IP6_MASK (CSUM_IP6_TCP | CSUM_IP6_UDP) +#define HN_CSUM_IP_HWASSIST(sc) \ + ((sc)->hn_tx_ring[0].hn_csum_assist & HN_CSUM_IP_MASK) +#define HN_CSUM_IP6_HWASSIST(sc) \ + ((sc)->hn_tx_ring[0].hn_csum_assist & HN_CSUM_IP6_MASK) + /* * Globals */ @@ -328,12 +327,14 @@ static int hn_tx_stat_ulong_sysctl(SYSCT static int hn_tx_conf_int_sysctl(SYSCTL_HANDLER_ARGS); static int hn_ndis_version_sysctl(SYSCTL_HANDLER_ARGS); static int hn_caps_sysctl(SYSCTL_HANDLER_ARGS); +static int hn_hwassist_sysctl(SYSCTL_HANDLER_ARGS); static int hn_rss_key_sysctl(SYSCTL_HANDLER_ARGS); static int hn_rss_ind_sysctl(SYSCTL_HANDLER_ARGS); static int hn_check_iplen(const struct mbuf *, int); static int hn_create_tx_ring(struct hn_softc *, int); static void hn_destroy_tx_ring(struct hn_tx_ring *); static int hn_create_tx_data(struct hn_softc *, int); +static void hn_fixup_tx_data(struct hn_softc *); static void hn_destroy_tx_data(struct hn_softc *); static void hn_start_taskfunc(void *, int); static void hn_start_txeof_taskfunc(void *, int); @@ -648,10 +649,10 @@ netvsc_attach(device_t dev) } #endif - hn_set_chim_size(sc, sc->hn_chim_szmax); - if (hn_tx_chimney_size > 0 && - hn_tx_chimney_size < sc->hn_chim_szmax) - hn_set_chim_size(sc, hn_tx_chimney_size); + /* + * Fixup TX stuffs after synthetic parts are attached. + */ + hn_fixup_tx_data(sc); ctx = device_get_sysctl_ctx(dev); child = SYSCTL_CHILDREN(device_get_sysctl_tree(dev)); @@ -663,6 +664,9 @@ netvsc_attach(device_t dev) SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "caps", CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, sc, 0, hn_caps_sysctl, "A", "capabilities"); + SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "hwassist", + CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, sc, 0, + hn_hwassist_sysctl, "A", "hwassist"); SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "rss_key", CTLTYPE_OPAQUE | CTLFLAG_RW | CTLFLAG_MPSAFE, sc, 0, hn_rss_key_sysctl, "IU", "RSS key"); @@ -697,13 +701,32 @@ netvsc_attach(device_t dev) ifp->if_qflush = hn_xmit_qflush; } - ifp->if_capabilities |= - IFCAP_VLAN_HWTAGGING | IFCAP_VLAN_MTU | IFCAP_HWCSUM | IFCAP_TSO | - IFCAP_LRO; - ifp->if_capenable |= - IFCAP_VLAN_HWTAGGING | IFCAP_VLAN_MTU | IFCAP_HWCSUM | IFCAP_TSO | - IFCAP_LRO; - ifp->if_hwassist = sc->hn_tx_ring[0].hn_csum_assist | CSUM_TSO; + ifp->if_capabilities |= IFCAP_RXCSUM | IFCAP_LRO; +#ifdef foo + /* We can't diff IPv6 packets from IPv4 packets on RX path. */ + ifp->if_capabilities |= IFCAP_RXCSUM_IPV6; +#endif + if (sc->hn_caps & HN_CAP_VLAN) { + /* XXX not sure about VLAN_MTU. */ + ifp->if_capabilities |= IFCAP_VLAN_HWTAGGING | IFCAP_VLAN_MTU; + } + + ifp->if_hwassist = sc->hn_tx_ring[0].hn_csum_assist; + if (ifp->if_hwassist & HN_CSUM_IP_MASK) + ifp->if_capabilities |= IFCAP_TXCSUM; + if (ifp->if_hwassist & HN_CSUM_IP6_MASK) + ifp->if_capabilities |= IFCAP_TXCSUM_IPV6; + if (sc->hn_caps & HN_CAP_TSO4) { + ifp->if_capabilities |= IFCAP_TSO4; + ifp->if_hwassist |= CSUM_IP_TSO; + } + if (sc->hn_caps & HN_CAP_TSO6) { + ifp->if_capabilities |= IFCAP_TSO6; + ifp->if_hwassist |= CSUM_IP6_TSO; + } + + /* Enable all available capabilities by default. */ + ifp->if_capenable = ifp->if_capabilities; tso_maxlen = hn_tso_maxlen; if (tso_maxlen <= 0 || tso_maxlen > IP_MAXPACKET) @@ -1063,14 +1086,19 @@ hn_encap(struct hn_tx_ring *txr, struct } else if (m_head->m_pkthdr.csum_flags & txr->hn_csum_assist) { pi_data = hn_rndis_pktinfo_append(pkt, HN_RNDIS_PKT_LEN, NDIS_TXCSUM_INFO_SIZE, NDIS_PKTINFO_TYPE_CSUM); - *pi_data = NDIS_TXCSUM_INFO_IPV4; - - if (m_head->m_pkthdr.csum_flags & CSUM_IP) - *pi_data |= NDIS_TXCSUM_INFO_IPCS; + if (m_head->m_pkthdr.csum_flags & + (CSUM_IP6_TCP | CSUM_IP6_UDP)) { + *pi_data = NDIS_TXCSUM_INFO_IPV6; + } else { + *pi_data = NDIS_TXCSUM_INFO_IPV4; + if (m_head->m_pkthdr.csum_flags & CSUM_IP) + *pi_data |= NDIS_TXCSUM_INFO_IPCS; + } - if (m_head->m_pkthdr.csum_flags & CSUM_TCP) + if (m_head->m_pkthdr.csum_flags & (CSUM_IP_TCP | CSUM_IP6_TCP)) *pi_data |= NDIS_TXCSUM_INFO_TCPCS; - else if (m_head->m_pkthdr.csum_flags & CSUM_UDP) + else if (m_head->m_pkthdr.csum_flags & + (CSUM_IP_UDP | CSUM_IP6_UDP)) *pi_data |= NDIS_TXCSUM_INFO_UDPCS; } @@ -1685,21 +1713,31 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, case SIOCSIFCAP: HN_LOCK(sc); - mask = ifr->ifr_reqcap ^ ifp->if_capenable; + if (mask & IFCAP_TXCSUM) { ifp->if_capenable ^= IFCAP_TXCSUM; - if (ifp->if_capenable & IFCAP_TXCSUM) { - ifp->if_hwassist |= - sc->hn_tx_ring[0].hn_csum_assist; - } else { - ifp->if_hwassist &= - ~sc->hn_tx_ring[0].hn_csum_assist; - } + if (ifp->if_capenable & IFCAP_TXCSUM) + ifp->if_hwassist |= HN_CSUM_IP_HWASSIST(sc); + else + ifp->if_hwassist &= ~HN_CSUM_IP_HWASSIST(sc); + } + if (mask & IFCAP_TXCSUM_IPV6) { + ifp->if_capenable ^= IFCAP_TXCSUM_IPV6; + if (ifp->if_capenable & IFCAP_TXCSUM_IPV6) + ifp->if_hwassist |= HN_CSUM_IP6_HWASSIST(sc); + else + ifp->if_hwassist &= ~HN_CSUM_IP6_HWASSIST(sc); } + /* TODO: flip RNDIS offload parameters for RXCSUM. */ if (mask & IFCAP_RXCSUM) ifp->if_capenable ^= IFCAP_RXCSUM; +#ifdef foo + /* We can't diff IPv6 packets from IPv4 packets on RX path. */ + if (mask & IFCAP_RXCSUM_IPV6) + ifp->if_capenable ^= IFCAP_RXCSUM_IPV6; +#endif if (mask & IFCAP_LRO) ifp->if_capenable ^= IFCAP_LRO; @@ -1711,7 +1749,6 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, else ifp->if_hwassist &= ~CSUM_IP_TSO; } - if (mask & IFCAP_TSO6) { ifp->if_capenable ^= IFCAP_TSO6; if (ifp->if_capenable & IFCAP_TSO6) @@ -2152,6 +2189,20 @@ hn_caps_sysctl(SYSCTL_HANDLER_ARGS) } static int +hn_hwassist_sysctl(SYSCTL_HANDLER_ARGS) +{ + struct hn_softc *sc = arg1; + char assist_str[128]; + uint32_t hwassist; + + HN_LOCK(sc); + hwassist = sc->hn_ifp->if_hwassist; + HN_UNLOCK(sc); + snprintf(assist_str, sizeof(assist_str), "%b", hwassist, CSUM_BITS); + return sysctl_handle_string(oidp, assist_str, sizeof(assist_str), req); +} + +static int hn_rss_key_sysctl(SYSCTL_HANDLER_ARGS) { struct hn_softc *sc = arg1; @@ -2508,7 +2559,6 @@ hn_create_tx_ring(struct hn_softc *sc, i device_t dev = sc->hn_dev; bus_dma_tag_t parent_dtag; int error, i; - uint32_t version; txr->hn_sc = sc; txr->hn_tx_idx = id; @@ -2547,18 +2597,6 @@ hn_create_tx_ring(struct hn_softc *sc, i } txr->hn_direct_tx_size = hn_direct_tx_size; - version = VMBUS_GET_VERSION(device_get_parent(dev), dev); - if (version >= VMBUS_VERSION_WIN8_1) { - txr->hn_csum_assist = HN_CSUM_ASSIST; - } else { - txr->hn_csum_assist = HN_CSUM_ASSIST_WIN8; - if (id == 0) { - device_printf(dev, "bus version %u.%u, " - "no UDP checksum offloading\n", - VMBUS_VERSION_MAJOR(version), - VMBUS_VERSION_MINOR(version)); - } - } /* * Always schedule transmission instead of trying to do direct @@ -2854,6 +2892,35 @@ hn_set_chim_size(struct hn_softc *sc, in } static void +hn_fixup_tx_data(struct hn_softc *sc) +{ + uint64_t csum_assist; + int i; + + hn_set_chim_size(sc, sc->hn_chim_szmax); + if (hn_tx_chimney_size > 0 && + hn_tx_chimney_size < sc->hn_chim_szmax) + hn_set_chim_size(sc, hn_tx_chimney_size); + + csum_assist = 0; + if (sc->hn_caps & HN_CAP_IPCS) + csum_assist |= CSUM_IP; + if (sc->hn_caps & HN_CAP_TCP4CS) + csum_assist |= CSUM_IP_TCP; + if (sc->hn_caps & HN_CAP_UDP4CS) + csum_assist |= CSUM_IP_UDP; +#ifdef notyet + if (sc->hn_caps & HN_CAP_TCP6CS) + csum_assist |= CSUM_IP6_TCP; + if (sc->hn_caps & HN_CAP_UDP6CS) + csum_assist |= CSUM_IP6_UDP; +#endif + + for (i = 0; i < sc->hn_tx_ring_cnt; ++i) + sc->hn_tx_ring[i].hn_csum_assist = csum_assist; +} + +static void hn_destroy_tx_data(struct hn_softc *sc) { int i; From owner-svn-src-all@freebsd.org Fri Oct 14 02:34:05 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 7B24AC11541; Fri, 14 Oct 2016 02:34:05 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 5639C6A7; Fri, 14 Oct 2016 02:34:05 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9E2Y4mG052951; Fri, 14 Oct 2016 02:34:04 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9E2Y4Na052947; Fri, 14 Oct 2016 02:34:04 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610140234.u9E2Y4Na052947@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Fri, 14 Oct 2016 02:34:04 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307247 - in stable/10/sys/dev/hyperv: include netvsc vmbus X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Oct 2016 02:34:05 -0000 Author: sephe Date: Fri Oct 14 02:34:03 2016 New Revision: 307247 URL: https://svnweb.freebsd.org/changeset/base/307247 Log: MFC 306072-306074,306076 306072 hyperv/vmbus: Allow bufrings preallocation. The assumption that the channel is only opened upon synthetic device attach time no longer holds, e.g. Hyper-V network device MTU changes. We have to allow device drivers to preallocate bufrings, e.g. in attach DEVMETHOD, to prevent bufring allocation failure once the system memory is fragmented after running for a while. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7960 306073 hyperv/hn: Allocate bufrings in attach DEVMETHOD. So that reinitialization, e.g. MTU change, will not fail when the system memory is excessively fragmented. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7961 306074 hyperv/vmbus: Assert that the bufring address is page aligned. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7962 306076 hyperv/hn: Put debug messages under bootverbose While I'm here, strip blank line. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7963 Modified: stable/10/sys/dev/hyperv/include/vmbus.h stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c stable/10/sys/dev/hyperv/vmbus/vmbus_chan.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/hyperv/include/vmbus.h ============================================================================== --- stable/10/sys/dev/hyperv/include/vmbus.h Fri Oct 14 02:27:19 2016 (r307246) +++ stable/10/sys/dev/hyperv/include/vmbus.h Fri Oct 14 02:34:03 2016 (r307247) @@ -109,6 +109,13 @@ struct vmbus_chanpkt_rxbuf { struct vmbus_rxbuf_desc cp_rxbuf[]; } __packed; +struct vmbus_chan_br { + void *cbr; + bus_addr_t cbr_paddr; + int cbr_txsz; + int cbr_rxsz; +}; + struct vmbus_channel; struct hyperv_guid; @@ -123,6 +130,9 @@ vmbus_get_channel(device_t dev) int vmbus_chan_open(struct vmbus_channel *chan, int txbr_size, int rxbr_size, const void *udata, int udlen, vmbus_chan_callback_t cb, void *cbarg); +int vmbus_chan_open_br(struct vmbus_channel *chan, + const struct vmbus_chan_br *cbr, const void *udata, + int udlen, vmbus_chan_callback_t cb, void *cbarg); void vmbus_chan_close(struct vmbus_channel *chan); int vmbus_chan_gpadl_connect(struct vmbus_channel *chan, Modified: stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h Fri Oct 14 02:27:19 2016 (r307246) +++ stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h Fri Oct 14 02:34:03 2016 (r307247) @@ -136,6 +136,9 @@ struct hn_rx_ring { /* Rarely used stuffs */ struct sysctl_oid *hn_rx_sysctl_tree; int hn_rx_flags; + + void *hn_br; /* TX/RX bufring */ + struct hyperv_dma hn_br_dma; } __aligned(CACHE_LINE_SIZE); #define HN_TRUST_HCSUM_IP 0x0001 Modified: stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Fri Oct 14 02:27:19 2016 (r307246) +++ stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Fri Oct 14 02:34:03 2016 (r307247) @@ -2378,7 +2378,8 @@ hn_create_rx_data(struct hn_softc *sc, i lroent_cnt = hn_lro_entry_count; if (lroent_cnt < TCP_LRO_ENTRIES) lroent_cnt = TCP_LRO_ENTRIES; - device_printf(dev, "LRO: entry count %d\n", lroent_cnt); + if (bootverbose) + device_printf(dev, "LRO: entry count %d\n", lroent_cnt); #endif #endif /* INET || INET6 */ @@ -2392,6 +2393,16 @@ hn_create_rx_data(struct hn_softc *sc, i for (i = 0; i < sc->hn_rx_ring_cnt; ++i) { struct hn_rx_ring *rxr = &sc->hn_rx_ring[i]; + rxr->hn_br = hyperv_dmamem_alloc(bus_get_dma_tag(dev), + PAGE_SIZE, 0, + NETVSC_DEVICE_RING_BUFFER_SIZE + + NETVSC_DEVICE_RING_BUFFER_SIZE, + &rxr->hn_br_dma, BUS_DMA_WAITOK); + if (rxr->hn_br == NULL) { + device_printf(dev, "allocate bufring failed\n"); + return (ENOMEM); + } + if (hn_trust_hosttcp) rxr->hn_trust_hcsum |= HN_TRUST_HCSUM_TCP; if (hn_trust_hostudp) @@ -2540,6 +2551,11 @@ hn_destroy_rx_data(struct hn_softc *sc) for (i = 0; i < sc->hn_rx_ring_cnt; ++i) { struct hn_rx_ring *rxr = &sc->hn_rx_ring[i]; + if (rxr->hn_br == NULL) + continue; + hyperv_dmamem_free(&rxr->hn_br_dma, rxr->hn_br); + rxr->hn_br = NULL; + #if defined(INET) || defined(INET6) tcp_lro_free(&rxr->hn_lro); #endif @@ -3145,6 +3161,7 @@ hn_xmit_txeof_taskfunc(void *xtxr, int p static int hn_chan_attach(struct hn_softc *sc, struct vmbus_channel *chan) { + struct vmbus_chan_br cbr; struct hn_rx_ring *rxr; struct hn_tx_ring *txr = NULL; int idx, error; @@ -3183,9 +3200,14 @@ hn_chan_attach(struct hn_softc *sc, stru /* Bind this channel to a proper CPU. */ vmbus_chan_cpu_set(chan, (sc->hn_cpu + idx) % mp_ncpus); - /* Open this channel */ - error = vmbus_chan_open(chan, NETVSC_DEVICE_RING_BUFFER_SIZE, - NETVSC_DEVICE_RING_BUFFER_SIZE, NULL, 0, hn_chan_callback, rxr); + /* + * Open this channel + */ + cbr.cbr = rxr->hn_br; + cbr.cbr_paddr = rxr->hn_br_dma.hv_paddr; + cbr.cbr_txsz = NETVSC_DEVICE_RING_BUFFER_SIZE; + cbr.cbr_rxsz = NETVSC_DEVICE_RING_BUFFER_SIZE; + error = vmbus_chan_open_br(chan, &cbr, NULL, 0, hn_chan_callback, rxr); if (error) { if_printf(sc->hn_ifp, "open chan%u failed: %d\n", vmbus_chan_id(chan), error); @@ -3328,8 +3350,10 @@ hn_synth_alloc_subchans(struct hn_softc *nsubch = 0; return (0); } - if_printf(sc->hn_ifp, "RX rings offered %u, requested %d\n", - rxr_cnt, nchan); + if (bootverbose) { + if_printf(sc->hn_ifp, "RX rings offered %u, requested %d\n", + rxr_cnt, nchan); + } if (nchan > rxr_cnt) nchan = rxr_cnt; @@ -3338,7 +3362,7 @@ hn_synth_alloc_subchans(struct hn_softc *nsubch = 0; return (0); } - + /* * Allocate sub-channels from NVS. */ Modified: stable/10/sys/dev/hyperv/vmbus/vmbus_chan.c ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/vmbus_chan.c Fri Oct 14 02:27:19 2016 (r307246) +++ stable/10/sys/dev/hyperv/vmbus/vmbus_chan.c Fri Oct 14 02:34:03 2016 (r307247) @@ -196,13 +196,45 @@ int vmbus_chan_open(struct vmbus_channel *chan, int txbr_size, int rxbr_size, const void *udata, int udlen, vmbus_chan_callback_t cb, void *cbarg) { + struct vmbus_chan_br cbr; + int error; + + /* + * Allocate the TX+RX bufrings. + */ + KASSERT(chan->ch_bufring == NULL, ("bufrings are allocated")); + chan->ch_bufring = hyperv_dmamem_alloc(bus_get_dma_tag(chan->ch_dev), + PAGE_SIZE, 0, txbr_size + rxbr_size, &chan->ch_bufring_dma, + BUS_DMA_WAITOK); + if (chan->ch_bufring == NULL) { + device_printf(chan->ch_dev, "bufring allocation failed\n"); + return (ENOMEM); + } + + cbr.cbr = chan->ch_bufring; + cbr.cbr_paddr = chan->ch_bufring_dma.hv_paddr; + cbr.cbr_txsz = txbr_size; + cbr.cbr_rxsz = rxbr_size; + + error = vmbus_chan_open_br(chan, &cbr, udata, udlen, cb, cbarg); + if (error) { + hyperv_dmamem_free(&chan->ch_bufring_dma, chan->ch_bufring); + chan->ch_bufring = NULL; + } + return (error); +} + +int +vmbus_chan_open_br(struct vmbus_channel *chan, const struct vmbus_chan_br *cbr, + const void *udata, int udlen, vmbus_chan_callback_t cb, void *cbarg) +{ struct vmbus_softc *sc = chan->ch_vmbus; const struct vmbus_chanmsg_chopen_resp *resp; const struct vmbus_message *msg; struct vmbus_chanmsg_chopen *req; struct vmbus_msghc *mh; uint32_t status; - int error; + int error, txbr_size, rxbr_size; uint8_t *br; if (udlen > VMBUS_CHANMSG_CHOPEN_UDATA_SIZE) { @@ -210,10 +242,21 @@ vmbus_chan_open(struct vmbus_channel *ch "invalid udata len %d for chan%u\n", udlen, chan->ch_id); return EINVAL; } + + br = cbr->cbr; + txbr_size = cbr->cbr_txsz; + rxbr_size = cbr->cbr_rxsz; KASSERT((txbr_size & PAGE_MASK) == 0, ("send bufring size is not multiple page")); KASSERT((rxbr_size & PAGE_MASK) == 0, ("recv bufring size is not multiple page")); + KASSERT((cbr->cbr_paddr & PAGE_MASK) == 0, + ("bufring is not page aligned")); + + /* + * Zero out the TX/RX bufrings, in case that they were used before. + */ + memset(br, 0, txbr_size + rxbr_size); if (atomic_testandset_int(&chan->ch_stflags, VMBUS_CHAN_ST_OPENED_SHIFT)) @@ -230,20 +273,6 @@ vmbus_chan_open(struct vmbus_channel *ch else TASK_INIT(&chan->ch_task, 0, vmbus_chan_task_nobatch, chan); - /* - * Allocate the TX+RX bufrings. - * XXX should use ch_dev dtag - */ - br = hyperv_dmamem_alloc(bus_get_dma_tag(sc->vmbus_dev), - PAGE_SIZE, 0, txbr_size + rxbr_size, &chan->ch_bufring_dma, - BUS_DMA_WAITOK | BUS_DMA_ZERO); - if (br == NULL) { - device_printf(sc->vmbus_dev, "bufring allocation failed\n"); - error = ENOMEM; - goto failed; - } - chan->ch_bufring = br; - /* TX bufring comes first */ vmbus_txbr_setup(&chan->ch_txbr, br, txbr_size); /* RX bufring immediately follows TX bufring */ @@ -255,7 +284,7 @@ vmbus_chan_open(struct vmbus_channel *ch /* * Connect the bufrings, both RX and TX, to this channel. */ - error = vmbus_chan_gpadl_connect(chan, chan->ch_bufring_dma.hv_paddr, + error = vmbus_chan_gpadl_connect(chan, cbr->cbr_paddr, txbr_size + rxbr_size, &chan->ch_bufring_gpadl); if (error) { device_printf(sc->vmbus_dev, @@ -316,10 +345,6 @@ failed: vmbus_chan_gpadl_disconnect(chan, chan->ch_bufring_gpadl); chan->ch_bufring_gpadl = 0; } - if (chan->ch_bufring != NULL) { - hyperv_dmamem_free(&chan->ch_bufring_dma, chan->ch_bufring); - chan->ch_bufring = NULL; - } atomic_clear_int(&chan->ch_stflags, VMBUS_CHAN_ST_OPENED); return error; } From owner-svn-src-all@freebsd.org Fri Oct 14 02:36:52 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E4842C115BA; Fri, 14 Oct 2016 02:36:52 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id B5F158A0; Fri, 14 Oct 2016 02:36:52 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9E2ap1l053121; Fri, 14 Oct 2016 02:36:51 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9E2apq2053120; Fri, 14 Oct 2016 02:36:51 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610140236.u9E2apq2053120@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Fri, 14 Oct 2016 02:36:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307248 - stable/10/sys/dev/pci X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Oct 2016 02:36:53 -0000 Author: sephe Date: Fri Oct 14 02:36:51 2016 New Revision: 307248 URL: https://svnweb.freebsd.org/changeset/base/307248 Log: MFC 306359 pci: Clear the MEM/PORT_EN bit when updating PCI BAR It's unsafe to update the BAR when the related EN bit is set. Submitted by: Dexuan Cui Reviewed by: jhb Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7914 Modified: stable/10/sys/dev/pci/pci.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/pci/pci.c ============================================================================== --- stable/10/sys/dev/pci/pci.c Fri Oct 14 02:34:03 2016 (r307247) +++ stable/10/sys/dev/pci/pci.c Fri Oct 14 02:36:51 2016 (r307248) @@ -4576,6 +4576,7 @@ pci_reserve_map(device_t dev, device_t c struct resource_list *rl = &dinfo->resources; struct resource *res; struct pci_map *pm; + uint16_t cmd; pci_addr_t map, testval; int mapsize; @@ -4660,8 +4661,17 @@ pci_reserve_map(device_t dev, device_t c device_printf(child, "Lazy allocation of %#lx bytes rid %#x type %d at %#lx\n", count, *rid, type, rman_get_start(res)); + + /* Disable decoding via the CMD register before updating the BAR */ + cmd = pci_read_config(child, PCIR_COMMAND, 2); + pci_write_config(child, PCIR_COMMAND, + cmd & ~(PCI_BAR_MEM(map) ? PCIM_CMD_MEMEN : PCIM_CMD_PORTEN), 2); + map = rman_get_start(res); pci_write_bar(child, pm, map); + + /* Restore the original value of the CMD register */ + pci_write_config(child, PCIR_COMMAND, cmd, 2); out: return (res); } From owner-svn-src-all@freebsd.org Fri Oct 14 02:42:10 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 99C1BC11766; Fri, 14 Oct 2016 02:42:10 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 3C92CB85; Fri, 14 Oct 2016 02:42:10 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9E2g97K055495; Fri, 14 Oct 2016 02:42:09 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9E2g8Ag054689; Fri, 14 Oct 2016 02:42:08 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610140242.u9E2g8Ag054689@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Fri, 14 Oct 2016 02:42:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307249 - in stable/10/sys/dev/hyperv: include vmbus X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Oct 2016 02:42:10 -0000 Author: sephe Date: Fri Oct 14 02:42:08 2016 New Revision: 307249 URL: https://svnweb.freebsd.org/changeset/base/307249 Log: MFC 306360,306387,306389 306360 hyperv/vmbus: Add dynamic device add and remove support Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8008 306387 hyperv/vmbus: Add functions to test RX/TX bufring emptiness Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8044 306389 hyperv/vmbus: Add function to drain channel interrupt task. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8045 Modified: stable/10/sys/dev/hyperv/include/vmbus.h stable/10/sys/dev/hyperv/vmbus/vmbus.c stable/10/sys/dev/hyperv/vmbus/vmbus_brvar.h stable/10/sys/dev/hyperv/vmbus/vmbus_chan.c stable/10/sys/dev/hyperv/vmbus/vmbus_chanvar.h stable/10/sys/dev/hyperv/vmbus/vmbus_var.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/hyperv/include/vmbus.h ============================================================================== --- stable/10/sys/dev/hyperv/include/vmbus.h Fri Oct 14 02:36:51 2016 (r307248) +++ stable/10/sys/dev/hyperv/include/vmbus.h Fri Oct 14 02:42:08 2016 (r307249) @@ -134,6 +134,7 @@ int vmbus_chan_open_br(struct vmbus_cha const struct vmbus_chan_br *cbr, const void *udata, int udlen, vmbus_chan_callback_t cb, void *cbarg); void vmbus_chan_close(struct vmbus_channel *chan); +void vmbus_chan_intr_drain(struct vmbus_channel *chan); int vmbus_chan_gpadl_connect(struct vmbus_channel *chan, bus_addr_t paddr, int size, uint32_t *gpadl); @@ -174,5 +175,7 @@ const struct hyperv_guid * vmbus_chan_guid_inst(const struct vmbus_channel *chan); int vmbus_chan_prplist_nelem(int br_size, int prpcnt_max, int dlen_max); +bool vmbus_chan_rx_empty(const struct vmbus_channel *chan); +bool vmbus_chan_tx_empty(const struct vmbus_channel *chan); #endif /* !_VMBUS_H_ */ Modified: stable/10/sys/dev/hyperv/vmbus/vmbus.c ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/vmbus.c Fri Oct 14 02:36:51 2016 (r307248) +++ stable/10/sys/dev/hyperv/vmbus/vmbus.c Fri Oct 14 02:42:08 2016 (r307249) @@ -85,9 +85,7 @@ static int vmbus_connect(struct vmbus_ static int vmbus_req_channels(struct vmbus_softc *sc); static void vmbus_disconnect(struct vmbus_softc *); static int vmbus_scan(struct vmbus_softc *); -static void vmbus_scan_wait(struct vmbus_softc *); -static void vmbus_scan_newchan(struct vmbus_softc *); -static void vmbus_scan_newdev(struct vmbus_softc *); +static void vmbus_scan_teardown(struct vmbus_softc *); static void vmbus_scan_done(struct vmbus_softc *, const struct vmbus_message *); static void vmbus_chanmsg_handle(struct vmbus_softc *, @@ -395,50 +393,22 @@ vmbus_req_channels(struct vmbus_softc *s } static void -vmbus_scan_newchan(struct vmbus_softc *sc) +vmbus_scan_done_task(void *xsc, int pending __unused) { - mtx_lock(&sc->vmbus_scan_lock); - if ((sc->vmbus_scan_chcnt & VMBUS_SCAN_CHCNT_DONE) == 0) - sc->vmbus_scan_chcnt++; - mtx_unlock(&sc->vmbus_scan_lock); + struct vmbus_softc *sc = xsc; + + mtx_lock(&Giant); + sc->vmbus_scandone = true; + mtx_unlock(&Giant); + wakeup(&sc->vmbus_scandone); } static void vmbus_scan_done(struct vmbus_softc *sc, const struct vmbus_message *msg __unused) { - mtx_lock(&sc->vmbus_scan_lock); - sc->vmbus_scan_chcnt |= VMBUS_SCAN_CHCNT_DONE; - mtx_unlock(&sc->vmbus_scan_lock); - wakeup(&sc->vmbus_scan_chcnt); -} - -static void -vmbus_scan_newdev(struct vmbus_softc *sc) -{ - mtx_lock(&sc->vmbus_scan_lock); - sc->vmbus_scan_devcnt++; - mtx_unlock(&sc->vmbus_scan_lock); - wakeup(&sc->vmbus_scan_devcnt); -} - -static void -vmbus_scan_wait(struct vmbus_softc *sc) -{ - uint32_t chancnt; - - mtx_lock(&sc->vmbus_scan_lock); - while ((sc->vmbus_scan_chcnt & VMBUS_SCAN_CHCNT_DONE) == 0) { - mtx_sleep(&sc->vmbus_scan_chcnt, &sc->vmbus_scan_lock, 0, - "waitch", 0); - } - chancnt = sc->vmbus_scan_chcnt & ~VMBUS_SCAN_CHCNT_DONE; - while (sc->vmbus_scan_devcnt != chancnt) { - mtx_sleep(&sc->vmbus_scan_devcnt, &sc->vmbus_scan_lock, 0, - "waitdev", 0); - } - mtx_unlock(&sc->vmbus_scan_lock); + taskqueue_enqueue(sc->vmbus_devtq, &sc->vmbus_scandone_task); } static int @@ -447,31 +417,71 @@ vmbus_scan(struct vmbus_softc *sc) int error; /* + * Identify, probe and attach for non-channel devices. + */ + bus_generic_probe(sc->vmbus_dev); + bus_generic_attach(sc->vmbus_dev); + + /* + * This taskqueue serializes vmbus devices' attach and detach + * for channel offer and rescind messages. + */ + sc->vmbus_devtq = taskqueue_create("vmbus dev", M_WAITOK, + taskqueue_thread_enqueue, &sc->vmbus_devtq); + taskqueue_start_threads(&sc->vmbus_devtq, 1, PI_NET, "vmbusdev"); + TASK_INIT(&sc->vmbus_scandone_task, 0, vmbus_scan_done_task, sc); + + /* + * This taskqueue handles sub-channel detach, so that vmbus + * device's detach running in vmbus_devtq can drain its sub- + * channels. + */ + sc->vmbus_subchtq = taskqueue_create("vmbus subch", M_WAITOK, + taskqueue_thread_enqueue, &sc->vmbus_subchtq); + taskqueue_start_threads(&sc->vmbus_subchtq, 1, PI_NET, "vmbussch"); + + /* * Start vmbus scanning. */ error = vmbus_req_channels(sc); if (error) { device_printf(sc->vmbus_dev, "channel request failed: %d\n", error); - return error; + return (error); } /* - * Wait for all devices are added to vmbus. + * Wait for all vmbus devices from the initial channel offers to be + * attached. */ - vmbus_scan_wait(sc); - - /* - * Identify, probe and attach. - */ - bus_generic_probe(sc->vmbus_dev); - bus_generic_attach(sc->vmbus_dev); + GIANT_REQUIRED; + while (!sc->vmbus_scandone) + mtx_sleep(&sc->vmbus_scandone, &Giant, 0, "vmbusdev", 0); if (bootverbose) { device_printf(sc->vmbus_dev, "device scan, probe and attach " "done\n"); } - return 0; + return (0); +} + +static void +vmbus_scan_teardown(struct vmbus_softc *sc) +{ + + GIANT_REQUIRED; + if (sc->vmbus_devtq != NULL) { + mtx_unlock(&Giant); + taskqueue_free(sc->vmbus_devtq); + mtx_lock(&Giant); + sc->vmbus_devtq = NULL; + } + if (sc->vmbus_subchtq != NULL) { + mtx_unlock(&Giant); + taskqueue_free(sc->vmbus_subchtq); + mtx_lock(&Giant); + sc->vmbus_subchtq = NULL; + } } static void @@ -1000,45 +1010,35 @@ vmbus_add_child(struct vmbus_channel *ch { struct vmbus_softc *sc = chan->ch_vmbus; device_t parent = sc->vmbus_dev; - int error = 0; - /* New channel has been offered */ - vmbus_scan_newchan(sc); + mtx_lock(&Giant); chan->ch_dev = device_add_child(parent, NULL, -1); if (chan->ch_dev == NULL) { + mtx_unlock(&Giant); device_printf(parent, "device_add_child for chan%u failed\n", chan->ch_id); - error = ENXIO; - goto done; + return (ENXIO); } device_set_ivars(chan->ch_dev, chan); + device_probe_and_attach(chan->ch_dev); -done: - /* New device has been/should be added to vmbus. */ - vmbus_scan_newdev(sc); - return error; + mtx_unlock(&Giant); + return (0); } int vmbus_delete_child(struct vmbus_channel *chan) { - int error; - - if (chan->ch_dev == NULL) { - /* Failed to add a device. */ - return 0; - } + int error = 0; - /* - * XXXKYS: Ensure that this is the opposite of - * device_add_child() - */ mtx_lock(&Giant); - error = device_delete_child(chan->ch_vmbus->vmbus_dev, chan->ch_dev); + if (chan->ch_dev != NULL) { + error = device_delete_child(chan->ch_vmbus->vmbus_dev, + chan->ch_dev); + } mtx_unlock(&Giant); - - return error; + return (error); } static int @@ -1110,10 +1110,11 @@ vmbus_doattach(struct vmbus_softc *sc) return (0); sc->vmbus_flags |= VMBUS_FLAG_ATTACHED; - mtx_init(&sc->vmbus_scan_lock, "vmbus scan", NULL, MTX_DEF); sc->vmbus_gpadl = VMBUS_GPADL_START; mtx_init(&sc->vmbus_prichan_lock, "vmbus prichan", NULL, MTX_DEF); TAILQ_INIT(&sc->vmbus_prichans); + mtx_init(&sc->vmbus_chan_lock, "vmbus channel", NULL, MTX_DEF); + TAILQ_INIT(&sc->vmbus_chans); sc->vmbus_chmap = malloc( sizeof(struct vmbus_channel *) * VMBUS_CHAN_MAX, M_DEVBUF, M_WAITOK | M_ZERO); @@ -1177,6 +1178,7 @@ vmbus_doattach(struct vmbus_softc *sc) return (ret); cleanup: + vmbus_scan_teardown(sc); vmbus_intr_teardown(sc); vmbus_dma_free(sc); if (sc->vmbus_xc != NULL) { @@ -1184,8 +1186,8 @@ cleanup: sc->vmbus_xc = NULL; } free(sc->vmbus_chmap, M_DEVBUF); - mtx_destroy(&sc->vmbus_scan_lock); mtx_destroy(&sc->vmbus_prichan_lock); + mtx_destroy(&sc->vmbus_chan_lock); return (ret); } @@ -1225,8 +1227,11 @@ vmbus_detach(device_t dev) { struct vmbus_softc *sc = device_get_softc(dev); + bus_generic_detach(dev); vmbus_chan_destroy_all(sc); + vmbus_scan_teardown(sc); + vmbus_disconnect(sc); if (sc->vmbus_flags & VMBUS_FLAG_SYNIC) { @@ -1243,8 +1248,8 @@ vmbus_detach(device_t dev) } free(sc->vmbus_chmap, M_DEVBUF); - mtx_destroy(&sc->vmbus_scan_lock); mtx_destroy(&sc->vmbus_prichan_lock); + mtx_destroy(&sc->vmbus_chan_lock); return (0); } Modified: stable/10/sys/dev/hyperv/vmbus/vmbus_brvar.h ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/vmbus_brvar.h Fri Oct 14 02:36:51 2016 (r307248) +++ stable/10/sys/dev/hyperv/vmbus/vmbus_brvar.h Fri Oct 14 02:42:08 2016 (r307249) @@ -83,6 +83,20 @@ vmbus_txbr_maxpktsz(const struct vmbus_t return (tbr->txbr_dsize - sizeof(uint64_t) - 1); } +static __inline bool +vmbus_txbr_empty(const struct vmbus_txbr *tbr) +{ + + return (tbr->txbr_windex == tbr->txbr_rindex ? true : false); +} + +static __inline bool +vmbus_rxbr_empty(const struct vmbus_rxbr *rbr) +{ + + return (rbr->rxbr_windex == rbr->rxbr_rindex ? true : false); +} + static __inline int vmbus_br_nelem(int br_size, int elem_size) { Modified: stable/10/sys/dev/hyperv/vmbus/vmbus_chan.c ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/vmbus_chan.c Fri Oct 14 02:36:51 2016 (r307248) +++ stable/10/sys/dev/hyperv/vmbus/vmbus_chan.c Fri Oct 14 02:42:08 2016 (r307249) @@ -59,10 +59,30 @@ static struct vmbus_channel *vmbus_chan_ static void vmbus_chan_free(struct vmbus_channel *); static int vmbus_chan_add(struct vmbus_channel *); static void vmbus_chan_cpu_default(struct vmbus_channel *); +static int vmbus_chan_release(struct vmbus_channel *); +static void vmbus_chan_set_chmap(struct vmbus_channel *); +static void vmbus_chan_clear_chmap(struct vmbus_channel *); + +static void vmbus_chan_ins_prilist(struct vmbus_softc *, + struct vmbus_channel *); +static void vmbus_chan_rem_prilist(struct vmbus_softc *, + struct vmbus_channel *); +static void vmbus_chan_ins_list(struct vmbus_softc *, + struct vmbus_channel *); +static void vmbus_chan_rem_list(struct vmbus_softc *, + struct vmbus_channel *); +static void vmbus_chan_ins_sublist(struct vmbus_channel *, + struct vmbus_channel *); +static void vmbus_chan_rem_sublist(struct vmbus_channel *, + struct vmbus_channel *); static void vmbus_chan_task(void *, int); static void vmbus_chan_task_nobatch(void *, int); -static void vmbus_chan_detach_task(void *, int); +static void vmbus_chan_clrchmap_task(void *, int); +static void vmbus_prichan_attach_task(void *, int); +static void vmbus_subchan_attach_task(void *, int); +static void vmbus_prichan_detach_task(void *, int); +static void vmbus_subchan_detach_task(void *, int); static void vmbus_chan_msgproc_choffer(struct vmbus_softc *, const struct vmbus_message *); @@ -96,6 +116,83 @@ vmbus_chan_signal_tx(const struct vmbus_ hypercall_signal_event(chan->ch_monprm_dma.hv_paddr); } +static void +vmbus_chan_ins_prilist(struct vmbus_softc *sc, struct vmbus_channel *chan) +{ + + mtx_assert(&sc->vmbus_prichan_lock, MA_OWNED); + if (atomic_testandset_int(&chan->ch_stflags, + VMBUS_CHAN_ST_ONPRIL_SHIFT)) + panic("channel is already on the prilist"); + TAILQ_INSERT_TAIL(&sc->vmbus_prichans, chan, ch_prilink); +} + +static void +vmbus_chan_rem_prilist(struct vmbus_softc *sc, struct vmbus_channel *chan) +{ + + mtx_assert(&sc->vmbus_prichan_lock, MA_OWNED); + if (atomic_testandclear_int(&chan->ch_stflags, + VMBUS_CHAN_ST_ONPRIL_SHIFT) == 0) + panic("channel is not on the prilist"); + TAILQ_REMOVE(&sc->vmbus_prichans, chan, ch_prilink); +} + +static void +vmbus_chan_ins_sublist(struct vmbus_channel *prichan, + struct vmbus_channel *chan) +{ + + mtx_assert(&prichan->ch_subchan_lock, MA_OWNED); + + if (atomic_testandset_int(&chan->ch_stflags, + VMBUS_CHAN_ST_ONSUBL_SHIFT)) + panic("channel is already on the sublist"); + TAILQ_INSERT_TAIL(&prichan->ch_subchans, chan, ch_sublink); + + /* Bump sub-channel count. */ + prichan->ch_subchan_cnt++; +} + +static void +vmbus_chan_rem_sublist(struct vmbus_channel *prichan, + struct vmbus_channel *chan) +{ + + mtx_assert(&prichan->ch_subchan_lock, MA_OWNED); + + KASSERT(prichan->ch_subchan_cnt > 0, + ("invalid subchan_cnt %d", prichan->ch_subchan_cnt)); + prichan->ch_subchan_cnt--; + + if (atomic_testandclear_int(&chan->ch_stflags, + VMBUS_CHAN_ST_ONSUBL_SHIFT) == 0) + panic("channel is not on the sublist"); + TAILQ_REMOVE(&prichan->ch_subchans, chan, ch_sublink); +} + +static void +vmbus_chan_ins_list(struct vmbus_softc *sc, struct vmbus_channel *chan) +{ + + mtx_assert(&sc->vmbus_chan_lock, MA_OWNED); + if (atomic_testandset_int(&chan->ch_stflags, + VMBUS_CHAN_ST_ONLIST_SHIFT)) + panic("channel is already on the list"); + TAILQ_INSERT_TAIL(&sc->vmbus_chans, chan, ch_link); +} + +static void +vmbus_chan_rem_list(struct vmbus_softc *sc, struct vmbus_channel *chan) +{ + + mtx_assert(&sc->vmbus_chan_lock, MA_OWNED); + if (atomic_testandclear_int(&chan->ch_stflags, + VMBUS_CHAN_ST_ONLIST_SHIFT) == 0) + panic("channel is not on the list"); + TAILQ_REMOVE(&sc->vmbus_chans, chan, ch_link); +} + static int vmbus_chan_sysctl_mnf(SYSCTL_HANDLER_ARGS) { @@ -235,6 +332,7 @@ vmbus_chan_open_br(struct vmbus_channel struct vmbus_msghc *mh; uint32_t status; int error, txbr_size, rxbr_size; + task_fn_t *task_fn; uint8_t *br; if (udlen > VMBUS_CHANMSG_CHOPEN_UDATA_SIZE) { @@ -269,9 +367,10 @@ vmbus_chan_open_br(struct vmbus_channel chan->ch_tq = VMBUS_PCPU_GET(chan->ch_vmbus, event_tq, chan->ch_cpuid); if (chan->ch_flags & VMBUS_CHAN_FLAG_BATCHREAD) - TASK_INIT(&chan->ch_task, 0, vmbus_chan_task, chan); + task_fn = vmbus_chan_task; else - TASK_INIT(&chan->ch_task, 0, vmbus_chan_task_nobatch, chan); + task_fn = vmbus_chan_task_nobatch; + TASK_INIT(&chan->ch_task, 0, task_fn, chan); /* TX bufring comes first */ vmbus_txbr_setup(&chan->ch_txbr, br, txbr_size); @@ -293,6 +392,12 @@ vmbus_chan_open_br(struct vmbus_channel } /* + * Install this channel, before it is opened, but after everything + * else has been setup. + */ + vmbus_chan_set_chmap(chan); + + /* * Open channel w/ the bufring GPADL on the target CPU. */ mh = vmbus_msghc_get(sc, sizeof(*req)); @@ -341,6 +446,7 @@ vmbus_chan_open_br(struct vmbus_channel error = ENXIO; failed: + vmbus_chan_clear_chmap(chan); if (chan->ch_bufring_gpadl) { vmbus_chan_gpadl_disconnect(chan, chan->ch_bufring_gpadl); chan->ch_bufring_gpadl = 0; @@ -517,12 +623,38 @@ vmbus_chan_gpadl_disconnect(struct vmbus } static void +vmbus_chan_clrchmap_task(void *xchan, int pending __unused) +{ + struct vmbus_channel *chan = xchan; + + critical_enter(); + chan->ch_vmbus->vmbus_chmap[chan->ch_id] = NULL; + critical_exit(); +} + +static void +vmbus_chan_clear_chmap(struct vmbus_channel *chan) +{ + struct task chmap_task; + + TASK_INIT(&chmap_task, 0, vmbus_chan_clrchmap_task, chan); + taskqueue_enqueue(chan->ch_tq, &chmap_task); + taskqueue_drain(chan->ch_tq, &chmap_task); +} + +static void +vmbus_chan_set_chmap(struct vmbus_channel *chan) +{ + __compiler_membar(); + chan->ch_vmbus->vmbus_chmap[chan->ch_id] = chan; +} + +static void vmbus_chan_close_internal(struct vmbus_channel *chan) { struct vmbus_softc *sc = chan->ch_vmbus; struct vmbus_msghc *mh; struct vmbus_chanmsg_chclose *req; - struct taskqueue *tq = chan->ch_tq; int error; /* TODO: stringent check */ @@ -535,12 +667,14 @@ vmbus_chan_close_internal(struct vmbus_c sysctl_ctx_free(&chan->ch_sysctl_ctx); /* - * Set ch_tq to NULL to avoid more requests be scheduled. - * XXX pretty broken; need rework. + * NOTE: + * Order is critical. This channel _must_ be uninstalled first, + * else the channel task may be enqueued by the IDT after it has + * been drained. */ + vmbus_chan_clear_chmap(chan); + taskqueue_drain(chan->ch_tq, &chan->ch_task); chan->ch_tq = NULL; - taskqueue_drain(tq, &chan->ch_task); - chan->ch_cb = NULL; /* * Close this channel. @@ -622,6 +756,13 @@ vmbus_chan_close(struct vmbus_channel *c vmbus_chan_close_internal(chan); } +void +vmbus_chan_intr_drain(struct vmbus_channel *chan) +{ + + taskqueue_drain(chan->ch_tq, &chan->ch_task); +} + int vmbus_chan_send(struct vmbus_channel *chan, uint16_t type, uint16_t flags, void *data, int dlen, uint64_t xactid) @@ -884,10 +1025,11 @@ vmbus_event_flags_proc(struct vmbus_soft flags &= ~(1UL << chid_ofs); chan = sc->vmbus_chmap[chid_base + chid_ofs]; - - /* if channel is closed or closing */ - if (chan == NULL || chan->ch_tq == NULL) + if (__predict_false(chan == NULL)) { + /* Channel is closed. */ continue; + } + __compiler_membar(); if (chan->ch_flags & VMBUS_CHAN_FLAG_BATCHREAD) vmbus_rxbr_intr_mask(&chan->ch_rxbr); @@ -968,7 +1110,6 @@ vmbus_chan_alloc(struct vmbus_softc *sc) chan->ch_vmbus = sc; mtx_init(&chan->ch_subchan_lock, "vmbus subchan", NULL, MTX_DEF); TAILQ_INIT(&chan->ch_subchans); - TASK_INIT(&chan->ch_detach_task, 0, vmbus_chan_detach_task, chan); vmbus_rxbr_init(&chan->ch_rxbr); vmbus_txbr_init(&chan->ch_txbr); @@ -978,9 +1119,14 @@ vmbus_chan_alloc(struct vmbus_softc *sc) static void vmbus_chan_free(struct vmbus_channel *chan) { - /* TODO: assert sub-channel list is empty */ - /* TODO: asset no longer on the primary channel's sub-channel list */ - /* TODO: asset no longer on the vmbus channel list */ + + KASSERT(TAILQ_EMPTY(&chan->ch_subchans) && chan->ch_subchan_cnt == 0, + ("still owns sub-channels")); + KASSERT((chan->ch_stflags & + (VMBUS_CHAN_ST_OPENED | + VMBUS_CHAN_ST_ONPRIL | + VMBUS_CHAN_ST_ONSUBL | + VMBUS_CHAN_ST_ONLIST)) == 0, ("free busy channel")); hyperv_dmamem_free(&chan->ch_monprm_dma, chan->ch_monprm); mtx_destroy(&chan->ch_subchan_lock); vmbus_rxbr_deinit(&chan->ch_rxbr); @@ -1007,7 +1153,6 @@ vmbus_chan_add(struct vmbus_channel *new newchan->ch_id); return EINVAL; } - sc->vmbus_chmap[newchan->ch_id] = newchan; if (bootverbose) { device_printf(sc->vmbus_dev, "chan%u subidx%u offer\n", @@ -1029,10 +1174,9 @@ vmbus_chan_add(struct vmbus_channel *new if (VMBUS_CHAN_ISPRIMARY(newchan)) { if (prichan == NULL) { /* Install the new primary channel */ - TAILQ_INSERT_TAIL(&sc->vmbus_prichans, newchan, - ch_prilink); + vmbus_chan_ins_prilist(sc, newchan); mtx_unlock(&sc->vmbus_prichan_lock); - return 0; + goto done; } else { mtx_unlock(&sc->vmbus_prichan_lock); device_printf(sc->vmbus_dev, "duplicated primary " @@ -1066,16 +1210,20 @@ vmbus_chan_add(struct vmbus_channel *new newchan->ch_dev = prichan->ch_dev; mtx_lock(&prichan->ch_subchan_lock); - TAILQ_INSERT_TAIL(&prichan->ch_subchans, newchan, ch_sublink); + vmbus_chan_ins_sublist(prichan, newchan); + mtx_unlock(&prichan->ch_subchan_lock); /* - * Bump up sub-channel count and notify anyone that is - * interested in this sub-channel, after this sub-channel - * is setup. + * Notify anyone that is interested in this sub-channel, + * after this sub-channel is setup. */ - prichan->ch_subchan_cnt++; - mtx_unlock(&prichan->ch_subchan_lock); wakeup(prichan); - +done: + /* + * Hook this channel up for later rescind. + */ + mtx_lock(&sc->vmbus_chan_lock); + vmbus_chan_ins_list(sc, newchan); + mtx_unlock(&sc->vmbus_chan_lock); return 0; } @@ -1126,6 +1274,7 @@ vmbus_chan_msgproc_choffer(struct vmbus_ { const struct vmbus_chanmsg_choffer *offer; struct vmbus_channel *chan; + task_fn_t *detach_fn, *attach_fn; int error; offer = (const struct vmbus_chanmsg_choffer *)msg->msg_data; @@ -1174,6 +1323,21 @@ vmbus_chan_msgproc_choffer(struct vmbus_ &sc->vmbus_tx_evtflags[chan->ch_id >> VMBUS_EVTFLAG_SHIFT]; chan->ch_evtflag_mask = 1UL << (chan->ch_id & VMBUS_EVTFLAG_MASK); + /* + * Setup attach and detach tasks. + */ + if (VMBUS_CHAN_ISPRIMARY(chan)) { + chan->ch_mgmt_tq = sc->vmbus_devtq; + attach_fn = vmbus_prichan_attach_task; + detach_fn = vmbus_prichan_detach_task; + } else { + chan->ch_mgmt_tq = sc->vmbus_subchtq; + attach_fn = vmbus_subchan_attach_task; + detach_fn = vmbus_subchan_detach_task; + } + TASK_INIT(&chan->ch_attach_task, 0, attach_fn, chan); + TASK_INIT(&chan->ch_detach_task, 0, detach_fn, chan); + /* Select default cpu for this channel. */ vmbus_chan_cpu_default(chan); @@ -1184,22 +1348,9 @@ vmbus_chan_msgproc_choffer(struct vmbus_ vmbus_chan_free(chan); return; } - - if (VMBUS_CHAN_ISPRIMARY(chan)) { - /* - * Add device for this primary channel. - * - * NOTE: - * Error is ignored here; don't have much to do if error - * really happens. - */ - vmbus_add_child(chan); - } + taskqueue_enqueue(chan->ch_mgmt_tq, &chan->ch_attach_task); } -/* - * XXX pretty broken; need rework. - */ static void vmbus_chan_msgproc_chrescind(struct vmbus_softc *sc, const struct vmbus_message *msg) @@ -1219,91 +1370,162 @@ vmbus_chan_msgproc_chrescind(struct vmbu note->chm_chanid); } - chan = sc->vmbus_chmap[note->chm_chanid]; - if (chan == NULL) + /* + * Find and remove the target channel from the channel list. + */ + mtx_lock(&sc->vmbus_chan_lock); + TAILQ_FOREACH(chan, &sc->vmbus_chans, ch_link) { + if (chan->ch_id == note->chm_chanid) + break; + } + if (chan == NULL) { + mtx_unlock(&sc->vmbus_chan_lock); + device_printf(sc->vmbus_dev, "chan%u is not offered\n", + note->chm_chanid); return; - sc->vmbus_chmap[note->chm_chanid] = NULL; + } + vmbus_chan_rem_list(sc, chan); + mtx_unlock(&sc->vmbus_chan_lock); + + if (VMBUS_CHAN_ISPRIMARY(chan)) { + /* + * The target channel is a primary channel; remove the + * target channel from the primary channel list now, + * instead of later, so that it will not be found by + * other sub-channel offers, which are processed in + * this thread. + */ + mtx_lock(&sc->vmbus_prichan_lock); + vmbus_chan_rem_prilist(sc, chan); + mtx_unlock(&sc->vmbus_prichan_lock); + } - taskqueue_enqueue(taskqueue_thread, &chan->ch_detach_task); + /* Detach the target channel. */ + taskqueue_enqueue(chan->ch_mgmt_tq, &chan->ch_detach_task); } -static void -vmbus_chan_detach_task(void *xchan, int pending __unused) +static int +vmbus_chan_release(struct vmbus_channel *chan) { - struct vmbus_channel *chan = xchan; + struct vmbus_softc *sc = chan->ch_vmbus; + struct vmbus_chanmsg_chfree *req; + struct vmbus_msghc *mh; + int error; - if (VMBUS_CHAN_ISPRIMARY(chan)) { - /* Only primary channel owns the device */ - vmbus_delete_child(chan); - /* NOTE: DO NOT free primary channel for now */ + mh = vmbus_msghc_get(sc, sizeof(*req)); + if (mh == NULL) { + device_printf(sc->vmbus_dev, "can not get msg hypercall for " + "chfree(chan%u)\n", chan->ch_id); + return (ENXIO); + } + + req = vmbus_msghc_dataptr(mh); + req->chm_hdr.chm_type = VMBUS_CHANMSG_TYPE_CHFREE; + req->chm_chanid = chan->ch_id; + + error = vmbus_msghc_exec_noresult(mh); + vmbus_msghc_put(sc, mh); + + if (error) { + device_printf(sc->vmbus_dev, "chfree(chan%u) failed: %d", + chan->ch_id, error); } else { - struct vmbus_softc *sc = chan->ch_vmbus; - struct vmbus_channel *pri_chan = chan->ch_prichan; - struct vmbus_chanmsg_chfree *req; - struct vmbus_msghc *mh; - int error; - - mh = vmbus_msghc_get(sc, sizeof(*req)); - if (mh == NULL) { - device_printf(sc->vmbus_dev, - "can not get msg hypercall for chfree(chan%u)\n", + if (bootverbose) { + device_printf(sc->vmbus_dev, "chan%u freed\n", chan->ch_id); - goto remove; } + } + return (error); +} - req = vmbus_msghc_dataptr(mh); - req->chm_hdr.chm_type = VMBUS_CHANMSG_TYPE_CHFREE; - req->chm_chanid = chan->ch_id; +static void +vmbus_prichan_detach_task(void *xchan, int pending __unused) +{ + struct vmbus_channel *chan = xchan; - error = vmbus_msghc_exec_noresult(mh); - vmbus_msghc_put(sc, mh); + KASSERT(VMBUS_CHAN_ISPRIMARY(chan), + ("chan%u is not primary channel", chan->ch_id)); - if (error) { - device_printf(sc->vmbus_dev, - "chfree(chan%u) failed: %d", - chan->ch_id, error); - /* NOTE: Move on! */ - } else { - if (bootverbose) { - device_printf(sc->vmbus_dev, "chan%u freed\n", - chan->ch_id); - } - } -remove: - mtx_lock(&pri_chan->ch_subchan_lock); - TAILQ_REMOVE(&pri_chan->ch_subchans, chan, ch_sublink); - KASSERT(pri_chan->ch_subchan_cnt > 0, - ("invalid subchan_cnt %d", pri_chan->ch_subchan_cnt)); - pri_chan->ch_subchan_cnt--; - mtx_unlock(&pri_chan->ch_subchan_lock); - wakeup(pri_chan); + /* Delete and detach the device associated with this channel. */ + vmbus_delete_child(chan); - vmbus_chan_free(chan); - } + /* Release this channel (back to vmbus). */ + vmbus_chan_release(chan); + + /* Free this channel's resource. */ + vmbus_chan_free(chan); +} + +static void +vmbus_subchan_detach_task(void *xchan, int pending __unused) +{ + struct vmbus_channel *chan = xchan; + struct vmbus_channel *pri_chan = chan->ch_prichan; + + KASSERT(!VMBUS_CHAN_ISPRIMARY(chan), + ("chan%u is primary channel", chan->ch_id)); + + /* Release this channel (back to vmbus). */ + vmbus_chan_release(chan); + + /* Unlink from its primary channel's sub-channel list. */ + mtx_lock(&pri_chan->ch_subchan_lock); + vmbus_chan_rem_sublist(pri_chan, chan); + mtx_unlock(&pri_chan->ch_subchan_lock); + /* Notify anyone that is waiting for this sub-channel to vanish. */ + wakeup(pri_chan); + + /* Free this channel's resource. */ + vmbus_chan_free(chan); +} + +static void +vmbus_prichan_attach_task(void *xchan, int pending __unused) +{ + + /* + * Add device for this primary channel. + */ + vmbus_add_child(xchan); +} + +static void +vmbus_subchan_attach_task(void *xchan __unused, int pending __unused) +{ + + /* Nothing */ } -/* - * Detach all devices and destroy the corresponding primary channels. - */ void vmbus_chan_destroy_all(struct vmbus_softc *sc) { - struct vmbus_channel *chan; - mtx_lock(&sc->vmbus_prichan_lock); - while ((chan = TAILQ_FIRST(&sc->vmbus_prichans)) != NULL) { - KASSERT(VMBUS_CHAN_ISPRIMARY(chan), ("not primary channel")); - TAILQ_REMOVE(&sc->vmbus_prichans, chan, ch_prilink); - mtx_unlock(&sc->vmbus_prichan_lock); + /* + * Detach all devices and destroy the corresponding primary + * channels. + */ + for (;;) { + struct vmbus_channel *chan; - vmbus_delete_child(chan); - vmbus_chan_free(chan); + mtx_lock(&sc->vmbus_chan_lock); + TAILQ_FOREACH(chan, &sc->vmbus_chans, ch_link) { + if (VMBUS_CHAN_ISPRIMARY(chan)) + break; + } + if (chan == NULL) { + /* No more primary channels; done. */ + mtx_unlock(&sc->vmbus_chan_lock); + break; + } + vmbus_chan_rem_list(sc, chan); + mtx_unlock(&sc->vmbus_chan_lock); mtx_lock(&sc->vmbus_prichan_lock); + vmbus_chan_rem_prilist(sc, chan); + mtx_unlock(&sc->vmbus_prichan_lock); + + taskqueue_enqueue(chan->ch_mgmt_tq, &chan->ch_detach_task); } - bzero(sc->vmbus_chmap, - sizeof(struct vmbus_channel *) * VMBUS_CHAN_MAX); - mtx_unlock(&sc->vmbus_prichan_lock); } /* @@ -1477,3 +1699,17 @@ vmbus_chan_prplist_nelem(int br_size, in return (vmbus_br_nelem(br_size, elem_size)); } + +bool +vmbus_chan_tx_empty(const struct vmbus_channel *chan) +{ + + return (vmbus_txbr_empty(&chan->ch_txbr)); +} + +bool +vmbus_chan_rx_empty(const struct vmbus_channel *chan) +{ + + return (vmbus_rxbr_empty(&chan->ch_rxbr)); +} Modified: stable/10/sys/dev/hyperv/vmbus/vmbus_chanvar.h ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/vmbus_chanvar.h Fri Oct 14 02:36:51 2016 (r307248) +++ stable/10/sys/dev/hyperv/vmbus/vmbus_chanvar.h Fri Oct 14 02:42:08 2016 (r307249) @@ -124,8 +124,14 @@ struct vmbus_channel { struct hyperv_dma ch_bufring_dma; uint32_t ch_bufring_gpadl; - struct task ch_detach_task; + struct task ch_attach_task; /* run in ch_mgmt_tq */ + struct task ch_detach_task; /* run in ch_mgmt_tq */ + struct taskqueue *ch_mgmt_tq; + + /* If this is a primary channel */ TAILQ_ENTRY(vmbus_channel) ch_prilink; /* primary chan link */ + + TAILQ_ENTRY(vmbus_channel) ch_link; /* channel link */ uint32_t ch_subidx; /* subchan index */ volatile uint32_t ch_stflags; /* atomic-op */ /* VMBUS_CHAN_ST_ */ @@ -150,7 +156,13 @@ struct vmbus_channel { #define VMBUS_CHAN_TXF_HASMNF 0x0001 #define VMBUS_CHAN_ST_OPENED_SHIFT 0 +#define VMBUS_CHAN_ST_ONPRIL_SHIFT 1 +#define VMBUS_CHAN_ST_ONSUBL_SHIFT 2 +#define VMBUS_CHAN_ST_ONLIST_SHIFT 3 #define VMBUS_CHAN_ST_OPENED (1 << VMBUS_CHAN_ST_OPENED_SHIFT) +#define VMBUS_CHAN_ST_ONPRIL (1 << VMBUS_CHAN_ST_ONPRIL_SHIFT) +#define VMBUS_CHAN_ST_ONSUBL (1 << VMBUS_CHAN_ST_ONSUBL_SHIFT) +#define VMBUS_CHAN_ST_ONLIST (1 << VMBUS_CHAN_ST_ONLIST_SHIFT) struct vmbus_softc; struct vmbus_message; Modified: stable/10/sys/dev/hyperv/vmbus/vmbus_var.h ============================================================================== --- stable/10/sys/dev/hyperv/vmbus/vmbus_var.h Fri Oct 14 02:36:51 2016 (r307248) +++ stable/10/sys/dev/hyperv/vmbus/vmbus_var.h Fri Oct 14 02:42:08 2016 (r307249) @@ -107,14 +107,19 @@ struct vmbus_softc { struct hyperv_dma vmbus_mnf1_dma; struct hyperv_dma vmbus_mnf2_dma; - struct mtx vmbus_scan_lock; - uint32_t vmbus_scan_chcnt; -#define VMBUS_SCAN_CHCNT_DONE 0x80000000 - uint32_t vmbus_scan_devcnt; + bool vmbus_scandone; + struct task vmbus_scandone_task; + + struct taskqueue *vmbus_devtq; /* for dev attach/detach */ + struct taskqueue *vmbus_subchtq; /* for sub-chan attach/detach */ /* Primary channels */ struct mtx vmbus_prichan_lock; TAILQ_HEAD(, vmbus_channel) vmbus_prichans; + + /* Complete channel list */ + struct mtx vmbus_chan_lock; + TAILQ_HEAD(, vmbus_channel) vmbus_chans; }; #define VMBUS_FLAG_ATTACHED 0x0001 /* vmbus was attached */ From owner-svn-src-all@freebsd.org Fri Oct 14 02:52:50 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 5DEBBC119AD; Fri, 14 Oct 2016 02:52:50 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 2EADF143; Fri, 14 Oct 2016 02:52:50 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9E2qnj8060694; Fri, 14 Oct 2016 02:52:49 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9E2qmaQ060688; Fri, 14 Oct 2016 02:52:48 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610140252.u9E2qmaQ060688@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Fri, 14 Oct 2016 02:52:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307250 - stable/10/sys/dev/hyperv/netvsc X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Oct 2016 02:52:50 -0000 Author: sephe Date: Fri Oct 14 02:52:48 2016 New Revision: 307250 URL: https://svnweb.freebsd.org/changeset/base/307250 Log: MFC 306390-306392 306390 hyperv/hn: Suspend and resume the backend properly upon MTU change. Suspend: - Prevent the backend from being touched on TX path. - Clear the RNDIS RX filter, and wait for RX to drain. - Make sure that NVS see the chimney sending buffer and RXBUF disconnection, before unlink these buffers from the channel. Resume: - Reconfigure the RNDIS filter. - Allow TX path to work on the backend. - Kick start the TX eof task, in case the OACTIVE is set. This fixes various panics, when the interface has traffic and MTU is being changed. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8046 306391 hyperv/hn: Reorganize the synthetic parts detach. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8047 306392 hyperv/hn: Reorder the comment a little bit. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8048 Modified: stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.c stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.c stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.h stable/10/sys/dev/hyperv/netvsc/if_hnvar.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.c Fri Oct 14 02:42:08 2016 (r307249) +++ stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.c Fri Oct 14 02:52:48 2016 (r307250) @@ -347,6 +347,16 @@ hn_nvs_disconn_rxbuf(struct hn_softc *sc return (error); } sc->hn_flags &= ~HN_FLAG_RXBUF_CONNECTED; + + /* + * Wait for the hypervisor to receive this NVS request. + */ + while (!vmbus_chan_tx_empty(sc->hn_prichan)) + pause("waittx", 1); + /* + * Linger long enough for NVS to disconnect RXBUF. + */ + pause("lingtx", (200 * hz) / 1000); } if (sc->hn_rxbuf_gpadl != 0) { @@ -388,6 +398,17 @@ hn_nvs_disconn_chim(struct hn_softc *sc) return (error); } sc->hn_flags &= ~HN_FLAG_CHIM_CONNECTED; + + /* + * Wait for the hypervisor to receive this NVS request. + */ + while (!vmbus_chan_tx_empty(sc->hn_prichan)) + pause("waittx", 1); + /* + * Linger long enough for NVS to disconnect chimney + * sending buffer. + */ + pause("lingtx", (200 * hz) / 1000); } if (sc->hn_chim_gpadl != 0) { @@ -596,27 +617,15 @@ hn_nvs_attach(struct hn_softc *sc, int m return (0); } -/* - * Net VSC disconnect from VSP - */ -static void -hv_nv_disconnect_from_vsp(struct hn_softc *sc) +void +hn_nvs_detach(struct hn_softc *sc) { + + /* NOTE: there are no requests to stop the NVS. */ hn_nvs_disconn_rxbuf(sc); hn_nvs_disconn_chim(sc); } -/* - * Net VSC on device remove - */ -int -hv_nv_on_device_remove(struct hn_softc *sc) -{ - - hv_nv_disconnect_from_vsp(sc); - return (0); -} - void hn_nvs_sent_xact(struct hn_send_ctx *sndc, struct hn_softc *sc __unused, struct vmbus_channel *chan __unused, Modified: stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h Fri Oct 14 02:42:08 2016 (r307249) +++ stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h Fri Oct 14 02:52:48 2016 (r307250) @@ -178,6 +178,7 @@ struct hn_tx_ring { bus_dma_tag_t hn_tx_data_dtag; uint64_t hn_csum_assist; + int hn_suspended; int hn_gpa_cnt; struct vmbus_gpa hn_gpa[NETVSC_PACKET_MAXPAGE]; @@ -269,8 +270,6 @@ extern int hv_promisc_mode; struct hn_send_ctx; void netvsc_linkstatus_callback(struct hn_softc *sc, uint32_t status); -int hn_nvs_attach(struct hn_softc *sc, int mtu); -int hv_nv_on_device_remove(struct hn_softc *sc); int hv_nv_on_send(struct vmbus_channel *chan, uint32_t rndis_mtype, struct hn_send_ctx *sndc, struct vmbus_gpa *gpa, int gpa_cnt); Modified: stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Fri Oct 14 02:42:08 2016 (r307249) +++ stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Fri Oct 14 02:52:48 2016 (r307250) @@ -350,6 +350,11 @@ static void hn_detach_allchans(struct hn static void hn_chan_callback(struct vmbus_channel *chan, void *xrxr); static void hn_set_ring_inuse(struct hn_softc *, int); static int hn_synth_attach(struct hn_softc *, int); +static void hn_synth_detach(struct hn_softc *); +static bool hn_tx_ring_pending(struct hn_tx_ring *); +static void hn_suspend(struct hn_softc *); +static void hn_resume(struct hn_softc *); +static void hn_tx_ring_qflush(struct hn_tx_ring *); static void hn_nvs_handle_notify(struct hn_softc *sc, const struct vmbus_chanpkt_hdr *pkt); @@ -756,29 +761,19 @@ failed: } /* - * Standard detach entry point + * TODO: Use this for error handling on attach path. */ static int netvsc_detach(device_t dev) { struct hn_softc *sc = device_get_softc(dev); - if (bootverbose) - printf("netvsc_detach\n"); - - /* - * XXXKYS: Need to clean up all our - * driver state; this is the driver - * unloading. - */ + /* TODO: ether_ifdetach */ - /* - * XXXKYS: Need to stop outgoing traffic and unregister - * the netdevice. - */ - - hv_rf_on_device_remove(sc); - hn_detach_allchans(sc); + HN_LOCK(sc); + /* TODO: hn_stop */ + hn_synth_detach(sc); + HN_UNLOCK(sc); hn_stop_tx_tasks(sc); @@ -791,6 +786,8 @@ netvsc_detach(device_t dev) vmbus_xact_ctx_destroy(sc->hn_xact); HN_LOCK_DESTROY(sc); + + /* TODO: if_free */ return (0); } @@ -921,6 +918,23 @@ hn_txdesc_hold(struct hn_txdesc *txd) atomic_add_int(&txd->refs, 1); } +static bool +hn_tx_ring_pending(struct hn_tx_ring *txr) +{ + bool pending = false; + +#ifndef HN_USE_TXDESC_BUFRING + mtx_lock_spin(&txr->hn_txlist_spin); + if (txr->hn_txdesc_avail != txr->hn_txdesc_cnt) + pending = true; + mtx_unlock_spin(&txr->hn_txlist_spin); +#else + if (!buf_ring_full(txr->hn_txdesc_br)) + pending = true; +#endif + return (pending); +} + static __inline void hn_txeof(struct hn_tx_ring *txr) { @@ -1263,6 +1277,9 @@ hn_start_locked(struct hn_tx_ring *txr, KASSERT(txr == &sc->hn_tx_ring[0], ("not the first TX ring")); mtx_assert(&txr->hn_tx_lock, MA_OWNED); + if (__predict_false(txr->hn_suspended)) + return 0; + if ((ifp->if_drv_flags & (IFF_DRV_RUNNING | IFF_DRV_OACTIVE)) != IFF_DRV_RUNNING) return 0; @@ -1647,23 +1664,17 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, hn_set_lro_lenlim(sc, HN_LRO_LENLIM_MIN(ifp)); #endif - /* We must remove and add back the device to cause the new - * MTU to take effect. This includes tearing down, but not - * deleting the channel, then bringing it back up. - */ - error = hv_rf_on_device_remove(sc); - if (error) { - HN_UNLOCK(sc); - break; - } + if (ifp->if_drv_flags & IFF_DRV_RUNNING) + hn_suspend(sc); /* - * Detach all of the channels. + * Detach the synthetics parts, i.e. NVS and RNDIS. */ - hn_detach_allchans(sc); + hn_synth_detach(sc); /* - * Attach the synthetic parts, i.e. NVS and RNDIS. + * Reattach the synthetic parts, i.e. NVS and RNDIS, + * with the new MTU setting. * XXX check error. */ hn_synth_attach(sc, ifr->ifr_mtu); @@ -1671,7 +1682,9 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, if (sc->hn_tx_ring[0].hn_chim_size > sc->hn_chim_szmax) hn_set_chim_size(sc, sc->hn_chim_szmax); - hn_init_locked(sc); + /* All done! Resume now. */ + if (ifp->if_drv_flags & IFF_DRV_RUNNING) + hn_resume(sc); HN_UNLOCK(sc); break; @@ -3004,6 +3017,9 @@ hn_xmit(struct hn_tx_ring *txr, int len) KASSERT(hn_use_if_start == 0, ("hn_xmit is called, when if_start is enabled")); + if (__predict_false(txr->hn_suspended)) + return 0; + if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0 || txr->hn_oactive) return 0; @@ -3090,20 +3106,24 @@ do_sched: } static void +hn_tx_ring_qflush(struct hn_tx_ring *txr) +{ + struct mbuf *m; + + mtx_lock(&txr->hn_tx_lock); + while ((m = buf_ring_dequeue_sc(txr->hn_mbuf_br)) != NULL) + m_freem(m); + mtx_unlock(&txr->hn_tx_lock); +} + +static void hn_xmit_qflush(struct ifnet *ifp) { struct hn_softc *sc = ifp->if_softc; int i; - for (i = 0; i < sc->hn_tx_ring_inuse; ++i) { - struct hn_tx_ring *txr = &sc->hn_tx_ring[i]; - struct mbuf *m; - - mtx_lock(&txr->hn_tx_lock); - while ((m = buf_ring_dequeue_sc(txr->hn_mbuf_br)) != NULL) - m_freem(m); - mtx_unlock(&txr->hn_tx_lock); - } + for (i = 0; i < sc->hn_tx_ring_inuse; ++i) + hn_tx_ring_qflush(&sc->hn_tx_ring[i]); if_qflush(ifp); } @@ -3504,6 +3524,26 @@ back: return (0); } +/* + * NOTE: + * The interface must have been suspended though hn_suspend(), before + * this function get called. + */ +static void +hn_synth_detach(struct hn_softc *sc) +{ + HN_LOCK_ASSERT(sc); + + /* Detach the RNDIS first. */ + hn_rndis_detach(sc); + + /* Detach NVS. */ + hn_nvs_detach(sc); + + /* Detach all of the channels. */ + hn_detach_allchans(sc); +} + static void hn_set_ring_inuse(struct hn_softc *sc, int ring_cnt) { @@ -3523,6 +3563,113 @@ hn_set_ring_inuse(struct hn_softc *sc, i } static void +hn_rx_drain(struct vmbus_channel *chan) +{ + + while (!vmbus_chan_rx_empty(chan) || !vmbus_chan_tx_empty(chan)) + pause("waitch", 1); + vmbus_chan_intr_drain(chan); +} + +static void +hn_suspend(struct hn_softc *sc) +{ + struct vmbus_channel **subch = NULL; + int i, nsubch; + + HN_LOCK_ASSERT(sc); + + /* + * Suspend TX. + */ + for (i = 0; i < sc->hn_tx_ring_inuse; ++i) { + struct hn_tx_ring *txr = &sc->hn_tx_ring[i]; + + mtx_lock(&txr->hn_tx_lock); + txr->hn_suspended = 1; + mtx_unlock(&txr->hn_tx_lock); + /* No one is able send more packets now. */ + + /* Wait for all pending sends to finish. */ + while (hn_tx_ring_pending(txr)) + pause("hnwtx", 1 /* 1 tick */); + } + + /* + * Disable RX. + */ + hv_rf_on_close(sc); + + /* + * Give RNDIS enough time to flush all pending data packets. + */ + pause("waitrx", (200 * hz) / 1000); + + /* + * Drain RX/TX bufrings and interrupts. + */ + nsubch = sc->hn_rx_ring_inuse - 1; + if (nsubch > 0) + subch = vmbus_subchan_get(sc->hn_prichan, nsubch); + + if (subch != NULL) { + for (i = 0; i < nsubch; ++i) + hn_rx_drain(subch[i]); + } + hn_rx_drain(sc->hn_prichan); + + if (subch != NULL) + vmbus_subchan_rel(subch, nsubch); +} + +static void +hn_resume(struct hn_softc *sc) +{ + struct hn_tx_ring *txr; + int i; + + HN_LOCK_ASSERT(sc); + + /* + * Re-enable RX. + */ + hv_rf_on_open(sc); + + /* + * Make sure to clear suspend status on "all" TX rings, + * since hn_tx_ring_inuse can be changed after hn_suspend(). + */ + for (i = 0; i < sc->hn_tx_ring_cnt; ++i) { + txr = &sc->hn_tx_ring[i]; + + mtx_lock(&txr->hn_tx_lock); + txr->hn_suspended = 0; + mtx_unlock(&txr->hn_tx_lock); + } + + if (!hn_use_if_start) { + /* + * Flush unused drbrs, since hn_tx_ring_inuse may be + * reduced. + */ + for (i = sc->hn_tx_ring_inuse; i < sc->hn_tx_ring_cnt; ++i) + hn_tx_ring_qflush(&sc->hn_tx_ring[i]); + } + + /* + * Kick start TX. + */ + for (i = 0; i < sc->hn_tx_ring_inuse; ++i) { + txr = &sc->hn_tx_ring[i]; + /* + * Use txeof task, so that any pending oactive can be + * cleared properly. + */ + taskqueue_enqueue(txr->hn_tx_taskq, &txr->hn_txeof_task); + } +} + +static void hn_nvs_handle_notify(struct hn_softc *sc, const struct vmbus_chanpkt_hdr *pkt) { const struct hn_nvs_hdr *hdr; Modified: stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.c Fri Oct 14 02:42:08 2016 (r307249) +++ stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.c Fri Oct 14 02:52:48 2016 (r307250) @@ -958,11 +958,8 @@ done: return (error); } -/* - * RNDIS filter halt device - */ static int -hv_rf_halt_device(struct hn_softc *sc) +hn_rndis_halt(struct hn_softc *sc) { struct vmbus_xact *xact; struct rndis_halt_req *halt; @@ -1009,21 +1006,12 @@ hn_rndis_attach(struct hn_softc *sc) return (0); } -/* - * RNDIS filter on device remove - */ -int -hv_rf_on_device_remove(struct hn_softc *sc) +void +hn_rndis_detach(struct hn_softc *sc) { - int ret; - - /* Halt and release the rndis device */ - ret = hv_rf_halt_device(sc); - - /* Pass control to inner driver to remove the device */ - ret |= hv_nv_on_device_remove(sc); - return (ret); + /* Halt the RNDIS. */ + hn_rndis_halt(sc); } /* Modified: stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.h ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.h Fri Oct 14 02:42:08 2016 (r307249) +++ stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.h Fri Oct 14 02:52:48 2016 (r307250) @@ -43,7 +43,6 @@ struct hn_rx_ring; void hv_rf_on_receive(struct hn_softc *sc, struct hn_rx_ring *rxr, const void *data, int dlen); void hv_rf_channel_rollup(struct hn_rx_ring *rxr, struct hn_tx_ring *txr); -int hv_rf_on_device_remove(struct hn_softc *sc); int hv_rf_on_open(struct hn_softc *sc); int hv_rf_on_close(struct hn_softc *sc); Modified: stable/10/sys/dev/hyperv/netvsc/if_hnvar.h ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/if_hnvar.h Fri Oct 14 02:42:08 2016 (r307249) +++ stable/10/sys/dev/hyperv/netvsc/if_hnvar.h Fri Oct 14 02:52:48 2016 (r307250) @@ -118,6 +118,7 @@ uint32_t hn_chim_alloc(struct hn_softc * void hn_chim_free(struct hn_softc *sc, uint32_t chim_idx); int hn_rndis_attach(struct hn_softc *sc); +void hn_rndis_detach(struct hn_softc *sc); int hn_rndis_conf_rss(struct hn_softc *sc, uint16_t flags); void *hn_rndis_pktinfo_append(struct rndis_packet_msg *, size_t pktsize, size_t pi_dlen, uint32_t pi_type); @@ -127,6 +128,7 @@ int hn_rndis_get_linkstatus(struct hn_s uint32_t *link_status); int hn_nvs_attach(struct hn_softc *sc, int mtu); +void hn_nvs_detach(struct hn_softc *sc); int hn_nvs_alloc_subchans(struct hn_softc *sc, int *nsubch); void hn_nvs_sent_xact(struct hn_send_ctx *sndc, struct hn_softc *sc, struct vmbus_channel *chan, const void *data, int dlen); From owner-svn-src-all@freebsd.org Fri Oct 14 02:58:32 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E43FDC11A7F; Fri, 14 Oct 2016 02:58:32 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id A4B5F33E; Fri, 14 Oct 2016 02:58:32 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9E2wVtZ061002; Fri, 14 Oct 2016 02:58:31 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9E2wViK060997; Fri, 14 Oct 2016 02:58:31 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610140258.u9E2wViK060997@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Fri, 14 Oct 2016 02:58:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307251 - stable/10/sys/dev/hyperv/netvsc X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Oct 2016 02:58:33 -0000 Author: sephe Date: Fri Oct 14 02:58:31 2016 New Revision: 307251 URL: https://svnweb.freebsd.org/changeset/base/307251 Log: MFC 306393 hyperv/hn: Flatten RX filter configuration. This paves way for more fixes. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8049 Modified: stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.c stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.h stable/10/sys/dev/hyperv/netvsc/if_hnvar.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h Fri Oct 14 02:52:48 2016 (r307250) +++ stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h Fri Oct 14 02:58:31 2016 (r307251) @@ -266,7 +266,6 @@ struct hn_softc { /* * Externs */ -extern int hv_promisc_mode; struct hn_send_ctx; void netvsc_linkstatus_callback(struct hn_softc *sc, uint32_t status); Modified: stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Fri Oct 14 02:52:48 2016 (r307250) +++ stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Fri Oct 14 02:58:31 2016 (r307251) @@ -207,8 +207,6 @@ struct hn_txdesc { * Globals */ -int hv_promisc_mode = 0; /* normal mode by default */ - SYSCTL_NODE(_hw, OID_AUTO, hn, CTLFLAG_RD | CTLFLAG_MPSAFE, NULL, "Hyper-V network interface"); @@ -1799,7 +1797,7 @@ static void hn_stop(struct hn_softc *sc) { struct ifnet *ifp; - int ret, i; + int i; HN_LOCK_ASSERT(sc); @@ -1815,7 +1813,8 @@ hn_stop(struct hn_softc *sc) if_link_state_change(ifp, LINK_STATE_DOWN); - ret = hv_rf_on_close(sc); + /* Disable RX by clearing RX filter. */ + hn_rndis_set_rxfilter(sc, 0); } /* @@ -1890,9 +1889,8 @@ hn_init_locked(struct hn_softc *sc) return; } - hv_promisc_mode = 1; - - ret = hv_rf_on_open(sc); + /* TODO: add hn_rx_filter */ + ret = hn_rndis_set_rxfilter(sc, NDIS_PACKET_TYPE_PROMISCUOUS); if (ret != 0) return; @@ -3596,9 +3594,9 @@ hn_suspend(struct hn_softc *sc) } /* - * Disable RX. + * Disable RX by clearing RX filter. */ - hv_rf_on_close(sc); + hn_rndis_set_rxfilter(sc, 0); /* * Give RNDIS enough time to flush all pending data packets. @@ -3632,8 +3630,9 @@ hn_resume(struct hn_softc *sc) /* * Re-enable RX. + * TODO: add hn_rx_filter. */ - hv_rf_on_open(sc); + hn_rndis_set_rxfilter(sc, NDIS_PACKET_TYPE_PROMISCUOUS); /* * Make sure to clear suspend status on "all" TX rings, Modified: stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.c Fri Oct 14 02:52:48 2016 (r307250) +++ stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.c Fri Oct 14 02:58:31 2016 (r307251) @@ -888,7 +888,7 @@ hn_rndis_conf_rss(struct hn_softc *sc, u return (error); } -static int +int hn_rndis_set_rxfilter(struct hn_softc *sc, uint32_t filter) { int error; @@ -1014,35 +1014,6 @@ hn_rndis_detach(struct hn_softc *sc) hn_rndis_halt(sc); } -/* - * RNDIS filter on open - */ -int -hv_rf_on_open(struct hn_softc *sc) -{ - uint32_t filter; - - /* XXX */ - if (hv_promisc_mode != 1) { - filter = NDIS_PACKET_TYPE_BROADCAST | - NDIS_PACKET_TYPE_ALL_MULTICAST | - NDIS_PACKET_TYPE_DIRECTED; - } else { - filter = NDIS_PACKET_TYPE_PROMISCUOUS; - } - return (hn_rndis_set_rxfilter(sc, filter)); -} - -/* - * RNDIS filter on close - */ -int -hv_rf_on_close(struct hn_softc *sc) -{ - - return (hn_rndis_set_rxfilter(sc, 0)); -} - void hv_rf_channel_rollup(struct hn_rx_ring *rxr, struct hn_tx_ring *txr) { Modified: stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.h ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.h Fri Oct 14 02:52:48 2016 (r307250) +++ stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.h Fri Oct 14 02:58:31 2016 (r307251) @@ -43,8 +43,6 @@ struct hn_rx_ring; void hv_rf_on_receive(struct hn_softc *sc, struct hn_rx_ring *rxr, const void *data, int dlen); void hv_rf_channel_rollup(struct hn_rx_ring *rxr, struct hn_tx_ring *txr); -int hv_rf_on_open(struct hn_softc *sc); -int hv_rf_on_close(struct hn_softc *sc); #endif /* __HV_RNDIS_FILTER_H__ */ Modified: stable/10/sys/dev/hyperv/netvsc/if_hnvar.h ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/if_hnvar.h Fri Oct 14 02:52:48 2016 (r307250) +++ stable/10/sys/dev/hyperv/netvsc/if_hnvar.h Fri Oct 14 02:58:31 2016 (r307251) @@ -126,6 +126,8 @@ int hn_rndis_get_rsscaps(struct hn_soft int hn_rndis_get_eaddr(struct hn_softc *sc, uint8_t *eaddr); int hn_rndis_get_linkstatus(struct hn_softc *sc, uint32_t *link_status); +/* filter: NDIS_PACKET_TYPE_ or 0. */ +int hn_rndis_set_rxfilter(struct hn_softc *sc, uint32_t filter); int hn_nvs_attach(struct hn_softc *sc, int mtu); void hn_nvs_detach(struct hn_softc *sc); From owner-svn-src-all@freebsd.org Fri Oct 14 03:00:54 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 7D7EEC11BB7; Fri, 14 Oct 2016 03:00:54 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 46115817; Fri, 14 Oct 2016 03:00:54 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9E30rJM061197; Fri, 14 Oct 2016 03:00:53 GMT (envelope-from gonzo@FreeBSD.org) Received: (from gonzo@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9E30r1O061196; Fri, 14 Oct 2016 03:00:53 GMT (envelope-from gonzo@FreeBSD.org) Message-Id: <201610140300.u9E30r1O061196@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: gonzo set sender to gonzo@FreeBSD.org using -f From: Oleksandr Tymoshenko Date: Fri, 14 Oct 2016 03:00:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307252 - head/sys/arm/broadcom/bcm2835 X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Oct 2016 03:00:54 -0000 Author: gonzo Date: Fri Oct 14 03:00:53 2016 New Revision: 307252 URL: https://svnweb.freebsd.org/changeset/base/307252 Log: Make bcm2835_machdep.c optional bcm2835_machdep.c contains only bits enabled by "options PLATFORM", this option available only on ARM, not ARM64 Modified: head/sys/arm/broadcom/bcm2835/files.bcm283x Modified: head/sys/arm/broadcom/bcm2835/files.bcm283x ============================================================================== --- head/sys/arm/broadcom/bcm2835/files.bcm283x Fri Oct 14 02:58:31 2016 (r307251) +++ head/sys/arm/broadcom/bcm2835/files.bcm283x Fri Oct 14 03:00:53 2016 (r307252) @@ -9,7 +9,7 @@ arm/broadcom/bcm2835/bcm2835_fbd.c opti arm/broadcom/bcm2835/bcm2835_ft5406.c optional evdev bcm2835_ft5406 arm/broadcom/bcm2835/bcm2835_gpio.c optional gpio arm/broadcom/bcm2835/bcm2835_intr.c standard -arm/broadcom/bcm2835/bcm2835_machdep.c standard +arm/broadcom/bcm2835/bcm2835_machdep.c optional platform arm/broadcom/bcm2835/bcm2835_mbox.c standard arm/broadcom/bcm2835/bcm2835_rng.c optional random arm/broadcom/bcm2835/bcm2835_sdhci.c optional sdhci From owner-svn-src-all@freebsd.org Fri Oct 14 03:11:32 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A8570C11E99; Fri, 14 Oct 2016 03:11:32 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 5FEF7FB2; Fri, 14 Oct 2016 03:11:32 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9E3BVtG067125; Fri, 14 Oct 2016 03:11:31 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9E3BVeN067123; Fri, 14 Oct 2016 03:11:31 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610140311.u9E3BVeN067123@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Fri, 14 Oct 2016 03:11:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307253 - in stable/10/sys: cam/ata sys X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Oct 2016 03:11:32 -0000 Author: sephe Date: Fri Oct 14 03:11:31 2016 New Revision: 307253 URL: https://svnweb.freebsd.org/changeset/base/307253 Log: MFC 306396 cam/ata: Allow drivers to veto ATA disk attachment. This eventhandler is mainly used by VMs, e.g. Hyper-V, whose disk controllers share the disks with the simulated ATA controllers. Submitted by: Hongjiang Zhang Discussed with: mav Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7693 Modified: stable/10/sys/cam/ata/ata_xpt.c stable/10/sys/sys/eventhandler.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/cam/ata/ata_xpt.c ============================================================================== --- stable/10/sys/cam/ata/ata_xpt.c Fri Oct 14 03:00:53 2016 (r307252) +++ stable/10/sys/cam/ata/ata_xpt.c Fri Oct 14 03:11:31 2016 (r307253) @@ -40,6 +40,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include #include @@ -827,12 +828,24 @@ noerror: { struct ccb_pathinq cpi; int16_t *ptr; + int veto = 0; ident_buf = &softc->ident_data; for (ptr = (int16_t *)ident_buf; ptr < (int16_t *)ident_buf + sizeof(struct ata_params)/2; ptr++) { *ptr = le16toh(*ptr); } + + /* + * Allow others to veto this ATA disk attachment. This + * is mainly used by VMs, whose disk controllers may + * share the disks with the simulated ATA controllers. + */ + EVENTHANDLER_INVOKE(ada_probe_veto, path, ident_buf, &veto); + if (veto) { + goto device_fail; + } + if (strncmp(ident_buf->model, "FX", 2) && strncmp(ident_buf->model, "NEC", 3) && strncmp(ident_buf->model, "Pioneer", 7) && Modified: stable/10/sys/sys/eventhandler.h ============================================================================== --- stable/10/sys/sys/eventhandler.h Fri Oct 14 03:00:53 2016 (r307252) +++ stable/10/sys/sys/eventhandler.h Fri Oct 14 03:11:31 2016 (r307253) @@ -283,4 +283,11 @@ typedef void (*unregister_framebuffer_fn EVENTHANDLER_DECLARE(register_framebuffer, register_framebuffer_fn); EVENTHANDLER_DECLARE(unregister_framebuffer, unregister_framebuffer_fn); +/* Veto ada attachment */ +struct cam_path; +struct ata_params; +typedef void (*ada_probe_veto_fn)(void *, struct cam_path *, + struct ata_params *, int *); +EVENTHANDLER_DECLARE(ada_probe_veto, ada_probe_veto_fn); + #endif /* SYS_EVENTHANDLER_H */ From owner-svn-src-all@freebsd.org Fri Oct 14 03:22:20 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E34F2C10063; Fri, 14 Oct 2016 03:22:20 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id A5202856; Fri, 14 Oct 2016 03:22:20 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9E3MJAH072900; Fri, 14 Oct 2016 03:22:19 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9E3MJrk072896; Fri, 14 Oct 2016 03:22:19 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610140322.u9E3MJrk072896@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Fri, 14 Oct 2016 03:22:19 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307254 - in stable/10/sys: conf dev/hyperv/stordisengage dev/hyperv/storvsc modules/hyperv modules/hyperv/stordisengage X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Oct 2016 03:22:21 -0000 Author: sephe Date: Fri Oct 14 03:22:19 2016 New Revision: 307254 URL: https://svnweb.freebsd.org/changeset/base/307254 Log: MFC 306426 hyperv/storvsc: Fix the blkvsc disk attachment issues. - The original 'disengage' ATA controller model does not work properly for all possible disk configurations. Use the newly added ATA disk veto eventhandler to fit into all possible disk configuration. - If the 'invalid LUN' happens on blkvsc controllers, return CAM_DEV_NOT_THERE so that CAM will not destroy attached disks under the blkvsc controllers. Submitted by: Hongjiang Zhang Discussed with: mav Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7693 Deleted: stable/10/sys/dev/hyperv/stordisengage/ stable/10/sys/modules/hyperv/stordisengage/ Modified: stable/10/sys/conf/files.amd64 stable/10/sys/conf/files.i386 stable/10/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c stable/10/sys/modules/hyperv/Makefile Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/conf/files.amd64 ============================================================================== --- stable/10/sys/conf/files.amd64 Fri Oct 14 03:11:31 2016 (r307253) +++ stable/10/sys/conf/files.amd64 Fri Oct 14 03:22:19 2016 (r307254) @@ -264,7 +264,6 @@ dev/hwpmc/hwpmc_x86.c optional hwpmc dev/hyperv/netvsc/hv_net_vsc.c optional hyperv dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c optional hyperv dev/hyperv/netvsc/hv_rndis_filter.c optional hyperv -dev/hyperv/stordisengage/hv_ata_pci_disengage.c optional hyperv dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c optional hyperv dev/hyperv/utilities/hv_heartbeat.c optional hyperv dev/hyperv/utilities/hv_kvp.c optional hyperv Modified: stable/10/sys/conf/files.i386 ============================================================================== --- stable/10/sys/conf/files.i386 Fri Oct 14 03:11:31 2016 (r307253) +++ stable/10/sys/conf/files.i386 Fri Oct 14 03:22:19 2016 (r307254) @@ -241,7 +241,6 @@ dev/hwpmc/hwpmc_x86.c optional hwpmc dev/hyperv/netvsc/hv_net_vsc.c optional hyperv dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c optional hyperv dev/hyperv/netvsc/hv_rndis_filter.c optional hyperv -dev/hyperv/stordisengage/hv_ata_pci_disengage.c optional hyperv dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c optional hyperv dev/hyperv/utilities/hv_heartbeat.c optional hyperv dev/hyperv/utilities/hv_kvp.c optional hyperv Modified: stable/10/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c ============================================================================== --- stable/10/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c Fri Oct 14 03:11:31 2016 (r307253) +++ stable/10/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c Fri Oct 14 03:22:19 2016 (r307254) @@ -60,6 +60,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -202,6 +203,7 @@ struct storvsc_softc { struct vmbus_channel *hs_sel_chan[MAXCPU]; }; +static eventhandler_tag storvsc_handler_tag; /* * The size of the vmscsi_request has changed in win8. The * additional size is for the newly added elements in the @@ -898,21 +900,15 @@ hv_storvsc_on_channel_callback(struct vm static int storvsc_probe(device_t dev) { - int ata_disk_enable = 0; int ret = ENXIO; switch (storvsc_get_storage_type(dev)) { case DRIVER_BLKVSC: if(bootverbose) - device_printf(dev, "DRIVER_BLKVSC-Emulated ATA/IDE probe\n"); - if (!getenv_int("hw.ata.disk_enable", &ata_disk_enable)) { - if(bootverbose) - device_printf(dev, - "Enlightened ATA/IDE detected\n"); - device_set_desc(dev, g_drv_props_table[DRIVER_BLKVSC].drv_desc); - ret = BUS_PROBE_DEFAULT; - } else if(bootverbose) - device_printf(dev, "Emulated ATA/IDE set (hw.ata.disk_enable set)\n"); + device_printf(dev, + "Enlightened ATA/IDE detected\n"); + device_set_desc(dev, g_drv_props_table[DRIVER_BLKVSC].drv_desc); + ret = BUS_PROBE_DEFAULT; break; case DRIVER_STORVSC: if(bootverbose) @@ -2155,27 +2151,45 @@ storvsc_io_done(struct hv_storvsc_reques ccb->ccb_h.status &= ~CAM_STATUS_MASK; if (vm_srb->scsi_status == SCSI_STATUS_OK) { const struct scsi_generic *cmd; - + cmd = (const struct scsi_generic *) + ((ccb->ccb_h.flags & CAM_CDB_POINTER) ? + csio->cdb_io.cdb_ptr : csio->cdb_io.cdb_bytes); if (vm_srb->srb_status != SRB_STATUS_SUCCESS) { - if (vm_srb->srb_status == SRB_STATUS_INVALID_LUN) { - xpt_print(ccb->ccb_h.path, "invalid LUN %d\n", - vm_srb->lun); - } else { - xpt_print(ccb->ccb_h.path, "Unknown SRB flag: %d\n", - vm_srb->srb_status); - } /* * If there are errors, for example, invalid LUN, * host will inform VM through SRB status. */ - ccb->ccb_h.status |= CAM_SEL_TIMEOUT; + if (bootverbose) { + if (vm_srb->srb_status == SRB_STATUS_INVALID_LUN) { + xpt_print(ccb->ccb_h.path, + "invalid LUN %d for op: %s\n", + vm_srb->lun, + scsi_op_desc(cmd->opcode, NULL)); + } else { + xpt_print(ccb->ccb_h.path, + "Unknown SRB flag: %d for op: %s\n", + vm_srb->srb_status, + scsi_op_desc(cmd->opcode, NULL)); + } + } + + /* + * XXX For a selection timeout, all of the LUNs + * on the target will be gone. It works for SCSI + * disks, but does not work for IDE disks. + * + * For CAM_DEV_NOT_THERE, CAM will only get + * rid of the device(s) specified by the path. + */ + if (storvsc_get_storage_type(sc->hs_dev) == + DRIVER_STORVSC) + ccb->ccb_h.status |= CAM_SEL_TIMEOUT; + else + ccb->ccb_h.status |= CAM_DEV_NOT_THERE; } else { ccb->ccb_h.status |= CAM_REQ_CMP; } - cmd = (const struct scsi_generic *) - ((ccb->ccb_h.flags & CAM_CDB_POINTER) ? - csio->cdb_io.cdb_ptr : csio->cdb_io.cdb_bytes); if (cmd->opcode == INQUIRY) { struct scsi_inquiry_data *inq_data = (struct scsi_inquiry_data *)csio->data_ptr; @@ -2287,3 +2301,58 @@ storvsc_get_storage_type(device_t dev) return DRIVER_STORVSC; return DRIVER_UNKNOWN; } + +#define PCI_VENDOR_INTEL 0x8086 +#define PCI_PRODUCT_PIIX4 0x7111 + +static void +storvsc_ada_probe_veto(void *arg __unused, struct cam_path *path, + struct ata_params *ident_buf __unused, int *veto) +{ + + /* + * The ATA disks are shared with the controllers managed + * by this driver, so veto the ATA disks' attachment; the + * ATA disks will be attached as SCSI disks once this driver + * attached. + */ + if (path->device->protocol == PROTO_ATA) { + struct ccb_pathinq cpi; + + bzero(&cpi, sizeof(cpi)); + xpt_setup_ccb(&cpi.ccb_h, path, CAM_PRIORITY_NONE); + cpi.ccb_h.func_code = XPT_PATH_INQ; + xpt_action((union ccb *)&cpi); + if (cpi.ccb_h.status == CAM_REQ_CMP && + cpi.hba_vendor == PCI_VENDOR_INTEL && + cpi.hba_device == PCI_PRODUCT_PIIX4) { + (*veto)++; + if (bootverbose) { + xpt_print(path, + "Disable ATA disks on " + "simulated ATA controller (0x%04x%04x)\n", + cpi.hba_device, cpi.hba_vendor); + } + } + } +} + +static void +storvsc_sysinit(void *arg __unused) +{ + if (vm_guest == VM_GUEST_HV) { + storvsc_handler_tag = EVENTHANDLER_REGISTER(ada_probe_veto, + storvsc_ada_probe_veto, NULL, EVENTHANDLER_PRI_ANY); + } +} +SYSINIT(storvsc_sys_init, SI_SUB_DRIVERS, SI_ORDER_SECOND, storvsc_sysinit, + NULL); + +static void +storvsc_sysuninit(void *arg __unused) +{ + if (storvsc_handler_tag != NULL) + EVENTHANDLER_DEREGISTER(ada_probe_veto, storvsc_handler_tag); +} +SYSUNINIT(storvsc_sys_uninit, SI_SUB_DRIVERS, SI_ORDER_SECOND, + storvsc_sysuninit, NULL); Modified: stable/10/sys/modules/hyperv/Makefile ============================================================================== --- stable/10/sys/modules/hyperv/Makefile Fri Oct 14 03:11:31 2016 (r307253) +++ stable/10/sys/modules/hyperv/Makefile Fri Oct 14 03:22:19 2016 (r307254) @@ -1,5 +1,5 @@ # $FreeBSD$ -SUBDIR = vmbus netvsc stordisengage storvsc utilities +SUBDIR = vmbus netvsc storvsc utilities .include From owner-svn-src-all@freebsd.org Fri Oct 14 03:25:17 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 6D6EFC10163; Fri, 14 Oct 2016 03:25:17 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mail105.syd.optusnet.com.au (mail105.syd.optusnet.com.au [211.29.132.249]) by mx1.freebsd.org (Postfix) with ESMTP id 2EE7AA46; Fri, 14 Oct 2016 03:25:16 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from besplex.bde.org (c110-21-100-78.carlnfd1.nsw.optusnet.com.au [110.21.100.78]) by mail105.syd.optusnet.com.au (Postfix) with ESMTPS id 3CE9710425F2; Fri, 14 Oct 2016 14:02:48 +1100 (AEDT) Date: Fri, 14 Oct 2016 14:02:47 +1100 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: Ed Maste cc: Bruce Evans , "src-committers@freebsd.org" , "svn-src-all@freebsd.org" , "svn-src-head@freebsd.org" Subject: Re: svn commit: r307231 - head/lib/libgcc_s In-Reply-To: Message-ID: <20161014132243.M1338@besplex.bde.org> References: <201610131918.u9DJI0bX085695@repo.freebsd.org> <20161014113603.F1039@besplex.bde.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.1 cv=RIxOZNW+ c=1 sm=1 tr=0 a=uGjuzT6u7JdBDS7kH8taPg==:117 a=uGjuzT6u7JdBDS7kH8taPg==:17 a=L9H7d07YOLsA:10 a=9cW_t1CCXrUA:10 a=s5jvgZ67dGcA:10 a=kj9zAlcOel0A:10 a=PO7r1zJSAAAA:8 a=nd2t5aUcH_zjbgAxzD4A:9 a=CjuIK1q_8ugA:10 a=Oa0T6EYmKFNB-xRHvYM1:22 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Oct 2016 03:25:17 -0000 On Fri, 14 Oct 2016, Ed Maste wrote: > Hi Bruce, thank you for the detailed response. > > On 14 October 2016 at 01:53, Bruce Evans wrote: >>> compiler-rt's complex division support routines contain calls to >>> compiler builtins such as `__builtin_scalbnl`. Unfortunately Clang >>> turns these back into a call to `scalbnl`. >> >> gcc-4.2 has the same bug. > > Oh, interesting. Do you know off hand if it's resolved in later GCC? Don't know. > It seems particularly unfortunate for the compiler to report (by > whatever mechanism) that a builtin exists, and then just turn that > builtin into a library call. Since there is no documentation, I sometimes use strings -a | grep builtin on the compiler binary to find builtins. This finds that there are too many for clang (4655 lines starting with __builtin for the amd64 binary). Then write some code to see if they are actual builtins. >>> For now link libm's C version of the required support routines. >> >> Even libm doesn't use these in some cases. i386 mostly uses asm >> versions. Hopefully the rt division routines don't need to be efficient >> because they are rarely called. > > Most likely I'll switch to the asm versions across suitable > architectures in a subsequent change, mirroring the choices made in > libm. I just wanted to get a version in, to enable further testing > (ports exp-runs, etc.) of this libunwind / compiler-rt combination. The ifdefs in the makefiles might get complicated sonce it was not designed for this. I usually build libm stand-alone, often with older compilers, and don't like any dependencies on other libraries or includes in it (I use stub libraries and includes). scalbn() is also in libc under the name ldexp(). This causes various messes. It used to have clones of a C implementation in alpha, amd64, arm, i386, ia64, powerpc and sparc64 (where at least the i386 version is in inline asm). This was cleaned up by removing all the MD implementations and using 1 generic C implementation with no inline asm. Then it was uncleaned by adding an extern asm version for mips. But the mips Makefile doesn't use this, except possibly by a magic .c.S suffix translation. The msun Makefiles have the relatively minor magic for suffixes. (They list the .c and .S file and then remove the .c file from the final list.) Bruce From owner-svn-src-all@freebsd.org Fri Oct 14 03:26:26 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 54BAFC101E4; Fri, 14 Oct 2016 03:26:26 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 12757BD6; Fri, 14 Oct 2016 03:26:25 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9E3QPSX073133; Fri, 14 Oct 2016 03:26:25 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9E3QP1G073132; Fri, 14 Oct 2016 03:26:25 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610140326.u9E3QP1G073132@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Fri, 14 Oct 2016 03:26:25 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307255 - stable/10/sys/dev/hyperv/netvsc X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Oct 2016 03:26:26 -0000 Author: sephe Date: Fri Oct 14 03:26:24 2016 New Revision: 307255 URL: https://svnweb.freebsd.org/changeset/base/307255 Log: MFC 306431,306432 306431 hyperv/hn: Move TX tasks' draining into hn_suspend(). This prepares to consolidate hn_stop() and netvsc_detach(). Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8055 306432 hyperv/hn: Consolidate hn_init() and hn_stop() Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8056 Modified: stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Fri Oct 14 03:22:19 2016 (r307254) +++ stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Fri Oct 14 03:26:24 2016 (r307255) @@ -336,7 +336,6 @@ static void hn_fixup_tx_data(struct hn_s static void hn_destroy_tx_data(struct hn_softc *); static void hn_start_taskfunc(void *, int); static void hn_start_txeof_taskfunc(void *, int); -static void hn_stop_tx_tasks(struct hn_softc *); static int hn_encap(struct hn_tx_ring *, struct hn_txdesc *, struct mbuf **); static int hn_create_rx_data(struct hn_softc *sc, int); static void hn_destroy_rx_data(struct hn_softc *sc); @@ -352,6 +351,8 @@ static void hn_synth_detach(struct hn_so static bool hn_tx_ring_pending(struct hn_tx_ring *); static void hn_suspend(struct hn_softc *); static void hn_resume(struct hn_softc *); +static void hn_rx_drain(struct vmbus_channel *); +static void hn_tx_resume(struct hn_softc *, int); static void hn_tx_ring_qflush(struct hn_tx_ring *); static void hn_nvs_handle_notify(struct hn_softc *sc, @@ -773,8 +774,6 @@ netvsc_detach(device_t dev) hn_synth_detach(sc); HN_UNLOCK(sc); - hn_stop_tx_tasks(sc); - ifmedia_removeall(&sc->hn_media); hn_destroy_rx_data(sc); hn_destroy_tx_data(sc); @@ -1796,25 +1795,19 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, static void hn_stop(struct hn_softc *sc) { - struct ifnet *ifp; + struct ifnet *ifp = sc->hn_ifp; int i; HN_LOCK_ASSERT(sc); - ifp = sc->hn_ifp; - - if (bootverbose) - printf(" Closing Device ...\n"); + /* Clear RUNNING bit _before_ hn_suspend() */ + atomic_clear_int(&ifp->if_drv_flags, IFF_DRV_RUNNING); + hn_suspend(sc); - atomic_clear_int(&ifp->if_drv_flags, - (IFF_DRV_RUNNING | IFF_DRV_OACTIVE)); + /* Clear OACTIVE bit. */ + atomic_clear_int(&ifp->if_drv_flags, IFF_DRV_OACTIVE); for (i = 0; i < sc->hn_tx_ring_inuse; ++i) sc->hn_tx_ring[i].hn_oactive = 0; - - if_link_state_change(ifp, LINK_STATE_DOWN); - - /* Disable RX by clearing RX filter. */ - hn_rndis_set_rxfilter(sc, 0); } /* @@ -1878,27 +1871,29 @@ do_sched: static void hn_init_locked(struct hn_softc *sc) { - struct ifnet *ifp; - int ret, i; + struct ifnet *ifp = sc->hn_ifp; + int i; HN_LOCK_ASSERT(sc); - ifp = sc->hn_ifp; - - if (ifp->if_drv_flags & IFF_DRV_RUNNING) { + if (ifp->if_drv_flags & IFF_DRV_RUNNING) return; - } /* TODO: add hn_rx_filter */ - ret = hn_rndis_set_rxfilter(sc, NDIS_PACKET_TYPE_PROMISCUOUS); - if (ret != 0) - return; + hn_rndis_set_rxfilter(sc, NDIS_PACKET_TYPE_PROMISCUOUS); + /* Clear OACTIVE bit. */ atomic_clear_int(&ifp->if_drv_flags, IFF_DRV_OACTIVE); for (i = 0; i < sc->hn_tx_ring_inuse; ++i) sc->hn_tx_ring[i].hn_oactive = 0; + /* Clear TX 'suspended' bit. */ + hn_tx_resume(sc, sc->hn_tx_ring_inuse); + + /* Everything is ready; unleash! */ atomic_set_int(&ifp->if_drv_flags, IFF_DRV_RUNNING); + + /* TODO: check RNDIS link status. */ if_link_state_change(ifp, LINK_STATE_UP); } @@ -2991,19 +2986,6 @@ hn_start_txeof_taskfunc(void *xtxr, int mtx_unlock(&txr->hn_tx_lock); } -static void -hn_stop_tx_tasks(struct hn_softc *sc) -{ - int i; - - for (i = 0; i < sc->hn_tx_ring_inuse; ++i) { - struct hn_tx_ring *txr = &sc->hn_tx_ring[i]; - - taskqueue_drain(txr->hn_tx_taskq, &txr->hn_tx_task); - taskqueue_drain(txr->hn_tx_taskq, &txr->hn_txeof_task); - } -} - static int hn_xmit(struct hn_tx_ring *txr, int len) { @@ -3591,6 +3573,9 @@ hn_suspend(struct hn_softc *sc) /* Wait for all pending sends to finish. */ while (hn_tx_ring_pending(txr)) pause("hnwtx", 1 /* 1 tick */); + + taskqueue_drain(txr->hn_tx_taskq, &txr->hn_tx_task); + taskqueue_drain(txr->hn_tx_taskq, &txr->hn_txeof_task); } /* @@ -3621,9 +3606,25 @@ hn_suspend(struct hn_softc *sc) } static void +hn_tx_resume(struct hn_softc *sc, int tx_ring_cnt) +{ + int i; + + KASSERT(tx_ring_cnt <= sc->hn_tx_ring_cnt, + ("invalid TX ring count %d", tx_ring_cnt)); + + for (i = 0; i < tx_ring_cnt; ++i) { + struct hn_tx_ring *txr = &sc->hn_tx_ring[i]; + + mtx_lock(&txr->hn_tx_lock); + txr->hn_suspended = 0; + mtx_unlock(&txr->hn_tx_lock); + } +} + +static void hn_resume(struct hn_softc *sc) { - struct hn_tx_ring *txr; int i; HN_LOCK_ASSERT(sc); @@ -3638,13 +3639,7 @@ hn_resume(struct hn_softc *sc) * Make sure to clear suspend status on "all" TX rings, * since hn_tx_ring_inuse can be changed after hn_suspend(). */ - for (i = 0; i < sc->hn_tx_ring_cnt; ++i) { - txr = &sc->hn_tx_ring[i]; - - mtx_lock(&txr->hn_tx_lock); - txr->hn_suspended = 0; - mtx_unlock(&txr->hn_tx_lock); - } + hn_tx_resume(sc, sc->hn_tx_ring_cnt); if (!hn_use_if_start) { /* @@ -3659,7 +3654,8 @@ hn_resume(struct hn_softc *sc) * Kick start TX. */ for (i = 0; i < sc->hn_tx_ring_inuse; ++i) { - txr = &sc->hn_tx_ring[i]; + struct hn_tx_ring *txr = &sc->hn_tx_ring[i]; + /* * Use txeof task, so that any pending oactive can be * cleared properly. From owner-svn-src-all@freebsd.org Fri Oct 14 03:32:21 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 7C6CDC1054F; Fri, 14 Oct 2016 03:32:21 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 3F406B2; Fri, 14 Oct 2016 03:32:21 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9E3WKrP076791; Fri, 14 Oct 2016 03:32:20 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9E3WKIT076789; Fri, 14 Oct 2016 03:32:20 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610140332.u9E3WKIT076789@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Fri, 14 Oct 2016 03:32:20 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307256 - stable/10/sys/dev/hyperv/netvsc X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Oct 2016 03:32:21 -0000 Author: sephe Date: Fri Oct 14 03:32:20 2016 New Revision: 307256 URL: https://svnweb.freebsd.org/changeset/base/307256 Log: MFC 306433 hyperv/hn: Don't set HASHVAL pktinfo for NDIS < 6.30 This unbreaks packet sending on WS2008R2. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8057 Modified: stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h Fri Oct 14 03:26:24 2016 (r307255) +++ stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h Fri Oct 14 03:32:20 2016 (r307256) @@ -168,6 +168,7 @@ struct hn_tx_ring { struct buf_ring *hn_mbuf_br; int hn_oactive; int hn_tx_idx; + int hn_tx_flags; struct mtx hn_tx_lock; struct hn_softc *hn_sc; @@ -194,10 +195,10 @@ struct hn_tx_ring { struct hn_txdesc *hn_txdesc; bus_dma_tag_t hn_tx_rndis_dtag; struct sysctl_oid *hn_tx_sysctl_tree; - int hn_tx_flags; } __aligned(CACHE_LINE_SIZE); #define HN_TX_FLAG_ATTACHED 0x1 +#define HN_TX_FLAG_HASHVAL 0x2 /* support HASHVAL pktinfo */ /* * Device-specific softc structure Modified: stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Fri Oct 14 03:26:24 2016 (r307255) +++ stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Fri Oct 14 03:32:20 2016 (r307256) @@ -1028,14 +1028,16 @@ hn_encap(struct hn_tx_ring *txr, struct pkt->rm_pktinfooffset = sizeof(*pkt); pkt->rm_pktinfolen = 0; - /* - * Set the hash value for this packet, so that the host could - * dispatch the TX done event for this packet back to this TX - * ring's channel. - */ - pi_data = hn_rndis_pktinfo_append(pkt, HN_RNDIS_PKT_LEN, - HN_NDIS_HASH_VALUE_SIZE, HN_NDIS_PKTINFO_TYPE_HASHVAL); - *pi_data = txr->hn_tx_idx; + if (txr->hn_tx_flags & HN_TX_FLAG_HASHVAL) { + /* + * Set the hash value for this packet, so that the host could + * dispatch the TX done event for this packet back to this TX + * ring's channel. + */ + pi_data = hn_rndis_pktinfo_append(pkt, HN_RNDIS_PKT_LEN, + HN_NDIS_HASH_VALUE_SIZE, HN_NDIS_PKTINFO_TYPE_HASHVAL); + *pi_data = txr->hn_tx_idx; + } if (m_head->m_flags & M_VLANTAG) { pi_data = hn_rndis_pktinfo_append(pkt, HN_RNDIS_PKT_LEN, @@ -2940,6 +2942,12 @@ hn_fixup_tx_data(struct hn_softc *sc) for (i = 0; i < sc->hn_tx_ring_cnt; ++i) sc->hn_tx_ring[i].hn_csum_assist = csum_assist; + + if (sc->hn_ndis_ver >= HN_NDIS_VERSION_6_30) { + /* Support HASHVAL pktinfo on TX path. */ + for (i = 0; i < sc->hn_tx_ring_cnt; ++i) + sc->hn_tx_ring[i].hn_tx_flags |= HN_TX_FLAG_HASHVAL; + } } static void From owner-svn-src-all@freebsd.org Fri Oct 14 03:37:37 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id AFDC8C105F6; Fri, 14 Oct 2016 03:37:37 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 645B3300; Fri, 14 Oct 2016 03:37:37 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9E3baNm077183; Fri, 14 Oct 2016 03:37:36 GMT (envelope-from gonzo@FreeBSD.org) Received: (from gonzo@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9E3baB7077179; Fri, 14 Oct 2016 03:37:36 GMT (envelope-from gonzo@FreeBSD.org) Message-Id: <201610140337.u9E3baB7077179@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: gonzo set sender to gonzo@FreeBSD.org using -f From: Oleksandr Tymoshenko Date: Fri, 14 Oct 2016 03:37:36 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307257 - in head/sys: arm/broadcom/bcm2835 arm64/broadcom arm64/broadcom/bcm2837 arm64/conf conf X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Oct 2016 03:37:37 -0000 Author: gonzo Date: Fri Oct 14 03:37:35 2016 New Revision: 307257 URL: https://svnweb.freebsd.org/changeset/base/307257 Log: Add initial Raspberry Pi 3 support RPI3 kernel config builds kernel compatible with latest upstream device tree and firmware: https://github.com/raspberrypi/firmware/tree/master/boot As of today it's 597c662a613df1144a6bc43e5f4505d83bd748ca Default console is PL01x, so pi3-disable-bt dt overlay should be configured in config.txt and stock U-Boot should be patched to use proper serial port. Yet unsupported: SMP, VCHIQ, RNG driver. RNG requires some work due to upstream device tree incompatibility. Multiple people contributed to this work over time: db@, loos@, manu@ Added: head/sys/arm64/broadcom/ head/sys/arm64/broadcom/bcm2837/ head/sys/arm64/broadcom/bcm2837/files.bcm2837 (contents, props changed) head/sys/arm64/conf/RPI3 (contents, props changed) Modified: head/sys/arm/broadcom/bcm2835/bcm2835_vcbus.h head/sys/conf/options.arm64 Modified: head/sys/arm/broadcom/bcm2835/bcm2835_vcbus.h ============================================================================== --- head/sys/arm/broadcom/bcm2835/bcm2835_vcbus.h Fri Oct 14 03:32:20 2016 (r307256) +++ head/sys/arm/broadcom/bcm2835/bcm2835_vcbus.h Fri Oct 14 03:37:35 2016 (r307257) @@ -37,7 +37,7 @@ #define BCM2835_VCBUS_IO_BASE 0x7E000000 #define BCM2835_VCBUS_SDRAM_UNCACHED 0xC0000000 -#ifdef SOC_BCM2836 +#if defined(SOC_BCM2836) || defined(SOC_BCM2837) #define BCM2835_ARM_IO_BASE 0x3f000000 #define BCM2835_VCBUS_SDRAM_BASE BCM2835_VCBUS_SDRAM_UNCACHED #else Added: head/sys/arm64/broadcom/bcm2837/files.bcm2837 ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/arm64/broadcom/bcm2837/files.bcm2837 Fri Oct 14 03:37:35 2016 (r307257) @@ -0,0 +1,4 @@ +# $FreeBSD$ + +arm/broadcom/bcm2835/bcm2836.c standard +kern/kern_clocksource.c standard Added: head/sys/arm64/conf/RPI3 ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/arm64/conf/RPI3 Fri Oct 14 03:37:35 2016 (r307257) @@ -0,0 +1,160 @@ +# +# +# RPI3 -- Custom configuration for the Raspberry Pi 3 +# +# For more information on this file, please read the config(5) manual page, +# and/or the handbook section on Kernel Configuration Files: +# +# http://www.FreeBSD.org/doc/en_US.ISO8859-1/books/handbook/kernelconfig-config.html +# +# The handbook is also available locally in /usr/share/doc/handbook +# if you've installed the doc distribution, otherwise always see the +# FreeBSD World Wide Web server (http://www.FreeBSD.org/) for the +# latest information. +# +# An exhaustive list of options and more detailed explanations of the +# device lines is also present in the ../../conf/NOTES and NOTES files. +# If you are in doubt as to the purpose or necessity of a line, check first +# in NOTES. +# +# $FreeBSD$ + +cpu ARM64 +ident RPI3 + +files "../../arm/broadcom/bcm2835/files.bcm283x" +files "../broadcom/bcm2837/files.bcm2837" + +makeoptions DEBUG=-g # Build kernel with gdb(1) debug symbols +#makeoptions WITH_CTF=1 # Run ctfconvert(1) for DTrace support + +options SCHED_ULE # ULE scheduler +options PREEMPTION # Enable kernel thread preemption +options INET # InterNETworking +options INET6 # IPv6 communications protocols +options IPSEC # IP (v4/v6) security +options TCP_HHOOK # hhook(9) framework for TCP +options TCP_OFFLOAD # TCP offload +options SCTP # Stream Control Transmission Protocol +options FFS # Berkeley Fast Filesystem +options SOFTUPDATES # Enable FFS soft updates support +options UFS_ACL # Support for access control lists +options UFS_DIRHASH # Improve performance on big directories +options UFS_GJOURNAL # Enable gjournal-based UFS journaling +options QUOTA # Enable disk quotas for UFS +options MD_ROOT # MD is a potential root device +options NFSCL # Network Filesystem Client +options NFSD # Network Filesystem Server +options NFSLOCKD # Network Lock Manager +options NFS_ROOT # NFS usable as /, requires NFSCL +options MSDOSFS # MSDOS Filesystem +options CD9660 # ISO 9660 Filesystem +options PROCFS # Process filesystem (requires PSEUDOFS) +options PSEUDOFS # Pseudo-filesystem framework +options GEOM_PART_GPT # GUID Partition Tables. +options GEOM_RAID # Soft RAID functionality. +options GEOM_LABEL # Provides labelization +options SCSI_DELAY=5000 # Delay (in ms) before probing SCSI +options KTRACE # ktrace(1) support +options STACK # stack(9) support +options SYSVSHM # SYSV-style shared memory +options SYSVMSG # SYSV-style message queues +options SYSVSEM # SYSV-style semaphores +options _KPOSIX_PRIORITY_SCHEDULING # POSIX P1003_1B real-time extensions +options PRINTF_BUFR_SIZE=128 # Prevent printf output being interspersed. +options KBD_INSTALL_CDEV # install a CDEV entry in /dev +options HWPMC_HOOKS # Necessary kernel hooks for hwpmc(4) +options AUDIT # Security event auditing +options CAPABILITY_MODE # Capsicum capability mode +options CAPABILITIES # Capsicum capabilities +options MAC # TrustedBSD MAC Framework +options KDTRACE_FRAME # Ensure frames are compiled in +options KDTRACE_HOOKS # Kernel DTrace hooks +options VFP # Floating-point support +options RACCT # Resource accounting framework +options RACCT_DEFAULT_TO_DISABLED # Set kern.racct.enable=0 by default +options RCTL # Resource limits +# SMP is not there yet +# options SMP +options INTRNG + +# Debugging support. Always need this: +options KDB # Enable kernel debugger support. +options KDB_TRACE # Print a stack trace for a panic. +# For full debugger support use (turn off in stable branch): +options DDB # Support DDB. +#options GDB # Support remote GDB. +options DEADLKRES # Enable the deadlock resolver +options INVARIANTS # Enable calls of extra sanity checking +options INVARIANT_SUPPORT # Extra sanity checks of internal structures, required by INVARIANTS +options WITNESS # Enable checks to detect deadlocks and cycles +options WITNESS_SKIPSPIN # Don't run witness on spinlocks for speed +options MALLOC_DEBUG_MAXZONES=8 # Separate malloc(9) zones + +options SOC_BCM2837 + +options ROOTDEVNAME=\"ufs:mmcsd0s2\" + +# SPI +device spibus +device bcm2835_spi + +# MMC/SD/SDIO Card slot support +device sdhci +device mmc # mmc/sd bus +device mmcsd # mmc/sd flash cards + +# Serial (COM) ports +device uart # Generic UART driver +device uart_ns8250 # ns8250-type UART driver +device pl011 + +# USB support +options USB_DEBUG # enable debug msgs +device usb # USB Bus (required) +device dwcotg # DWC OTG controller + +# USB storage support +device scbus +device da +device umass + +# USB ethernet support +device smcphy +device mii +device smsc + +# Comment following lines for boot console on serial port +device vt +device kbdmux +device ukbd # Keyboard + +# GPIO +device gpio +device fdt_pinctrl +device gpioled + +# I2C +device iicbus +device bcm2835_bsc + +# Not ready for ARM64 yet +# device vchiq +# device sound + +# Pseudo devices. +device bpf +device loop # Network loopback +device random # Entropy device +device ether # Ethernet support +device vlan # 802.1Q VLAN support +device tun # Packet tunnel. +device md # Memory "disks" +device gif # IPv6 and IPv4 tunneling +device firmware # firmware assist module +device psci # Support for ARM PSCI + +options FDT + +# The crypto framework is required by IPSEC +device crypto # Required by IPSEC Modified: head/sys/conf/options.arm64 ============================================================================== --- head/sys/conf/options.arm64 Fri Oct 14 03:32:20 2016 (r307256) +++ head/sys/conf/options.arm64 Fri Oct 14 03:37:35 2016 (r307257) @@ -9,5 +9,6 @@ VFP opt_global.h # SoC Support SOC_ALLWINNER_A64 opt_soc.h +SOC_BCM2837 opt_global.h SOC_CAVM_THUNDERX opt_soc.h SOC_HISI_HI6220 opt_soc.h From owner-svn-src-all@freebsd.org Fri Oct 14 04:14:00 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id AC274C10ED2; Fri, 14 Oct 2016 04:14:00 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 7D3F382C; Fri, 14 Oct 2016 04:14:00 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9E4DxrN092124; Fri, 14 Oct 2016 04:13:59 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9E4DxYw092123; Fri, 14 Oct 2016 04:13:59 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610140413.u9E4DxYw092123@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Fri, 14 Oct 2016 04:13:59 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307258 - stable/10/sys/x86/x86 X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Oct 2016 04:14:00 -0000 Author: sephe Date: Fri Oct 14 04:13:59 2016 New Revision: 307258 URL: https://svnweb.freebsd.org/changeset/base/307258 Log: MFC 306481 x86/ioapic: Fix destination cpu for Hyper-V On Hyper-V: - Stick to the first cpu for all I/O APIC pins. - And don't allow destination cpu changes. Reviewed by: jhb Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7949 Modified: stable/10/sys/x86/x86/io_apic.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/x86/x86/io_apic.c ============================================================================== --- stable/10/sys/x86/x86/io_apic.c Fri Oct 14 03:37:35 2016 (r307257) +++ stable/10/sys/x86/x86/io_apic.c Fri Oct 14 04:13:59 2016 (r307258) @@ -325,6 +325,18 @@ ioapic_assign_cpu(struct intsrc *isrc, u u_int old_id; /* + * On Hyper-V: + * - Stick to the first cpu for all I/O APIC pins. + * - And don't allow destination cpu changes. + */ + if (vm_guest == VM_GUEST_HV) { + if (intpin->io_vector) + return (EINVAL); + else + apic_id = 0; + } + + /* * keep 1st core as the destination for NMI */ if (intpin->io_irq == IRQ_NMI) From owner-svn-src-all@freebsd.org Fri Oct 14 04:53:53 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 90176C0F61B; Fri, 14 Oct 2016 04:53:53 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4904F6D9; Fri, 14 Oct 2016 04:53:53 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9E4rqg7007255; Fri, 14 Oct 2016 04:53:52 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9E4rq2e007253; Fri, 14 Oct 2016 04:53:52 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610140453.u9E4rq2e007253@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Fri, 14 Oct 2016 04:53:52 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307259 - stable/10/sys/dev/hyperv/netvsc X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Oct 2016 04:53:53 -0000 Author: sephe Date: Fri Oct 14 04:53:52 2016 New Revision: 307259 URL: https://svnweb.freebsd.org/changeset/base/307259 Log: MFC 306482,306483 306482 hyperv/hn: If synthetic parts are detached, don't touch them. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8065 306483 hyperv/hn: Fix detach and attach error handling. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8066 Modified: stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h Fri Oct 14 04:13:59 2016 (r307258) +++ stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.h Fri Oct 14 04:53:52 2016 (r307259) @@ -253,6 +253,7 @@ struct hn_softc { #define HN_FLAG_CHIM_CONNECTED 0x0002 #define HN_FLAG_HAS_RSSKEY 0x0004 #define HN_FLAG_HAS_RSSIND 0x0008 +#define HN_FLAG_SYNTH_ATTACHED 0x0010 #define HN_CAP_VLAN 0x0001 #define HN_CAP_MTU 0x0002 Modified: stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Fri Oct 14 04:13:59 2016 (r307258) +++ stable/10/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Fri Oct 14 04:53:52 2016 (r307259) @@ -354,6 +354,7 @@ static void hn_resume(struct hn_softc *) static void hn_rx_drain(struct vmbus_channel *); static void hn_tx_resume(struct hn_softc *, int); static void hn_tx_ring_qflush(struct hn_tx_ring *); +static int netvsc_detach(device_t dev); static void hn_nvs_handle_notify(struct hn_softc *sc, const struct vmbus_chanpkt_hdr *pkt); @@ -407,6 +408,9 @@ hn_rss_reconfig(struct hn_softc *sc) HN_LOCK_ASSERT(sc); + if ((sc->hn_flags & HN_FLAG_SYNTH_ATTACHED) == 0) + return (ENXIO); + /* * Disable RSS first. * @@ -752,27 +756,28 @@ netvsc_attach(device_t dev) return (0); failed: - /* TODO: reuse netvsc_detach() */ - hn_destroy_tx_data(sc); - if (ifp != NULL) - if_free(ifp); + if (sc->hn_flags & HN_FLAG_SYNTH_ATTACHED) + hn_synth_detach(sc); + netvsc_detach(dev); return (error); } -/* - * TODO: Use this for error handling on attach path. - */ static int netvsc_detach(device_t dev) { struct hn_softc *sc = device_get_softc(dev); + struct ifnet *ifp = sc->hn_ifp; - /* TODO: ether_ifdetach */ - - HN_LOCK(sc); - /* TODO: hn_stop */ - hn_synth_detach(sc); - HN_UNLOCK(sc); + if (device_is_attached(dev)) { + HN_LOCK(sc); + if (sc->hn_flags & HN_FLAG_SYNTH_ATTACHED) { + if (ifp->if_drv_flags & IFF_DRV_RUNNING) + hn_stop(sc); + hn_synth_detach(sc); + } + HN_UNLOCK(sc); + ether_ifdetach(ifp); + } ifmedia_removeall(&sc->hn_media); hn_destroy_rx_data(sc); @@ -781,10 +786,12 @@ netvsc_detach(device_t dev) if (sc->hn_tx_taskq != hn_tx_taskq) taskqueue_free(sc->hn_tx_taskq); - vmbus_xact_ctx_destroy(sc->hn_xact); - HN_LOCK_DESTROY(sc); + if (sc->hn_xact != NULL) + vmbus_xact_ctx_destroy(sc->hn_xact); + + if_free(ifp); - /* TODO: if_free */ + HN_LOCK_DESTROY(sc); return (0); } @@ -1638,6 +1645,11 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, HN_LOCK(sc); + if ((sc->hn_flags & HN_FLAG_SYNTH_ATTACHED) == 0) { + HN_UNLOCK(sc); + break; + } + if ((sc->hn_caps & HN_CAP_MTU) == 0) { /* Can't change MTU */ HN_UNLOCK(sc); @@ -1691,6 +1703,11 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, case SIOCSIFFLAGS: HN_LOCK(sc); + if ((sc->hn_flags & HN_FLAG_SYNTH_ATTACHED) == 0) { + HN_UNLOCK(sc); + break; + } + if (ifp->if_flags & IFF_UP) { /* * If only the state of the PROMISC flag changed, @@ -1802,6 +1819,9 @@ hn_stop(struct hn_softc *sc) HN_LOCK_ASSERT(sc); + KASSERT(sc->hn_flags & HN_FLAG_SYNTH_ATTACHED, + ("synthetic parts were not attached")); + /* Clear RUNNING bit _before_ hn_suspend() */ atomic_clear_int(&ifp->if_drv_flags, IFF_DRV_RUNNING); hn_suspend(sc); @@ -1878,6 +1898,9 @@ hn_init_locked(struct hn_softc *sc) HN_LOCK_ASSERT(sc); + if ((sc->hn_flags & HN_FLAG_SYNTH_ATTACHED) == 0) + return; + if (ifp->if_drv_flags & IFF_DRV_RUNNING) return; @@ -3397,6 +3420,9 @@ hn_synth_attach(struct hn_softc *sc, int int error, nsubch, nchan, i; uint32_t old_caps; + KASSERT((sc->hn_flags & HN_FLAG_SYNTH_ATTACHED) == 0, + ("synthetic parts were attached")); + /* Save capabilities for later verification. */ old_caps = sc->hn_caps; sc->hn_caps = 0; @@ -3509,6 +3535,8 @@ back: error = hn_attach_subchans(sc); if (error) return (error); + + sc->hn_flags |= HN_FLAG_SYNTH_ATTACHED; return (0); } @@ -3522,6 +3550,9 @@ hn_synth_detach(struct hn_softc *sc) { HN_LOCK_ASSERT(sc); + KASSERT(sc->hn_flags & HN_FLAG_SYNTH_ATTACHED, + ("synthetic parts were not attached")); + /* Detach the RNDIS first. */ hn_rndis_detach(sc); @@ -3530,6 +3561,8 @@ hn_synth_detach(struct hn_softc *sc) /* Detach all of the channels. */ hn_detach_allchans(sc); + + sc->hn_flags &= ~HN_FLAG_SYNTH_ATTACHED; } static void From owner-svn-src-all@freebsd.org Fri Oct 14 05:05:25 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 9B9E6C0F92A; Fri, 14 Oct 2016 05:05:25 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4B2A3C4A; Fri, 14 Oct 2016 05:05:25 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9E55Oco011079; Fri, 14 Oct 2016 05:05:24 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9E55O2V011076; Fri, 14 Oct 2016 05:05:24 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610140505.u9E55O2V011076@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Fri, 14 Oct 2016 05:05:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307260 - in stable/10/sys: dev/hyperv/netvsc modules/hyperv/vmbus net X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Oct 2016 05:05:25 -0000 Author: sephe Date: Fri Oct 14 05:05:23 2016 New Revision: 307260 URL: https://svnweb.freebsd.org/changeset/base/307260 Log: MFC 306484,306485 306484 hyperv/vmbus: Add missing vmbus_if.c to module build. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8067 306485 hyperv/hn: Add stubs for OFFLOAD_CURRENT_CONFIG and NETWORK_CHANGE status Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8068 Modified: stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.c stable/10/sys/modules/hyperv/vmbus/Makefile stable/10/sys/net/rndis.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.c ============================================================================== --- stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.c Fri Oct 14 04:53:52 2016 (r307259) +++ stable/10/sys/dev/hyperv/netvsc/hv_rndis_filter.c Fri Oct 14 05:05:23 2016 (r307260) @@ -156,6 +156,15 @@ hv_rf_receive_indicate_status(struct hn_ netvsc_linkstatus_callback(sc, 0); break; + case RNDIS_STATUS_TASK_OFFLOAD_CURRENT_CONFIG: + /* Not really useful; ignore. */ + break; + + case RNDIS_STATUS_NETWORK_CHANGE: + /* TODO */ + if_printf(sc->hn_ifp, "network changed\n"); + break; + default: /* TODO: */ if_printf(sc->hn_ifp, "unknown RNDIS status 0x%08x\n", Modified: stable/10/sys/modules/hyperv/vmbus/Makefile ============================================================================== --- stable/10/sys/modules/hyperv/vmbus/Makefile Fri Oct 14 04:53:52 2016 (r307259) +++ stable/10/sys/modules/hyperv/vmbus/Makefile Fri Oct 14 05:05:23 2016 (r307260) @@ -11,6 +11,7 @@ SRCS= hyperv.c \ vmbus_br.c \ vmbus_chan.c \ vmbus_et.c \ + vmbus_if.c \ vmbus_xact.c SRCS+= acpi_if.h bus_if.h device_if.h opt_acpi.h vmbus_if.h Modified: stable/10/sys/net/rndis.h ============================================================================== --- stable/10/sys/net/rndis.h Fri Oct 14 04:53:52 2016 (r307259) +++ stable/10/sys/net/rndis.h Fri Oct 14 05:05:23 2016 (r307260) @@ -31,6 +31,8 @@ #define RNDIS_STATUS_PENDING 0x00000103L #define RNDIS_STATUS_MEDIA_CONNECT 0x4001000BL #define RNDIS_STATUS_MEDIA_DISCONNECT 0x4001000CL +#define RNDIS_STATUS_NETWORK_CHANGE 0x40010018L +#define RNDIS_STATUS_TASK_OFFLOAD_CURRENT_CONFIG 0x40020006L #define RNDIS_STATUS_BUFFER_OVERFLOW 0x80000005L #define RNDIS_STATUS_FAILURE 0xC0000001L #define RNDIS_STATUS_NOT_SUPPORTED 0xC00000BBL From owner-svn-src-all@freebsd.org Fri Oct 14 05:32:48 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 69238C0FE35; Fri, 14 Oct 2016 05:32:48 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 33A49850; Fri, 14 Oct 2016 05:32:48 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9E5WlHY022381; Fri, 14 Oct 2016 05:32:47 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9E5WlqF022380; Fri, 14 Oct 2016 05:32:47 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610140532.u9E5WlqF022380@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Fri, 14 Oct 2016 05:32:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307261 - head/sys/dev/hyperv/storvsc X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Oct 2016 05:32:48 -0000 Author: sephe Date: Fri Oct 14 05:32:47 2016 New Revision: 307261 URL: https://svnweb.freebsd.org/changeset/base/307261 Log: hyperv/stor: Fix off-by-one bug; this brings back TRIM support. Submitted by: Hongjiang Zhang Reported by: Lili Deng MFC after: 3 days Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8238 Modified: head/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c Modified: head/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c ============================================================================== --- head/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c Fri Oct 14 05:05:23 2016 (r307260) +++ head/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c Fri Oct 14 05:32:47 2016 (r307261) @@ -2210,7 +2210,7 @@ storvsc_io_done(struct hv_storvsc_reques resp_buf[3], resp_buf[4]); } if (vm_srb->srb_status == SRB_STATUS_SUCCESS && - data_len > SHORT_INQUIRY_LENGTH) { + data_len >= SHORT_INQUIRY_LENGTH) { char vendor[16]; cam_strvis(vendor, inq_data->vendor, From owner-svn-src-all@freebsd.org Fri Oct 14 05:41:53 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 4E790C110CF; Fri, 14 Oct 2016 05:41:53 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id F3163D6D; Fri, 14 Oct 2016 05:41:52 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9E5fqwU025479; Fri, 14 Oct 2016 05:41:52 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9E5fpxJ025478; Fri, 14 Oct 2016 05:41:51 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610140541.u9E5fpxJ025478@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Fri, 14 Oct 2016 05:41:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307262 - head/sys/dev/hyperv/netvsc X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Oct 2016 05:41:53 -0000 Author: sephe Date: Fri Oct 14 05:41:51 2016 New Revision: 307262 URL: https://svnweb.freebsd.org/changeset/base/307262 Log: hyperv/hn: Management parts always need suspend and resume. MFC after: 3 days Sponsored by: Microsoft Modified: head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Modified: head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c ============================================================================== --- head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Fri Oct 14 05:32:47 2016 (r307261) +++ head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Fri Oct 14 05:41:51 2016 (r307262) @@ -354,6 +354,8 @@ static void hn_suspend(struct hn_softc * static void hn_suspend_data(struct hn_softc *); static void hn_suspend_mgmt(struct hn_softc *); static void hn_resume(struct hn_softc *); +static void hn_resume_data(struct hn_softc *); +static void hn_resume_mgmt(struct hn_softc *); static void hn_rx_drain(struct vmbus_channel *); static void hn_tx_resume(struct hn_softc *, int); static void hn_tx_ring_qflush(struct hn_tx_ring *); @@ -1689,8 +1691,11 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, hn_set_lro_lenlim(sc, HN_LRO_LENLIM_MIN(ifp)); #endif - if (ifp->if_drv_flags & IFF_DRV_RUNNING) - hn_suspend(sc); + /* + * Suspend this interface before the synthetic parts + * are ripped. + */ + hn_suspend(sc); /* * Detach the synthetics parts, i.e. NVS and RNDIS. @@ -1708,9 +1713,10 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, hn_set_chim_size(sc, sc->hn_chim_szmax); hn_set_tso_maxsize(sc, hn_tso_maxlen, ifr->ifr_mtu); - /* All done! Resume now. */ - if (ifp->if_drv_flags & IFF_DRV_RUNNING) - hn_resume(sc); + /* + * All done! Resume the interface now. + */ + hn_resume(sc); HN_UNLOCK(sc); break; @@ -3717,7 +3723,8 @@ static void hn_suspend(struct hn_softc *sc) { - hn_suspend_data(sc); + if (sc->hn_ifp->if_drv_flags & IFF_DRV_RUNNING) + hn_suspend_data(sc); hn_suspend_mgmt(sc); } @@ -3739,7 +3746,7 @@ hn_tx_resume(struct hn_softc *sc, int tx } static void -hn_resume(struct hn_softc *sc) +hn_resume_data(struct hn_softc *sc) { int i; @@ -3779,6 +3786,11 @@ hn_resume(struct hn_softc *sc) */ taskqueue_enqueue(txr->hn_tx_taskq, &txr->hn_txeof_task); } +} + +static void +hn_resume_mgmt(struct hn_softc *sc) +{ /* * Kick off link status check. @@ -3788,6 +3800,15 @@ hn_resume(struct hn_softc *sc) } static void +hn_resume(struct hn_softc *sc) +{ + + if (sc->hn_ifp->if_drv_flags & IFF_DRV_RUNNING) + hn_resume_data(sc); + hn_resume_mgmt(sc); +} + +static void hn_nvs_handle_notify(struct hn_softc *sc, const struct vmbus_chanpkt_hdr *pkt) { const struct hn_nvs_hdr *hdr; From owner-svn-src-all@freebsd.org Fri Oct 14 05:48:00 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 97D51C11227; Fri, 14 Oct 2016 05:48:00 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 685848A; Fri, 14 Oct 2016 05:48:00 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9E5lx2g026366; Fri, 14 Oct 2016 05:47:59 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9E5lxcs026365; Fri, 14 Oct 2016 05:47:59 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610140547.u9E5lxcs026365@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Fri, 14 Oct 2016 05:47:59 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307263 - head/sys/dev/hyperv/vmbus X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Oct 2016 05:48:00 -0000 Author: sephe Date: Fri Oct 14 05:47:59 2016 New Revision: 307263 URL: https://svnweb.freebsd.org/changeset/base/307263 Log: hyperv/vmbus: Add __FBSDID Sponsored by: Microsoft Modified: head/sys/dev/hyperv/vmbus/vmbus_br.c Modified: head/sys/dev/hyperv/vmbus/vmbus_br.c ============================================================================== --- head/sys/dev/hyperv/vmbus/vmbus_br.c Fri Oct 14 05:41:51 2016 (r307262) +++ head/sys/dev/hyperv/vmbus/vmbus_br.c Fri Oct 14 05:47:59 2016 (r307263) @@ -26,6 +26,9 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include +__FBSDID("$FreeBSD$"); + #include #include #include From owner-svn-src-all@freebsd.org Fri Oct 14 06:56:08 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 29114C11D05; Fri, 14 Oct 2016 06:56:08 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id CF4ADE20; Fri, 14 Oct 2016 06:56:07 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9E6u67R052662; Fri, 14 Oct 2016 06:56:06 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9E6u6eM052660; Fri, 14 Oct 2016 06:56:06 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201610140656.u9E6u6eM052660@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Fri, 14 Oct 2016 06:56:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307264 - stable/11/sys/cam X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Oct 2016 06:56:08 -0000 Author: mav Date: Fri Oct 14 06:56:06 2016 New Revision: 307264 URL: https://svnweb.freebsd.org/changeset/base/307264 Log: MFC r306747, r307042: Fix ABI compat shims, broken by adding NVMe support. Modified: stable/11/sys/cam/cam_compat.c stable/11/sys/cam/cam_compat.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/cam/cam_compat.c ============================================================================== --- stable/11/sys/cam/cam_compat.c Fri Oct 14 05:47:59 2016 (r307263) +++ stable/11/sys/cam/cam_compat.c Fri Oct 14 06:56:06 2016 (r307264) @@ -149,7 +149,24 @@ cam_compat_handle_0x17(struct cdev *dev, ccbb = (uint8_t *)&hdr[1]; ccbb17 = (uint8_t *)&hdr17[1]; - bcopy(ccbb17, ccbb, CAM_0X17_DATA_LEN); + if (ccb->ccb_h.func_code == XPT_SET_TRAN_SETTINGS) { + struct ccb_trans_settings *cts; + struct ccb_trans_settings_0x17 *cts17; + + cts = &ccb->cts; + cts17 = (struct ccb_trans_settings_0x17 *)hdr17; + cts->type = cts17->type; + cts->protocol = cts17->protocol; + cts->protocol_version = cts17->protocol_version; + cts->transport = cts17->transport; + cts->transport_version = cts17->transport_version; + bcopy(&cts17->proto_specific, &cts->proto_specific, + sizeof(cts17->proto_specific)); + bcopy(&cts17->xport_specific, &cts->xport_specific, + sizeof(cts17->xport_specific)); + } else { + bcopy(ccbb17, ccbb, CAM_0X17_DATA_LEN); + } error = (cbfnp)(dev, cmd, (caddr_t)ccb, flag, td); @@ -205,6 +222,21 @@ cam_compat_handle_0x17(struct cdev *dev, cpi17->hba_device = cpi->hba_device; cpi17->hba_subvendor = cpi->hba_subvendor; cpi17->hba_subdevice = cpi->hba_subdevice; + } else if (ccb->ccb_h.func_code == XPT_GET_TRAN_SETTINGS) { + struct ccb_trans_settings *cts; + struct ccb_trans_settings_0x17 *cts17; + + cts = &ccb->cts; + cts17 = (struct ccb_trans_settings_0x17 *)hdr17; + cts17->type = cts->type; + cts17->protocol = cts->protocol; + cts17->protocol_version = cts->protocol_version; + cts17->transport = cts->transport; + cts17->transport_version = cts->transport_version; + bcopy(&cts->proto_specific, &cts17->proto_specific, + sizeof(cts17->proto_specific)); + bcopy(&cts->xport_specific, &cts17->xport_specific, + sizeof(cts17->xport_specific)); } else if (ccb->ccb_h.func_code == XPT_DEV_MATCH) { /* Copy the rest of the header over */ bcopy(ccbb, ccbb17, CAM_0X17_DATA_LEN); @@ -257,7 +289,24 @@ cam_compat_handle_0x18(struct cdev *dev, ccbb = (uint8_t *)&hdr[1]; ccbb18 = (uint8_t *)&hdr18[1]; - bcopy(ccbb18, ccbb, CAM_0X18_DATA_LEN); + if (ccb->ccb_h.func_code == XPT_SET_TRAN_SETTINGS) { + struct ccb_trans_settings *cts; + struct ccb_trans_settings_0x18 *cts18; + + cts = &ccb->cts; + cts18 = (struct ccb_trans_settings_0x18 *)hdr18; + cts->type = cts18->type; + cts->protocol = cts18->protocol; + cts->protocol_version = cts18->protocol_version; + cts->transport = cts18->transport; + cts->transport_version = cts18->transport_version; + bcopy(&cts18->proto_specific, &cts->proto_specific, + sizeof(cts18->proto_specific)); + bcopy(&cts18->xport_specific, &cts->xport_specific, + sizeof(cts18->xport_specific)); + } else { + bcopy(ccbb18, ccbb, CAM_0X18_DATA_LEN); + } error = (cbfnp)(dev, cmd, (caddr_t)ccb, flag, td); @@ -280,10 +329,27 @@ cam_compat_handle_0x18(struct cdev *dev, hdr18->sim_priv = hdr->sim_priv; hdr18->timeout = hdr->timeout; - bcopy(ccbb, ccbb18, CAM_0X18_DATA_LEN); - - if (ccb->ccb_h.func_code == XPT_DEV_MATCH) + if (ccb->ccb_h.func_code == XPT_GET_TRAN_SETTINGS) { + struct ccb_trans_settings *cts; + struct ccb_trans_settings_0x18 *cts18; + + cts = &ccb->cts; + cts18 = (struct ccb_trans_settings_0x18 *)hdr18; + cts18->type = cts->type; + cts18->protocol = cts->protocol; + cts18->protocol_version = cts->protocol_version; + cts18->transport = cts->transport; + cts18->transport_version = cts->transport_version; + bcopy(&cts->proto_specific, &cts18->proto_specific, + sizeof(cts18->proto_specific)); + bcopy(&cts->xport_specific, &cts18->xport_specific, + sizeof(cts18->xport_specific)); + } else if (ccb->ccb_h.func_code == XPT_DEV_MATCH) { + bcopy(ccbb, ccbb18, CAM_0X18_DATA_LEN); cam_compat_translate_dev_match_0x18(ccb); + } else { + bcopy(ccbb, ccbb18, CAM_0X18_DATA_LEN); + } xpt_free_ccb(ccb); Modified: stable/11/sys/cam/cam_compat.h ============================================================================== --- stable/11/sys/cam/cam_compat.h Fri Oct 14 05:47:59 2016 (r307263) +++ stable/11/sys/cam/cam_compat.h Fri Oct 14 06:56:06 2016 (r307264) @@ -43,8 +43,8 @@ int cam_compat_ioctl(struct cdev *dev, u #define CAM_VERSION_0x16 0x16 /* The size of the union ccb didn't change when going to 0x17 */ -#define CAMIOCOMMAND_0x16 _IOWR(CAM_VERSION_0x16, 2, union ccb) -#define CAMGETPASSTHRU_0x16 _IOWR(CAM_VERSION_0x16, 3, union ccb) +#define CAMIOCOMMAND_0x16 _IOC(IOC_INOUT, CAM_VERSION_0x16, 2, CAM_0X17_LEN) +#define CAMGETPASSTHRU_0x16 _IOC(IOC_INOUT, CAM_VERSION_0x16, 3, CAM_0X17_LEN) #define CAM_SCATTER_VALID_0x16 0x00000010 #define CAM_SG_LIST_PHYS_0x16 0x00040000 @@ -110,8 +110,30 @@ struct ccb_pathinq_0x17 { u_int16_t hba_subdevice; /* HBA subdevice ID */ }; -#define CAM_0X17_LEN (sizeof(union ccb) - sizeof(struct ccb_hdr) + sizeof(struct ccb_hdr_0x17)) -#define CAM_0X17_DATA_LEN (sizeof(union ccb) - sizeof(struct ccb_hdr_0x17)) +struct ccb_trans_settings_0x17 { + struct ccb_hdr_0x17 ccb_h; + cts_type type; /* Current or User settings */ + cam_proto protocol; + u_int protocol_version; + cam_xport transport; + u_int transport_version; + union { + u_int valid; /* Which fields to honor */ + struct ccb_trans_settings_ata ata; + struct ccb_trans_settings_scsi scsi; + } proto_specific; + union { + u_int valid; /* Which fields to honor */ + struct ccb_trans_settings_spi spi; + struct ccb_trans_settings_fc fc; + struct ccb_trans_settings_sas sas; + struct ccb_trans_settings_pata ata; + struct ccb_trans_settings_sata sata; + } xport_specific; +}; + +#define CAM_0X17_DATA_LEN CAM_0X18_DATA_LEN +#define CAM_0X17_LEN (sizeof(struct ccb_hdr_0x17) + CAM_0X17_DATA_LEN) #define CAMIOCOMMAND_0x17 _IOC(IOC_INOUT, CAM_VERSION_0x17, 2, CAM_0X17_LEN) #define CAMGETPASSTHRU_0x17 _IOC(IOC_INOUT, CAM_VERSION_0x17, 3, CAM_0X17_LEN) @@ -146,6 +168,28 @@ typedef enum { CAM_EXTLUN_VALID_0x18 = 0x00000001,/* 64bit lun field is valid */ } ccb_xflags_0x18; +struct ccb_trans_settings_0x18 { + struct ccb_hdr_0x18 ccb_h; + cts_type type; /* Current or User settings */ + cam_proto protocol; + u_int protocol_version; + cam_xport transport; + u_int transport_version; + union { + u_int valid; /* Which fields to honor */ + struct ccb_trans_settings_ata ata; + struct ccb_trans_settings_scsi scsi; + } proto_specific; + union { + u_int valid; /* Which fields to honor */ + struct ccb_trans_settings_spi spi; + struct ccb_trans_settings_fc fc; + struct ccb_trans_settings_sas sas; + struct ccb_trans_settings_pata ata; + struct ccb_trans_settings_sata sata; + } xport_specific; +}; + struct dev_match_result_0x18 { dev_match_type type; union { @@ -169,8 +213,8 @@ struct dev_match_result_0x18 { } result; }; -#define CAM_0X18_LEN (sizeof(union ccb) - sizeof(struct ccb_hdr) + sizeof(struct ccb_hdr_0x18)) -#define CAM_0X18_DATA_LEN (sizeof(union ccb) - sizeof(struct ccb_hdr_0x18)) +#define CAM_0X18_DATA_LEN (sizeof(union ccb) - 2*sizeof(void *) - sizeof(struct ccb_hdr)) +#define CAM_0X18_LEN (sizeof(struct ccb_hdr_0x18) + CAM_0X18_DATA_LEN) #define CAMIOCOMMAND_0x18 _IOC(IOC_INOUT, CAM_VERSION_0x18, 2, CAM_0X18_LEN) #define CAMGETPASSTHRU_0x18 _IOC(IOC_INOUT, CAM_VERSION_0x18, 3, CAM_0X18_LEN) From owner-svn-src-all@freebsd.org Fri Oct 14 07:13:45 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id AFC9EC110F7; Fri, 14 Oct 2016 07:13:45 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 5310C96E; Fri, 14 Oct 2016 07:13:45 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9E7DimA060343; Fri, 14 Oct 2016 07:13:44 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9E7DiKt060339; Fri, 14 Oct 2016 07:13:44 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201610140713.u9E7DiKt060339@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Fri, 14 Oct 2016 07:13:44 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307265 - in stable/11: cddl/contrib/opensolaris/cmd/zdb cddl/contrib/opensolaris/cmd/ztest sys/cddl/contrib/opensolaris/uts/common/fs/zfs sys/cddl/contrib/opensolaris/uts/common/fs/zfs... X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Oct 2016 07:13:45 -0000 Author: mav Date: Fri Oct 14 07:13:43 2016 New Revision: 307265 URL: https://svnweb.freebsd.org/changeset/base/307265 Log: MFC r305323: MFV r302991: 6950 ARC should cache compressed data illumos/illumos-gate@dcbf3bd6a1f1360fc1afcee9e22c6dcff7844bf2 https://github.com/illumos/illumos-gate/commit/dcbf3bd6a1f1360fc1afcee9e22c6dcff7844bf2 https://www.illumos.org/issues/6950 When reading compressed data from disk, the ARC should keep the compressed block cached and only decompress it when consumers access the block. The uncompressed data should be short-lived allowing the ARC to cache a much larger amount of data. The DMU would also maintain a smaller cache of uncompressed blocks to minimize the impact of decompressing frequently accessed blocks. Reviewed by: Prakash Surya Reviewed by: Dan Kimmel Reviewed by: Matt Ahrens Reviewed by: Paul Dagnelie Reviewed by: Don Brady Reviewed by: Richard Elling Approved by: Richard Lowe Author: George Wilson Modified: stable/11/cddl/contrib/opensolaris/cmd/zdb/zdb.c stable/11/cddl/contrib/opensolaris/cmd/ztest/ztest.c stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dbuf.c stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu.c stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_diff.c stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_objset.c stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_send.c stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_traverse.c stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dnode.c stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dnode_sync.c stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_scan.c stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/refcount.c stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/arc.h stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dbuf.h stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/refcount.h stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/spa.h stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zio.h stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zio_checksum.h stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zil.c stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zio.c stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zio_checksum.c Directory Properties: stable/11/ (props changed) Modified: stable/11/cddl/contrib/opensolaris/cmd/zdb/zdb.c ============================================================================== --- stable/11/cddl/contrib/opensolaris/cmd/zdb/zdb.c Fri Oct 14 06:56:06 2016 (r307264) +++ stable/11/cddl/contrib/opensolaris/cmd/zdb/zdb.c Fri Oct 14 07:13:43 2016 (r307265) @@ -1289,7 +1289,7 @@ visit_indirect(spa_t *spa, const dnode_p } if (!err) ASSERT3U(fill, ==, BP_GET_FILL(bp)); - (void) arc_buf_remove_ref(buf, &buf); + arc_buf_destroy(buf, &buf); } return (err); Modified: stable/11/cddl/contrib/opensolaris/cmd/ztest/ztest.c ============================================================================== --- stable/11/cddl/contrib/opensolaris/cmd/ztest/ztest.c Fri Oct 14 06:56:06 2016 (r307264) +++ stable/11/cddl/contrib/opensolaris/cmd/ztest/ztest.c Fri Oct 14 07:13:43 2016 (r307265) @@ -189,6 +189,7 @@ extern uint64_t metaslab_gang_bang; extern uint64_t metaslab_df_alloc_threshold; extern uint64_t zfs_deadman_synctime_ms; extern int metaslab_preload_limit; +extern boolean_t zfs_compressed_arc_enabled; static ztest_shared_opts_t *ztest_shared_opts; static ztest_shared_opts_t ztest_opts; @@ -5355,6 +5356,12 @@ ztest_resume_thread(void *arg) if (spa_suspended(spa)) ztest_resume(spa); (void) poll(NULL, 0, 100); + + /* + * Periodically change the zfs_compressed_arc_enabled setting. + */ + if (ztest_random(10) == 0) + zfs_compressed_arc_enabled = ztest_random(2); } return (NULL); } Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c ============================================================================== --- stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c Fri Oct 14 06:56:06 2016 (r307264) +++ stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c Fri Oct 14 07:13:43 2016 (r307265) @@ -120,9 +120,134 @@ * - ARC header release, as it removes from L2ARC buflists */ +/* + * ARC operation: + * + * Every block that is in the ARC is tracked by an arc_buf_hdr_t structure. + * This structure can point either to a block that is still in the cache or to + * one that is only accessible in an L2 ARC device, or it can provide + * information about a block that was recently evicted. If a block is + * only accessible in the L2ARC, then the arc_buf_hdr_t only has enough + * information to retrieve it from the L2ARC device. This information is + * stored in the l2arc_buf_hdr_t sub-structure of the arc_buf_hdr_t. A block + * that is in this state cannot access the data directly. + * + * Blocks that are actively being referenced or have not been evicted + * are cached in the L1ARC. The L1ARC (l1arc_buf_hdr_t) is a structure within + * the arc_buf_hdr_t that will point to the data block in memory. A block can + * only be read by a consumer if it has an l1arc_buf_hdr_t. The L1ARC + * caches data in two ways -- in a list of arc buffers (arc_buf_t) and + * also in the arc_buf_hdr_t's private physical data block pointer (b_pdata). + * Each arc buffer (arc_buf_t) is being actively accessed by a specific ARC + * consumer, and always contains uncompressed data. The ARC will provide + * references to this data and will keep it cached until it is no longer in + * use. Typically, the arc will try to cache only the L1ARC's physical data + * block and will aggressively evict any arc_buf_t that is no longer referenced. + * The amount of memory consumed by the arc_buf_t's can be seen via the + * "overhead_size" kstat. + * + * + * arc_buf_hdr_t + * +-----------+ + * | | + * | | + * | | + * +-----------+ + * l2arc_buf_hdr_t| | + * | | + * +-----------+ + * l1arc_buf_hdr_t| | + * | | arc_buf_t + * | b_buf +------------>+---------+ arc_buf_t + * | | |b_next +---->+---------+ + * | b_pdata +-+ |---------| |b_next +-->NULL + * +-----------+ | | | +---------+ + * | |b_data +-+ | | + * | +---------+ | |b_data +-+ + * +->+------+ | +---------+ | + * (potentially) | | | | + * compressed | | | | + * data +------+ | v + * +->+------+ +------+ + * uncompressed | | | | + * data | | | | + * +------+ +------+ + * + * The L1ARC's data pointer, however, may or may not be uncompressed. The + * ARC has the ability to store the physical data (b_pdata) associated with + * the DVA of the arc_buf_hdr_t. Since the b_pdata is a copy of the on-disk + * physical block, it will match its on-disk compression characteristics. + * If the block on-disk is compressed, then the physical data block + * in the cache will also be compressed and vice-versa. This behavior + * can be disabled by setting 'zfs_compressed_arc_enabled' to B_FALSE. When the + * compressed ARC functionality is disabled, the b_pdata will point to an + * uncompressed version of the on-disk data. + * + * When a consumer reads a block, the ARC must first look to see if the + * arc_buf_hdr_t is cached. If the hdr is cached and already has an arc_buf_t, + * then an additional arc_buf_t is allocated and the uncompressed data is + * bcopied from the existing arc_buf_t. If the hdr is cached but does not + * have an arc_buf_t, then the ARC allocates a new arc_buf_t and decompresses + * the b_pdata contents into the arc_buf_t's b_data. If the arc_buf_hdr_t's + * b_pdata is not compressed, then the block is shared with the newly + * allocated arc_buf_t. This block sharing only occurs with one arc_buf_t + * in the arc buffer chain. Sharing the block reduces the memory overhead + * required when the hdr is caching uncompressed blocks or the compressed + * arc functionality has been disabled via 'zfs_compressed_arc_enabled'. + * + * The diagram below shows an example of an uncompressed ARC hdr that is + * sharing its data with an arc_buf_t: + * + * arc_buf_hdr_t + * +-----------+ + * | | + * | | + * | | + * +-----------+ + * l2arc_buf_hdr_t| | + * | | + * +-----------+ + * l1arc_buf_hdr_t| | + * | | arc_buf_t (shared) + * | b_buf +------------>+---------+ arc_buf_t + * | | |b_next +---->+---------+ + * | b_pdata +-+ |---------| |b_next +-->NULL + * +-----------+ | | | +---------+ + * | |b_data +-+ | | + * | +---------+ | |b_data +-+ + * +->+------+ | +---------+ | + * | | | | + * uncompressed | | | | + * data +------+ | | + * ^ +->+------+ | + * | uncompressed | | | + * | data | | | + * | +------+ | + * +---------------------------------+ + * + * Writing to the arc requires that the ARC first discard the b_pdata + * since the physical block is about to be rewritten. The new data contents + * will be contained in the arc_buf_t (uncompressed). As the I/O pipeline + * performs the write, it may compress the data before writing it to disk. + * The ARC will be called with the transformed data and will bcopy the + * transformed on-disk block into a newly allocated b_pdata. + * + * When the L2ARC is in use, it will also take advantage of the b_pdata. The + * L2ARC will always write the contents of b_pdata to the L2ARC. This means + * that when compressed arc is enabled that the L2ARC blocks are identical + * to the on-disk block in the main data pool. This provides a significant + * advantage since the ARC can leverage the bp's checksum when reading from the + * L2ARC to determine if the contents are valid. However, if the compressed + * arc is disabled, then the L2ARC's block must be transformed to look + * like the physical block in the main data pool before comparing the + * checksum and determining its validity. + */ + #include #include +#include #include +#include #include #include #include @@ -155,10 +280,6 @@ static kcondvar_t arc_reclaim_thread_cv; static boolean_t arc_reclaim_thread_exit; static kcondvar_t arc_reclaim_waiters_cv; -static kmutex_t arc_user_evicts_lock; -static kcondvar_t arc_user_evicts_cv; -static boolean_t arc_user_evicts_thread_exit; - static kmutex_t arc_dnlc_evicts_lock; static kcondvar_t arc_dnlc_evicts_cv; static boolean_t arc_dnlc_evicts_thread_exit; @@ -234,13 +355,14 @@ uint64_t zfs_arc_meta_min = 0; int zfs_arc_grow_retry = 0; int zfs_arc_shrink_shift = 0; int zfs_arc_p_min_shift = 0; -int zfs_disable_dup_eviction = 0; uint64_t zfs_arc_average_blocksize = 8 * 1024; /* 8KB */ u_int zfs_arc_free_target = 0; /* Absolute min for arc min / max is 16MB. */ static uint64_t arc_abs_min = 16 << 20; +boolean_t zfs_compressed_arc_enabled = B_TRUE; + static int sysctl_vfs_zfs_arc_free_target(SYSCTL_HANDLER_ARGS); static int sysctl_vfs_zfs_arc_meta_limit(SYSCTL_HANDLER_ARGS); static int sysctl_vfs_zfs_arc_max(SYSCTL_HANDLER_ARGS); @@ -270,6 +392,8 @@ SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, arc_ave SYSCTL_INT(_vfs_zfs, OID_AUTO, arc_shrink_shift, CTLFLAG_RW, &arc_shrink_shift, 0, "log2(fraction of arc to reclaim)"); +SYSCTL_INT(_vfs_zfs, OID_AUTO, compressed_arc_enabled, CTLFLAG_RDTUN, + &zfs_compressed_arc_enabled, 0, "Enable compressed ARC"); /* * We don't have a tunable for arc_free_target due to the dependency on @@ -351,7 +475,7 @@ typedef struct arc_state { /* * total amount of evictable data in this state */ - uint64_t arcs_lsize[ARC_BUFC_NUMTYPES]; + refcount_t arcs_esize[ARC_BUFC_NUMTYPES]; /* * total amount of data in this state; this includes: evictable, * non-evictable, ARC_BUFC_DATA, and ARC_BUFC_METADATA. @@ -417,6 +541,26 @@ typedef struct arc_stats { kstat_named_t arcstat_c_max; kstat_named_t arcstat_size; /* + * Number of compressed bytes stored in the arc_buf_hdr_t's b_pdata. + * Note that the compressed bytes may match the uncompressed bytes + * if the block is either not compressed or compressed arc is disabled. + */ + kstat_named_t arcstat_compressed_size; + /* + * Uncompressed size of the data stored in b_pdata. If compressed + * arc is disabled then this value will be identical to the stat + * above. + */ + kstat_named_t arcstat_uncompressed_size; + /* + * Number of bytes stored in all the arc_buf_t's. This is classified + * as "overhead" since this data is typically short-lived and will + * be evicted from the arc when it becomes unreferenced unless the + * zfs_keep_uncompressed_metadata or zfs_keep_uncompressed_level + * values have been set (see comment in dbuf.c for more information). + */ + kstat_named_t arcstat_overhead_size; + /* * Number of bytes consumed by internal ARC structures necessary * for tracking purposes; these structures are not actually * backed by ARC buffers. This includes arc_buf_hdr_t structures @@ -561,16 +705,12 @@ typedef struct arc_stats { kstat_named_t arcstat_l2_evict_reading; kstat_named_t arcstat_l2_evict_l1cached; kstat_named_t arcstat_l2_free_on_write; - kstat_named_t arcstat_l2_cdata_free_on_write; kstat_named_t arcstat_l2_abort_lowmem; kstat_named_t arcstat_l2_cksum_bad; kstat_named_t arcstat_l2_io_error; kstat_named_t arcstat_l2_size; kstat_named_t arcstat_l2_asize; kstat_named_t arcstat_l2_hdr_size; - kstat_named_t arcstat_l2_compress_successes; - kstat_named_t arcstat_l2_compress_zeros; - kstat_named_t arcstat_l2_compress_failures; kstat_named_t arcstat_l2_padding_needed; kstat_named_t arcstat_l2_write_trylock_fail; kstat_named_t arcstat_l2_write_passed_headroom; @@ -585,9 +725,6 @@ typedef struct arc_stats { kstat_named_t arcstat_l2_write_buffer_list_iter; kstat_named_t arcstat_l2_write_buffer_list_null_iter; kstat_named_t arcstat_memory_throttle_count; - kstat_named_t arcstat_duplicate_buffers; - kstat_named_t arcstat_duplicate_buffers_size; - kstat_named_t arcstat_duplicate_reads; kstat_named_t arcstat_meta_used; kstat_named_t arcstat_meta_limit; kstat_named_t arcstat_meta_max; @@ -630,6 +767,9 @@ static arc_stats_t arc_stats = { { "c_min", KSTAT_DATA_UINT64 }, { "c_max", KSTAT_DATA_UINT64 }, { "size", KSTAT_DATA_UINT64 }, + { "compressed_size", KSTAT_DATA_UINT64 }, + { "uncompressed_size", KSTAT_DATA_UINT64 }, + { "overhead_size", KSTAT_DATA_UINT64 }, { "hdr_size", KSTAT_DATA_UINT64 }, { "data_size", KSTAT_DATA_UINT64 }, { "metadata_size", KSTAT_DATA_UINT64 }, @@ -663,16 +803,12 @@ static arc_stats_t arc_stats = { { "l2_evict_reading", KSTAT_DATA_UINT64 }, { "l2_evict_l1cached", KSTAT_DATA_UINT64 }, { "l2_free_on_write", KSTAT_DATA_UINT64 }, - { "l2_cdata_free_on_write", KSTAT_DATA_UINT64 }, { "l2_abort_lowmem", KSTAT_DATA_UINT64 }, { "l2_cksum_bad", KSTAT_DATA_UINT64 }, { "l2_io_error", KSTAT_DATA_UINT64 }, { "l2_size", KSTAT_DATA_UINT64 }, { "l2_asize", KSTAT_DATA_UINT64 }, { "l2_hdr_size", KSTAT_DATA_UINT64 }, - { "l2_compress_successes", KSTAT_DATA_UINT64 }, - { "l2_compress_zeros", KSTAT_DATA_UINT64 }, - { "l2_compress_failures", KSTAT_DATA_UINT64 }, { "l2_padding_needed", KSTAT_DATA_UINT64 }, { "l2_write_trylock_fail", KSTAT_DATA_UINT64 }, { "l2_write_passed_headroom", KSTAT_DATA_UINT64 }, @@ -687,9 +823,6 @@ static arc_stats_t arc_stats = { { "l2_write_buffer_list_iter", KSTAT_DATA_UINT64 }, { "l2_write_buffer_list_null_iter", KSTAT_DATA_UINT64 }, { "memory_throttle_count", KSTAT_DATA_UINT64 }, - { "duplicate_buffers", KSTAT_DATA_UINT64 }, - { "duplicate_buffers_size", KSTAT_DATA_UINT64 }, - { "duplicate_reads", KSTAT_DATA_UINT64 }, { "arc_meta_used", KSTAT_DATA_UINT64 }, { "arc_meta_limit", KSTAT_DATA_UINT64 }, { "arc_meta_max", KSTAT_DATA_UINT64 }, @@ -762,8 +895,12 @@ static arc_state_t *arc_l2c_only; #define arc_meta_used ARCSTAT(arcstat_meta_used) /* size of metadata */ #define arc_meta_max ARCSTAT(arcstat_meta_max) /* max size of metadata */ -#define L2ARC_IS_VALID_COMPRESS(_c_) \ - ((_c_) == ZIO_COMPRESS_LZ4 || (_c_) == ZIO_COMPRESS_EMPTY) +/* compressed size of entire arc */ +#define arc_compressed_size ARCSTAT(arcstat_compressed_size) +/* uncompressed size of entire arc */ +#define arc_uncompressed_size ARCSTAT(arcstat_uncompressed_size) +/* number of bytes in the arc from arc_buf_t's */ +#define arc_overhead_size ARCSTAT(arcstat_overhead_size) static int arc_no_grow; /* Don't try to grow cache size */ static uint64_t arc_tempreserve; @@ -823,6 +960,7 @@ struct arc_write_callback { */ typedef struct l1arc_buf_hdr { kmutex_t b_freeze_lock; + zio_cksum_t *b_freeze_cksum; #ifdef ZFS_DEBUG /* * used for debugging wtih kmem_flags - by allocating and freeing @@ -833,9 +971,10 @@ typedef struct l1arc_buf_hdr { #endif arc_buf_t *b_buf; - uint32_t b_datacnt; + uint32_t b_bufcnt; /* for waiting on writes to complete */ kcondvar_t b_cv; + uint8_t b_byteswap; /* protected by arc state mutex */ arc_state_t *b_state; @@ -848,8 +987,7 @@ typedef struct l1arc_buf_hdr { refcount_t b_refcnt; arc_callback_t *b_acb; - /* temporary buffer holder for in-flight compressed or padded data */ - void *b_tmp_cdata; + void *b_pdata; } l1arc_buf_hdr_t; typedef struct l2arc_dev l2arc_dev_t; @@ -858,9 +996,6 @@ typedef struct l2arc_buf_hdr { /* protected by arc_buf_hdr mutex */ l2arc_dev_t *b_dev; /* L2ARC device */ uint64_t b_daddr; /* disk address, offset byte */ - /* real alloc'd buffer size depending on b_compress applied */ - int32_t b_asize; - uint8_t b_compress; list_node_t b_l2node; } l2arc_buf_hdr_t; @@ -869,20 +1004,37 @@ struct arc_buf_hdr { /* protected by hash lock */ dva_t b_dva; uint64_t b_birth; - /* - * Even though this checksum is only set/verified when a buffer is in - * the L1 cache, it needs to be in the set of common fields because it - * must be preserved from the time before a buffer is written out to - * L2ARC until after it is read back in. - */ - zio_cksum_t *b_freeze_cksum; + arc_buf_contents_t b_type; arc_buf_hdr_t *b_hash_next; arc_flags_t b_flags; - /* immutable */ - int32_t b_size; - uint64_t b_spa; + /* + * This field stores the size of the data buffer after + * compression, and is set in the arc's zio completion handlers. + * It is in units of SPA_MINBLOCKSIZE (e.g. 1 == 512 bytes). + * + * While the block pointers can store up to 32MB in their psize + * field, we can only store up to 32MB minus 512B. This is due + * to the bp using a bias of 1, whereas we use a bias of 0 (i.e. + * a field of zeros represents 512B in the bp). We can't use a + * bias of 1 since we need to reserve a psize of zero, here, to + * represent holes and embedded blocks. + * + * This isn't a problem in practice, since the maximum size of a + * buffer is limited to 16MB, so we never need to store 32MB in + * this field. Even in the upstream illumos code base, the + * maximum size of a buffer is limited to 16MB. + */ + uint16_t b_psize; + + /* + * This field stores the size of the data buffer before + * compression, and cannot change once set. It is in units + * of SPA_MINBLOCKSIZE (e.g. 2 == 1024 bytes) + */ + uint16_t b_lsize; /* immutable */ + uint64_t b_spa; /* immutable */ /* L2ARC fields. Undefined when not in L2ARC. */ l2arc_buf_hdr_t b_l2hdr; @@ -986,9 +1138,6 @@ sysctl_vfs_zfs_arc_min(SYSCTL_HANDLER_AR } #endif -static arc_buf_t *arc_eviction_list; -static arc_buf_hdr_t arc_eviction_hdr; - #define GHOST_STATE(state) \ ((state) == arc_mru_ghost || (state) == arc_mfu_ghost || \ (state) == arc_l2c_only) @@ -997,25 +1146,35 @@ static arc_buf_hdr_t arc_eviction_hdr; #define HDR_IO_IN_PROGRESS(hdr) ((hdr)->b_flags & ARC_FLAG_IO_IN_PROGRESS) #define HDR_IO_ERROR(hdr) ((hdr)->b_flags & ARC_FLAG_IO_ERROR) #define HDR_PREFETCH(hdr) ((hdr)->b_flags & ARC_FLAG_PREFETCH) -#define HDR_FREED_IN_READ(hdr) ((hdr)->b_flags & ARC_FLAG_FREED_IN_READ) -#define HDR_BUF_AVAILABLE(hdr) ((hdr)->b_flags & ARC_FLAG_BUF_AVAILABLE) +#define HDR_COMPRESSION_ENABLED(hdr) \ + ((hdr)->b_flags & ARC_FLAG_COMPRESSED_ARC) #define HDR_L2CACHE(hdr) ((hdr)->b_flags & ARC_FLAG_L2CACHE) -#define HDR_L2COMPRESS(hdr) ((hdr)->b_flags & ARC_FLAG_L2COMPRESS) #define HDR_L2_READING(hdr) \ - (((hdr)->b_flags & ARC_FLAG_IO_IN_PROGRESS) && \ - ((hdr)->b_flags & ARC_FLAG_HAS_L2HDR)) + (((hdr)->b_flags & ARC_FLAG_IO_IN_PROGRESS) && \ + ((hdr)->b_flags & ARC_FLAG_HAS_L2HDR)) #define HDR_L2_WRITING(hdr) ((hdr)->b_flags & ARC_FLAG_L2_WRITING) #define HDR_L2_EVICTED(hdr) ((hdr)->b_flags & ARC_FLAG_L2_EVICTED) #define HDR_L2_WRITE_HEAD(hdr) ((hdr)->b_flags & ARC_FLAG_L2_WRITE_HEAD) +#define HDR_SHARED_DATA(hdr) ((hdr)->b_flags & ARC_FLAG_SHARED_DATA) #define HDR_ISTYPE_METADATA(hdr) \ - ((hdr)->b_flags & ARC_FLAG_BUFC_METADATA) + ((hdr)->b_flags & ARC_FLAG_BUFC_METADATA) #define HDR_ISTYPE_DATA(hdr) (!HDR_ISTYPE_METADATA(hdr)) #define HDR_HAS_L1HDR(hdr) ((hdr)->b_flags & ARC_FLAG_HAS_L1HDR) #define HDR_HAS_L2HDR(hdr) ((hdr)->b_flags & ARC_FLAG_HAS_L2HDR) +/* For storing compression mode in b_flags */ +#define HDR_COMPRESS_OFFSET (highbit64(ARC_FLAG_COMPRESS_0) - 1) + +#define HDR_GET_COMPRESS(hdr) ((enum zio_compress)BF32_GET((hdr)->b_flags, \ + HDR_COMPRESS_OFFSET, SPA_COMPRESSBITS)) +#define HDR_SET_COMPRESS(hdr, cmp) BF32_SET((hdr)->b_flags, \ + HDR_COMPRESS_OFFSET, SPA_COMPRESSBITS, (cmp)); + +#define ARC_BUF_LAST(buf) ((buf)->b_next == NULL) + /* * Other sizes */ @@ -1068,16 +1227,6 @@ uint64_t zfs_crc64_table[256]; #define L2ARC_FEED_SECS 1 /* caching interval secs */ #define L2ARC_FEED_MIN_MS 200 /* min caching interval ms */ -/* - * Used to distinguish headers that are being process by - * l2arc_write_buffers(), but have yet to be assigned to a l2arc disk - * address. This can happen when the header is added to the l2arc's list - * of buffers to write in the first stage of l2arc_write_buffers(), but - * has not yet been written out which happens in the second stage of - * l2arc_write_buffers(). - */ -#define L2ARC_ADDR_UNSET ((uint64_t)(-1)) - #define l2arc_writes_sent ARCSTAT(arcstat_l2_writes_sent) #define l2arc_writes_done ARCSTAT(arcstat_l2_writes_done) @@ -1112,41 +1261,47 @@ SYSCTL_INT(_vfs_zfs, OID_AUTO, l2arc_nor SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, anon_size, CTLFLAG_RD, &ARC_anon.arcs_size.rc_count, 0, "size of anonymous state"); -SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, anon_metadata_lsize, CTLFLAG_RD, - &ARC_anon.arcs_lsize[ARC_BUFC_METADATA], 0, "size of anonymous state"); -SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, anon_data_lsize, CTLFLAG_RD, - &ARC_anon.arcs_lsize[ARC_BUFC_DATA], 0, "size of anonymous state"); +SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, anon_metadata_esize, CTLFLAG_RD, + &ARC_anon.arcs_esize[ARC_BUFC_METADATA].rc_count, 0, + "size of anonymous state"); +SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, anon_data_esize, CTLFLAG_RD, + &ARC_anon.arcs_esize[ARC_BUFC_DATA].rc_count, 0, + "size of anonymous state"); SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, mru_size, CTLFLAG_RD, &ARC_mru.arcs_size.rc_count, 0, "size of mru state"); -SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, mru_metadata_lsize, CTLFLAG_RD, - &ARC_mru.arcs_lsize[ARC_BUFC_METADATA], 0, "size of metadata in mru state"); -SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, mru_data_lsize, CTLFLAG_RD, - &ARC_mru.arcs_lsize[ARC_BUFC_DATA], 0, "size of data in mru state"); +SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, mru_metadata_esize, CTLFLAG_RD, + &ARC_mru.arcs_esize[ARC_BUFC_METADATA].rc_count, 0, + "size of metadata in mru state"); +SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, mru_data_esize, CTLFLAG_RD, + &ARC_mru.arcs_esize[ARC_BUFC_DATA].rc_count, 0, + "size of data in mru state"); SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, mru_ghost_size, CTLFLAG_RD, &ARC_mru_ghost.arcs_size.rc_count, 0, "size of mru ghost state"); -SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, mru_ghost_metadata_lsize, CTLFLAG_RD, - &ARC_mru_ghost.arcs_lsize[ARC_BUFC_METADATA], 0, +SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, mru_ghost_metadata_esize, CTLFLAG_RD, + &ARC_mru_ghost.arcs_esize[ARC_BUFC_METADATA].rc_count, 0, "size of metadata in mru ghost state"); -SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, mru_ghost_data_lsize, CTLFLAG_RD, - &ARC_mru_ghost.arcs_lsize[ARC_BUFC_DATA], 0, +SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, mru_ghost_data_esize, CTLFLAG_RD, + &ARC_mru_ghost.arcs_esize[ARC_BUFC_DATA].rc_count, 0, "size of data in mru ghost state"); SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, mfu_size, CTLFLAG_RD, &ARC_mfu.arcs_size.rc_count, 0, "size of mfu state"); -SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, mfu_metadata_lsize, CTLFLAG_RD, - &ARC_mfu.arcs_lsize[ARC_BUFC_METADATA], 0, "size of metadata in mfu state"); -SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, mfu_data_lsize, CTLFLAG_RD, - &ARC_mfu.arcs_lsize[ARC_BUFC_DATA], 0, "size of data in mfu state"); +SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, mfu_metadata_esize, CTLFLAG_RD, + &ARC_mfu.arcs_esize[ARC_BUFC_METADATA].rc_count, 0, + "size of metadata in mfu state"); +SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, mfu_data_esize, CTLFLAG_RD, + &ARC_mfu.arcs_esize[ARC_BUFC_DATA].rc_count, 0, + "size of data in mfu state"); SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, mfu_ghost_size, CTLFLAG_RD, &ARC_mfu_ghost.arcs_size.rc_count, 0, "size of mfu ghost state"); -SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, mfu_ghost_metadata_lsize, CTLFLAG_RD, - &ARC_mfu_ghost.arcs_lsize[ARC_BUFC_METADATA], 0, +SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, mfu_ghost_metadata_esize, CTLFLAG_RD, + &ARC_mfu_ghost.arcs_esize[ARC_BUFC_METADATA].rc_count, 0, "size of metadata in mfu ghost state"); -SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, mfu_ghost_data_lsize, CTLFLAG_RD, - &ARC_mfu_ghost.arcs_lsize[ARC_BUFC_DATA], 0, +SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, mfu_ghost_data_esize, CTLFLAG_RD, + &ARC_mfu_ghost.arcs_esize[ARC_BUFC_DATA].rc_count, 0, "size of data in mfu ghost state"); SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, l2c_only_size, CTLFLAG_RD, @@ -1179,12 +1334,10 @@ static kmutex_t l2arc_free_on_write_mtx; static uint64_t l2arc_ndev; /* number of devices */ typedef struct l2arc_read_callback { - arc_buf_t *l2rcb_buf; /* read buffer */ - spa_t *l2rcb_spa; /* spa */ + arc_buf_hdr_t *l2rcb_hdr; /* read buffer */ blkptr_t l2rcb_bp; /* original blkptr */ zbookmark_phys_t l2rcb_zb; /* original bookmark */ int l2rcb_flags; /* original flags */ - enum zio_compress l2rcb_compress; /* applied compress */ void *l2rcb_data; /* temporary buffer */ } l2arc_read_callback_t; @@ -1197,7 +1350,7 @@ typedef struct l2arc_data_free { /* protected by l2arc_free_on_write_mtx */ void *l2df_data; size_t l2df_size; - void (*l2df_func)(void *, size_t); + arc_buf_contents_t l2df_type; list_node_t l2df_list_node; } l2arc_data_free_t; @@ -1205,21 +1358,22 @@ static kmutex_t l2arc_feed_thr_lock; static kcondvar_t l2arc_feed_thr_cv; static uint8_t l2arc_thread_exit; -static void arc_get_data_buf(arc_buf_t *); +static void *arc_get_data_buf(arc_buf_hdr_t *, uint64_t, void *); +static void arc_free_data_buf(arc_buf_hdr_t *, void *, uint64_t, void *); +static void arc_hdr_free_pdata(arc_buf_hdr_t *hdr); +static void arc_hdr_alloc_pdata(arc_buf_hdr_t *); static void arc_access(arc_buf_hdr_t *, kmutex_t *); static boolean_t arc_is_overflowing(); static void arc_buf_watch(arc_buf_t *); static arc_buf_contents_t arc_buf_type(arc_buf_hdr_t *); static uint32_t arc_bufc_to_flags(arc_buf_contents_t); +static inline void arc_hdr_set_flags(arc_buf_hdr_t *hdr, arc_flags_t flags); +static inline void arc_hdr_clear_flags(arc_buf_hdr_t *hdr, arc_flags_t flags); static boolean_t l2arc_write_eligible(uint64_t, arc_buf_hdr_t *); static void l2arc_read_done(zio_t *); -static boolean_t l2arc_transform_buf(arc_buf_hdr_t *, boolean_t); -static void l2arc_decompress_zio(zio_t *, arc_buf_hdr_t *, enum zio_compress); -static void l2arc_release_cdata_buf(arc_buf_hdr_t *); - static void l2arc_trim(const arc_buf_hdr_t *hdr) { @@ -1228,13 +1382,9 @@ l2arc_trim(const arc_buf_hdr_t *hdr) ASSERT(HDR_HAS_L2HDR(hdr)); ASSERT(MUTEX_HELD(&dev->l2ad_mtx)); - if (hdr->b_l2hdr.b_daddr == L2ARC_ADDR_UNSET) - return; - if (hdr->b_l2hdr.b_asize != 0) { + if (HDR_GET_PSIZE(hdr) != 0) { trim_map_free(dev->l2ad_vdev, hdr->b_l2hdr.b_daddr, - hdr->b_l2hdr.b_asize, 0); - } else { - ASSERT3U(hdr->b_l2hdr.b_compress, ==, ZIO_COMPRESS_EMPTY); + HDR_GET_PSIZE(hdr), 0); } } @@ -1255,14 +1405,14 @@ buf_hash(uint64_t spa, const dva_t *dva, return (crc); } -#define BUF_EMPTY(buf) \ - ((buf)->b_dva.dva_word[0] == 0 && \ - (buf)->b_dva.dva_word[1] == 0) - -#define BUF_EQUAL(spa, dva, birth, buf) \ - ((buf)->b_dva.dva_word[0] == (dva)->dva_word[0]) && \ - ((buf)->b_dva.dva_word[1] == (dva)->dva_word[1]) && \ - ((buf)->b_birth == birth) && ((buf)->b_spa == spa) +#define HDR_EMPTY(hdr) \ + ((hdr)->b_dva.dva_word[0] == 0 && \ + (hdr)->b_dva.dva_word[1] == 0) + +#define HDR_EQUAL(spa, dva, birth, hdr) \ + ((hdr)->b_dva.dva_word[0] == (dva)->dva_word[0]) && \ + ((hdr)->b_dva.dva_word[1] == (dva)->dva_word[1]) && \ + ((hdr)->b_birth == birth) && ((hdr)->b_spa == spa) static void buf_discard_identity(arc_buf_hdr_t *hdr) @@ -1284,7 +1434,7 @@ buf_hash_find(uint64_t spa, const blkptr mutex_enter(hash_lock); for (hdr = buf_hash_table.ht_table[idx]; hdr != NULL; hdr = hdr->b_hash_next) { - if (BUF_EQUAL(spa, dva, birth, hdr)) { + if (HDR_EQUAL(spa, dva, birth, hdr)) { *lockp = hash_lock; return (hdr); } @@ -1322,13 +1472,13 @@ buf_hash_insert(arc_buf_hdr_t *hdr, kmut for (fhdr = buf_hash_table.ht_table[idx], i = 0; fhdr != NULL; fhdr = fhdr->b_hash_next, i++) { - if (BUF_EQUAL(hdr->b_spa, &hdr->b_dva, hdr->b_birth, fhdr)) + if (HDR_EQUAL(hdr->b_spa, &hdr->b_dva, hdr->b_birth, fhdr)) return (fhdr); } hdr->b_hash_next = buf_hash_table.ht_table[idx]; buf_hash_table.ht_table[idx] = hdr; - hdr->b_flags |= ARC_FLAG_IN_HASH_TABLE; + arc_hdr_set_flags(hdr, ARC_FLAG_IN_HASH_TABLE); /* collect some hash table performance data */ if (i > 0) { @@ -1356,12 +1506,12 @@ buf_hash_remove(arc_buf_hdr_t *hdr) hdrp = &buf_hash_table.ht_table[idx]; while ((fhdr = *hdrp) != hdr) { - ASSERT(fhdr != NULL); + ASSERT3P(fhdr, !=, NULL); hdrp = &fhdr->b_hash_next; } *hdrp = hdr->b_hash_next; hdr->b_hash_next = NULL; - hdr->b_flags &= ~ARC_FLAG_IN_HASH_TABLE; + arc_hdr_clear_flags(hdr, ARC_FLAG_IN_HASH_TABLE); /* collect some hash table performance data */ ARCSTAT_BUMPDOWN(arcstat_hash_elements); @@ -1447,7 +1597,7 @@ hdr_full_dest(void *vbuf, void *unused) { arc_buf_hdr_t *hdr = vbuf; - ASSERT(BUF_EMPTY(hdr)); + ASSERT(HDR_EMPTY(hdr)); cv_destroy(&hdr->b_l1hdr.b_cv); refcount_destroy(&hdr->b_l1hdr.b_refcnt); mutex_destroy(&hdr->b_l1hdr.b_freeze_lock); @@ -1461,7 +1611,7 @@ hdr_l2only_dest(void *vbuf, void *unused { arc_buf_hdr_t *hdr = vbuf; - ASSERT(BUF_EMPTY(hdr)); + ASSERT(HDR_EMPTY(hdr)); arc_space_return(HDR_L2ONLY_SIZE, ARC_SPACE_L2HDRS); } @@ -1534,166 +1684,138 @@ retry: } } -/* - * Transition between the two allocation states for the arc_buf_hdr struct. - * The arc_buf_hdr struct can be allocated with (hdr_full_cache) or without - * (hdr_l2only_cache) the fields necessary for the L1 cache - the smaller - * version is used when a cache buffer is only in the L2ARC in order to reduce - * memory usage. - */ -static arc_buf_hdr_t * -arc_hdr_realloc(arc_buf_hdr_t *hdr, kmem_cache_t *old, kmem_cache_t *new) -{ - ASSERT(HDR_HAS_L2HDR(hdr)); - - arc_buf_hdr_t *nhdr; - l2arc_dev_t *dev = hdr->b_l2hdr.b_dev; - - ASSERT((old == hdr_full_cache && new == hdr_l2only_cache) || - (old == hdr_l2only_cache && new == hdr_full_cache)); - - nhdr = kmem_cache_alloc(new, KM_PUSHPAGE); - - ASSERT(MUTEX_HELD(HDR_LOCK(hdr))); - buf_hash_remove(hdr); - - bcopy(hdr, nhdr, HDR_L2ONLY_SIZE); - - if (new == hdr_full_cache) { - nhdr->b_flags |= ARC_FLAG_HAS_L1HDR; - /* - * arc_access and arc_change_state need to be aware that a - * header has just come out of L2ARC, so we set its state to - * l2c_only even though it's about to change. - */ - nhdr->b_l1hdr.b_state = arc_l2c_only; - - /* Verify previous threads set to NULL before freeing */ - ASSERT3P(nhdr->b_l1hdr.b_tmp_cdata, ==, NULL); - } else { - ASSERT(hdr->b_l1hdr.b_buf == NULL); - ASSERT0(hdr->b_l1hdr.b_datacnt); - - /* - * If we've reached here, We must have been called from - * arc_evict_hdr(), as such we should have already been - * removed from any ghost list we were previously on - * (which protects us from racing with arc_evict_state), - * thus no locking is needed during this check. - */ - ASSERT(!multilist_link_active(&hdr->b_l1hdr.b_arc_node)); - - /* - * A buffer must not be moved into the arc_l2c_only - * state if it's not finished being written out to the - * l2arc device. Otherwise, the b_l1hdr.b_tmp_cdata field - * might try to be accessed, even though it was removed. - */ - VERIFY(!HDR_L2_WRITING(hdr)); - VERIFY3P(hdr->b_l1hdr.b_tmp_cdata, ==, NULL); +#define ARC_MINTIME (hz>>4) /* 62 ms */ -#ifdef ZFS_DEBUG - if (hdr->b_l1hdr.b_thawed != NULL) { - kmem_free(hdr->b_l1hdr.b_thawed, 1); - hdr->b_l1hdr.b_thawed = NULL; - } -#endif +static inline boolean_t +arc_buf_is_shared(arc_buf_t *buf) +{ + boolean_t shared = (buf->b_data != NULL && + buf->b_data == buf->b_hdr->b_l1hdr.b_pdata); + IMPLY(shared, HDR_SHARED_DATA(buf->b_hdr)); + return (shared); +} - nhdr->b_flags &= ~ARC_FLAG_HAS_L1HDR; +static inline void +arc_cksum_free(arc_buf_hdr_t *hdr) +{ + ASSERT(HDR_HAS_L1HDR(hdr)); + mutex_enter(&hdr->b_l1hdr.b_freeze_lock); + if (hdr->b_l1hdr.b_freeze_cksum != NULL) { + kmem_free(hdr->b_l1hdr.b_freeze_cksum, sizeof (zio_cksum_t)); + hdr->b_l1hdr.b_freeze_cksum = NULL; } - /* - * The header has been reallocated so we need to re-insert it into any - * lists it was on. - */ - (void) buf_hash_insert(nhdr, NULL); - - ASSERT(list_link_active(&hdr->b_l2hdr.b_l2node)); - - mutex_enter(&dev->l2ad_mtx); - - /* - * We must place the realloc'ed header back into the list at - * the same spot. Otherwise, if it's placed earlier in the list, - * l2arc_write_buffers() could find it during the function's - * write phase, and try to write it out to the l2arc. - */ - list_insert_after(&dev->l2ad_buflist, hdr, nhdr); - list_remove(&dev->l2ad_buflist, hdr); - - mutex_exit(&dev->l2ad_mtx); - - /* - * Since we're using the pointer address as the tag when - * incrementing and decrementing the l2ad_alloc refcount, we - * must remove the old pointer (that we're about to destroy) and - * add the new pointer to the refcount. Otherwise we'd remove - * the wrong pointer address when calling arc_hdr_destroy() later. - */ - - (void) refcount_remove_many(&dev->l2ad_alloc, - hdr->b_l2hdr.b_asize, hdr); - - (void) refcount_add_many(&dev->l2ad_alloc, - nhdr->b_l2hdr.b_asize, nhdr); - - buf_discard_identity(hdr); - hdr->b_freeze_cksum = NULL; - kmem_cache_free(old, hdr); - - return (nhdr); + mutex_exit(&hdr->b_l1hdr.b_freeze_lock); } - -#define ARC_MINTIME (hz>>4) /* 62 ms */ - static void arc_cksum_verify(arc_buf_t *buf) { + arc_buf_hdr_t *hdr = buf->b_hdr; zio_cksum_t zc; if (!(zfs_flags & ZFS_DEBUG_MODIFY)) return; - mutex_enter(&buf->b_hdr->b_l1hdr.b_freeze_lock); - if (buf->b_hdr->b_freeze_cksum == NULL || HDR_IO_ERROR(buf->b_hdr)) { - mutex_exit(&buf->b_hdr->b_l1hdr.b_freeze_lock); + ASSERT(HDR_HAS_L1HDR(hdr)); + + mutex_enter(&hdr->b_l1hdr.b_freeze_lock); + if (hdr->b_l1hdr.b_freeze_cksum == NULL || HDR_IO_ERROR(hdr)) { + mutex_exit(&hdr->b_l1hdr.b_freeze_lock); return; } - fletcher_2_native(buf->b_data, buf->b_hdr->b_size, NULL, &zc); - if (!ZIO_CHECKSUM_EQUAL(*buf->b_hdr->b_freeze_cksum, zc)) + fletcher_2_native(buf->b_data, HDR_GET_LSIZE(hdr), NULL, &zc); + if (!ZIO_CHECKSUM_EQUAL(*hdr->b_l1hdr.b_freeze_cksum, zc)) panic("buffer modified while frozen!"); - mutex_exit(&buf->b_hdr->b_l1hdr.b_freeze_lock); + mutex_exit(&hdr->b_l1hdr.b_freeze_lock); } -static int -arc_cksum_equal(arc_buf_t *buf) +static boolean_t +arc_cksum_is_equal(arc_buf_hdr_t *hdr, zio_t *zio) { - zio_cksum_t zc; - int equal; + enum zio_compress compress = BP_GET_COMPRESS(zio->io_bp); + boolean_t valid_cksum; - mutex_enter(&buf->b_hdr->b_l1hdr.b_freeze_lock); - fletcher_2_native(buf->b_data, buf->b_hdr->b_size, NULL, &zc); - equal = ZIO_CHECKSUM_EQUAL(*buf->b_hdr->b_freeze_cksum, zc); - mutex_exit(&buf->b_hdr->b_l1hdr.b_freeze_lock); + ASSERT(!BP_IS_EMBEDDED(zio->io_bp)); + VERIFY3U(BP_GET_PSIZE(zio->io_bp), ==, HDR_GET_PSIZE(hdr)); + + /* + * We rely on the blkptr's checksum to determine if the block + * is valid or not. When compressed arc is enabled, the l2arc + * writes the block to the l2arc just as it appears in the pool. + * This allows us to use the blkptr's checksum to validate the + * data that we just read off of the l2arc without having to store + * a separate checksum in the arc_buf_hdr_t. However, if compressed + * arc is disabled, then the data written to the l2arc is always + * uncompressed and won't match the block as it exists in the main + * pool. When this is the case, we must first compress it if it is + * compressed on the main pool before we can validate the checksum. + */ + if (!HDR_COMPRESSION_ENABLED(hdr) && compress != ZIO_COMPRESS_OFF) { + ASSERT3U(HDR_GET_COMPRESS(hdr), ==, ZIO_COMPRESS_OFF); + uint64_t lsize = HDR_GET_LSIZE(hdr); + uint64_t csize; + + void *cbuf = zio_buf_alloc(HDR_GET_PSIZE(hdr)); + csize = zio_compress_data(compress, zio->io_data, cbuf, lsize); + ASSERT3U(csize, <=, HDR_GET_PSIZE(hdr)); + if (csize < HDR_GET_PSIZE(hdr)) { + /* + * Compressed blocks are always a multiple of the + * smallest ashift in the pool. Ideally, we would + * like to round up the csize to the next + * spa_min_ashift but that value may have changed + * since the block was last written. Instead, + * we rely on the fact that the hdr's psize + * was set to the psize of the block when it was + * last written. We set the csize to that value + * and zero out any part that should not contain + * data. + */ + bzero((char *)cbuf + csize, HDR_GET_PSIZE(hdr) - csize); + csize = HDR_GET_PSIZE(hdr); + } + zio_push_transform(zio, cbuf, csize, HDR_GET_PSIZE(hdr), NULL); + } - return (equal); + /* + * Block pointers always store the checksum for the logical data. + * If the block pointer has the gang bit set, then the checksum + * it represents is for the reconstituted data and not for an + * individual gang member. The zio pipeline, however, must be able to + * determine the checksum of each of the gang constituents so it + * treats the checksum comparison differently than what we need + * for l2arc blocks. This prevents us from using the + * zio_checksum_error() interface directly. Instead we must call the + * zio_checksum_error_impl() so that we can ensure the checksum is + * generated using the correct checksum algorithm and accounts for the + * logical I/O size and not just a gang fragment. + */ + valid_cksum = (zio_checksum_error_impl(zio->io_spa, zio->io_bp, + BP_GET_CHECKSUM(zio->io_bp), zio->io_data, zio->io_size, + zio->io_offset, NULL) == 0); + zio_pop_transforms(zio); + return (valid_cksum); } static void -arc_cksum_compute(arc_buf_t *buf, boolean_t force) +arc_cksum_compute(arc_buf_t *buf) { - if (!force && !(zfs_flags & ZFS_DEBUG_MODIFY)) + arc_buf_hdr_t *hdr = buf->b_hdr; + + if (!(zfs_flags & ZFS_DEBUG_MODIFY)) return; + ASSERT(HDR_HAS_L1HDR(hdr)); mutex_enter(&buf->b_hdr->b_l1hdr.b_freeze_lock); - if (buf->b_hdr->b_freeze_cksum != NULL) { - mutex_exit(&buf->b_hdr->b_l1hdr.b_freeze_lock); + if (hdr->b_l1hdr.b_freeze_cksum != NULL) { + mutex_exit(&hdr->b_l1hdr.b_freeze_lock); return; } - buf->b_hdr->b_freeze_cksum = kmem_alloc(sizeof (zio_cksum_t), KM_SLEEP); - fletcher_2_native(buf->b_data, buf->b_hdr->b_size, - NULL, buf->b_hdr->b_freeze_cksum); - mutex_exit(&buf->b_hdr->b_l1hdr.b_freeze_lock); + hdr->b_l1hdr.b_freeze_cksum = kmem_alloc(sizeof (zio_cksum_t), + KM_SLEEP); + fletcher_2_native(buf->b_data, HDR_GET_LSIZE(hdr), NULL, + hdr->b_l1hdr.b_freeze_cksum); + mutex_exit(&hdr->b_l1hdr.b_freeze_lock); #ifdef illumos arc_buf_watch(buf); #endif @@ -1735,7 +1857,7 @@ arc_buf_watch(arc_buf_t *buf) procctl_t ctl; ctl.cmd = PCWATCH; ctl.prwatch.pr_vaddr = (uintptr_t)buf->b_data; - ctl.prwatch.pr_size = buf->b_hdr->b_size; + ctl.prwatch.pr_size = HDR_GET_LSIZE(buf->b_hdr); ctl.prwatch.pr_wflags = WA_WRITE; result = write(arc_procfd, &ctl, sizeof (ctl)); ASSERT3U(result, ==, sizeof (ctl)); @@ -1747,11 +1869,14 @@ arc_buf_watch(arc_buf_t *buf) static arc_buf_contents_t arc_buf_type(arc_buf_hdr_t *hdr) { + arc_buf_contents_t type; if (HDR_ISTYPE_METADATA(hdr)) { - return (ARC_BUFC_METADATA); + type = ARC_BUFC_METADATA; } else { - return (ARC_BUFC_DATA); + type = ARC_BUFC_DATA; } + VERIFY3U(hdr->b_type, ==, type); + return (type); } static uint32_t @@ -1773,29 +1898,29 @@ arc_bufc_to_flags(arc_buf_contents_t typ void arc_buf_thaw(arc_buf_t *buf) { + arc_buf_hdr_t *hdr = buf->b_hdr; + if (zfs_flags & ZFS_DEBUG_MODIFY) { - if (buf->b_hdr->b_l1hdr.b_state != arc_anon) + if (hdr->b_l1hdr.b_state != arc_anon) panic("modifying non-anon buffer!"); *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-all@freebsd.org Fri Oct 14 07:14:37 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 79AEAC11160; Fri, 14 Oct 2016 07:14:37 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 3242EAE7; Fri, 14 Oct 2016 07:14:37 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9E7EalE060434; Fri, 14 Oct 2016 07:14:36 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9E7EaS9060430; Fri, 14 Oct 2016 07:14:36 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201610140714.u9E7EaS9060430@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Fri, 14 Oct 2016 07:14:36 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307266 - in stable/10: cddl/contrib/opensolaris/cmd/zdb cddl/contrib/opensolaris/cmd/ztest sys/cddl/contrib/opensolaris/uts/common/fs/zfs sys/cddl/contrib/opensolaris/uts/common/fs/zfs... X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Oct 2016 07:14:37 -0000 Author: mav Date: Fri Oct 14 07:14:35 2016 New Revision: 307266 URL: https://svnweb.freebsd.org/changeset/base/307266 Log: MFC r305323: MFV r302991: 6950 ARC should cache compressed data illumos/illumos-gate@dcbf3bd6a1f1360fc1afcee9e22c6dcff7844bf2 https://github.com/illumos/illumos-gate/commit/dcbf3bd6a1f1360fc1afcee9e22c6dcff 7844bf2 https://www.illumos.org/issues/6950 When reading compressed data from disk, the ARC should keep the compressed block cached and only decompress it when consumers access the block. The uncompressed data should be short-lived allowing the ARC to cache a much large r amount of data. The DMU would also maintain a smaller cache of uncompressed blocks to minimize the impact of decompressing frequently accessed blocks. Reviewed by: Prakash Surya Reviewed by: Dan Kimmel Reviewed by: Matt Ahrens Reviewed by: Paul Dagnelie Reviewed by: Don Brady Reviewed by: Richard Elling Approved by: Richard Lowe Author: George Wilson Modified: stable/10/cddl/contrib/opensolaris/cmd/zdb/zdb.c stable/10/cddl/contrib/opensolaris/cmd/ztest/ztest.c stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dbuf.c stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu.c stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_diff.c stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_objset.c stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_send.c stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_traverse.c stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dnode.c stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dnode_sync.c stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_scan.c stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/refcount.c stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/arc.h stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dbuf.h stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/refcount.h stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/spa.h stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zio.h stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zio_checksum.h stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zil.c stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zio.c stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zio_checksum.c Directory Properties: stable/10/ (props changed) Modified: stable/10/cddl/contrib/opensolaris/cmd/zdb/zdb.c ============================================================================== --- stable/10/cddl/contrib/opensolaris/cmd/zdb/zdb.c Fri Oct 14 07:13:43 2016 (r307265) +++ stable/10/cddl/contrib/opensolaris/cmd/zdb/zdb.c Fri Oct 14 07:14:35 2016 (r307266) @@ -1289,7 +1289,7 @@ visit_indirect(spa_t *spa, const dnode_p } if (!err) ASSERT3U(fill, ==, BP_GET_FILL(bp)); - (void) arc_buf_remove_ref(buf, &buf); + arc_buf_destroy(buf, &buf); } return (err); Modified: stable/10/cddl/contrib/opensolaris/cmd/ztest/ztest.c ============================================================================== --- stable/10/cddl/contrib/opensolaris/cmd/ztest/ztest.c Fri Oct 14 07:13:43 2016 (r307265) +++ stable/10/cddl/contrib/opensolaris/cmd/ztest/ztest.c Fri Oct 14 07:14:35 2016 (r307266) @@ -189,6 +189,7 @@ extern uint64_t metaslab_gang_bang; extern uint64_t metaslab_df_alloc_threshold; extern uint64_t zfs_deadman_synctime_ms; extern int metaslab_preload_limit; +extern boolean_t zfs_compressed_arc_enabled; static ztest_shared_opts_t *ztest_shared_opts; static ztest_shared_opts_t ztest_opts; @@ -5355,6 +5356,12 @@ ztest_resume_thread(void *arg) if (spa_suspended(spa)) ztest_resume(spa); (void) poll(NULL, 0, 100); + + /* + * Periodically change the zfs_compressed_arc_enabled setting. + */ + if (ztest_random(10) == 0) + zfs_compressed_arc_enabled = ztest_random(2); } return (NULL); } Modified: stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c ============================================================================== --- stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c Fri Oct 14 07:13:43 2016 (r307265) +++ stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c Fri Oct 14 07:14:35 2016 (r307266) @@ -120,9 +120,134 @@ * - ARC header release, as it removes from L2ARC buflists */ +/* + * ARC operation: + * + * Every block that is in the ARC is tracked by an arc_buf_hdr_t structure. + * This structure can point either to a block that is still in the cache or to + * one that is only accessible in an L2 ARC device, or it can provide + * information about a block that was recently evicted. If a block is + * only accessible in the L2ARC, then the arc_buf_hdr_t only has enough + * information to retrieve it from the L2ARC device. This information is + * stored in the l2arc_buf_hdr_t sub-structure of the arc_buf_hdr_t. A block + * that is in this state cannot access the data directly. + * + * Blocks that are actively being referenced or have not been evicted + * are cached in the L1ARC. The L1ARC (l1arc_buf_hdr_t) is a structure within + * the arc_buf_hdr_t that will point to the data block in memory. A block can + * only be read by a consumer if it has an l1arc_buf_hdr_t. The L1ARC + * caches data in two ways -- in a list of arc buffers (arc_buf_t) and + * also in the arc_buf_hdr_t's private physical data block pointer (b_pdata). + * Each arc buffer (arc_buf_t) is being actively accessed by a specific ARC + * consumer, and always contains uncompressed data. The ARC will provide + * references to this data and will keep it cached until it is no longer in + * use. Typically, the arc will try to cache only the L1ARC's physical data + * block and will aggressively evict any arc_buf_t that is no longer referenced. + * The amount of memory consumed by the arc_buf_t's can be seen via the + * "overhead_size" kstat. + * + * + * arc_buf_hdr_t + * +-----------+ + * | | + * | | + * | | + * +-----------+ + * l2arc_buf_hdr_t| | + * | | + * +-----------+ + * l1arc_buf_hdr_t| | + * | | arc_buf_t + * | b_buf +------------>+---------+ arc_buf_t + * | | |b_next +---->+---------+ + * | b_pdata +-+ |---------| |b_next +-->NULL + * +-----------+ | | | +---------+ + * | |b_data +-+ | | + * | +---------+ | |b_data +-+ + * +->+------+ | +---------+ | + * (potentially) | | | | + * compressed | | | | + * data +------+ | v + * +->+------+ +------+ + * uncompressed | | | | + * data | | | | + * +------+ +------+ + * + * The L1ARC's data pointer, however, may or may not be uncompressed. The + * ARC has the ability to store the physical data (b_pdata) associated with + * the DVA of the arc_buf_hdr_t. Since the b_pdata is a copy of the on-disk + * physical block, it will match its on-disk compression characteristics. + * If the block on-disk is compressed, then the physical data block + * in the cache will also be compressed and vice-versa. This behavior + * can be disabled by setting 'zfs_compressed_arc_enabled' to B_FALSE. When the + * compressed ARC functionality is disabled, the b_pdata will point to an + * uncompressed version of the on-disk data. + * + * When a consumer reads a block, the ARC must first look to see if the + * arc_buf_hdr_t is cached. If the hdr is cached and already has an arc_buf_t, + * then an additional arc_buf_t is allocated and the uncompressed data is + * bcopied from the existing arc_buf_t. If the hdr is cached but does not + * have an arc_buf_t, then the ARC allocates a new arc_buf_t and decompresses + * the b_pdata contents into the arc_buf_t's b_data. If the arc_buf_hdr_t's + * b_pdata is not compressed, then the block is shared with the newly + * allocated arc_buf_t. This block sharing only occurs with one arc_buf_t + * in the arc buffer chain. Sharing the block reduces the memory overhead + * required when the hdr is caching uncompressed blocks or the compressed + * arc functionality has been disabled via 'zfs_compressed_arc_enabled'. + * + * The diagram below shows an example of an uncompressed ARC hdr that is + * sharing its data with an arc_buf_t: + * + * arc_buf_hdr_t + * +-----------+ + * | | + * | | + * | | + * +-----------+ + * l2arc_buf_hdr_t| | + * | | + * +-----------+ + * l1arc_buf_hdr_t| | + * | | arc_buf_t (shared) + * | b_buf +------------>+---------+ arc_buf_t + * | | |b_next +---->+---------+ + * | b_pdata +-+ |---------| |b_next +-->NULL + * +-----------+ | | | +---------+ + * | |b_data +-+ | | + * | +---------+ | |b_data +-+ + * +->+------+ | +---------+ | + * | | | | + * uncompressed | | | | + * data +------+ | | + * ^ +->+------+ | + * | uncompressed | | | + * | data | | | + * | +------+ | + * +---------------------------------+ + * + * Writing to the arc requires that the ARC first discard the b_pdata + * since the physical block is about to be rewritten. The new data contents + * will be contained in the arc_buf_t (uncompressed). As the I/O pipeline + * performs the write, it may compress the data before writing it to disk. + * The ARC will be called with the transformed data and will bcopy the + * transformed on-disk block into a newly allocated b_pdata. + * + * When the L2ARC is in use, it will also take advantage of the b_pdata. The + * L2ARC will always write the contents of b_pdata to the L2ARC. This means + * that when compressed arc is enabled that the L2ARC blocks are identical + * to the on-disk block in the main data pool. This provides a significant + * advantage since the ARC can leverage the bp's checksum when reading from the + * L2ARC to determine if the contents are valid. However, if the compressed + * arc is disabled, then the L2ARC's block must be transformed to look + * like the physical block in the main data pool before comparing the + * checksum and determining its validity. + */ + #include #include +#include #include +#include #include #include #include @@ -154,10 +279,6 @@ static kcondvar_t arc_reclaim_thread_cv; static boolean_t arc_reclaim_thread_exit; static kcondvar_t arc_reclaim_waiters_cv; -static kmutex_t arc_user_evicts_lock; -static kcondvar_t arc_user_evicts_cv; -static boolean_t arc_user_evicts_thread_exit; - uint_t arc_reduce_dnlc_percent = 3; /* @@ -229,13 +350,14 @@ uint64_t zfs_arc_meta_min = 0; int zfs_arc_grow_retry = 0; int zfs_arc_shrink_shift = 0; int zfs_arc_p_min_shift = 0; -int zfs_disable_dup_eviction = 0; uint64_t zfs_arc_average_blocksize = 8 * 1024; /* 8KB */ u_int zfs_arc_free_target = 0; /* Absolute min for arc min / max is 16MB. */ static uint64_t arc_abs_min = 16 << 20; +boolean_t zfs_compressed_arc_enabled = B_TRUE; + static int sysctl_vfs_zfs_arc_free_target(SYSCTL_HANDLER_ARGS); static int sysctl_vfs_zfs_arc_meta_limit(SYSCTL_HANDLER_ARGS); static int sysctl_vfs_zfs_arc_max(SYSCTL_HANDLER_ARGS); @@ -268,6 +390,8 @@ SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, arc_ave SYSCTL_INT(_vfs_zfs, OID_AUTO, arc_shrink_shift, CTLFLAG_RW, &arc_shrink_shift, 0, "log2(fraction of arc to reclaim)"); +SYSCTL_INT(_vfs_zfs, OID_AUTO, compressed_arc_enabled, CTLFLAG_RDTUN, + &zfs_compressed_arc_enabled, 0, "Enable compressed ARC"); /* * We don't have a tunable for arc_free_target due to the dependency on @@ -349,7 +473,7 @@ typedef struct arc_state { /* * total amount of evictable data in this state */ - uint64_t arcs_lsize[ARC_BUFC_NUMTYPES]; + refcount_t arcs_esize[ARC_BUFC_NUMTYPES]; /* * total amount of data in this state; this includes: evictable, * non-evictable, ARC_BUFC_DATA, and ARC_BUFC_METADATA. @@ -415,6 +539,26 @@ typedef struct arc_stats { kstat_named_t arcstat_c_max; kstat_named_t arcstat_size; /* + * Number of compressed bytes stored in the arc_buf_hdr_t's b_pdata. + * Note that the compressed bytes may match the uncompressed bytes + * if the block is either not compressed or compressed arc is disabled. + */ + kstat_named_t arcstat_compressed_size; + /* + * Uncompressed size of the data stored in b_pdata. If compressed + * arc is disabled then this value will be identical to the stat + * above. + */ + kstat_named_t arcstat_uncompressed_size; + /* + * Number of bytes stored in all the arc_buf_t's. This is classified + * as "overhead" since this data is typically short-lived and will + * be evicted from the arc when it becomes unreferenced unless the + * zfs_keep_uncompressed_metadata or zfs_keep_uncompressed_level + * values have been set (see comment in dbuf.c for more information). + */ + kstat_named_t arcstat_overhead_size; + /* * Number of bytes consumed by internal ARC structures necessary * for tracking purposes; these structures are not actually * backed by ARC buffers. This includes arc_buf_hdr_t structures @@ -559,16 +703,12 @@ typedef struct arc_stats { kstat_named_t arcstat_l2_evict_reading; kstat_named_t arcstat_l2_evict_l1cached; kstat_named_t arcstat_l2_free_on_write; - kstat_named_t arcstat_l2_cdata_free_on_write; kstat_named_t arcstat_l2_abort_lowmem; kstat_named_t arcstat_l2_cksum_bad; kstat_named_t arcstat_l2_io_error; kstat_named_t arcstat_l2_size; kstat_named_t arcstat_l2_asize; kstat_named_t arcstat_l2_hdr_size; - kstat_named_t arcstat_l2_compress_successes; - kstat_named_t arcstat_l2_compress_zeros; - kstat_named_t arcstat_l2_compress_failures; kstat_named_t arcstat_l2_padding_needed; kstat_named_t arcstat_l2_write_trylock_fail; kstat_named_t arcstat_l2_write_passed_headroom; @@ -583,9 +723,6 @@ typedef struct arc_stats { kstat_named_t arcstat_l2_write_buffer_list_iter; kstat_named_t arcstat_l2_write_buffer_list_null_iter; kstat_named_t arcstat_memory_throttle_count; - kstat_named_t arcstat_duplicate_buffers; - kstat_named_t arcstat_duplicate_buffers_size; - kstat_named_t arcstat_duplicate_reads; kstat_named_t arcstat_meta_used; kstat_named_t arcstat_meta_limit; kstat_named_t arcstat_meta_max; @@ -628,6 +765,9 @@ static arc_stats_t arc_stats = { { "c_min", KSTAT_DATA_UINT64 }, { "c_max", KSTAT_DATA_UINT64 }, { "size", KSTAT_DATA_UINT64 }, + { "compressed_size", KSTAT_DATA_UINT64 }, + { "uncompressed_size", KSTAT_DATA_UINT64 }, + { "overhead_size", KSTAT_DATA_UINT64 }, { "hdr_size", KSTAT_DATA_UINT64 }, { "data_size", KSTAT_DATA_UINT64 }, { "metadata_size", KSTAT_DATA_UINT64 }, @@ -661,16 +801,12 @@ static arc_stats_t arc_stats = { { "l2_evict_reading", KSTAT_DATA_UINT64 }, { "l2_evict_l1cached", KSTAT_DATA_UINT64 }, { "l2_free_on_write", KSTAT_DATA_UINT64 }, - { "l2_cdata_free_on_write", KSTAT_DATA_UINT64 }, { "l2_abort_lowmem", KSTAT_DATA_UINT64 }, { "l2_cksum_bad", KSTAT_DATA_UINT64 }, { "l2_io_error", KSTAT_DATA_UINT64 }, { "l2_size", KSTAT_DATA_UINT64 }, { "l2_asize", KSTAT_DATA_UINT64 }, { "l2_hdr_size", KSTAT_DATA_UINT64 }, - { "l2_compress_successes", KSTAT_DATA_UINT64 }, - { "l2_compress_zeros", KSTAT_DATA_UINT64 }, - { "l2_compress_failures", KSTAT_DATA_UINT64 }, { "l2_padding_needed", KSTAT_DATA_UINT64 }, { "l2_write_trylock_fail", KSTAT_DATA_UINT64 }, { "l2_write_passed_headroom", KSTAT_DATA_UINT64 }, @@ -685,9 +821,6 @@ static arc_stats_t arc_stats = { { "l2_write_buffer_list_iter", KSTAT_DATA_UINT64 }, { "l2_write_buffer_list_null_iter", KSTAT_DATA_UINT64 }, { "memory_throttle_count", KSTAT_DATA_UINT64 }, - { "duplicate_buffers", KSTAT_DATA_UINT64 }, - { "duplicate_buffers_size", KSTAT_DATA_UINT64 }, - { "duplicate_reads", KSTAT_DATA_UINT64 }, { "arc_meta_used", KSTAT_DATA_UINT64 }, { "arc_meta_limit", KSTAT_DATA_UINT64 }, { "arc_meta_max", KSTAT_DATA_UINT64 }, @@ -760,8 +893,12 @@ static arc_state_t *arc_l2c_only; #define arc_meta_used ARCSTAT(arcstat_meta_used) /* size of metadata */ #define arc_meta_max ARCSTAT(arcstat_meta_max) /* max size of metadata */ -#define L2ARC_IS_VALID_COMPRESS(_c_) \ - ((_c_) == ZIO_COMPRESS_LZ4 || (_c_) == ZIO_COMPRESS_EMPTY) +/* compressed size of entire arc */ +#define arc_compressed_size ARCSTAT(arcstat_compressed_size) +/* uncompressed size of entire arc */ +#define arc_uncompressed_size ARCSTAT(arcstat_uncompressed_size) +/* number of bytes in the arc from arc_buf_t's */ +#define arc_overhead_size ARCSTAT(arcstat_overhead_size) static int arc_no_grow; /* Don't try to grow cache size */ static uint64_t arc_tempreserve; @@ -821,6 +958,7 @@ struct arc_write_callback { */ typedef struct l1arc_buf_hdr { kmutex_t b_freeze_lock; + zio_cksum_t *b_freeze_cksum; #ifdef ZFS_DEBUG /* * used for debugging wtih kmem_flags - by allocating and freeing @@ -831,9 +969,10 @@ typedef struct l1arc_buf_hdr { #endif arc_buf_t *b_buf; - uint32_t b_datacnt; + uint32_t b_bufcnt; /* for waiting on writes to complete */ kcondvar_t b_cv; + uint8_t b_byteswap; /* protected by arc state mutex */ arc_state_t *b_state; @@ -846,8 +985,7 @@ typedef struct l1arc_buf_hdr { refcount_t b_refcnt; arc_callback_t *b_acb; - /* temporary buffer holder for in-flight compressed or padded data */ - void *b_tmp_cdata; + void *b_pdata; } l1arc_buf_hdr_t; typedef struct l2arc_dev l2arc_dev_t; @@ -856,9 +994,6 @@ typedef struct l2arc_buf_hdr { /* protected by arc_buf_hdr mutex */ l2arc_dev_t *b_dev; /* L2ARC device */ uint64_t b_daddr; /* disk address, offset byte */ - /* real alloc'd buffer size depending on b_compress applied */ - int32_t b_asize; - uint8_t b_compress; list_node_t b_l2node; } l2arc_buf_hdr_t; @@ -867,20 +1002,37 @@ struct arc_buf_hdr { /* protected by hash lock */ dva_t b_dva; uint64_t b_birth; - /* - * Even though this checksum is only set/verified when a buffer is in - * the L1 cache, it needs to be in the set of common fields because it - * must be preserved from the time before a buffer is written out to - * L2ARC until after it is read back in. - */ - zio_cksum_t *b_freeze_cksum; + arc_buf_contents_t b_type; arc_buf_hdr_t *b_hash_next; arc_flags_t b_flags; - /* immutable */ - int32_t b_size; - uint64_t b_spa; + /* + * This field stores the size of the data buffer after + * compression, and is set in the arc's zio completion handlers. + * It is in units of SPA_MINBLOCKSIZE (e.g. 1 == 512 bytes). + * + * While the block pointers can store up to 32MB in their psize + * field, we can only store up to 32MB minus 512B. This is due + * to the bp using a bias of 1, whereas we use a bias of 0 (i.e. + * a field of zeros represents 512B in the bp). We can't use a + * bias of 1 since we need to reserve a psize of zero, here, to + * represent holes and embedded blocks. + * + * This isn't a problem in practice, since the maximum size of a + * buffer is limited to 16MB, so we never need to store 32MB in + * this field. Even in the upstream illumos code base, the + * maximum size of a buffer is limited to 16MB. + */ + uint16_t b_psize; + + /* + * This field stores the size of the data buffer before + * compression, and cannot change once set. It is in units + * of SPA_MINBLOCKSIZE (e.g. 2 == 1024 bytes) + */ + uint16_t b_lsize; /* immutable */ + uint64_t b_spa; /* immutable */ /* L2ARC fields. Undefined when not in L2ARC. */ l2arc_buf_hdr_t b_l2hdr; @@ -984,9 +1136,6 @@ sysctl_vfs_zfs_arc_min(SYSCTL_HANDLER_AR } #endif -static arc_buf_t *arc_eviction_list; -static arc_buf_hdr_t arc_eviction_hdr; - #define GHOST_STATE(state) \ ((state) == arc_mru_ghost || (state) == arc_mfu_ghost || \ (state) == arc_l2c_only) @@ -995,25 +1144,35 @@ static arc_buf_hdr_t arc_eviction_hdr; #define HDR_IO_IN_PROGRESS(hdr) ((hdr)->b_flags & ARC_FLAG_IO_IN_PROGRESS) #define HDR_IO_ERROR(hdr) ((hdr)->b_flags & ARC_FLAG_IO_ERROR) #define HDR_PREFETCH(hdr) ((hdr)->b_flags & ARC_FLAG_PREFETCH) -#define HDR_FREED_IN_READ(hdr) ((hdr)->b_flags & ARC_FLAG_FREED_IN_READ) -#define HDR_BUF_AVAILABLE(hdr) ((hdr)->b_flags & ARC_FLAG_BUF_AVAILABLE) +#define HDR_COMPRESSION_ENABLED(hdr) \ + ((hdr)->b_flags & ARC_FLAG_COMPRESSED_ARC) #define HDR_L2CACHE(hdr) ((hdr)->b_flags & ARC_FLAG_L2CACHE) -#define HDR_L2COMPRESS(hdr) ((hdr)->b_flags & ARC_FLAG_L2COMPRESS) #define HDR_L2_READING(hdr) \ - (((hdr)->b_flags & ARC_FLAG_IO_IN_PROGRESS) && \ - ((hdr)->b_flags & ARC_FLAG_HAS_L2HDR)) + (((hdr)->b_flags & ARC_FLAG_IO_IN_PROGRESS) && \ + ((hdr)->b_flags & ARC_FLAG_HAS_L2HDR)) #define HDR_L2_WRITING(hdr) ((hdr)->b_flags & ARC_FLAG_L2_WRITING) #define HDR_L2_EVICTED(hdr) ((hdr)->b_flags & ARC_FLAG_L2_EVICTED) #define HDR_L2_WRITE_HEAD(hdr) ((hdr)->b_flags & ARC_FLAG_L2_WRITE_HEAD) +#define HDR_SHARED_DATA(hdr) ((hdr)->b_flags & ARC_FLAG_SHARED_DATA) #define HDR_ISTYPE_METADATA(hdr) \ - ((hdr)->b_flags & ARC_FLAG_BUFC_METADATA) + ((hdr)->b_flags & ARC_FLAG_BUFC_METADATA) #define HDR_ISTYPE_DATA(hdr) (!HDR_ISTYPE_METADATA(hdr)) #define HDR_HAS_L1HDR(hdr) ((hdr)->b_flags & ARC_FLAG_HAS_L1HDR) #define HDR_HAS_L2HDR(hdr) ((hdr)->b_flags & ARC_FLAG_HAS_L2HDR) +/* For storing compression mode in b_flags */ +#define HDR_COMPRESS_OFFSET (highbit64(ARC_FLAG_COMPRESS_0) - 1) + +#define HDR_GET_COMPRESS(hdr) ((enum zio_compress)BF32_GET((hdr)->b_flags, \ + HDR_COMPRESS_OFFSET, SPA_COMPRESSBITS)) +#define HDR_SET_COMPRESS(hdr, cmp) BF32_SET((hdr)->b_flags, \ + HDR_COMPRESS_OFFSET, SPA_COMPRESSBITS, (cmp)); + +#define ARC_BUF_LAST(buf) ((buf)->b_next == NULL) + /* * Other sizes */ @@ -1066,16 +1225,6 @@ uint64_t zfs_crc64_table[256]; #define L2ARC_FEED_SECS 1 /* caching interval secs */ #define L2ARC_FEED_MIN_MS 200 /* min caching interval ms */ -/* - * Used to distinguish headers that are being process by - * l2arc_write_buffers(), but have yet to be assigned to a l2arc disk - * address. This can happen when the header is added to the l2arc's list - * of buffers to write in the first stage of l2arc_write_buffers(), but - * has not yet been written out which happens in the second stage of - * l2arc_write_buffers(). - */ -#define L2ARC_ADDR_UNSET ((uint64_t)(-1)) - #define l2arc_writes_sent ARCSTAT(arcstat_l2_writes_sent) #define l2arc_writes_done ARCSTAT(arcstat_l2_writes_done) @@ -1110,41 +1259,47 @@ SYSCTL_INT(_vfs_zfs, OID_AUTO, l2arc_nor SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, anon_size, CTLFLAG_RD, &ARC_anon.arcs_size.rc_count, 0, "size of anonymous state"); -SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, anon_metadata_lsize, CTLFLAG_RD, - &ARC_anon.arcs_lsize[ARC_BUFC_METADATA], 0, "size of anonymous state"); -SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, anon_data_lsize, CTLFLAG_RD, - &ARC_anon.arcs_lsize[ARC_BUFC_DATA], 0, "size of anonymous state"); +SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, anon_metadata_esize, CTLFLAG_RD, + &ARC_anon.arcs_esize[ARC_BUFC_METADATA].rc_count, 0, + "size of anonymous state"); +SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, anon_data_esize, CTLFLAG_RD, + &ARC_anon.arcs_esize[ARC_BUFC_DATA].rc_count, 0, + "size of anonymous state"); SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, mru_size, CTLFLAG_RD, &ARC_mru.arcs_size.rc_count, 0, "size of mru state"); -SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, mru_metadata_lsize, CTLFLAG_RD, - &ARC_mru.arcs_lsize[ARC_BUFC_METADATA], 0, "size of metadata in mru state"); -SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, mru_data_lsize, CTLFLAG_RD, - &ARC_mru.arcs_lsize[ARC_BUFC_DATA], 0, "size of data in mru state"); +SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, mru_metadata_esize, CTLFLAG_RD, + &ARC_mru.arcs_esize[ARC_BUFC_METADATA].rc_count, 0, + "size of metadata in mru state"); +SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, mru_data_esize, CTLFLAG_RD, + &ARC_mru.arcs_esize[ARC_BUFC_DATA].rc_count, 0, + "size of data in mru state"); SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, mru_ghost_size, CTLFLAG_RD, &ARC_mru_ghost.arcs_size.rc_count, 0, "size of mru ghost state"); -SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, mru_ghost_metadata_lsize, CTLFLAG_RD, - &ARC_mru_ghost.arcs_lsize[ARC_BUFC_METADATA], 0, +SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, mru_ghost_metadata_esize, CTLFLAG_RD, + &ARC_mru_ghost.arcs_esize[ARC_BUFC_METADATA].rc_count, 0, "size of metadata in mru ghost state"); -SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, mru_ghost_data_lsize, CTLFLAG_RD, - &ARC_mru_ghost.arcs_lsize[ARC_BUFC_DATA], 0, +SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, mru_ghost_data_esize, CTLFLAG_RD, + &ARC_mru_ghost.arcs_esize[ARC_BUFC_DATA].rc_count, 0, "size of data in mru ghost state"); SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, mfu_size, CTLFLAG_RD, &ARC_mfu.arcs_size.rc_count, 0, "size of mfu state"); -SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, mfu_metadata_lsize, CTLFLAG_RD, - &ARC_mfu.arcs_lsize[ARC_BUFC_METADATA], 0, "size of metadata in mfu state"); -SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, mfu_data_lsize, CTLFLAG_RD, - &ARC_mfu.arcs_lsize[ARC_BUFC_DATA], 0, "size of data in mfu state"); +SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, mfu_metadata_esize, CTLFLAG_RD, + &ARC_mfu.arcs_esize[ARC_BUFC_METADATA].rc_count, 0, + "size of metadata in mfu state"); +SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, mfu_data_esize, CTLFLAG_RD, + &ARC_mfu.arcs_esize[ARC_BUFC_DATA].rc_count, 0, + "size of data in mfu state"); SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, mfu_ghost_size, CTLFLAG_RD, &ARC_mfu_ghost.arcs_size.rc_count, 0, "size of mfu ghost state"); -SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, mfu_ghost_metadata_lsize, CTLFLAG_RD, - &ARC_mfu_ghost.arcs_lsize[ARC_BUFC_METADATA], 0, +SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, mfu_ghost_metadata_esize, CTLFLAG_RD, + &ARC_mfu_ghost.arcs_esize[ARC_BUFC_METADATA].rc_count, 0, "size of metadata in mfu ghost state"); -SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, mfu_ghost_data_lsize, CTLFLAG_RD, - &ARC_mfu_ghost.arcs_lsize[ARC_BUFC_DATA], 0, +SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, mfu_ghost_data_esize, CTLFLAG_RD, + &ARC_mfu_ghost.arcs_esize[ARC_BUFC_DATA].rc_count, 0, "size of data in mfu ghost state"); SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, l2c_only_size, CTLFLAG_RD, @@ -1177,12 +1332,10 @@ static kmutex_t l2arc_free_on_write_mtx; static uint64_t l2arc_ndev; /* number of devices */ typedef struct l2arc_read_callback { - arc_buf_t *l2rcb_buf; /* read buffer */ - spa_t *l2rcb_spa; /* spa */ + arc_buf_hdr_t *l2rcb_hdr; /* read buffer */ blkptr_t l2rcb_bp; /* original blkptr */ zbookmark_phys_t l2rcb_zb; /* original bookmark */ int l2rcb_flags; /* original flags */ - enum zio_compress l2rcb_compress; /* applied compress */ void *l2rcb_data; /* temporary buffer */ } l2arc_read_callback_t; @@ -1195,7 +1348,7 @@ typedef struct l2arc_data_free { /* protected by l2arc_free_on_write_mtx */ void *l2df_data; size_t l2df_size; - void (*l2df_func)(void *, size_t); + arc_buf_contents_t l2df_type; list_node_t l2df_list_node; } l2arc_data_free_t; @@ -1203,21 +1356,22 @@ static kmutex_t l2arc_feed_thr_lock; static kcondvar_t l2arc_feed_thr_cv; static uint8_t l2arc_thread_exit; -static void arc_get_data_buf(arc_buf_t *); +static void *arc_get_data_buf(arc_buf_hdr_t *, uint64_t, void *); +static void arc_free_data_buf(arc_buf_hdr_t *, void *, uint64_t, void *); +static void arc_hdr_free_pdata(arc_buf_hdr_t *hdr); +static void arc_hdr_alloc_pdata(arc_buf_hdr_t *); static void arc_access(arc_buf_hdr_t *, kmutex_t *); static boolean_t arc_is_overflowing(); static void arc_buf_watch(arc_buf_t *); static arc_buf_contents_t arc_buf_type(arc_buf_hdr_t *); static uint32_t arc_bufc_to_flags(arc_buf_contents_t); +static inline void arc_hdr_set_flags(arc_buf_hdr_t *hdr, arc_flags_t flags); +static inline void arc_hdr_clear_flags(arc_buf_hdr_t *hdr, arc_flags_t flags); static boolean_t l2arc_write_eligible(uint64_t, arc_buf_hdr_t *); static void l2arc_read_done(zio_t *); -static boolean_t l2arc_transform_buf(arc_buf_hdr_t *, boolean_t); -static void l2arc_decompress_zio(zio_t *, arc_buf_hdr_t *, enum zio_compress); -static void l2arc_release_cdata_buf(arc_buf_hdr_t *); - static void l2arc_trim(const arc_buf_hdr_t *hdr) { @@ -1226,13 +1380,9 @@ l2arc_trim(const arc_buf_hdr_t *hdr) ASSERT(HDR_HAS_L2HDR(hdr)); ASSERT(MUTEX_HELD(&dev->l2ad_mtx)); - if (hdr->b_l2hdr.b_daddr == L2ARC_ADDR_UNSET) - return; - if (hdr->b_l2hdr.b_asize != 0) { + if (HDR_GET_PSIZE(hdr) != 0) { trim_map_free(dev->l2ad_vdev, hdr->b_l2hdr.b_daddr, - hdr->b_l2hdr.b_asize, 0); - } else { - ASSERT3U(hdr->b_l2hdr.b_compress, ==, ZIO_COMPRESS_EMPTY); + HDR_GET_PSIZE(hdr), 0); } } @@ -1253,14 +1403,14 @@ buf_hash(uint64_t spa, const dva_t *dva, return (crc); } -#define BUF_EMPTY(buf) \ - ((buf)->b_dva.dva_word[0] == 0 && \ - (buf)->b_dva.dva_word[1] == 0) - -#define BUF_EQUAL(spa, dva, birth, buf) \ - ((buf)->b_dva.dva_word[0] == (dva)->dva_word[0]) && \ - ((buf)->b_dva.dva_word[1] == (dva)->dva_word[1]) && \ - ((buf)->b_birth == birth) && ((buf)->b_spa == spa) +#define HDR_EMPTY(hdr) \ + ((hdr)->b_dva.dva_word[0] == 0 && \ + (hdr)->b_dva.dva_word[1] == 0) + +#define HDR_EQUAL(spa, dva, birth, hdr) \ + ((hdr)->b_dva.dva_word[0] == (dva)->dva_word[0]) && \ + ((hdr)->b_dva.dva_word[1] == (dva)->dva_word[1]) && \ + ((hdr)->b_birth == birth) && ((hdr)->b_spa == spa) static void buf_discard_identity(arc_buf_hdr_t *hdr) @@ -1282,7 +1432,7 @@ buf_hash_find(uint64_t spa, const blkptr mutex_enter(hash_lock); for (hdr = buf_hash_table.ht_table[idx]; hdr != NULL; hdr = hdr->b_hash_next) { - if (BUF_EQUAL(spa, dva, birth, hdr)) { + if (HDR_EQUAL(spa, dva, birth, hdr)) { *lockp = hash_lock; return (hdr); } @@ -1320,13 +1470,13 @@ buf_hash_insert(arc_buf_hdr_t *hdr, kmut for (fhdr = buf_hash_table.ht_table[idx], i = 0; fhdr != NULL; fhdr = fhdr->b_hash_next, i++) { - if (BUF_EQUAL(hdr->b_spa, &hdr->b_dva, hdr->b_birth, fhdr)) + if (HDR_EQUAL(hdr->b_spa, &hdr->b_dva, hdr->b_birth, fhdr)) return (fhdr); } hdr->b_hash_next = buf_hash_table.ht_table[idx]; buf_hash_table.ht_table[idx] = hdr; - hdr->b_flags |= ARC_FLAG_IN_HASH_TABLE; + arc_hdr_set_flags(hdr, ARC_FLAG_IN_HASH_TABLE); /* collect some hash table performance data */ if (i > 0) { @@ -1354,12 +1504,12 @@ buf_hash_remove(arc_buf_hdr_t *hdr) hdrp = &buf_hash_table.ht_table[idx]; while ((fhdr = *hdrp) != hdr) { - ASSERT(fhdr != NULL); + ASSERT3P(fhdr, !=, NULL); hdrp = &fhdr->b_hash_next; } *hdrp = hdr->b_hash_next; hdr->b_hash_next = NULL; - hdr->b_flags &= ~ARC_FLAG_IN_HASH_TABLE; + arc_hdr_clear_flags(hdr, ARC_FLAG_IN_HASH_TABLE); /* collect some hash table performance data */ ARCSTAT_BUMPDOWN(arcstat_hash_elements); @@ -1445,7 +1595,7 @@ hdr_full_dest(void *vbuf, void *unused) { arc_buf_hdr_t *hdr = vbuf; - ASSERT(BUF_EMPTY(hdr)); + ASSERT(HDR_EMPTY(hdr)); cv_destroy(&hdr->b_l1hdr.b_cv); refcount_destroy(&hdr->b_l1hdr.b_refcnt); mutex_destroy(&hdr->b_l1hdr.b_freeze_lock); @@ -1459,7 +1609,7 @@ hdr_l2only_dest(void *vbuf, void *unused { arc_buf_hdr_t *hdr = vbuf; - ASSERT(BUF_EMPTY(hdr)); + ASSERT(HDR_EMPTY(hdr)); arc_space_return(HDR_L2ONLY_SIZE, ARC_SPACE_L2HDRS); } @@ -1532,166 +1682,138 @@ retry: } } -/* - * Transition between the two allocation states for the arc_buf_hdr struct. - * The arc_buf_hdr struct can be allocated with (hdr_full_cache) or without - * (hdr_l2only_cache) the fields necessary for the L1 cache - the smaller - * version is used when a cache buffer is only in the L2ARC in order to reduce - * memory usage. - */ -static arc_buf_hdr_t * -arc_hdr_realloc(arc_buf_hdr_t *hdr, kmem_cache_t *old, kmem_cache_t *new) -{ - ASSERT(HDR_HAS_L2HDR(hdr)); - - arc_buf_hdr_t *nhdr; - l2arc_dev_t *dev = hdr->b_l2hdr.b_dev; - - ASSERT((old == hdr_full_cache && new == hdr_l2only_cache) || - (old == hdr_l2only_cache && new == hdr_full_cache)); - - nhdr = kmem_cache_alloc(new, KM_PUSHPAGE); - - ASSERT(MUTEX_HELD(HDR_LOCK(hdr))); - buf_hash_remove(hdr); - - bcopy(hdr, nhdr, HDR_L2ONLY_SIZE); - - if (new == hdr_full_cache) { - nhdr->b_flags |= ARC_FLAG_HAS_L1HDR; - /* - * arc_access and arc_change_state need to be aware that a - * header has just come out of L2ARC, so we set its state to - * l2c_only even though it's about to change. - */ - nhdr->b_l1hdr.b_state = arc_l2c_only; - - /* Verify previous threads set to NULL before freeing */ - ASSERT3P(nhdr->b_l1hdr.b_tmp_cdata, ==, NULL); - } else { - ASSERT(hdr->b_l1hdr.b_buf == NULL); - ASSERT0(hdr->b_l1hdr.b_datacnt); - - /* - * If we've reached here, We must have been called from - * arc_evict_hdr(), as such we should have already been - * removed from any ghost list we were previously on - * (which protects us from racing with arc_evict_state), - * thus no locking is needed during this check. - */ - ASSERT(!multilist_link_active(&hdr->b_l1hdr.b_arc_node)); - - /* - * A buffer must not be moved into the arc_l2c_only - * state if it's not finished being written out to the - * l2arc device. Otherwise, the b_l1hdr.b_tmp_cdata field - * might try to be accessed, even though it was removed. - */ - VERIFY(!HDR_L2_WRITING(hdr)); - VERIFY3P(hdr->b_l1hdr.b_tmp_cdata, ==, NULL); +#define ARC_MINTIME (hz>>4) /* 62 ms */ -#ifdef ZFS_DEBUG - if (hdr->b_l1hdr.b_thawed != NULL) { - kmem_free(hdr->b_l1hdr.b_thawed, 1); - hdr->b_l1hdr.b_thawed = NULL; - } -#endif +static inline boolean_t +arc_buf_is_shared(arc_buf_t *buf) +{ + boolean_t shared = (buf->b_data != NULL && + buf->b_data == buf->b_hdr->b_l1hdr.b_pdata); + IMPLY(shared, HDR_SHARED_DATA(buf->b_hdr)); + return (shared); +} - nhdr->b_flags &= ~ARC_FLAG_HAS_L1HDR; +static inline void +arc_cksum_free(arc_buf_hdr_t *hdr) +{ + ASSERT(HDR_HAS_L1HDR(hdr)); + mutex_enter(&hdr->b_l1hdr.b_freeze_lock); + if (hdr->b_l1hdr.b_freeze_cksum != NULL) { + kmem_free(hdr->b_l1hdr.b_freeze_cksum, sizeof (zio_cksum_t)); + hdr->b_l1hdr.b_freeze_cksum = NULL; } - /* - * The header has been reallocated so we need to re-insert it into any - * lists it was on. - */ - (void) buf_hash_insert(nhdr, NULL); - - ASSERT(list_link_active(&hdr->b_l2hdr.b_l2node)); - - mutex_enter(&dev->l2ad_mtx); - - /* - * We must place the realloc'ed header back into the list at - * the same spot. Otherwise, if it's placed earlier in the list, - * l2arc_write_buffers() could find it during the function's - * write phase, and try to write it out to the l2arc. - */ - list_insert_after(&dev->l2ad_buflist, hdr, nhdr); - list_remove(&dev->l2ad_buflist, hdr); - - mutex_exit(&dev->l2ad_mtx); - - /* - * Since we're using the pointer address as the tag when - * incrementing and decrementing the l2ad_alloc refcount, we - * must remove the old pointer (that we're about to destroy) and - * add the new pointer to the refcount. Otherwise we'd remove - * the wrong pointer address when calling arc_hdr_destroy() later. - */ - - (void) refcount_remove_many(&dev->l2ad_alloc, - hdr->b_l2hdr.b_asize, hdr); - - (void) refcount_add_many(&dev->l2ad_alloc, - nhdr->b_l2hdr.b_asize, nhdr); - - buf_discard_identity(hdr); - hdr->b_freeze_cksum = NULL; - kmem_cache_free(old, hdr); - - return (nhdr); + mutex_exit(&hdr->b_l1hdr.b_freeze_lock); } - -#define ARC_MINTIME (hz>>4) /* 62 ms */ - static void arc_cksum_verify(arc_buf_t *buf) { + arc_buf_hdr_t *hdr = buf->b_hdr; zio_cksum_t zc; if (!(zfs_flags & ZFS_DEBUG_MODIFY)) return; - mutex_enter(&buf->b_hdr->b_l1hdr.b_freeze_lock); - if (buf->b_hdr->b_freeze_cksum == NULL || HDR_IO_ERROR(buf->b_hdr)) { - mutex_exit(&buf->b_hdr->b_l1hdr.b_freeze_lock); + ASSERT(HDR_HAS_L1HDR(hdr)); + + mutex_enter(&hdr->b_l1hdr.b_freeze_lock); + if (hdr->b_l1hdr.b_freeze_cksum == NULL || HDR_IO_ERROR(hdr)) { + mutex_exit(&hdr->b_l1hdr.b_freeze_lock); return; } - fletcher_2_native(buf->b_data, buf->b_hdr->b_size, NULL, &zc); - if (!ZIO_CHECKSUM_EQUAL(*buf->b_hdr->b_freeze_cksum, zc)) + fletcher_2_native(buf->b_data, HDR_GET_LSIZE(hdr), NULL, &zc); + if (!ZIO_CHECKSUM_EQUAL(*hdr->b_l1hdr.b_freeze_cksum, zc)) panic("buffer modified while frozen!"); - mutex_exit(&buf->b_hdr->b_l1hdr.b_freeze_lock); + mutex_exit(&hdr->b_l1hdr.b_freeze_lock); } -static int -arc_cksum_equal(arc_buf_t *buf) +static boolean_t +arc_cksum_is_equal(arc_buf_hdr_t *hdr, zio_t *zio) { - zio_cksum_t zc; - int equal; + enum zio_compress compress = BP_GET_COMPRESS(zio->io_bp); + boolean_t valid_cksum; - mutex_enter(&buf->b_hdr->b_l1hdr.b_freeze_lock); - fletcher_2_native(buf->b_data, buf->b_hdr->b_size, NULL, &zc); - equal = ZIO_CHECKSUM_EQUAL(*buf->b_hdr->b_freeze_cksum, zc); - mutex_exit(&buf->b_hdr->b_l1hdr.b_freeze_lock); + ASSERT(!BP_IS_EMBEDDED(zio->io_bp)); + VERIFY3U(BP_GET_PSIZE(zio->io_bp), ==, HDR_GET_PSIZE(hdr)); + + /* + * We rely on the blkptr's checksum to determine if the block + * is valid or not. When compressed arc is enabled, the l2arc + * writes the block to the l2arc just as it appears in the pool. + * This allows us to use the blkptr's checksum to validate the + * data that we just read off of the l2arc without having to store + * a separate checksum in the arc_buf_hdr_t. However, if compressed + * arc is disabled, then the data written to the l2arc is always + * uncompressed and won't match the block as it exists in the main + * pool. When this is the case, we must first compress it if it is + * compressed on the main pool before we can validate the checksum. + */ + if (!HDR_COMPRESSION_ENABLED(hdr) && compress != ZIO_COMPRESS_OFF) { + ASSERT3U(HDR_GET_COMPRESS(hdr), ==, ZIO_COMPRESS_OFF); + uint64_t lsize = HDR_GET_LSIZE(hdr); + uint64_t csize; + + void *cbuf = zio_buf_alloc(HDR_GET_PSIZE(hdr)); + csize = zio_compress_data(compress, zio->io_data, cbuf, lsize); + ASSERT3U(csize, <=, HDR_GET_PSIZE(hdr)); + if (csize < HDR_GET_PSIZE(hdr)) { + /* + * Compressed blocks are always a multiple of the + * smallest ashift in the pool. Ideally, we would + * like to round up the csize to the next + * spa_min_ashift but that value may have changed + * since the block was last written. Instead, + * we rely on the fact that the hdr's psize + * was set to the psize of the block when it was + * last written. We set the csize to that value + * and zero out any part that should not contain + * data. + */ + bzero((char *)cbuf + csize, HDR_GET_PSIZE(hdr) - csize); + csize = HDR_GET_PSIZE(hdr); + } + zio_push_transform(zio, cbuf, csize, HDR_GET_PSIZE(hdr), NULL); + } - return (equal); + /* + * Block pointers always store the checksum for the logical data. + * If the block pointer has the gang bit set, then the checksum + * it represents is for the reconstituted data and not for an + * individual gang member. The zio pipeline, however, must be able to + * determine the checksum of each of the gang constituents so it + * treats the checksum comparison differently than what we need + * for l2arc blocks. This prevents us from using the + * zio_checksum_error() interface directly. Instead we must call the + * zio_checksum_error_impl() so that we can ensure the checksum is + * generated using the correct checksum algorithm and accounts for the + * logical I/O size and not just a gang fragment. + */ + valid_cksum = (zio_checksum_error_impl(zio->io_spa, zio->io_bp, + BP_GET_CHECKSUM(zio->io_bp), zio->io_data, zio->io_size, + zio->io_offset, NULL) == 0); + zio_pop_transforms(zio); + return (valid_cksum); } static void -arc_cksum_compute(arc_buf_t *buf, boolean_t force) +arc_cksum_compute(arc_buf_t *buf) { - if (!force && !(zfs_flags & ZFS_DEBUG_MODIFY)) + arc_buf_hdr_t *hdr = buf->b_hdr; + + if (!(zfs_flags & ZFS_DEBUG_MODIFY)) return; + ASSERT(HDR_HAS_L1HDR(hdr)); mutex_enter(&buf->b_hdr->b_l1hdr.b_freeze_lock); - if (buf->b_hdr->b_freeze_cksum != NULL) { - mutex_exit(&buf->b_hdr->b_l1hdr.b_freeze_lock); + if (hdr->b_l1hdr.b_freeze_cksum != NULL) { + mutex_exit(&hdr->b_l1hdr.b_freeze_lock); return; } - buf->b_hdr->b_freeze_cksum = kmem_alloc(sizeof (zio_cksum_t), KM_SLEEP); - fletcher_2_native(buf->b_data, buf->b_hdr->b_size, - NULL, buf->b_hdr->b_freeze_cksum); - mutex_exit(&buf->b_hdr->b_l1hdr.b_freeze_lock); + hdr->b_l1hdr.b_freeze_cksum = kmem_alloc(sizeof (zio_cksum_t), + KM_SLEEP); + fletcher_2_native(buf->b_data, HDR_GET_LSIZE(hdr), NULL, + hdr->b_l1hdr.b_freeze_cksum); + mutex_exit(&hdr->b_l1hdr.b_freeze_lock); #ifdef illumos arc_buf_watch(buf); #endif @@ -1733,7 +1855,7 @@ arc_buf_watch(arc_buf_t *buf) procctl_t ctl; ctl.cmd = PCWATCH; ctl.prwatch.pr_vaddr = (uintptr_t)buf->b_data; - ctl.prwatch.pr_size = buf->b_hdr->b_size; + ctl.prwatch.pr_size = HDR_GET_LSIZE(buf->b_hdr); ctl.prwatch.pr_wflags = WA_WRITE; result = write(arc_procfd, &ctl, sizeof (ctl)); ASSERT3U(result, ==, sizeof (ctl)); @@ -1745,11 +1867,14 @@ arc_buf_watch(arc_buf_t *buf) static arc_buf_contents_t arc_buf_type(arc_buf_hdr_t *hdr) { + arc_buf_contents_t type; if (HDR_ISTYPE_METADATA(hdr)) { - return (ARC_BUFC_METADATA); + type = ARC_BUFC_METADATA; } else { - return (ARC_BUFC_DATA); + type = ARC_BUFC_DATA; } + VERIFY3U(hdr->b_type, ==, type); + return (type); } static uint32_t @@ -1771,29 +1896,29 @@ arc_bufc_to_flags(arc_buf_contents_t typ void arc_buf_thaw(arc_buf_t *buf) { + arc_buf_hdr_t *hdr = buf->b_hdr; + if (zfs_flags & ZFS_DEBUG_MODIFY) { - if (buf->b_hdr->b_l1hdr.b_state != arc_anon) + if (hdr->b_l1hdr.b_state != arc_anon) panic("modifying non-anon buffer!"); *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-all@freebsd.org Fri Oct 14 07:16:13 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 7EABDC11210; Fri, 14 Oct 2016 07:16:13 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 3B181CF7; Fri, 14 Oct 2016 07:16:13 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9E7GCe3060551; Fri, 14 Oct 2016 07:16:12 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9E7GC1a060548; Fri, 14 Oct 2016 07:16:12 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201610140716.u9E7GC1a060548@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Fri, 14 Oct 2016 07:16:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307267 - stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Oct 2016 07:16:13 -0000 Author: mav Date: Fri Oct 14 07:16:11 2016 New Revision: 307267 URL: https://svnweb.freebsd.org/changeset/base/307267 Log: MFC r305324: MFV r303077: 7072 zfs fails to expand if lun added when os is in shutdown state illumos/illumos-gate@c39a2aae1e2c439d156021edfc20910dad7f9891 https://github.com/illumos/illumos-gate/commit/c39a2aae1e2c439d156021edfc20910dad7f9891 https://www.illumos.org/issues/7072 upstream: 38733 zfs fails to expand if lun added when os is in shutdown state DLPX-36910 spares and caches should not display expandable space DLPX-39262 vdev_disk_open spam zfs_dbgmsg buffer Reviewed by: Igor Kozhukhov Reviewed by: Dan Kimmel Reviewed by: Matthew Ahrens Reviewed by: Prakash Surya Reviewed by: Alex Reece Approved by: Dan McDonald Author: George Wilson Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/metaslab.c stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev.c stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_disk.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/metaslab.c ============================================================================== --- stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/metaslab.c Fri Oct 14 07:14:35 2016 (r307266) +++ stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/metaslab.c Fri Oct 14 07:16:11 2016 (r307267) @@ -468,7 +468,13 @@ metaslab_class_expandable_space(metaslab continue; } - space += tvd->vdev_max_asize - tvd->vdev_asize; + /* + * Calculate if we have enough space to add additional + * metaslabs. We report the expandable space in terms + * of the metaslab size since that's the unit of expansion. + */ + space += P2ALIGN(tvd->vdev_max_asize - tvd->vdev_asize, + 1ULL << tvd->vdev_ms_shift); } spa_config_exit(mc->mc_spa, SCL_VDEV, FTAG); return (space); Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev.c ============================================================================== --- stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev.c Fri Oct 14 07:14:35 2016 (r307266) +++ stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev.c Fri Oct 14 07:16:11 2016 (r307267) @@ -2885,6 +2885,7 @@ vdev_get_stats(vdev_t *vd, vdev_stat_t * { spa_t *spa = vd->vdev_spa; vdev_t *rvd = spa->spa_root_vdev; + vdev_t *tvd = vd->vdev_top; ASSERT(spa_config_held(spa, SCL_ALL, RW_READER) != 0); @@ -2895,8 +2896,15 @@ vdev_get_stats(vdev_t *vd, vdev_stat_t * vs->vs_rsize = vdev_get_min_asize(vd); if (vd->vdev_ops->vdev_op_leaf) vs->vs_rsize += VDEV_LABEL_START_SIZE + VDEV_LABEL_END_SIZE; - if (vd->vdev_max_asize != 0) - vs->vs_esize = vd->vdev_max_asize - vd->vdev_asize; + /* + * Report expandable space on top-level, non-auxillary devices only. + * The expandable space is reported in terms of metaslab sized units + * since that determines how much space the pool can expand. + */ + if (vd->vdev_aux == NULL && tvd != NULL && vd->vdev_max_asize != 0) { + vs->vs_esize = P2ALIGN(vd->vdev_max_asize - vd->vdev_asize, + 1ULL << tvd->vdev_ms_shift); + } vs->vs_configured_ashift = vd->vdev_top != NULL ? vd->vdev_top->vdev_ashift : vd->vdev_ashift; vs->vs_logical_ashift = vd->vdev_logical_ashift; Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_disk.c ============================================================================== --- stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_disk.c Fri Oct 14 07:14:35 2016 (r307266) +++ stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_disk.c Fri Oct 14 07:16:11 2016 (r307267) @@ -241,34 +241,6 @@ vdev_disk_rele(vdev_t *vd) } } -static uint64_t -vdev_disk_get_space(vdev_t *vd, uint64_t capacity, uint_t blksz) -{ - ASSERT(vd->vdev_wholedisk); - - vdev_disk_t *dvd = vd->vdev_tsd; - dk_efi_t dk_ioc; - efi_gpt_t *efi; - uint64_t avail_space = 0; - int efisize = EFI_LABEL_SIZE * 2; - - dk_ioc.dki_data = kmem_alloc(efisize, KM_SLEEP); - dk_ioc.dki_lba = 1; - dk_ioc.dki_length = efisize; - dk_ioc.dki_data_64 = (uint64_t)(uintptr_t)dk_ioc.dki_data; - efi = dk_ioc.dki_data; - - if (ldi_ioctl(dvd->vd_lh, DKIOCGETEFI, (intptr_t)&dk_ioc, - FKIOCTL, kcred, NULL) == 0) { - uint64_t efi_altern_lba = LE_64(efi->efi_gpt_AlternateLBA); - - if (capacity > efi_altern_lba) - avail_space = (capacity - efi_altern_lba) * blksz; - } - kmem_free(dk_ioc.dki_data, efisize); - return (avail_space); -} - /* * We want to be loud in DEBUG kernels when DKIOCGMEDIAINFOEXT fails, or when * even a fallback to DKIOCGMEDIAINFO fails. @@ -559,10 +531,7 @@ skip_open: * Adjust max_psize upward accordingly since we know * we own the whole disk now. */ - *max_psize += vdev_disk_get_space(vd, capacity, blksz); - zfs_dbgmsg("capacity change: vdev %s, psize %llu, " - "max_psize %llu", vd->vdev_path, *psize, - *max_psize); + *max_psize = capacity * blksz; } /* From owner-svn-src-all@freebsd.org Fri Oct 14 07:16:53 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 4D7DEC1127F; Fri, 14 Oct 2016 07:16:53 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 0CB40E62; Fri, 14 Oct 2016 07:16:52 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9E7GqMj060635; Fri, 14 Oct 2016 07:16:52 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9E7Gpiw060632; Fri, 14 Oct 2016 07:16:51 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201610140716.u9E7Gpiw060632@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Fri, 14 Oct 2016 07:16:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307268 - stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Oct 2016 07:16:53 -0000 Author: mav Date: Fri Oct 14 07:16:51 2016 New Revision: 307268 URL: https://svnweb.freebsd.org/changeset/base/307268 Log: MFC r305324: MFV r303077: 7072 zfs fails to expand if lun added when os is in shutdown state illumos/illumos-gate@c39a2aae1e2c439d156021edfc20910dad7f9891 https://github.com/illumos/illumos-gate/commit/c39a2aae1e2c439d156021edfc20910da d7f9891 https://www.illumos.org/issues/7072 upstream: 38733 zfs fails to expand if lun added when os is in shutdown state DLPX-36910 spares and caches should not display expandable space DLPX-39262 vdev_disk_open spam zfs_dbgmsg buffer Reviewed by: Igor Kozhukhov Reviewed by: Dan Kimmel Reviewed by: Matthew Ahrens Reviewed by: Prakash Surya Reviewed by: Alex Reece Approved by: Dan McDonald Author: George Wilson Modified: stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/metaslab.c stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev.c stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_disk.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/metaslab.c ============================================================================== --- stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/metaslab.c Fri Oct 14 07:16:11 2016 (r307267) +++ stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/metaslab.c Fri Oct 14 07:16:51 2016 (r307268) @@ -489,7 +489,13 @@ metaslab_class_expandable_space(metaslab continue; } - space += tvd->vdev_max_asize - tvd->vdev_asize; + /* + * Calculate if we have enough space to add additional + * metaslabs. We report the expandable space in terms + * of the metaslab size since that's the unit of expansion. + */ + space += P2ALIGN(tvd->vdev_max_asize - tvd->vdev_asize, + 1ULL << tvd->vdev_ms_shift); } spa_config_exit(mc->mc_spa, SCL_VDEV, FTAG); return (space); Modified: stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev.c ============================================================================== --- stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev.c Fri Oct 14 07:16:11 2016 (r307267) +++ stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev.c Fri Oct 14 07:16:51 2016 (r307268) @@ -2808,6 +2808,7 @@ vdev_get_stats(vdev_t *vd, vdev_stat_t * { spa_t *spa = vd->vdev_spa; vdev_t *rvd = spa->spa_root_vdev; + vdev_t *tvd = vd->vdev_top; ASSERT(spa_config_held(spa, SCL_ALL, RW_READER) != 0); @@ -2818,8 +2819,15 @@ vdev_get_stats(vdev_t *vd, vdev_stat_t * vs->vs_rsize = vdev_get_min_asize(vd); if (vd->vdev_ops->vdev_op_leaf) vs->vs_rsize += VDEV_LABEL_START_SIZE + VDEV_LABEL_END_SIZE; - if (vd->vdev_max_asize != 0) - vs->vs_esize = vd->vdev_max_asize - vd->vdev_asize; + /* + * Report expandable space on top-level, non-auxillary devices only. + * The expandable space is reported in terms of metaslab sized units + * since that determines how much space the pool can expand. + */ + if (vd->vdev_aux == NULL && tvd != NULL && vd->vdev_max_asize != 0) { + vs->vs_esize = P2ALIGN(vd->vdev_max_asize - vd->vdev_asize, + 1ULL << tvd->vdev_ms_shift); + } vs->vs_configured_ashift = vd->vdev_top != NULL ? vd->vdev_top->vdev_ashift : vd->vdev_ashift; vs->vs_logical_ashift = vd->vdev_logical_ashift; Modified: stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_disk.c ============================================================================== --- stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_disk.c Fri Oct 14 07:16:11 2016 (r307267) +++ stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_disk.c Fri Oct 14 07:16:51 2016 (r307268) @@ -241,34 +241,6 @@ vdev_disk_rele(vdev_t *vd) } } -static uint64_t -vdev_disk_get_space(vdev_t *vd, uint64_t capacity, uint_t blksz) -{ - ASSERT(vd->vdev_wholedisk); - - vdev_disk_t *dvd = vd->vdev_tsd; - dk_efi_t dk_ioc; - efi_gpt_t *efi; - uint64_t avail_space = 0; - int efisize = EFI_LABEL_SIZE * 2; - - dk_ioc.dki_data = kmem_alloc(efisize, KM_SLEEP); - dk_ioc.dki_lba = 1; - dk_ioc.dki_length = efisize; - dk_ioc.dki_data_64 = (uint64_t)(uintptr_t)dk_ioc.dki_data; - efi = dk_ioc.dki_data; - - if (ldi_ioctl(dvd->vd_lh, DKIOCGETEFI, (intptr_t)&dk_ioc, - FKIOCTL, kcred, NULL) == 0) { - uint64_t efi_altern_lba = LE_64(efi->efi_gpt_AlternateLBA); - - if (capacity > efi_altern_lba) - avail_space = (capacity - efi_altern_lba) * blksz; - } - kmem_free(dk_ioc.dki_data, efisize); - return (avail_space); -} - /* * We want to be loud in DEBUG kernels when DKIOCGMEDIAINFOEXT fails, or when * even a fallback to DKIOCGMEDIAINFO fails. @@ -559,10 +531,7 @@ skip_open: * Adjust max_psize upward accordingly since we know * we own the whole disk now. */ - *max_psize += vdev_disk_get_space(vd, capacity, blksz); - zfs_dbgmsg("capacity change: vdev %s, psize %llu, " - "max_psize %llu", vd->vdev_path, *psize, - *max_psize); + *max_psize = capacity * blksz; } /* From owner-svn-src-all@freebsd.org Fri Oct 14 07:18:28 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B68BCC112F7; Fri, 14 Oct 2016 07:18:28 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 8F778FC9; Fri, 14 Oct 2016 07:18:28 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9E7IRQU060750; Fri, 14 Oct 2016 07:18:27 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9E7IRW9060749; Fri, 14 Oct 2016 07:18:27 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201610140718.u9E7IRW9060749@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Fri, 14 Oct 2016 07:18:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307269 - stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Oct 2016 07:18:28 -0000 Author: mav Date: Fri Oct 14 07:18:27 2016 New Revision: 307269 URL: https://svnweb.freebsd.org/changeset/base/307269 Log: MFC r305325: MFV r303078: 7086 ztest attempts dva_get_dsize_sync on an embedded blockpointer illumos/illumos-gate@926549256b71acd595f69b236779ff6b78fa08ef https://github.com/illumos/illumos-gate/commit/926549256b71acd595f69b236779ff6b7 8fa08ef https://www.illumos.org/issues/7086 In dbuf_dirty(), we need to grab the dn_struct_rwlock before looking at the db_blkptr, to prevent it from being changed by syncing context. Otherwise we may see that ztest got a segfault from this stack: libzpool.so.1`dva_get_dsize_sync+0x98(872f000, b32b240, fed7811b, 0, b4cda20, 0) libzpool.so.1`bp_get_dsize+0x60(872f000, b32b240, 0, 97cb780, 9d4c1a8, 0) libzpool.so.1`dbuf_dirty+0x9b3(ce0a100, 97cb780, 9, fecd2530) libzpool.so.1`dmu_buf_will_dirty+0xc3(ce0a100, 97cb780, ea293d6c, 1) libzpool.so.1`zap_lockdir+0x1a0(8aaa3c0, 1, 0, 97cb780, 1, 1) libzpool.so.1`zap_remove_norm+0x30(8aaa3c0, 1, 0, 8728b10, 0, 97cb780) libzpool.so.1`zap_remove+0x29(8aaa3c0, 1, 0, 8728b10, 97cb780, a) ztest_replay_remove+0x225(ea294588, 8728ae8, 0, 38010000, 0, 0) ztest_remove+0x9f(ea294588, ea293f50, 4, 3) ztest_object_init+0x78(ea294588, ea293f50, 4e0, 1) ztest_dmu_object_alloc_free+0x71(ea294588, 13) ztest_dmu_objset_create_destroy+0x224(80cef08, 13, 0, 805d36c, 9017ad44, 0) ztest_execute+0x89(a, 807c720, 13, 0) ztest_thread+0xea(13, 0, 0, 0) libc.so.1`_thrp_setup+0x88(f0983240) libc.so.1`_lwp_start(f0983240, 0, 0, 0, 0, 0) Looking into it a bit, we see that this is an embedded blockpointer, so BP_GET_NDVAS should have returned 0: b32b240::blkptr EMBEDDED [L0 ZAP_OTHER] et=0 LZ4 size=200L/4aP birth=80L Instead, it looks like another thread is modifying this blockpointer: b32b240::ugrep | ::whatis f47a0e0c is in [ stack tid=0x19f ] ebd6ec40 is in [ stack tid=0x226 ] ea293bd0 is in [ stack tid=0x244 ] ea293be4 is in [ stack tid=0x244 ] Reviewed by: Prakash Surya Reviewed by: George Wilson Approved by: Robert Mustacchi Author: Matthew Ahrens Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dbuf.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dbuf.c ============================================================================== --- stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dbuf.c Fri Oct 14 07:16:51 2016 (r307268) +++ stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dbuf.c Fri Oct 14 07:18:27 2016 (r307269) @@ -1662,7 +1662,20 @@ dbuf_dirty(dmu_buf_impl_t *db, dmu_tx_t dnode_setdirty(dn, tx); DB_DNODE_EXIT(db); return (dr); - } else if (do_free_accounting) { + } + + /* + * The dn_struct_rwlock prevents db_blkptr from changing + * due to a write from syncing context completing + * while we are running, so we want to acquire it before + * looking at db_blkptr. + */ + if (!RW_WRITE_HELD(&dn->dn_struct_rwlock)) { + rw_enter(&dn->dn_struct_rwlock, RW_READER); + drop_struct_lock = TRUE; + } + + if (do_free_accounting) { blkptr_t *bp = db->db_blkptr; int64_t willfree = (bp && !BP_IS_HOLE(bp)) ? bp_get_dsize(os->os_spa, bp) : db->db.db_size; @@ -1678,11 +1691,6 @@ dbuf_dirty(dmu_buf_impl_t *db, dmu_tx_t dnode_willuse_space(dn, -willfree, tx); } - if (!RW_WRITE_HELD(&dn->dn_struct_rwlock)) { - rw_enter(&dn->dn_struct_rwlock, RW_READER); - drop_struct_lock = TRUE; - } - if (db->db_level == 0) { dnode_new_blkid(dn, db->db_blkid, tx, drop_struct_lock); ASSERT(dn->dn_maxblkid >= db->db_blkid); From owner-svn-src-all@freebsd.org Fri Oct 14 07:19:10 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 3440DC1134E; Fri, 14 Oct 2016 07:19:10 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 0FCF4192; Fri, 14 Oct 2016 07:19:09 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9E7J9YX060830; Fri, 14 Oct 2016 07:19:09 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9E7J9f0060829; Fri, 14 Oct 2016 07:19:09 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201610140719.u9E7J9f0060829@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Fri, 14 Oct 2016 07:19:09 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307270 - stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Oct 2016 07:19:10 -0000 Author: mav Date: Fri Oct 14 07:19:08 2016 New Revision: 307270 URL: https://svnweb.freebsd.org/changeset/base/307270 Log: MFC r305325: MFV r303078: 7086 ztest attempts dva_get_dsize_sync on an embedded blockpointer illumos/illumos-gate@926549256b71acd595f69b236779ff6b78fa08ef https://github.com/illumos/illumos-gate/commit/926549256b71acd595f69b236779ff6b7 8fa08ef https://www.illumos.org/issues/7086 In dbuf_dirty(), we need to grab the dn_struct_rwlock before looking at the db_blkptr, to prevent it from being changed by syncing context. Otherwise we may see that ztest got a segfault from this stack: libzpool.so.1`dva_get_dsize_sync+0x98(872f000, b32b240, fed7811b, 0, b4cda20, 0) libzpool.so.1`bp_get_dsize+0x60(872f000, b32b240, 0, 97cb780, 9d4c1a8, 0) libzpool.so.1`dbuf_dirty+0x9b3(ce0a100, 97cb780, 9, fecd2530) libzpool.so.1`dmu_buf_will_dirty+0xc3(ce0a100, 97cb780, ea293d6c, 1) libzpool.so.1`zap_lockdir+0x1a0(8aaa3c0, 1, 0, 97cb780, 1, 1) libzpool.so.1`zap_remove_norm+0x30(8aaa3c0, 1, 0, 8728b10, 0, 97cb780) libzpool.so.1`zap_remove+0x29(8aaa3c0, 1, 0, 8728b10, 97cb780, a) ztest_replay_remove+0x225(ea294588, 8728ae8, 0, 38010000, 0, 0) ztest_remove+0x9f(ea294588, ea293f50, 4, 3) ztest_object_init+0x78(ea294588, ea293f50, 4e0, 1) ztest_dmu_object_alloc_free+0x71(ea294588, 13) ztest_dmu_objset_create_destroy+0x224(80cef08, 13, 0, 805d36c, 9017ad44, 0) ztest_execute+0x89(a, 807c720, 13, 0) ztest_thread+0xea(13, 0, 0, 0) libc.so.1`_thrp_setup+0x88(f0983240) libc.so.1`_lwp_start(f0983240, 0, 0, 0, 0, 0) Looking into it a bit, we see that this is an embedded blockpointer, so BP_GET_NDVAS should have returned 0: b32b240::blkptr EMBEDDED [L0 ZAP_OTHER] et=0 LZ4 size=200L/4aP birth=80L Instead, it looks like another thread is modifying this blockpointer: b32b240::ugrep | ::whatis f47a0e0c is in [ stack tid=0x19f ] ebd6ec40 is in [ stack tid=0x226 ] ea293bd0 is in [ stack tid=0x244 ] ea293be4 is in [ stack tid=0x244 ] Reviewed by: Prakash Surya Reviewed by: George Wilson Approved by: Robert Mustacchi Author: Matthew Ahrens Modified: stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dbuf.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dbuf.c ============================================================================== --- stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dbuf.c Fri Oct 14 07:18:27 2016 (r307269) +++ stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dbuf.c Fri Oct 14 07:19:08 2016 (r307270) @@ -1655,7 +1655,20 @@ dbuf_dirty(dmu_buf_impl_t *db, dmu_tx_t dnode_setdirty(dn, tx); DB_DNODE_EXIT(db); return (dr); - } else if (do_free_accounting) { + } + + /* + * The dn_struct_rwlock prevents db_blkptr from changing + * due to a write from syncing context completing + * while we are running, so we want to acquire it before + * looking at db_blkptr. + */ + if (!RW_WRITE_HELD(&dn->dn_struct_rwlock)) { + rw_enter(&dn->dn_struct_rwlock, RW_READER); + drop_struct_lock = TRUE; + } + + if (do_free_accounting) { blkptr_t *bp = db->db_blkptr; int64_t willfree = (bp && !BP_IS_HOLE(bp)) ? bp_get_dsize(os->os_spa, bp) : db->db.db_size; @@ -1671,11 +1684,6 @@ dbuf_dirty(dmu_buf_impl_t *db, dmu_tx_t dnode_willuse_space(dn, -willfree, tx); } - if (!RW_WRITE_HELD(&dn->dn_struct_rwlock)) { - rw_enter(&dn->dn_struct_rwlock, RW_READER); - drop_struct_lock = TRUE; - } - if (db->db_level == 0) { dnode_new_blkid(dn, db->db_blkid, tx, drop_struct_lock); ASSERT(dn->dn_maxblkid >= db->db_blkid); From owner-svn-src-all@freebsd.org Fri Oct 14 07:20:08 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A799FC11456; Fri, 14 Oct 2016 07:20:08 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 834E26ED; Fri, 14 Oct 2016 07:20:08 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9E7K7x6060944; Fri, 14 Oct 2016 07:20:07 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9E7K7va060943; Fri, 14 Oct 2016 07:20:07 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201610140720.u9E7K7va060943@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Fri, 14 Oct 2016 07:20:07 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307271 - stable/11/cddl/contrib/opensolaris/cmd/ztest X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Oct 2016 07:20:08 -0000 Author: mav Date: Fri Oct 14 07:20:07 2016 New Revision: 307271 URL: https://svnweb.freebsd.org/changeset/base/307271 Log: MFC r305326: MFV r303079: 7147 ztest: ztest_ddt_repair fails with ztest_pattern_match assertion illumos/illumos-gate@aab80726335c76a7cae32c7300890248d73a51e3 https://github.com/illumos/illumos-gate/commit/aab80726335c76a7cae32c7300890248d 73a51e3 https://www.illumos.org/issues/7147 Here's the dbuf we're currently reading: 966f200::dbuf addr object lvl blkid holds os 966f200 4 0 0 1 ztest/ds_3 966f200::print dmu_buf_t db_data db_data = 0x9ae0400 0x9ae0400/10J 0x9ae0400: c1c7ced932020d c1c7ced932020d c1c7ced932020d c1c7ced932020d c1c7ced932020d c1c7ced932020d c1c7ced932020d c1c7ced932020d c1c7ced932020d c1c7ced932020d The pattern we're expecting is actually this: a34ae10b5f2db2. If we attempt to read the block on disk we find that it has matches what ztest_ddt_repair() would have written: ~c1c7ced932020d=J ff3e383126cdfdf2 966f200::print dmu_buf_impl_t db_blkptr | ::blkptr DVA0=<0:71d3c00:800> [L0 UINT64_OTHER] SHA256 OFF LE contiguous dedup single size=400L/400P birth=55L/55P fill=1 cksum=18486450d3ce8c6d:75a72f4bbf117b0f:2d3a226314eb5650:2eb0fd68648b1af0 1. zdb -U /rpool/tmp/zpool.cache -R ztest 0:71d3c00:800 | head Found vdev type: mirror 0:71d3c00:800 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef 000000: ff3e383126cdfdf2 ff3e383126cdfdf2 ...&18>....&18>. 000010: ff3e383126cdfdf2 ff3e383126cdfdf2 ...&18>....&18>. 000020: ff3e383126cdfdf2 ff3e383126cdfdf2 ...&18>....&18>. 000030: ff3e383126cdfdf2 ff3e383126cdfdf2 ...&18>....&18>. 000040: ff3e383126cdfdf2 ff3e383126cdfdf2 ...&18>....&18>. 000050: ff3e383126cdfdf2 ff3e383126cdfdf2 ...&18>....&18>. Reviewed by: Matthew Ahrens Reviewed by: Prakash Surya Approved by: Robert Mustacchi Author: George Wilson Modified: stable/11/cddl/contrib/opensolaris/cmd/ztest/ztest.c Directory Properties: stable/11/ (props changed) Modified: stable/11/cddl/contrib/opensolaris/cmd/ztest/ztest.c ============================================================================== --- stable/11/cddl/contrib/opensolaris/cmd/ztest/ztest.c Fri Oct 14 07:19:08 2016 (r307270) +++ stable/11/cddl/contrib/opensolaris/cmd/ztest/ztest.c Fri Oct 14 07:20:07 2016 (r307271) @@ -20,7 +20,7 @@ */ /* * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2011, 2015 by Delphix. All rights reserved. + * Copyright (c) 2011, 2016 by Delphix. All rights reserved. * Copyright 2011 Nexenta Systems, Inc. All rights reserved. * Copyright (c) 2012 Martin Matuska . All rights reserved. * Copyright (c) 2013 Steven Hartland. All rights reserved. @@ -5022,9 +5022,14 @@ ztest_ddt_repair(ztest_ds_t *zd, uint64_ return; } + dmu_objset_stats_t dds; + dsl_pool_config_enter(dmu_objset_pool(os), FTAG); + dmu_objset_fast_stat(os, &dds); + dsl_pool_config_exit(dmu_objset_pool(os), FTAG); + object = od[0].od_object; blocksize = od[0].od_blocksize; - pattern = zs->zs_guid ^ dmu_objset_fsid_guid(os); + pattern = zs->zs_guid ^ dds.dds_guid; ASSERT(object != 0); @@ -5627,9 +5632,13 @@ ztest_run(ztest_shared_t *zs) metaslab_preload_limit = ztest_random(20) + 1; ztest_spa = spa; + dmu_objset_stats_t dds; VERIFY0(dmu_objset_own(ztest_opts.zo_pool, DMU_OST_ANY, B_TRUE, FTAG, &os)); - zs->zs_guid = dmu_objset_fsid_guid(os); + dsl_pool_config_enter(dmu_objset_pool(os), FTAG); + dmu_objset_fast_stat(os, &dds); + dsl_pool_config_exit(dmu_objset_pool(os), FTAG); + zs->zs_guid = dds.dds_guid; dmu_objset_disown(os, FTAG); spa->spa_dedup_ditto = 2 * ZIO_DEDUPDITTO_MIN; From owner-svn-src-all@freebsd.org Fri Oct 14 07:20:51 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 356B5C114FC; Fri, 14 Oct 2016 07:20:51 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 0ECB6902; Fri, 14 Oct 2016 07:20:50 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9E7Ko2O061028; Fri, 14 Oct 2016 07:20:50 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9E7Ko3P061027; Fri, 14 Oct 2016 07:20:50 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201610140720.u9E7Ko3P061027@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Fri, 14 Oct 2016 07:20:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307272 - stable/10/cddl/contrib/opensolaris/cmd/ztest X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Oct 2016 07:20:51 -0000 Author: mav Date: Fri Oct 14 07:20:49 2016 New Revision: 307272 URL: https://svnweb.freebsd.org/changeset/base/307272 Log: MFC r305326: MFV r303079: 7147 ztest: ztest_ddt_repair fails with ztest_pattern_match assertion illumos/illumos-gate@aab80726335c76a7cae32c7300890248d73a51e3 https://github.com/illumos/illumos-gate/commit/aab80726335c76a7cae32c7300890248d 73a51e3 https://www.illumos.org/issues/7147 Here's the dbuf we're currently reading: 966f200::dbuf addr object lvl blkid holds os 966f200 4 0 0 1 ztest/ds_3 966f200::print dmu_buf_t db_data db_data = 0x9ae0400 0x9ae0400/10J 0x9ae0400: c1c7ced932020d c1c7ced932020d c1c7ced932020d c1c7ced932020d c1c7ced932020d c1c7ced932020d c1c7ced932020d c1c7ced932020d c1c7ced932020d c1c7ced932020d The pattern we're expecting is actually this: a34ae10b5f2db2. If we attempt to read the block on disk we find that it has matches what ztest_ddt_repair() would have written: ~c1c7ced932020d=J ff3e383126cdfdf2 966f200::print dmu_buf_impl_t db_blkptr | ::blkptr DVA0=<0:71d3c00:800> [L0 UINT64_OTHER] SHA256 OFF LE contiguous dedup single size=400L/400P birth=55L/55P fill=1 cksum=18486450d3ce8c6d:75a72f4bbf117b0f:2d3a226314eb5650:2eb0fd68648b1af0 1. zdb -U /rpool/tmp/zpool.cache -R ztest 0:71d3c00:800 | head Found vdev type: mirror 0:71d3c00:800 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef 000000: ff3e383126cdfdf2 ff3e383126cdfdf2 ...&18>....&18>. 000010: ff3e383126cdfdf2 ff3e383126cdfdf2 ...&18>....&18>. 000020: ff3e383126cdfdf2 ff3e383126cdfdf2 ...&18>....&18>. 000030: ff3e383126cdfdf2 ff3e383126cdfdf2 ...&18>....&18>. 000040: ff3e383126cdfdf2 ff3e383126cdfdf2 ...&18>....&18>. 000050: ff3e383126cdfdf2 ff3e383126cdfdf2 ...&18>....&18>. Reviewed by: Matthew Ahrens Reviewed by: Prakash Surya Approved by: Robert Mustacchi Author: George Wilson Modified: stable/10/cddl/contrib/opensolaris/cmd/ztest/ztest.c Directory Properties: stable/10/ (props changed) Modified: stable/10/cddl/contrib/opensolaris/cmd/ztest/ztest.c ============================================================================== --- stable/10/cddl/contrib/opensolaris/cmd/ztest/ztest.c Fri Oct 14 07:20:07 2016 (r307271) +++ stable/10/cddl/contrib/opensolaris/cmd/ztest/ztest.c Fri Oct 14 07:20:49 2016 (r307272) @@ -20,7 +20,7 @@ */ /* * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2011, 2015 by Delphix. All rights reserved. + * Copyright (c) 2011, 2016 by Delphix. All rights reserved. * Copyright 2011 Nexenta Systems, Inc. All rights reserved. * Copyright (c) 2012 Martin Matuska . All rights reserved. * Copyright (c) 2013 Steven Hartland. All rights reserved. @@ -5022,9 +5022,14 @@ ztest_ddt_repair(ztest_ds_t *zd, uint64_ return; } + dmu_objset_stats_t dds; + dsl_pool_config_enter(dmu_objset_pool(os), FTAG); + dmu_objset_fast_stat(os, &dds); + dsl_pool_config_exit(dmu_objset_pool(os), FTAG); + object = od[0].od_object; blocksize = od[0].od_blocksize; - pattern = zs->zs_guid ^ dmu_objset_fsid_guid(os); + pattern = zs->zs_guid ^ dds.dds_guid; ASSERT(object != 0); @@ -5627,9 +5632,13 @@ ztest_run(ztest_shared_t *zs) metaslab_preload_limit = ztest_random(20) + 1; ztest_spa = spa; + dmu_objset_stats_t dds; VERIFY0(dmu_objset_own(ztest_opts.zo_pool, DMU_OST_ANY, B_TRUE, FTAG, &os)); - zs->zs_guid = dmu_objset_fsid_guid(os); + dsl_pool_config_enter(dmu_objset_pool(os), FTAG); + dmu_objset_fast_stat(os, &dds); + dsl_pool_config_exit(dmu_objset_pool(os), FTAG); + zs->zs_guid = dds.dds_guid; dmu_objset_disown(os, FTAG); spa->spa_dedup_ditto = 2 * ZIO_DEDUPDITTO_MIN; From owner-svn-src-all@freebsd.org Fri Oct 14 07:21:57 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 415EAC115A4; Fri, 14 Oct 2016 07:21:57 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 01397B41; Fri, 14 Oct 2016 07:21:56 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9E7Lu1o061790; Fri, 14 Oct 2016 07:21:56 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9E7LuGj061789; Fri, 14 Oct 2016 07:21:56 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201610140721.u9E7LuGj061789@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Fri, 14 Oct 2016 07:21:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307273 - stable/11/cddl/contrib/opensolaris/cmd/ztest X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Oct 2016 07:21:57 -0000 Author: mav Date: Fri Oct 14 07:21:55 2016 New Revision: 307273 URL: https://svnweb.freebsd.org/changeset/base/307273 Log: MFC r305327: MFV r303080: 6451 ztest fails due to checksum errors illumos/illumos-gate@f9eb9fdf196b6ed476e4ffc69cecd8b0da3cb7e7 https://github.com/illumos/illumos-gate/commit/f9eb9fdf196b6ed476e4ffc69cecd8b0d a3cb7e7 https://www.illumos.org/issues/6451 Sometimes ztest fails because zdb detects checksum errors. e.g.: Traversing all blocks to verify checksums and verify nothing leaked ... zdb_blkptr_cb: Got error 50 reading <71, 47, 0, 8000160> DVA0=<0:1cc2000: 180000> [L0 other uint64[]] sha256 uncompressed LE contiguou s unique single size=100000L/100000P birth=271L/271P fill=1 cksum=c5a3e27d1ed0f894:843bca3a5473c4bf:f76a19b6830a2e4:91292591613a12bf -- skipping zdb_blkptr_cb: Got error 50 reading <71, 47, 0, 800000180> DVA0=<0:ce16800: 180000> [L0 other uint64[]] sha256 uncompressed LE contigu ous unique single size=100000L/100000P birth=840L/840P fill=1 cksum=5d018f3d061e17f3:6d1584784587bf63:2805a74a0ce37369:ba68a214806c7e75 -- skipping zdb_blkptr_cb: Got error 50 reading <71, 47, 0, 1000000360> DVA0=<0:10d37400: 180000> [L0 other uint64[]] sha256 uncompressed LE conti guous unique single size=100000L/100000P birth=904L/904P fill=1 cksum=fa1e11d4138bd14b:86c9488c444473e3:f31e43c72e72e46b:e3446472d1174d ba -- skipping zdb_blkptr_cb: Got error 50 reading <71, 47, 0, 400000002c0> DVA0=<0:127ef400: 180000> [L0 other uint64[]] sha256 uncompressed LE cont iguous dedup single size=100000L/100000P birth=549L/549P fill=1 cksum=30e14955ebf13522:66dc2ff8067e6810:4607e750abb9d3b3:6582b8af909fcb 58 -- skipping zdb_blkptr_cb: Got error 50 reading <657, 5, 0, 1c0> DVA0=<0:1a180400:180000> [L0 other uint64[]] fletcher4 uncompressed LE contiguou s unique single size=100000L/100000P birth=1091L/1091P fill=1 cksum=a6cf1e50: 29b3bd01c57e5:36779b914035db9a:db61cdcf6bec56f0 -- skippin g The problem is that ztest_fault_inject() can inject multiple faults into the same block. It is designed such that it can inject errors on all leafs of a RAID-Z or mirror, but for a given range of offsets, it will only inject errors Reviewed by: George Wilson Reviewed by: Prakash Surya Reviewed by: Jorgen Lundman Approved by: Dan McDonald Author: Matthew Ahrens Modified: stable/11/cddl/contrib/opensolaris/cmd/ztest/ztest.c Directory Properties: stable/11/ (props changed) Modified: stable/11/cddl/contrib/opensolaris/cmd/ztest/ztest.c ============================================================================== --- stable/11/cddl/contrib/opensolaris/cmd/ztest/ztest.c Fri Oct 14 07:20:49 2016 (r307272) +++ stable/11/cddl/contrib/opensolaris/cmd/ztest/ztest.c Fri Oct 14 07:21:55 2016 (r307273) @@ -4793,7 +4793,7 @@ ztest_fault_inject(ztest_ds_t *zd, uint6 char path0[MAXPATHLEN]; char pathrand[MAXPATHLEN]; size_t fsize; - int bshift = SPA_OLD_MAXBLOCKSHIFT + 2; /* don't scrog all labels */ + int bshift = SPA_MAXBLOCKSHIFT + 2; /* don't scrog all labels */ int iters = 1000; int maxfaults; int mirror_save; @@ -4954,6 +4954,31 @@ ztest_fault_inject(ztest_ds_t *zd, uint6 fsize = lseek(fd, 0, SEEK_END); while (--iters != 0) { + /* + * The offset must be chosen carefully to ensure that + * we do not inject a given logical block with errors + * on two different leaf devices, because ZFS can not + * tolerate that (if maxfaults==1). + * + * We divide each leaf into chunks of size + * (# leaves * SPA_MAXBLOCKSIZE * 4). Within each chunk + * there is a series of ranges to which we can inject errors. + * Each range can accept errors on only a single leaf vdev. + * The error injection ranges are separated by ranges + * which we will not inject errors on any device (DMZs). + * Each DMZ must be large enough such that a single block + * can not straddle it, so that a single block can not be + * a target in two different injection ranges (on different + * leaf vdevs). + * + * For example, with 3 leaves, each chunk looks like: + * 0 to 32M: injection range for leaf 0 + * 32M to 64M: DMZ - no injection allowed + * 64M to 96M: injection range for leaf 1 + * 96M to 128M: DMZ - no injection allowed + * 128M to 160M: injection range for leaf 2 + * 160M to 192M: DMZ - no injection allowed + */ offset = ztest_random(fsize / (leaves << bshift)) * (leaves << bshift) + (leaf << bshift) + (ztest_random(1ULL << (bshift - 1)) & -8ULL); From owner-svn-src-all@freebsd.org Fri Oct 14 07:22:45 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id CCF58C116CA; Fri, 14 Oct 2016 07:22:45 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 899D2DF8; Fri, 14 Oct 2016 07:22:45 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9E7MiFs064687; Fri, 14 Oct 2016 07:22:44 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9E7Mi38064686; Fri, 14 Oct 2016 07:22:44 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201610140722.u9E7Mi38064686@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Fri, 14 Oct 2016 07:22:44 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307274 - stable/10/cddl/contrib/opensolaris/cmd/ztest X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Oct 2016 07:22:45 -0000 Author: mav Date: Fri Oct 14 07:22:44 2016 New Revision: 307274 URL: https://svnweb.freebsd.org/changeset/base/307274 Log: MFC r305327: MFV r303080: 6451 ztest fails due to checksum errors illumos/illumos-gate@f9eb9fdf196b6ed476e4ffc69cecd8b0da3cb7e7 https://github.com/illumos/illumos-gate/commit/f9eb9fdf196b6ed476e4ffc69cecd8b0d a3cb7e7 https://www.illumos.org/issues/6451 Sometimes ztest fails because zdb detects checksum errors. e.g.: Traversing all blocks to verify checksums and verify nothing leaked ... zdb_blkptr_cb: Got error 50 reading <71, 47, 0, 8000160> DVA0=<0:1cc2000: 180000> [L0 other uint64[]] sha256 uncompressed LE contiguou s unique single size=100000L/100000P birth=271L/271P fill=1 cksum=c5a3e27d1ed0f894:843bca3a5473c4bf:f76a19b6830a2e4:91292591613a12bf -- skipping zdb_blkptr_cb: Got error 50 reading <71, 47, 0, 800000180> DVA0=<0:ce16800: 180000> [L0 other uint64[]] sha256 uncompressed LE contigu ous unique single size=100000L/100000P birth=840L/840P fill=1 cksum=5d018f3d061e17f3:6d1584784587bf63:2805a74a0ce37369:ba68a214806c7e75 -- skipping zdb_blkptr_cb: Got error 50 reading <71, 47, 0, 1000000360> DVA0=<0:10d37400: 180000> [L0 other uint64[]] sha256 uncompressed LE conti guous unique single size=100000L/100000P birth=904L/904P fill=1 cksum=fa1e11d4138bd14b:86c9488c444473e3:f31e43c72e72e46b:e3446472d1174d ba -- skipping zdb_blkptr_cb: Got error 50 reading <71, 47, 0, 400000002c0> DVA0=<0:127ef400: 180000> [L0 other uint64[]] sha256 uncompressed LE cont iguous dedup single size=100000L/100000P birth=549L/549P fill=1 cksum=30e14955ebf13522:66dc2ff8067e6810:4607e750abb9d3b3:6582b8af909fcb 58 -- skipping zdb_blkptr_cb: Got error 50 reading <657, 5, 0, 1c0> DVA0=<0:1a180400:180000> [L0 other uint64[]] fletcher4 uncompressed LE contiguou s unique single size=100000L/100000P birth=1091L/1091P fill=1 cksum=a6cf1e50: 29b3bd01c57e5:36779b914035db9a:db61cdcf6bec56f0 -- skippin g The problem is that ztest_fault_inject() can inject multiple faults into the same block. It is designed such that it can inject errors on all leafs of a RAID-Z or mirror, but for a given range of offsets, it will only inject errors Reviewed by: George Wilson Reviewed by: Prakash Surya Reviewed by: Jorgen Lundman Approved by: Dan McDonald Author: Matthew Ahrens Modified: stable/10/cddl/contrib/opensolaris/cmd/ztest/ztest.c Directory Properties: stable/10/ (props changed) Modified: stable/10/cddl/contrib/opensolaris/cmd/ztest/ztest.c ============================================================================== --- stable/10/cddl/contrib/opensolaris/cmd/ztest/ztest.c Fri Oct 14 07:21:55 2016 (r307273) +++ stable/10/cddl/contrib/opensolaris/cmd/ztest/ztest.c Fri Oct 14 07:22:44 2016 (r307274) @@ -4793,7 +4793,7 @@ ztest_fault_inject(ztest_ds_t *zd, uint6 char path0[MAXPATHLEN]; char pathrand[MAXPATHLEN]; size_t fsize; - int bshift = SPA_OLD_MAXBLOCKSHIFT + 2; /* don't scrog all labels */ + int bshift = SPA_MAXBLOCKSHIFT + 2; /* don't scrog all labels */ int iters = 1000; int maxfaults; int mirror_save; @@ -4954,6 +4954,31 @@ ztest_fault_inject(ztest_ds_t *zd, uint6 fsize = lseek(fd, 0, SEEK_END); while (--iters != 0) { + /* + * The offset must be chosen carefully to ensure that + * we do not inject a given logical block with errors + * on two different leaf devices, because ZFS can not + * tolerate that (if maxfaults==1). + * + * We divide each leaf into chunks of size + * (# leaves * SPA_MAXBLOCKSIZE * 4). Within each chunk + * there is a series of ranges to which we can inject errors. + * Each range can accept errors on only a single leaf vdev. + * The error injection ranges are separated by ranges + * which we will not inject errors on any device (DMZs). + * Each DMZ must be large enough such that a single block + * can not straddle it, so that a single block can not be + * a target in two different injection ranges (on different + * leaf vdevs). + * + * For example, with 3 leaves, each chunk looks like: + * 0 to 32M: injection range for leaf 0 + * 32M to 64M: DMZ - no injection allowed + * 64M to 96M: injection range for leaf 1 + * 96M to 128M: DMZ - no injection allowed + * 128M to 160M: injection range for leaf 2 + * 160M to 192M: DMZ - no injection allowed + */ offset = ztest_random(fsize / (leaves << bshift)) * (leaves << bshift) + (leaf << bshift) + (ztest_random(1ULL << (bshift - 1)) & -8ULL); From owner-svn-src-all@freebsd.org Fri Oct 14 07:23:59 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E191CC11729; Fri, 14 Oct 2016 07:23:59 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id BA8ABF5A; Fri, 14 Oct 2016 07:23:59 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9E7NwQW064798; Fri, 14 Oct 2016 07:23:58 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9E7NwbK064797; Fri, 14 Oct 2016 07:23:58 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201610140723.u9E7NwbK064797@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Fri, 14 Oct 2016 07:23:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307275 - stable/11/cddl/contrib/opensolaris/cmd/ztest X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Oct 2016 07:24:00 -0000 Author: mav Date: Fri Oct 14 07:23:58 2016 New Revision: 307275 URL: https://svnweb.freebsd.org/changeset/base/307275 Log: MFC r305328: MFV r303081: 7163 ztest failures due to excess error injection illumos/illumos-gate@f34284d835bc555f987c1310df46c034c3101155 https://github.com/illumos/illumos-gate/commit/f34284d835bc555f987c1310df46c034c 3101155 https://www.illumos.org/issues/7163 Running zloop from zfs-precommit hit this assertion: *panicstr/s 0xfffffd7fd7419370: assertion failed for thread 0xfffffd7fe29ed240, thread-id 577: parent != NULL, file ../../../uts/common/fs/zfs/dbuf.c, line 1827 $c libc.so.1`_lwp_kill+0xa() libc.so.1`_assfail+0x182(fffffd7ffb1c29fa, fffffd7ffb1cc028, 723) libc.so.1`assfail+0x19(fffffd7ffb1c29fa, fffffd7ffb1cc028, 723) libzpool.so.1`dbuf_dirty+0xc69(10e3bc10, 3601700) libzpool.so.1`dbuf_dirty+0x61e(10c73640, 3601700) libzpool.so.1`dbuf_dirty+0x61e(10e28280, 3601700) libzpool.so.1`dmu_buf_will_fill+0x64(10e28280, 3601700) libzpool.so.1`dmu_write+0x1b6(2c7e640, d, 400000002e000000, 200, 3717b40, 3601700) ztest_replay_write+0x568(4950d0, 3717a80, 0) ztest_write+0x125(4950d0, d, 400000002e000000, 200, 413f000) ztest_io+0x1bb(4950d0, d, 400000002e000000) ztest_dmu_write_parallel+0xaa(4950d0, 6) ztest_execute+0x83(1, 420c98, 6) ztest_thread+0xf4(6) libc.so.1`_thrp_setup+0x8a(fffffd7fe29ed240) libc.so.1`_lwp_start() This is another manifestation of ECKSUM in ztest: The lowest level ancestor that’s in memory is the L8 (topmost). The L7 ancestor is blkid 0x10: ::dbufs -O 0x2c7e640 -o d -l 7 |::dbuf addr object lvl blkid holds os 600be50 d 7 4 1 ztest/ds_6 719d880 d 7 0 4 ztest/ds_6 Reviewed by: George Wilson Reviewed by: Paul Dagnelie Approved by: Robert Mustacchi Author: Matthew Ahrens Modified: stable/11/cddl/contrib/opensolaris/cmd/ztest/ztest.c Directory Properties: stable/11/ (props changed) Modified: stable/11/cddl/contrib/opensolaris/cmd/ztest/ztest.c ============================================================================== --- stable/11/cddl/contrib/opensolaris/cmd/ztest/ztest.c Fri Oct 14 07:22:44 2016 (r307274) +++ stable/11/cddl/contrib/opensolaris/cmd/ztest/ztest.c Fri Oct 14 07:23:58 2016 (r307275) @@ -4793,7 +4793,7 @@ ztest_fault_inject(ztest_ds_t *zd, uint6 char path0[MAXPATHLEN]; char pathrand[MAXPATHLEN]; size_t fsize; - int bshift = SPA_MAXBLOCKSHIFT + 2; /* don't scrog all labels */ + int bshift = SPA_MAXBLOCKSHIFT + 2; int iters = 1000; int maxfaults; int mirror_save; @@ -4983,7 +4983,29 @@ ztest_fault_inject(ztest_ds_t *zd, uint6 (leaves << bshift) + (leaf << bshift) + (ztest_random(1ULL << (bshift - 1)) & -8ULL); - if (offset >= fsize) + /* + * Only allow damage to the labels at one end of the vdev. + * + * If all labels are damaged, the device will be totally + * inaccessible, which will result in loss of data, + * because we also damage (parts of) the other side of + * the mirror/raidz. + * + * Additionally, we will always have both an even and an + * odd label, so that we can handle crashes in the + * middle of vdev_config_sync(). + */ + if ((leaf & 1) == 0 && offset < VDEV_LABEL_START_SIZE) + continue; + + /* + * The two end labels are stored at the "end" of the disk, but + * the end of the disk (vdev_psize) is aligned to + * sizeof (vdev_label_t). + */ + uint64_t psize = P2ALIGN(fsize, sizeof (vdev_label_t)); + if ((leaf & 1) == 1 && + offset + sizeof (bad) > psize - VDEV_LABEL_END_SIZE) continue; VERIFY(mutex_lock(&ztest_vdev_lock) == 0); From owner-svn-src-all@freebsd.org Fri Oct 14 07:24:44 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id F3711C11788; Fri, 14 Oct 2016 07:24:44 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id CBFAF115; Fri, 14 Oct 2016 07:24:44 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9E7OhbK064887; Fri, 14 Oct 2016 07:24:43 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9E7OhSh064886; Fri, 14 Oct 2016 07:24:43 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201610140724.u9E7OhSh064886@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Fri, 14 Oct 2016 07:24:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307276 - stable/10/cddl/contrib/opensolaris/cmd/ztest X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Oct 2016 07:24:45 -0000 Author: mav Date: Fri Oct 14 07:24:43 2016 New Revision: 307276 URL: https://svnweb.freebsd.org/changeset/base/307276 Log: MFC r305328: MFV r303081: 7163 ztest failures due to excess error injection illumos/illumos-gate@f34284d835bc555f987c1310df46c034c3101155 https://github.com/illumos/illumos-gate/commit/f34284d835bc555f987c1310df46c034c 3101155 https://www.illumos.org/issues/7163 Running zloop from zfs-precommit hit this assertion: *panicstr/s 0xfffffd7fd7419370: assertion failed for thread 0xfffffd7fe29ed240, thread-id 577: parent != NULL, file ../../../uts/common/fs/zfs/dbuf.c, line 1827 $c libc.so.1`_lwp_kill+0xa() libc.so.1`_assfail+0x182(fffffd7ffb1c29fa, fffffd7ffb1cc028, 723) libc.so.1`assfail+0x19(fffffd7ffb1c29fa, fffffd7ffb1cc028, 723) libzpool.so.1`dbuf_dirty+0xc69(10e3bc10, 3601700) libzpool.so.1`dbuf_dirty+0x61e(10c73640, 3601700) libzpool.so.1`dbuf_dirty+0x61e(10e28280, 3601700) libzpool.so.1`dmu_buf_will_fill+0x64(10e28280, 3601700) libzpool.so.1`dmu_write+0x1b6(2c7e640, d, 400000002e000000, 200, 3717b40, 3601700) ztest_replay_write+0x568(4950d0, 3717a80, 0) ztest_write+0x125(4950d0, d, 400000002e000000, 200, 413f000) ztest_io+0x1bb(4950d0, d, 400000002e000000) ztest_dmu_write_parallel+0xaa(4950d0, 6) ztest_execute+0x83(1, 420c98, 6) ztest_thread+0xf4(6) libc.so.1`_thrp_setup+0x8a(fffffd7fe29ed240) libc.so.1`_lwp_start() This is another manifestation of ECKSUM in ztest: The lowest level ancestor that’s in memory is the L8 (topmost). The L7 ancestor is blkid 0x10: ::dbufs -O 0x2c7e640 -o d -l 7 |::dbuf addr object lvl blkid holds os 600be50 d 7 4 1 ztest/ds_6 719d880 d 7 0 4 ztest/ds_6 Reviewed by: George Wilson Reviewed by: Paul Dagnelie Approved by: Robert Mustacchi Author: Matthew Ahrens Modified: stable/10/cddl/contrib/opensolaris/cmd/ztest/ztest.c Directory Properties: stable/10/ (props changed) Modified: stable/10/cddl/contrib/opensolaris/cmd/ztest/ztest.c ============================================================================== --- stable/10/cddl/contrib/opensolaris/cmd/ztest/ztest.c Fri Oct 14 07:23:58 2016 (r307275) +++ stable/10/cddl/contrib/opensolaris/cmd/ztest/ztest.c Fri Oct 14 07:24:43 2016 (r307276) @@ -4793,7 +4793,7 @@ ztest_fault_inject(ztest_ds_t *zd, uint6 char path0[MAXPATHLEN]; char pathrand[MAXPATHLEN]; size_t fsize; - int bshift = SPA_MAXBLOCKSHIFT + 2; /* don't scrog all labels */ + int bshift = SPA_MAXBLOCKSHIFT + 2; int iters = 1000; int maxfaults; int mirror_save; @@ -4983,7 +4983,29 @@ ztest_fault_inject(ztest_ds_t *zd, uint6 (leaves << bshift) + (leaf << bshift) + (ztest_random(1ULL << (bshift - 1)) & -8ULL); - if (offset >= fsize) + /* + * Only allow damage to the labels at one end of the vdev. + * + * If all labels are damaged, the device will be totally + * inaccessible, which will result in loss of data, + * because we also damage (parts of) the other side of + * the mirror/raidz. + * + * Additionally, we will always have both an even and an + * odd label, so that we can handle crashes in the + * middle of vdev_config_sync(). + */ + if ((leaf & 1) == 0 && offset < VDEV_LABEL_START_SIZE) + continue; + + /* + * The two end labels are stored at the "end" of the disk, but + * the end of the disk (vdev_psize) is aligned to + * sizeof (vdev_label_t). + */ + uint64_t psize = P2ALIGN(fsize, sizeof (vdev_label_t)); + if ((leaf & 1) == 1 && + offset + sizeof (bad) > psize - VDEV_LABEL_END_SIZE) continue; VERIFY(mutex_lock(&ztest_vdev_lock) == 0); From owner-svn-src-all@freebsd.org Fri Oct 14 07:26:21 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id CE468C117EA; Fri, 14 Oct 2016 07:26:21 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 651DB286; Fri, 14 Oct 2016 07:26:21 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9E7QKHd065030; Fri, 14 Oct 2016 07:26:20 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9E7QJhq065019; Fri, 14 Oct 2016 07:26:19 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201610140726.u9E7QJhq065019@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Fri, 14 Oct 2016 07:26:19 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307277 - in stable/11/sys/cddl/contrib/opensolaris/uts/common: fs/zfs fs/zfs/sys sys/fs X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Oct 2016 07:26:21 -0000 Author: mav Date: Fri Oct 14 07:26:19 2016 New Revision: 307277 URL: https://svnweb.freebsd.org/changeset/base/307277 Log: MFC r305331: MFV r304155: 7090 zfs should improve allocation order and throttle allocations illumos/illumos-gate@0f7643c7376dd69a08acbfc9d1d7d548b10c846a https://github.com/illumos/illumos-gate/commit/0f7643c7376dd69a08acbfc9d1d7d548b 10c846a https://www.illumos.org/issues/7090 When write I/Os are issued, they are issued in block order but the ZIO pipelin e will drive them asynchronously through the allocation stage which can result i n blocks being allocated out-of-order. It would be nice to preserve as much of the logical order as possible. In addition, the allocations are equally scattered across all top-level VDEVs but not all top-level VDEVs are created equally. The pipeline should be able t o detect devices that are more capable of handling allocations and should allocate more blocks to those devices. This allows for dynamic allocation distribution when devices are imbalanced as fuller devices will tend to be slower than empty devices. The change includes a new pool-wide allocation queue which would throttle and order allocations in the ZIO pipeline. The queue would be ordered by issued time and offset and would provide an initial amount of allocation of work to each top-level vdev. The allocation logic utilizes a reservation system to reserve allocations that will be performed by the allocator. Once an allocatio n is successfully completed it's scheduled on a given top-level vdev. Each top- level vdev maintains a maximum number of allocations that it can handle (mg_alloc_queue_depth). The pool-wide reserved allocations (top-levels * mg_alloc_queue_depth) are distributed across the top-level vdevs metaslab groups and round robin across all eligible metaslab groups to distribute the work. As top-levels complete their work, they receive additional work from the pool-wide allocation queue until the allocation queue is emptied. Reviewed by: Adam Leventhal Reviewed by: Alex Reece Reviewed by: Christopher Siden Reviewed by: Dan Kimmel Reviewed by: Matthew Ahrens Reviewed by: Paul Dagnelie Reviewed by: Prakash Surya Reviewed by: Sebastien Roy Approved by: Robert Mustacchi Author: George Wilson Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/metaslab.c stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/refcount.c stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_misc.c stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/metaslab.h stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/metaslab_impl.h stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/refcount.h stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/spa_impl.h stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/vdev_impl.h stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zio.h stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zio_impl.h stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev.c stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_cache.c stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_mirror.c stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_queue.c stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zio.c stable/11/sys/cddl/contrib/opensolaris/uts/common/sys/fs/zfs.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/metaslab.c ============================================================================== --- stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/metaslab.c Fri Oct 14 07:24:43 2016 (r307276) +++ stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/metaslab.c Fri Oct 14 07:26:19 2016 (r307277) @@ -38,17 +38,8 @@ SYSCTL_DECL(_vfs_zfs); SYSCTL_NODE(_vfs_zfs, OID_AUTO, metaslab, CTLFLAG_RW, 0, "ZFS metaslab"); -/* - * Allow allocations to switch to gang blocks quickly. We do this to - * avoid having to load lots of space_maps in a given txg. There are, - * however, some cases where we want to avoid "fast" ganging and instead - * we want to do an exhaustive search of all metaslabs on this device. - * Currently we don't allow any gang, slog, or dump device related allocations - * to "fast" gang. - */ -#define CAN_FASTGANG(flags) \ - (!((flags) & (METASLAB_GANG_CHILD | METASLAB_GANG_HEADER | \ - METASLAB_GANG_AVOID))) +#define GANG_ALLOCATION(flags) \ + ((flags) & (METASLAB_GANG_CHILD | METASLAB_GANG_HEADER)) #define METASLAB_WEIGHT_PRIMARY (1ULL << 63) #define METASLAB_WEIGHT_SECONDARY (1ULL << 62) @@ -256,6 +247,8 @@ metaslab_class_create(spa_t *spa, metasl mc->mc_spa = spa; mc->mc_rotor = NULL; mc->mc_ops = ops; + mutex_init(&mc->mc_lock, NULL, MUTEX_DEFAULT, NULL); + refcount_create_tracked(&mc->mc_alloc_slots); return (mc); } @@ -269,6 +262,8 @@ metaslab_class_destroy(metaslab_class_t ASSERT(mc->mc_space == 0); ASSERT(mc->mc_dspace == 0); + refcount_destroy(&mc->mc_alloc_slots); + mutex_destroy(&mc->mc_lock); kmem_free(mc, sizeof (metaslab_class_t)); } @@ -512,9 +507,10 @@ metaslab_compare(const void *x1, const v /* * Update the allocatable flag and the metaslab group's capacity. * The allocatable flag is set to true if the capacity is below - * the zfs_mg_noalloc_threshold. If a metaslab group transitions - * from allocatable to non-allocatable or vice versa then the metaslab - * group's class is updated to reflect the transition. + * the zfs_mg_noalloc_threshold or has a fragmentation value that is + * greater than zfs_mg_fragmentation_threshold. If a metaslab group + * transitions from allocatable to non-allocatable or vice versa then the + * metaslab group's class is updated to reflect the transition. */ static void metaslab_group_alloc_update(metaslab_group_t *mg) @@ -523,22 +519,45 @@ metaslab_group_alloc_update(metaslab_gro metaslab_class_t *mc = mg->mg_class; vdev_stat_t *vs = &vd->vdev_stat; boolean_t was_allocatable; + boolean_t was_initialized; ASSERT(vd == vd->vdev_top); mutex_enter(&mg->mg_lock); was_allocatable = mg->mg_allocatable; + was_initialized = mg->mg_initialized; mg->mg_free_capacity = ((vs->vs_space - vs->vs_alloc) * 100) / (vs->vs_space + 1); + mutex_enter(&mc->mc_lock); + + /* + * If the metaslab group was just added then it won't + * have any space until we finish syncing out this txg. + * At that point we will consider it initialized and available + * for allocations. We also don't consider non-activated + * metaslab groups (e.g. vdevs that are in the middle of being removed) + * to be initialized, because they can't be used for allocation. + */ + mg->mg_initialized = metaslab_group_initialized(mg); + if (!was_initialized && mg->mg_initialized) { + mc->mc_groups++; + } else if (was_initialized && !mg->mg_initialized) { + ASSERT3U(mc->mc_groups, >, 0); + mc->mc_groups--; + } + if (mg->mg_initialized) + mg->mg_no_free_space = B_FALSE; + /* * A metaslab group is considered allocatable if it has plenty * of free space or is not heavily fragmented. We only take * fragmentation into account if the metaslab group has a valid * fragmentation metric (i.e. a value between 0 and 100). */ - mg->mg_allocatable = (mg->mg_free_capacity > zfs_mg_noalloc_threshold && + mg->mg_allocatable = (mg->mg_activation_count > 0 && + mg->mg_free_capacity > zfs_mg_noalloc_threshold && (mg->mg_fragmentation == ZFS_FRAG_INVALID || mg->mg_fragmentation <= zfs_mg_fragmentation_threshold)); @@ -561,6 +580,7 @@ metaslab_group_alloc_update(metaslab_gro mc->mc_alloc_groups--; else if (!was_allocatable && mg->mg_allocatable) mc->mc_alloc_groups++; + mutex_exit(&mc->mc_lock); mutex_exit(&mg->mg_lock); } @@ -577,6 +597,9 @@ metaslab_group_create(metaslab_class_t * mg->mg_vd = vd; mg->mg_class = mc; mg->mg_activation_count = 0; + mg->mg_initialized = B_FALSE; + mg->mg_no_free_space = B_TRUE; + refcount_create_tracked(&mg->mg_alloc_queue_depth); mg->mg_taskq = taskq_create("metaslab_group_taskq", metaslab_load_pct, minclsyspri, 10, INT_MAX, TASKQ_THREADS_CPU_PCT); @@ -599,6 +622,7 @@ metaslab_group_destroy(metaslab_group_t taskq_destroy(mg->mg_taskq); avl_destroy(&mg->mg_metaslab_tree); mutex_destroy(&mg->mg_lock); + refcount_destroy(&mg->mg_alloc_queue_depth); kmem_free(mg, sizeof (metaslab_group_t)); } @@ -670,6 +694,15 @@ metaslab_group_passivate(metaslab_group_ metaslab_class_minblocksize_update(mc); } +boolean_t +metaslab_group_initialized(metaslab_group_t *mg) +{ + vdev_t *vd = mg->mg_vd; + vdev_stat_t *vs = &vd->vdev_stat; + + return (vs->vs_space != 0 && mg->mg_activation_count > 0); +} + uint64_t metaslab_group_get_space(metaslab_group_t *mg) { @@ -839,30 +872,97 @@ metaslab_group_fragmentation(metaslab_gr * group should avoid allocations if its free capacity is less than the * zfs_mg_noalloc_threshold or its fragmentation metric is greater than * zfs_mg_fragmentation_threshold and there is at least one metaslab group - * that can still handle allocations. + * that can still handle allocations. If the allocation throttle is enabled + * then we skip allocations to devices that have reached their maximum + * allocation queue depth unless the selected metaslab group is the only + * eligible group remaining. */ static boolean_t -metaslab_group_allocatable(metaslab_group_t *mg) +metaslab_group_allocatable(metaslab_group_t *mg, metaslab_group_t *rotor, + uint64_t psize) { - vdev_t *vd = mg->mg_vd; - spa_t *spa = vd->vdev_spa; + spa_t *spa = mg->mg_vd->vdev_spa; metaslab_class_t *mc = mg->mg_class; /* - * We use two key metrics to determine if a metaslab group is - * considered allocatable -- free space and fragmentation. If - * the free space is greater than the free space threshold and - * the fragmentation is less than the fragmentation threshold then - * consider the group allocatable. There are two case when we will - * not consider these key metrics. The first is if the group is - * associated with a slog device and the second is if all groups - * in this metaslab class have already been consider ineligible + * We can only consider skipping this metaslab group if it's + * in the normal metaslab class and there are other metaslab + * groups to select from. Otherwise, we always consider it eligible * for allocations. */ - return ((mg->mg_free_capacity > zfs_mg_noalloc_threshold && - (mg->mg_fragmentation == ZFS_FRAG_INVALID || - mg->mg_fragmentation <= zfs_mg_fragmentation_threshold)) || - mc != spa_normal_class(spa) || mc->mc_alloc_groups == 0); + if (mc != spa_normal_class(spa) || mc->mc_groups <= 1) + return (B_TRUE); + + /* + * If the metaslab group's mg_allocatable flag is set (see comments + * in metaslab_group_alloc_update() for more information) and + * the allocation throttle is disabled then allow allocations to this + * device. However, if the allocation throttle is enabled then + * check if we have reached our allocation limit (mg_alloc_queue_depth) + * to determine if we should allow allocations to this metaslab group. + * If all metaslab groups are no longer considered allocatable + * (mc_alloc_groups == 0) or we're trying to allocate the smallest + * gang block size then we allow allocations on this metaslab group + * regardless of the mg_allocatable or throttle settings. + */ + if (mg->mg_allocatable) { + metaslab_group_t *mgp; + int64_t qdepth; + uint64_t qmax = mg->mg_max_alloc_queue_depth; + + if (!mc->mc_alloc_throttle_enabled) + return (B_TRUE); + + /* + * If this metaslab group does not have any free space, then + * there is no point in looking further. + */ + if (mg->mg_no_free_space) + return (B_FALSE); + + qdepth = refcount_count(&mg->mg_alloc_queue_depth); + + /* + * If this metaslab group is below its qmax or it's + * the only allocatable metasable group, then attempt + * to allocate from it. + */ + if (qdepth < qmax || mc->mc_alloc_groups == 1) + return (B_TRUE); + ASSERT3U(mc->mc_alloc_groups, >, 1); + + /* + * Since this metaslab group is at or over its qmax, we + * need to determine if there are metaslab groups after this + * one that might be able to handle this allocation. This is + * racy since we can't hold the locks for all metaslab + * groups at the same time when we make this check. + */ + for (mgp = mg->mg_next; mgp != rotor; mgp = mgp->mg_next) { + qmax = mgp->mg_max_alloc_queue_depth; + + qdepth = refcount_count(&mgp->mg_alloc_queue_depth); + + /* + * If there is another metaslab group that + * might be able to handle the allocation, then + * we return false so that we skip this group. + */ + if (qdepth < qmax && !mgp->mg_no_free_space) + return (B_FALSE); + } + + /* + * We didn't find another group to handle the allocation + * so we can't skip this metaslab group even though + * we are at or over our qmax. + */ + return (B_TRUE); + + } else if (mc->mc_alloc_groups == 0 || psize == SPA_MINBLOCKSIZE) { + return (B_TRUE); + } + return (B_FALSE); } /* @@ -2130,8 +2230,57 @@ metaslab_distance(metaslab_t *msp, dva_t return (0); } +/* + * ========================================================================== + * Metaslab block operations + * ========================================================================== + */ + +static void +metaslab_group_alloc_increment(spa_t *spa, uint64_t vdev, void *tag, int flags) +{ + if (!(flags & METASLAB_ASYNC_ALLOC) || + flags & METASLAB_DONT_THROTTLE) + return; + + metaslab_group_t *mg = vdev_lookup_top(spa, vdev)->vdev_mg; + if (!mg->mg_class->mc_alloc_throttle_enabled) + return; + + (void) refcount_add(&mg->mg_alloc_queue_depth, tag); +} + +void +metaslab_group_alloc_decrement(spa_t *spa, uint64_t vdev, void *tag, int flags) +{ + if (!(flags & METASLAB_ASYNC_ALLOC) || + flags & METASLAB_DONT_THROTTLE) + return; + + metaslab_group_t *mg = vdev_lookup_top(spa, vdev)->vdev_mg; + if (!mg->mg_class->mc_alloc_throttle_enabled) + return; + + (void) refcount_remove(&mg->mg_alloc_queue_depth, tag); +} + +void +metaslab_group_alloc_verify(spa_t *spa, const blkptr_t *bp, void *tag) +{ +#ifdef ZFS_DEBUG + const dva_t *dva = bp->blk_dva; + int ndvas = BP_GET_NDVAS(bp); + + for (int d = 0; d < ndvas; d++) { + uint64_t vdev = DVA_GET_VDEV(&dva[d]); + metaslab_group_t *mg = vdev_lookup_top(spa, vdev)->vdev_mg; + VERIFY(refcount_not_held(&mg->mg_alloc_queue_depth, tag)); + } +#endif +} + static uint64_t -metaslab_group_alloc(metaslab_group_t *mg, uint64_t psize, uint64_t asize, +metaslab_group_alloc(metaslab_group_t *mg, uint64_t asize, uint64_t txg, uint64_t min_distance, dva_t *dva, int d) { spa_t *spa = mg->mg_vd->vdev_spa; @@ -2158,10 +2307,10 @@ metaslab_group_alloc(metaslab_group_t *m if (msp->ms_weight < asize) { spa_dbgmsg(spa, "%s: failed to meet weight " "requirement: vdev %llu, txg %llu, mg %p, " - "msp %p, psize %llu, asize %llu, " + "msp %p, asize %llu, " "weight %llu", spa_name(spa), mg->mg_vd->vdev_id, txg, - mg, msp, psize, asize, msp->ms_weight); + mg, msp, asize, msp->ms_weight); mutex_exit(&mg->mg_lock); return (-1ULL); } @@ -2243,7 +2392,6 @@ metaslab_group_alloc(metaslab_group_t *m msp->ms_access_txg = txg + metaslab_unload_delay; mutex_exit(&msp->ms_lock); - return (offset); } @@ -2260,7 +2408,6 @@ metaslab_alloc_dva(spa_t *spa, metaslab_ int all_zero; int zio_lock = B_FALSE; boolean_t allocatable; - uint64_t offset = -1ULL; uint64_t asize; uint64_t distance; @@ -2330,7 +2477,6 @@ top: all_zero = B_TRUE; do { ASSERT(mg->mg_activation_count == 1); - vd = mg->mg_vd; /* @@ -2346,24 +2492,23 @@ top: /* * Determine if the selected metaslab group is eligible - * for allocations. If we're ganging or have requested - * an allocation for the smallest gang block size - * then we don't want to avoid allocating to the this - * metaslab group. If we're in this condition we should - * try to allocate from any device possible so that we - * don't inadvertently return ENOSPC and suspend the pool + * for allocations. If we're ganging then don't allow + * this metaslab group to skip allocations since that would + * inadvertently return ENOSPC and suspend the pool * even though space is still available. */ - if (allocatable && CAN_FASTGANG(flags) && - psize > SPA_GANGBLOCKSIZE) - allocatable = metaslab_group_allocatable(mg); + if (allocatable && !GANG_ALLOCATION(flags) && !zio_lock) { + allocatable = metaslab_group_allocatable(mg, rotor, + psize); + } if (!allocatable) goto next; + ASSERT(mg->mg_initialized); + /* - * Avoid writing single-copy data to a failing vdev - * unless the user instructs us that it is okay. + * Avoid writing single-copy data to a failing vdev. */ if ((vd->vdev_stat.vs_write_errors > 0 || vd->vdev_state < VDEV_STATE_HEALTHY) && @@ -2383,8 +2528,32 @@ top: asize = vdev_psize_to_asize(vd, psize); ASSERT(P2PHASE(asize, 1ULL << vd->vdev_ashift) == 0); - offset = metaslab_group_alloc(mg, psize, asize, txg, distance, - dva, d); + uint64_t offset = metaslab_group_alloc(mg, asize, txg, + distance, dva, d); + + mutex_enter(&mg->mg_lock); + if (offset == -1ULL) { + mg->mg_failed_allocations++; + if (asize == SPA_GANGBLOCKSIZE) { + /* + * This metaslab group was unable to allocate + * the minimum gang block size so it must be + * out of space. We must notify the allocation + * throttle to start skipping allocation + * attempts to this metaslab group until more + * space becomes available. + * + * Note: this failure cannot be caused by the + * allocation throttle since the allocation + * throttle is only responsible for skipping + * devices and not failing block allocations. + */ + mg->mg_no_free_space = B_TRUE; + } + } + mg->mg_allocations++; + mutex_exit(&mg->mg_lock); + if (offset != -1ULL) { /* * If we've just selected this metaslab group, @@ -2565,9 +2734,57 @@ metaslab_claim_dva(spa_t *spa, const dva return (0); } +/* + * Reserve some allocation slots. The reservation system must be called + * before we call into the allocator. If there aren't any available slots + * then the I/O will be throttled until an I/O completes and its slots are + * freed up. The function returns true if it was successful in placing + * the reservation. + */ +boolean_t +metaslab_class_throttle_reserve(metaslab_class_t *mc, int slots, zio_t *zio, + int flags) +{ + uint64_t available_slots = 0; + boolean_t slot_reserved = B_FALSE; + + ASSERT(mc->mc_alloc_throttle_enabled); + mutex_enter(&mc->mc_lock); + + uint64_t reserved_slots = refcount_count(&mc->mc_alloc_slots); + if (reserved_slots < mc->mc_alloc_max_slots) + available_slots = mc->mc_alloc_max_slots - reserved_slots; + + if (slots <= available_slots || GANG_ALLOCATION(flags)) { + /* + * We reserve the slots individually so that we can unreserve + * them individually when an I/O completes. + */ + for (int d = 0; d < slots; d++) { + reserved_slots = refcount_add(&mc->mc_alloc_slots, zio); + } + zio->io_flags |= ZIO_FLAG_IO_ALLOCATING; + slot_reserved = B_TRUE; + } + + mutex_exit(&mc->mc_lock); + return (slot_reserved); +} + +void +metaslab_class_throttle_unreserve(metaslab_class_t *mc, int slots, zio_t *zio) +{ + ASSERT(mc->mc_alloc_throttle_enabled); + mutex_enter(&mc->mc_lock); + for (int d = 0; d < slots; d++) { + (void) refcount_remove(&mc->mc_alloc_slots, zio); + } + mutex_exit(&mc->mc_lock); +} + int metaslab_alloc(spa_t *spa, metaslab_class_t *mc, uint64_t psize, blkptr_t *bp, - int ndvas, uint64_t txg, blkptr_t *hintbp, int flags) + int ndvas, uint64_t txg, blkptr_t *hintbp, int flags, zio_t *zio) { dva_t *dva = bp->blk_dva; dva_t *hintdva = hintbp->blk_dva; @@ -2593,11 +2810,21 @@ metaslab_alloc(spa_t *spa, metaslab_clas if (error != 0) { for (d--; d >= 0; d--) { metaslab_free_dva(spa, &dva[d], txg, B_TRUE); + metaslab_group_alloc_decrement(spa, + DVA_GET_VDEV(&dva[d]), zio, flags); bzero(&dva[d], sizeof (dva_t)); } spa_config_exit(spa, SCL_ALLOC, FTAG); return (error); + } else { + /* + * Update the metaslab group's queue depth + * based on the newly allocated dva. + */ + metaslab_group_alloc_increment(spa, + DVA_GET_VDEV(&dva[d]), zio, flags); } + } ASSERT(error == 0); ASSERT(BP_GET_NDVAS(bp) == ndvas); Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/refcount.c ============================================================================== --- stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/refcount.c Fri Oct 14 07:24:43 2016 (r307276) +++ stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/refcount.c Fri Oct 14 07:26:19 2016 (r307277) @@ -20,7 +20,7 @@ */ /* * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2012 by Delphix. All rights reserved. + * Copyright (c) 2012, 2015 by Delphix. All rights reserved. */ #include @@ -73,6 +73,13 @@ refcount_create(refcount_t *rc) } void +refcount_create_tracked(refcount_t *rc) +{ + refcount_create(rc); + rc->rc_tracked = B_TRUE; +} + +void refcount_create_untracked(refcount_t *rc) { refcount_create(rc); @@ -255,4 +262,60 @@ refcount_transfer_ownership(refcount_t * ASSERT(found); mutex_exit(&rc->rc_mtx); } + +/* + * If tracking is enabled, return true if a reference exists that matches + * the "holder" tag. If tracking is disabled, then return true if a reference + * might be held. + */ +boolean_t +refcount_held(refcount_t *rc, void *holder) +{ + reference_t *ref; + + mutex_enter(&rc->rc_mtx); + + if (!rc->rc_tracked) { + mutex_exit(&rc->rc_mtx); + return (rc->rc_count > 0); + } + + for (ref = list_head(&rc->rc_list); ref; + ref = list_next(&rc->rc_list, ref)) { + if (ref->ref_holder == holder) { + mutex_exit(&rc->rc_mtx); + return (B_TRUE); + } + } + mutex_exit(&rc->rc_mtx); + return (B_FALSE); +} + +/* + * If tracking is enabled, return true if a reference does not exist that + * matches the "holder" tag. If tracking is disabled, always return true + * since the reference might not be held. + */ +boolean_t +refcount_not_held(refcount_t *rc, void *holder) +{ + reference_t *ref; + + mutex_enter(&rc->rc_mtx); + + if (!rc->rc_tracked) { + mutex_exit(&rc->rc_mtx); + return (B_TRUE); + } + + for (ref = list_head(&rc->rc_list); ref; + ref = list_next(&rc->rc_list, ref)) { + if (ref->ref_holder == holder) { + mutex_exit(&rc->rc_mtx); + return (B_FALSE); + } + } + mutex_exit(&rc->rc_mtx); + return (B_TRUE); +} #endif /* ZFS_DEBUG */ Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c ============================================================================== --- stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c Fri Oct 14 07:24:43 2016 (r307276) +++ stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c Fri Oct 14 07:26:19 2016 (r307277) @@ -1332,7 +1332,6 @@ spa_unload(spa_t *spa) ddt_unload(spa); - /* * Drop and purge level 2 cache */ @@ -3720,6 +3719,7 @@ spa_create(const char *pool, nvlist_t *n spa->spa_uberblock.ub_txg = txg - 1; spa->spa_uberblock.ub_version = version; spa->spa_ubsync = spa->spa_uberblock; + spa->spa_load_state = SPA_LOAD_CREATE; /* * Create "The Godfather" zio to hold all async IOs @@ -3905,6 +3905,7 @@ spa_create(const char *pool, nvlist_t *n */ spa_evicting_os_wait(spa); spa->spa_minref = refcount_count(&spa->spa_refcount); + spa->spa_load_state = SPA_LOAD_NONE; mutex_exit(&spa_namespace_lock); @@ -5615,7 +5616,7 @@ spa_nvlist_lookup_by_guid(nvlist_t **nvp static void spa_vdev_remove_aux(nvlist_t *config, char *name, nvlist_t **dev, int count, - nvlist_t *dev_to_remove) + nvlist_t *dev_to_remove) { nvlist_t **newdev = NULL; @@ -6830,6 +6831,8 @@ spa_sync(spa_t *spa, uint64_t txg) vdev_t *vd; dmu_tx_t *tx; int error; + uint32_t max_queue_depth = zfs_vdev_async_write_max_active * + zfs_vdev_queue_depth_pct / 100; VERIFY(spa_writeable(spa)); @@ -6841,6 +6844,10 @@ spa_sync(spa_t *spa, uint64_t txg) spa->spa_syncing_txg = txg; spa->spa_sync_pass = 0; + mutex_enter(&spa->spa_alloc_lock); + VERIFY0(avl_numnodes(&spa->spa_alloc_tree)); + mutex_exit(&spa->spa_alloc_lock); + /* * If there are any pending vdev state changes, convert them * into config changes that go out with this transaction group. @@ -6900,6 +6907,38 @@ spa_sync(spa_t *spa, uint64_t txg) } /* + * Set the top-level vdev's max queue depth. Evaluate each + * top-level's async write queue depth in case it changed. + * The max queue depth will not change in the middle of syncing + * out this txg. + */ + uint64_t queue_depth_total = 0; + for (int c = 0; c < rvd->vdev_children; c++) { + vdev_t *tvd = rvd->vdev_child[c]; + metaslab_group_t *mg = tvd->vdev_mg; + + if (mg == NULL || mg->mg_class != spa_normal_class(spa) || + !metaslab_group_initialized(mg)) + continue; + + /* + * It is safe to do a lock-free check here because only async + * allocations look at mg_max_alloc_queue_depth, and async + * allocations all happen from spa_sync(). + */ + ASSERT0(refcount_count(&mg->mg_alloc_queue_depth)); + mg->mg_max_alloc_queue_depth = max_queue_depth; + queue_depth_total += mg->mg_max_alloc_queue_depth; + } + metaslab_class_t *mc = spa_normal_class(spa); + ASSERT0(refcount_count(&mc->mc_alloc_slots)); + mc->mc_alloc_max_slots = queue_depth_total; + mc->mc_alloc_throttle_enabled = zio_dva_throttle_enabled; + + ASSERT3U(mc->mc_alloc_max_slots, <=, + max_queue_depth * rvd->vdev_children); + + /* * Iterate to convergence. */ do { @@ -7056,6 +7095,10 @@ spa_sync(spa_t *spa, uint64_t txg) dsl_pool_sync_done(dp, txg); + mutex_enter(&spa->spa_alloc_lock); + VERIFY0(avl_numnodes(&spa->spa_alloc_tree)); + mutex_exit(&spa->spa_alloc_lock); + /* * Update usable space statistics. */ Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_misc.c ============================================================================== --- stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_misc.c Fri Oct 14 07:24:43 2016 (r307276) +++ stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_misc.c Fri Oct 14 07:26:19 2016 (r307277) @@ -657,6 +657,7 @@ spa_add(const char *name, nvlist_t *conf mutex_init(&spa->spa_scrub_lock, NULL, MUTEX_DEFAULT, NULL); mutex_init(&spa->spa_suspend_lock, NULL, MUTEX_DEFAULT, NULL); mutex_init(&spa->spa_vdev_top_lock, NULL, MUTEX_DEFAULT, NULL); + mutex_init(&spa->spa_alloc_lock, NULL, MUTEX_DEFAULT, NULL); cv_init(&spa->spa_async_cv, NULL, CV_DEFAULT, NULL); cv_init(&spa->spa_evicting_os_cv, NULL, CV_DEFAULT, NULL); @@ -713,6 +714,9 @@ spa_add(const char *name, nvlist_t *conf spa_active_count++; } + avl_create(&spa->spa_alloc_tree, zio_timestamp_compare, + sizeof (zio_t), offsetof(zio_t, io_alloc_node)); + /* * Every pool starts with the default cachefile */ @@ -791,6 +795,7 @@ spa_remove(spa_t *spa) kmem_free(dp, sizeof (spa_config_dirent_t)); } + avl_destroy(&spa->spa_alloc_tree); list_destroy(&spa->spa_config_list); nvlist_free(spa->spa_label_features); @@ -824,6 +829,7 @@ spa_remove(spa_t *spa) cv_destroy(&spa->spa_scrub_io_cv); cv_destroy(&spa->spa_suspend_cv); + mutex_destroy(&spa->spa_alloc_lock); mutex_destroy(&spa->spa_async_lock); mutex_destroy(&spa->spa_errlist_lock); mutex_destroy(&spa->spa_errlog_lock); Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/metaslab.h ============================================================================== --- stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/metaslab.h Fri Oct 14 07:24:43 2016 (r307276) +++ stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/metaslab.h Fri Oct 14 07:26:19 2016 (r307277) @@ -20,7 +20,7 @@ */ /* * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2011, 2014 by Delphix. All rights reserved. + * Copyright (c) 2011, 2015 by Delphix. All rights reserved. */ #ifndef _SYS_METASLAB_H @@ -55,14 +55,15 @@ void metaslab_sync_done(metaslab_t *, ui void metaslab_sync_reassess(metaslab_group_t *); uint64_t metaslab_block_maxsize(metaslab_t *); -#define METASLAB_HINTBP_FAVOR 0x0 -#define METASLAB_HINTBP_AVOID 0x1 -#define METASLAB_GANG_HEADER 0x2 -#define METASLAB_GANG_CHILD 0x4 -#define METASLAB_GANG_AVOID 0x8 +#define METASLAB_HINTBP_FAVOR 0x0 +#define METASLAB_HINTBP_AVOID 0x1 +#define METASLAB_GANG_HEADER 0x2 +#define METASLAB_GANG_CHILD 0x4 +#define METASLAB_ASYNC_ALLOC 0x8 +#define METASLAB_DONT_THROTTLE 0x10 int metaslab_alloc(spa_t *, metaslab_class_t *, uint64_t, - blkptr_t *, int, uint64_t, blkptr_t *, int); + blkptr_t *, int, uint64_t, blkptr_t *, int, zio_t *); void metaslab_free(spa_t *, const blkptr_t *, uint64_t, boolean_t); int metaslab_claim(spa_t *, const blkptr_t *, uint64_t); void metaslab_check_free(spa_t *, const blkptr_t *); @@ -73,6 +74,9 @@ int metaslab_class_validate(metaslab_cla void metaslab_class_histogram_verify(metaslab_class_t *); uint64_t metaslab_class_fragmentation(metaslab_class_t *); uint64_t metaslab_class_expandable_space(metaslab_class_t *); +boolean_t metaslab_class_throttle_reserve(metaslab_class_t *, int, + zio_t *, int); +void metaslab_class_throttle_unreserve(metaslab_class_t *, int, zio_t *); void metaslab_class_space_update(metaslab_class_t *, int64_t, int64_t, int64_t, int64_t); @@ -86,10 +90,13 @@ metaslab_group_t *metaslab_group_create( void metaslab_group_destroy(metaslab_group_t *); void metaslab_group_activate(metaslab_group_t *); void metaslab_group_passivate(metaslab_group_t *); +boolean_t metaslab_group_initialized(metaslab_group_t *); uint64_t metaslab_group_get_space(metaslab_group_t *); void metaslab_group_histogram_verify(metaslab_group_t *); uint64_t metaslab_group_fragmentation(metaslab_group_t *); void metaslab_group_histogram_remove(metaslab_group_t *, metaslab_t *); +void metaslab_group_alloc_decrement(spa_t *, uint64_t, void *, int); +void metaslab_group_alloc_verify(spa_t *, const blkptr_t *, void *); #ifdef __cplusplus } Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/metaslab_impl.h ============================================================================== --- stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/metaslab_impl.h Fri Oct 14 07:24:43 2016 (r307276) +++ stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/metaslab_impl.h Fri Oct 14 07:26:19 2016 (r307277) @@ -24,7 +24,7 @@ */ /* - * Copyright (c) 2011, 2014 by Delphix. All rights reserved. + * Copyright (c) 2011, 2015 by Delphix. All rights reserved. */ #ifndef _SYS_METASLAB_IMPL_H @@ -59,11 +59,42 @@ extern "C" { * to use a block allocator that best suits that class. */ struct metaslab_class { + kmutex_t mc_lock; spa_t *mc_spa; metaslab_group_t *mc_rotor; metaslab_ops_t *mc_ops; uint64_t mc_aliquot; + + /* + * Track the number of metaslab groups that have been initialized + * and can accept allocations. An initialized metaslab group is + * one has been completely added to the config (i.e. we have + * updated the MOS config and the space has been added to the pool). + */ + uint64_t mc_groups; + + /* + * Toggle to enable/disable the allocation throttle. + */ + boolean_t mc_alloc_throttle_enabled; + + /* + * The allocation throttle works on a reservation system. Whenever + * an asynchronous zio wants to perform an allocation it must + * first reserve the number of blocks that it wants to allocate. + * If there aren't sufficient slots available for the pending zio + * then that I/O is throttled until more slots free up. The current + * number of reserved allocations is maintained by the mc_alloc_slots + * refcount. The mc_alloc_max_slots value determines the maximum + * number of allocations that the system allows. Gang blocks are + * allowed to reserve slots even if we've reached the maximum + * number of allocations allowed. + */ + uint64_t mc_alloc_max_slots; + refcount_t mc_alloc_slots; + uint64_t mc_alloc_groups; /* # of allocatable groups */ + uint64_t mc_alloc; /* total allocated space */ uint64_t mc_deferred; /* total deferred frees */ uint64_t mc_space; /* total space (alloc + free) */ @@ -86,6 +117,15 @@ struct metaslab_group { avl_tree_t mg_metaslab_tree; uint64_t mg_aliquot; boolean_t mg_allocatable; /* can we allocate? */ + + /* + * A metaslab group is considered to be initialized only after + * we have updated the MOS config and added the space to the pool. + * We only allow allocation attempts to a metaslab group if it + * has been initialized. + */ + boolean_t mg_initialized; + uint64_t mg_free_capacity; /* percentage free */ int64_t mg_bias; int64_t mg_activation_count; @@ -94,6 +134,27 @@ struct metaslab_group { taskq_t *mg_taskq; metaslab_group_t *mg_prev; metaslab_group_t *mg_next; + + /* + * Each metaslab group can handle mg_max_alloc_queue_depth allocations + * which are tracked by mg_alloc_queue_depth. It's possible for a + * metaslab group to handle more allocations than its max. This + * can occur when gang blocks are required or when other groups + * are unable to handle their share of allocations. + */ + uint64_t mg_max_alloc_queue_depth; + refcount_t mg_alloc_queue_depth; + + /* + * A metalab group that can no longer allocate the minimum block + * size will set mg_no_free_space. Once a metaslab group is out + * of space then its share of work must be distributed to other + * groups. + */ + boolean_t mg_no_free_space; + + uint64_t mg_allocations; + uint64_t mg_failed_allocations; uint64_t mg_fragmentation; uint64_t mg_histogram[RANGE_TREE_HISTOGRAM_SIZE]; }; Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/refcount.h ============================================================================== --- stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/refcount.h Fri Oct 14 07:24:43 2016 (r307276) +++ stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/refcount.h Fri Oct 14 07:26:19 2016 (r307277) @@ -20,7 +20,7 @@ */ /* * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2012 by Delphix. All rights reserved. + * Copyright (c) 2012, 2015 by Delphix. All rights reserved. */ #ifndef _SYS_REFCOUNT_H @@ -64,6 +64,7 @@ typedef struct refcount { void refcount_create(refcount_t *rc); void refcount_create_untracked(refcount_t *rc); +void refcount_create_tracked(refcount_t *rc); void refcount_destroy(refcount_t *rc); void refcount_destroy_many(refcount_t *rc, uint64_t number); int refcount_is_zero(refcount_t *rc); @@ -74,6 +75,8 @@ int64_t refcount_add_many(refcount_t *rc int64_t refcount_remove_many(refcount_t *rc, uint64_t number, void *holder_tag); void refcount_transfer(refcount_t *dst, refcount_t *src); void refcount_transfer_ownership(refcount_t *, void *, void *); +boolean_t refcount_held(refcount_t *, void *); +boolean_t refcount_not_held(refcount_t *, void *); void refcount_sysinit(void); void refcount_fini(void); @@ -86,6 +89,7 @@ typedef struct refcount { #define refcount_create(rc) ((rc)->rc_count = 0) #define refcount_create_untracked(rc) ((rc)->rc_count = 0) +#define refcount_create_tracked(rc) ((rc)->rc_count = 0) #define refcount_destroy(rc) ((rc)->rc_count = 0) #define refcount_destroy_many(rc, number) ((rc)->rc_count = 0) #define refcount_is_zero(rc) ((rc)->rc_count == 0) @@ -102,6 +106,8 @@ typedef struct refcount { atomic_add_64(&(dst)->rc_count, __tmp); \ } #define refcount_transfer_ownership(rc, current_holder, new_holder) +#define refcount_held(rc, holder) ((rc)->rc_count > 0) +#define refcount_not_held(rc, holder) (B_TRUE) #define refcount_sysinit() #define refcount_fini() Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/spa_impl.h ============================================================================== --- stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/spa_impl.h Fri Oct 14 07:24:43 2016 (r307276) +++ stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/spa_impl.h Fri Oct 14 07:26:19 2016 (r307277) @@ -165,6 +165,8 @@ struct spa { uint64_t spa_last_synced_guid; /* last synced guid */ list_t spa_config_dirty_list; /* vdevs with dirty config */ list_t spa_state_dirty_list; /* vdevs with dirty state */ + kmutex_t spa_alloc_lock; + avl_tree_t spa_alloc_tree; spa_aux_vdev_t spa_spares; /* hot spares */ spa_aux_vdev_t spa_l2cache; /* L2ARC cache devices */ nvlist_t *spa_label_features; /* Features for reading MOS */ Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/vdev_impl.h ============================================================================== --- stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/vdev_impl.h Fri Oct 14 07:24:43 2016 (r307276) +++ stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/vdev_impl.h Fri Oct 14 07:26:19 2016 (r307277) @@ -53,6 +53,9 @@ typedef struct vdev_queue vdev_queue_t; typedef struct vdev_cache vdev_cache_t; typedef struct vdev_cache_entry vdev_cache_entry_t; +extern int zfs_vdev_queue_depth_pct; +extern uint32_t zfs_vdev_async_write_max_active; + /* * Virtual device operations */ @@ -190,10 +193,21 @@ struct vdev { uint64_t vdev_deflate_ratio; /* deflation ratio (x512) */ uint64_t vdev_islog; /* is an intent log device */ uint64_t vdev_removing; /* device is being removed? */ - boolean_t vdev_ishole; /* is a hole in the namespace */ + boolean_t vdev_ishole; /* is a hole in the namespace */ + kmutex_t vdev_queue_lock; /* protects vdev_queue_depth */ uint64_t vdev_top_zap; /* + * The queue depth parameters determine how many async writes are + * still pending (i.e. allocated by net yet issued to disk) per + * top-level (vdev_async_write_queue_depth) and the maximum allowed + * (vdev_max_async_write_queue_depth). These values only apply to + * top-level vdevs. + */ + uint64_t vdev_async_write_queue_depth; + uint64_t vdev_max_async_write_queue_depth; + + /* * Leaf vdev state. */ range_tree_t *vdev_dtl[DTL_TYPES]; /* dirty time logs */ Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zio.h ============================================================================== --- stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zio.h Fri Oct 14 07:24:43 2016 (r307276) +++ stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zio.h Fri Oct 14 07:26:19 2016 (r307277) @@ -175,6 +175,7 @@ enum zio_flag { ZIO_FLAG_DONT_CACHE = 1 << 11, ZIO_FLAG_NODATA = 1 << 12, ZIO_FLAG_INDUCE_DAMAGE = 1 << 13, + ZIO_FLAG_IO_ALLOCATING = 1 << 14, #define ZIO_FLAG_DDT_INHERIT (ZIO_FLAG_IO_RETRY - 1) #define ZIO_FLAG_GANG_INHERIT (ZIO_FLAG_IO_RETRY - 1) @@ -182,27 +183,27 @@ enum zio_flag { /* * Flags inherited by vdev children. */ - ZIO_FLAG_IO_RETRY = 1 << 14, /* must be first for INHERIT */ - ZIO_FLAG_PROBE = 1 << 15, - ZIO_FLAG_TRYHARD = 1 << 16, - ZIO_FLAG_OPTIONAL = 1 << 17, + ZIO_FLAG_IO_RETRY = 1 << 15, /* must be first for INHERIT */ + ZIO_FLAG_PROBE = 1 << 16, + ZIO_FLAG_TRYHARD = 1 << 17, + ZIO_FLAG_OPTIONAL = 1 << 18, *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-all@freebsd.org Fri Oct 14 07:27:32 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 045BDC1186A; Fri, 14 Oct 2016 07:27:32 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 973E4646; Fri, 14 Oct 2016 07:27:31 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9E7RU7A065148; Fri, 14 Oct 2016 07:27:30 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9E7RTci065138; Fri, 14 Oct 2016 07:27:29 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610140727.u9E7RTci065138@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Fri, 14 Oct 2016 07:27:29 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307278 - in stable/11/sys/dev/hyperv: include vmbus X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Oct 2016 07:27:32 -0000 Author: sephe Date: Fri Oct 14 07:27:29 2016 New Revision: 307278 URL: https://svnweb.freebsd.org/changeset/base/307278 Log: MFC 302540 hyperv/vmbus: Implement a new set of APIs for post message Hypercall And use this new APIs for Initial Contact post message Hypercall. More post message Hypercalls will be converted. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D6830 Modified: stable/11/sys/dev/hyperv/include/hyperv.h stable/11/sys/dev/hyperv/vmbus/hv_channel_mgmt.c stable/11/sys/dev/hyperv/vmbus/hv_connection.c stable/11/sys/dev/hyperv/vmbus/hv_vmbus_priv.h stable/11/sys/dev/hyperv/vmbus/hyperv.c stable/11/sys/dev/hyperv/vmbus/hyperv_reg.h stable/11/sys/dev/hyperv/vmbus/hyperv_var.h stable/11/sys/dev/hyperv/vmbus/vmbus.c stable/11/sys/dev/hyperv/vmbus/vmbus_reg.h stable/11/sys/dev/hyperv/vmbus/vmbus_var.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/hyperv/include/hyperv.h ============================================================================== --- stable/11/sys/dev/hyperv/include/hyperv.h Fri Oct 14 07:26:19 2016 (r307277) +++ stable/11/sys/dev/hyperv/include/hyperv.h Fri Oct 14 07:27:29 2016 (r307278) @@ -77,10 +77,6 @@ typedef uint8_t hv_bool_uint8_t; #define HV_VMBUS_VERSION_WIN8 ((2 << 16) | (4)) #define HV_VMBUS_VERSION_WIN8_1 ((3 << 16) | (0)) -#define HV_VMBUS_VERSION_INVALID -1 - -#define HV_VMBUS_VERSION_CURRENT HV_VMBUS_VERSION_WIN8_1 - /* * Make maximum size of pipe payload of 16K */ @@ -537,20 +533,6 @@ typedef struct { uint32_t child_rel_id; } __packed hv_vmbus_channel_relid_released; -typedef struct { - hv_vmbus_channel_msg_header header; - uint32_t vmbus_version_requested; - uint32_t padding2; - uint64_t interrupt_page; - uint64_t monitor_page_1; - uint64_t monitor_page_2; -} __packed hv_vmbus_channel_initiate_contact; - -typedef struct { - hv_vmbus_channel_msg_header header; - hv_bool_uint8_t version_supported; -} __packed hv_vmbus_channel_version_response; - typedef hv_vmbus_channel_msg_header hv_vmbus_channel_unload; #define HW_MACADDR_LEN 6 Modified: stable/11/sys/dev/hyperv/vmbus/hv_channel_mgmt.c ============================================================================== --- stable/11/sys/dev/hyperv/vmbus/hv_channel_mgmt.c Fri Oct 14 07:26:19 2016 (r307277) +++ stable/11/sys/dev/hyperv/vmbus/hv_channel_mgmt.c Fri Oct 14 07:27:29 2016 (r307278) @@ -40,29 +40,30 @@ * Internal functions */ -typedef void (*vmbus_msg_handler)(const hv_vmbus_channel_msg_header *msg); - typedef struct hv_vmbus_channel_msg_table_entry { hv_vmbus_channel_msg_type messageType; - vmbus_msg_handler messageHandler; + void (*messageHandler) + (struct vmbus_softc *sc, + const struct vmbus_message *msg); } hv_vmbus_channel_msg_table_entry; static void vmbus_channel_on_offer_internal(void *context); static void vmbus_channel_on_offer_rescind_internal(void *context); -static void vmbus_channel_on_offer(const hv_vmbus_channel_msg_header *hdr); -static void vmbus_channel_on_open_result( - const hv_vmbus_channel_msg_header *hdr); -static void vmbus_channel_on_offer_rescind( - const hv_vmbus_channel_msg_header *hdr); -static void vmbus_channel_on_gpadl_created( - const hv_vmbus_channel_msg_header *hdr); -static void vmbus_channel_on_gpadl_torndown( - const hv_vmbus_channel_msg_header *hdr); -static void vmbus_channel_on_offers_delivered( - const hv_vmbus_channel_msg_header *hdr); -static void vmbus_channel_on_version_response( - const hv_vmbus_channel_msg_header *hdr); +static void vmbus_channel_on_offer(struct vmbus_softc *, + const struct vmbus_message *); +static void vmbus_channel_on_open_result(struct vmbus_softc *, + const struct vmbus_message *); +static void vmbus_channel_on_offer_rescind(struct vmbus_softc *, + const struct vmbus_message *); +static void vmbus_channel_on_gpadl_created(struct vmbus_softc *, + const struct vmbus_message *); +static void vmbus_channel_on_gpadl_torndown(struct vmbus_softc *, + const struct vmbus_message *); +static void vmbus_channel_on_offers_delivered(struct vmbus_softc *, + const struct vmbus_message *); +static void vmbus_channel_on_version_response(struct vmbus_softc *, + const struct vmbus_message *); /** * Channel message dispatch table @@ -398,8 +399,11 @@ vmbus_channel_select_defcpu(struct hv_vm * object to process the offer synchronously */ static void -vmbus_channel_on_offer(const hv_vmbus_channel_msg_header *hdr) +vmbus_channel_on_offer(struct vmbus_softc *sc, const struct vmbus_message *msg) { + const hv_vmbus_channel_msg_header *hdr = + (const hv_vmbus_channel_msg_header *)msg->msg_data; + const hv_vmbus_channel_offer_channel *offer; hv_vmbus_channel_offer_channel *copied; @@ -476,8 +480,12 @@ vmbus_channel_on_offer_internal(void* co * synchronously */ static void -vmbus_channel_on_offer_rescind(const hv_vmbus_channel_msg_header *hdr) +vmbus_channel_on_offer_rescind(struct vmbus_softc *sc, + const struct vmbus_message *msg) { + const hv_vmbus_channel_msg_header *hdr = + (const hv_vmbus_channel_msg_header *)msg->msg_data; + const hv_vmbus_channel_rescind_offer *rescind; hv_vmbus_channel* channel; @@ -508,8 +516,8 @@ vmbus_channel_on_offer_rescind_internal( * @brief Invoked when all offers have been delivered. */ static void -vmbus_channel_on_offers_delivered( - const hv_vmbus_channel_msg_header *hdr __unused) +vmbus_channel_on_offers_delivered(struct vmbus_softc *sc __unused, + const struct vmbus_message *msg __unused) { mtx_lock(&vmbus_chwait_lock); @@ -526,8 +534,12 @@ vmbus_channel_on_offers_delivered( * response and signal the requesting thread. */ static void -vmbus_channel_on_open_result(const hv_vmbus_channel_msg_header *hdr) +vmbus_channel_on_open_result(struct vmbus_softc *sc, + const struct vmbus_message *msg) { + const hv_vmbus_channel_msg_header *hdr = + (const hv_vmbus_channel_msg_header *)msg->msg_data; + const hv_vmbus_channel_open_result *result; hv_vmbus_channel_msg_info* msg_info; hv_vmbus_channel_msg_header* requestHeader; @@ -568,8 +580,12 @@ vmbus_channel_on_open_result(const hv_vm * response and signal the requesting thread. */ static void -vmbus_channel_on_gpadl_created(const hv_vmbus_channel_msg_header *hdr) +vmbus_channel_on_gpadl_created(struct vmbus_softc *sc, + const struct vmbus_message *msg) { + const hv_vmbus_channel_msg_header *hdr = + (const hv_vmbus_channel_msg_header *)msg->msg_data; + const hv_vmbus_channel_gpadl_created *gpadl_created; hv_vmbus_channel_msg_info* msg_info; hv_vmbus_channel_msg_header* request_header; @@ -610,8 +626,12 @@ vmbus_channel_on_gpadl_created(const hv_ * response and signal the requesting thread */ static void -vmbus_channel_on_gpadl_torndown(const hv_vmbus_channel_msg_header *hdr) +vmbus_channel_on_gpadl_torndown(struct vmbus_softc *sc, + const struct vmbus_message *msg) { + const hv_vmbus_channel_msg_header *hdr = + (const hv_vmbus_channel_msg_header *)msg->msg_data; + const hv_vmbus_channel_gpadl_torndown *gpadl_torndown; hv_vmbus_channel_msg_info* msg_info; hv_vmbus_channel_msg_header* requestHeader; @@ -647,39 +667,11 @@ vmbus_channel_on_gpadl_torndown(const hv mtx_unlock(&hv_vmbus_g_connection.channel_msg_lock); } -/** - * @brief Version response handler. - * - * This is invoked when we received a response - * to our initiate contact request. Find the matching request, copy th - * response and signal the requesting thread. - */ static void -vmbus_channel_on_version_response(const hv_vmbus_channel_msg_header *hdr) +vmbus_channel_on_version_response(struct vmbus_softc *sc, + const struct vmbus_message *msg) { - hv_vmbus_channel_msg_info* msg_info; - hv_vmbus_channel_msg_header* requestHeader; - hv_vmbus_channel_initiate_contact* initiate; - const hv_vmbus_channel_version_response *versionResponse; - - versionResponse = (const hv_vmbus_channel_version_response *)hdr; - - mtx_lock(&hv_vmbus_g_connection.channel_msg_lock); - TAILQ_FOREACH(msg_info, &hv_vmbus_g_connection.channel_msg_anchor, - msg_list_entry) { - requestHeader = (hv_vmbus_channel_msg_header*) msg_info->msg; - if (requestHeader->message_type - == HV_CHANNEL_MESSAGE_INITIATED_CONTACT) { - initiate = - (hv_vmbus_channel_initiate_contact*) requestHeader; - memcpy(&msg_info->response.version_response, - versionResponse, - sizeof(hv_vmbus_channel_version_response)); - sema_post(&msg_info->wait_sema); - } - } - mtx_unlock(&hv_vmbus_g_connection.channel_msg_lock); - + vmbus_msghc_wakeup(sc, msg); } /** @@ -865,5 +857,5 @@ vmbus_chan_msgproc(struct vmbus_softc *s entry = &g_channel_message_table[msg_type]; if (entry->messageHandler) - entry->messageHandler(hdr); + entry->messageHandler(sc, msg); } Modified: stable/11/sys/dev/hyperv/vmbus/hv_connection.c ============================================================================== --- stable/11/sys/dev/hyperv/vmbus/hv_connection.c Fri Oct 14 07:26:19 2016 (r307277) +++ stable/11/sys/dev/hyperv/vmbus/hv_connection.c Fri Oct 14 07:27:29 2016 (r307278) @@ -39,6 +39,7 @@ #include #include +#include #include #include @@ -49,97 +50,7 @@ hv_vmbus_connection hv_vmbus_g_connectio { .connect_state = HV_DISCONNECTED, .next_gpadl_handle = 0xE1E10, }; -uint32_t hv_vmbus_protocal_version = HV_VMBUS_VERSION_WS2008; - -static uint32_t -hv_vmbus_get_next_version(uint32_t current_ver) -{ - switch (current_ver) { - case (HV_VMBUS_VERSION_WIN7): - return(HV_VMBUS_VERSION_WS2008); - - case (HV_VMBUS_VERSION_WIN8): - return(HV_VMBUS_VERSION_WIN7); - - case (HV_VMBUS_VERSION_WIN8_1): - return(HV_VMBUS_VERSION_WIN8); - - case (HV_VMBUS_VERSION_WS2008): - default: - return(HV_VMBUS_VERSION_INVALID); - } -} - -/** - * Negotiate the highest supported hypervisor version. - */ -static int -hv_vmbus_negotiate_version(struct vmbus_softc *sc, - hv_vmbus_channel_msg_info *msg_info, uint32_t version) -{ - int ret = 0; - hv_vmbus_channel_initiate_contact *msg; - - sema_init(&msg_info->wait_sema, 0, "Msg Info Sema"); - msg = (hv_vmbus_channel_initiate_contact*) msg_info->msg; - - msg->header.message_type = HV_CHANNEL_MESSAGE_INITIATED_CONTACT; - msg->vmbus_version_requested = version; - - msg->interrupt_page = sc->vmbus_evtflags_dma.hv_paddr; - msg->monitor_page_1 = sc->vmbus_mnf1_dma.hv_paddr; - msg->monitor_page_2 = sc->vmbus_mnf2_dma.hv_paddr; - - /** - * Add to list before we send the request since we may receive the - * response before returning from this routine - */ - mtx_lock(&hv_vmbus_g_connection.channel_msg_lock); - - TAILQ_INSERT_TAIL( - &hv_vmbus_g_connection.channel_msg_anchor, - msg_info, - msg_list_entry); - - mtx_unlock(&hv_vmbus_g_connection.channel_msg_lock); - - ret = hv_vmbus_post_message( - msg, - sizeof(hv_vmbus_channel_initiate_contact)); - - if (ret != 0) { - mtx_lock(&hv_vmbus_g_connection.channel_msg_lock); - TAILQ_REMOVE( - &hv_vmbus_g_connection.channel_msg_anchor, - msg_info, - msg_list_entry); - mtx_unlock(&hv_vmbus_g_connection.channel_msg_lock); - return (ret); - } - - /** - * Wait for the connection response - */ - ret = sema_timedwait(&msg_info->wait_sema, 5 * hz); /* KYS 5 seconds */ - - mtx_lock(&hv_vmbus_g_connection.channel_msg_lock); - TAILQ_REMOVE( - &hv_vmbus_g_connection.channel_msg_anchor, - msg_info, - msg_list_entry); - mtx_unlock(&hv_vmbus_g_connection.channel_msg_lock); - - /** - * Check if successful - */ - if (msg_info->response.version_response.version_supported) { - hv_vmbus_g_connection.connect_state = HV_CONNECTED; - } else { - ret = ECONNREFUSED; - } - - return (ret); -} +uint32_t hv_vmbus_protocal_version; /** * Send a connect request on the partition service connection @@ -147,10 +58,6 @@ hv_vmbus_negotiate_version(struct vmbus_ int hv_vmbus_connect(struct vmbus_softc *sc) { - int ret = 0; - uint32_t version; - hv_vmbus_channel_msg_info* msg_info = NULL; - /** * Make sure we are not connecting or connected */ @@ -171,60 +78,12 @@ hv_vmbus_connect(struct vmbus_softc *sc) mtx_init(&hv_vmbus_g_connection.channel_lock, "vmbus channel", NULL, MTX_DEF); - msg_info = (hv_vmbus_channel_msg_info*) - malloc(sizeof(hv_vmbus_channel_msg_info) + - sizeof(hv_vmbus_channel_initiate_contact), - M_DEVBUF, M_WAITOK | M_ZERO); - hv_vmbus_g_connection.channels = malloc(sizeof(hv_vmbus_channel*) * VMBUS_CHAN_MAX, M_DEVBUF, M_WAITOK | M_ZERO); - /* - * Find the highest vmbus version number we can support. - */ - version = HV_VMBUS_VERSION_CURRENT; - - do { - ret = hv_vmbus_negotiate_version(sc, msg_info, version); - if (ret == EWOULDBLOCK) { - /* - * We timed out. - */ - goto cleanup; - } - - if (hv_vmbus_g_connection.connect_state == HV_CONNECTED) - break; - - version = hv_vmbus_get_next_version(version); - } while (version != HV_VMBUS_VERSION_INVALID); - - hv_vmbus_protocal_version = version; - if (bootverbose) - printf("VMBUS: Protocol Version: %d.%d\n", - version >> 16, version & 0xFFFF); - sema_destroy(&msg_info->wait_sema); - free(msg_info, M_DEVBUF); + hv_vmbus_g_connection.connect_state = HV_CONNECTED; return (0); - - /* - * Cleanup after failure! - */ - cleanup: - - hv_vmbus_g_connection.connect_state = HV_DISCONNECTED; - - mtx_destroy(&hv_vmbus_g_connection.channel_lock); - mtx_destroy(&hv_vmbus_g_connection.channel_msg_lock); - - if (msg_info) { - sema_destroy(&msg_info->wait_sema); - free(msg_info, M_DEVBUF); - } - - free(hv_vmbus_g_connection.channels, M_DEVBUF); - return (ret); } /** @@ -330,7 +189,7 @@ int hv_vmbus_post_message(void *buffer, */ for (retries = 0; retries < 20; retries++) { ret = hv_vmbus_post_msg_via_msg_ipc(connId, - VMBUS_MSGTYPE_CHANNEL, buffer, bufferLen); + HYPERV_MSGTYPE_CHANNEL, buffer, bufferLen); if (ret == HV_STATUS_SUCCESS) return (0); Modified: stable/11/sys/dev/hyperv/vmbus/hv_vmbus_priv.h ============================================================================== --- stable/11/sys/dev/hyperv/vmbus/hv_vmbus_priv.h Fri Oct 14 07:26:19 2016 (r307277) +++ stable/11/sys/dev/hyperv/vmbus/hv_vmbus_priv.h Fri Oct 14 07:27:29 2016 (r307278) @@ -95,7 +95,6 @@ typedef union { hv_vmbus_channel_open_result open_result; hv_vmbus_channel_gpadl_torndown gpadl_torndown; hv_vmbus_channel_gpadl_created gpadl_created; - hv_vmbus_channel_version_response version_response; } hv_vmbus_channel_msg_response; /* Modified: stable/11/sys/dev/hyperv/vmbus/hyperv.c ============================================================================== --- stable/11/sys/dev/hyperv/vmbus/hyperv.c Fri Oct 14 07:26:19 2016 (r307277) +++ stable/11/sys/dev/hyperv/vmbus/hyperv.c Fri Oct 14 07:27:29 2016 (r307278) @@ -118,6 +118,13 @@ hv_vmbus_do_hypercall(uint64_t value, vo in_paddr, out_paddr); } +uint64_t +hypercall_post_message(bus_addr_t msg_paddr) +{ + return hypercall_md(hypercall_context.hc_addr, + HYPERCALL_POST_MESSAGE, msg_paddr, 0); +} + /** * @brief Post a message using the hypervisor message IPC. * (This involves a hypercall.) Modified: stable/11/sys/dev/hyperv/vmbus/hyperv_reg.h ============================================================================== --- stable/11/sys/dev/hyperv/vmbus/hyperv_reg.h Fri Oct 14 07:26:19 2016 (r307277) +++ stable/11/sys/dev/hyperv/vmbus/hyperv_reg.h Fri Oct 14 07:27:29 2016 (r307278) @@ -29,6 +29,8 @@ #ifndef _HYPERV_REG_H_ #define _HYPERV_REG_H_ +#include + /* * Hyper-V Synthetic MSRs */ @@ -130,4 +132,41 @@ #define CPUID_LEAF_HV_LIMITS 0x40000005 #define CPUID_LEAF_HV_HWFEATURES 0x40000006 +/* + * Hyper-V message types + */ +#define HYPERV_MSGTYPE_NONE 0 +#define HYPERV_MSGTYPE_CHANNEL 1 +#define HYPERV_MSGTYPE_TIMER_EXPIRED 0x80000010 + +/* + * Hypercall status codes + */ +#define HYPERCALL_STATUS_SUCCESS 0x0000 + +/* + * Hypercall input values + */ +#define HYPERCALL_POST_MESSAGE 0x005c + +/* + * Hypercall input parameters + */ + +/* + * HYPERCALL_POST_MESSAGE + */ +#define HYPERCALL_POSTMSGIN_DSIZE_MAX 240 +#define HYPERCALL_POSTMSGIN_SIZE 256 +#define HYPERCALL_POSTMSGIN_ALIGN 8 + +struct hypercall_postmsg_in { + uint32_t hc_connid; + uint32_t hc_rsvd; + uint32_t hc_msgtype; /* HYPERV_MSGTYPE_ */ + uint32_t hc_dsize; + uint8_t hc_data[HYPERCALL_POSTMSGIN_DSIZE_MAX]; +} __packed; +CTASSERT(sizeof(struct hypercall_postmsg_in) == HYPERCALL_POSTMSGIN_SIZE); + #endif /* !_HYPERV_REG_H_ */ Modified: stable/11/sys/dev/hyperv/vmbus/hyperv_var.h ============================================================================== --- stable/11/sys/dev/hyperv/vmbus/hyperv_var.h Fri Oct 14 07:26:19 2016 (r307277) +++ stable/11/sys/dev/hyperv/vmbus/hyperv_var.h Fri Oct 14 07:27:29 2016 (r307278) @@ -38,4 +38,6 @@ extern u_int hyperv_features; extern u_int hyperv_recommends; +uint64_t hypercall_post_message(bus_addr_t msg_paddr); + #endif /* !_HYPERV_VAR_H_ */ Modified: stable/11/sys/dev/hyperv/vmbus/vmbus.c ============================================================================== --- stable/11/sys/dev/hyperv/vmbus/vmbus.c Fri Oct 14 07:26:19 2016 (r307277) +++ stable/11/sys/dev/hyperv/vmbus/vmbus.c Fri Oct 14 07:27:29 2016 (r307278) @@ -69,10 +69,354 @@ __FBSDID("$FreeBSD$"); #include #include "acpi_if.h" +/* + * NOTE: DO NOT CHANGE THESE + */ +#define VMBUS_CONNID_MESSAGE 1 +#define VMBUS_CONNID_EVENT 2 + +struct vmbus_msghc { + struct hypercall_postmsg_in *mh_inprm; + struct hypercall_postmsg_in mh_inprm_save; + struct hyperv_dma mh_inprm_dma; + + struct vmbus_message *mh_resp; + struct vmbus_message mh_resp0; +}; + +struct vmbus_msghc_ctx { + struct vmbus_msghc *mhc_free; + struct mtx mhc_free_lock; + uint32_t mhc_flags; + + struct vmbus_msghc *mhc_active; + struct mtx mhc_active_lock; +}; + +#define VMBUS_MSGHC_CTXF_DESTROY 0x0001 + +static int vmbus_init(struct vmbus_softc *); +static int vmbus_init_contact(struct vmbus_softc *, + uint32_t); + +static struct vmbus_msghc_ctx *vmbus_msghc_ctx_create(bus_dma_tag_t); +static void vmbus_msghc_ctx_destroy( + struct vmbus_msghc_ctx *); +static void vmbus_msghc_ctx_free(struct vmbus_msghc_ctx *); +static struct vmbus_msghc *vmbus_msghc_alloc(bus_dma_tag_t); +static void vmbus_msghc_free(struct vmbus_msghc *); +static struct vmbus_msghc *vmbus_msghc_get1(struct vmbus_msghc_ctx *, + uint32_t); + struct vmbus_softc *vmbus_sc; extern inthand_t IDTVEC(vmbus_isr); +static const uint32_t vmbus_version[] = { + HV_VMBUS_VERSION_WIN8_1, + HV_VMBUS_VERSION_WIN8, + HV_VMBUS_VERSION_WIN7, + HV_VMBUS_VERSION_WS2008 +}; + +static struct vmbus_msghc * +vmbus_msghc_alloc(bus_dma_tag_t parent_dtag) +{ + struct vmbus_msghc *mh; + + mh = malloc(sizeof(*mh), M_DEVBUF, M_WAITOK | M_ZERO); + + mh->mh_inprm = hyperv_dmamem_alloc(parent_dtag, + HYPERCALL_POSTMSGIN_ALIGN, 0, HYPERCALL_POSTMSGIN_SIZE, + &mh->mh_inprm_dma, BUS_DMA_WAITOK); + if (mh->mh_inprm == NULL) { + free(mh, M_DEVBUF); + return NULL; + } + return mh; +} + +static void +vmbus_msghc_free(struct vmbus_msghc *mh) +{ + hyperv_dmamem_free(&mh->mh_inprm_dma, mh->mh_inprm); + free(mh, M_DEVBUF); +} + +static void +vmbus_msghc_ctx_free(struct vmbus_msghc_ctx *mhc) +{ + KASSERT(mhc->mhc_active == NULL, ("still have active msg hypercall")); + KASSERT(mhc->mhc_free == NULL, ("still have hypercall msg")); + + mtx_destroy(&mhc->mhc_free_lock); + mtx_destroy(&mhc->mhc_active_lock); + free(mhc, M_DEVBUF); +} + +static struct vmbus_msghc_ctx * +vmbus_msghc_ctx_create(bus_dma_tag_t parent_dtag) +{ + struct vmbus_msghc_ctx *mhc; + + mhc = malloc(sizeof(*mhc), M_DEVBUF, M_WAITOK | M_ZERO); + mtx_init(&mhc->mhc_free_lock, "vmbus msghc free", NULL, MTX_DEF); + mtx_init(&mhc->mhc_active_lock, "vmbus msghc act", NULL, MTX_DEF); + + mhc->mhc_free = vmbus_msghc_alloc(parent_dtag); + if (mhc->mhc_free == NULL) { + vmbus_msghc_ctx_free(mhc); + return NULL; + } + return mhc; +} + +static struct vmbus_msghc * +vmbus_msghc_get1(struct vmbus_msghc_ctx *mhc, uint32_t dtor_flag) +{ + struct vmbus_msghc *mh; + + mtx_lock(&mhc->mhc_free_lock); + + while ((mhc->mhc_flags & dtor_flag) == 0 && mhc->mhc_free == NULL) { + mtx_sleep(&mhc->mhc_free, &mhc->mhc_free_lock, 0, + "gmsghc", 0); + } + if (mhc->mhc_flags & dtor_flag) { + /* Being destroyed */ + mh = NULL; + } else { + mh = mhc->mhc_free; + KASSERT(mh != NULL, ("no free hypercall msg")); + KASSERT(mh->mh_resp == NULL, + ("hypercall msg has pending response")); + mhc->mhc_free = NULL; + } + + mtx_unlock(&mhc->mhc_free_lock); + + return mh; +} + +struct vmbus_msghc * +vmbus_msghc_get(struct vmbus_softc *sc, size_t dsize) +{ + struct hypercall_postmsg_in *inprm; + struct vmbus_msghc *mh; + + if (dsize > HYPERCALL_POSTMSGIN_DSIZE_MAX) + return NULL; + + mh = vmbus_msghc_get1(sc->vmbus_msg_hc, VMBUS_MSGHC_CTXF_DESTROY); + if (mh == NULL) + return NULL; + + inprm = mh->mh_inprm; + memset(inprm, 0, HYPERCALL_POSTMSGIN_SIZE); + inprm->hc_connid = VMBUS_CONNID_MESSAGE; + inprm->hc_msgtype = HYPERV_MSGTYPE_CHANNEL; + inprm->hc_dsize = dsize; + + return mh; +} + +void +vmbus_msghc_put(struct vmbus_softc *sc, struct vmbus_msghc *mh) +{ + struct vmbus_msghc_ctx *mhc = sc->vmbus_msg_hc; + + KASSERT(mhc->mhc_active == NULL, ("msg hypercall is active")); + mh->mh_resp = NULL; + + mtx_lock(&mhc->mhc_free_lock); + KASSERT(mhc->mhc_free == NULL, ("has free hypercall msg")); + mhc->mhc_free = mh; + mtx_unlock(&mhc->mhc_free_lock); + wakeup(&mhc->mhc_free); +} + +void * +vmbus_msghc_dataptr(struct vmbus_msghc *mh) +{ + return mh->mh_inprm->hc_data; +} + +static void +vmbus_msghc_ctx_destroy(struct vmbus_msghc_ctx *mhc) +{ + struct vmbus_msghc *mh; + + mtx_lock(&mhc->mhc_free_lock); + mhc->mhc_flags |= VMBUS_MSGHC_CTXF_DESTROY; + mtx_unlock(&mhc->mhc_free_lock); + wakeup(&mhc->mhc_free); + + mh = vmbus_msghc_get1(mhc, 0); + if (mh == NULL) + panic("can't get msghc"); + + vmbus_msghc_free(mh); + vmbus_msghc_ctx_free(mhc); +} + +int +vmbus_msghc_exec_noresult(struct vmbus_msghc *mh) +{ + sbintime_t time = SBT_1MS; + int i; + + /* + * Save the input parameter so that we could restore the input + * parameter if the Hypercall failed. + * + * XXX + * Is this really necessary?! i.e. Will the Hypercall ever + * overwrite the input parameter? + */ + memcpy(&mh->mh_inprm_save, mh->mh_inprm, HYPERCALL_POSTMSGIN_SIZE); + + /* + * In order to cope with transient failures, e.g. insufficient + * resources on host side, we retry the post message Hypercall + * several times. 20 retries seem sufficient. + */ +#define HC_RETRY_MAX 20 + + for (i = 0; i < HC_RETRY_MAX; ++i) { + uint64_t status; + + status = hypercall_post_message(mh->mh_inprm_dma.hv_paddr); + if (status == HYPERCALL_STATUS_SUCCESS) + return 0; + + pause_sbt("hcpmsg", time, 0, C_HARDCLOCK); + if (time < SBT_1S * 2) + time *= 2; + + /* Restore input parameter and try again */ + memcpy(mh->mh_inprm, &mh->mh_inprm_save, + HYPERCALL_POSTMSGIN_SIZE); + } + +#undef HC_RETRY_MAX + + return EIO; +} + +int +vmbus_msghc_exec(struct vmbus_softc *sc, struct vmbus_msghc *mh) +{ + struct vmbus_msghc_ctx *mhc = sc->vmbus_msg_hc; + int error; + + KASSERT(mh->mh_resp == NULL, ("hypercall msg has pending response")); + + mtx_lock(&mhc->mhc_active_lock); + KASSERT(mhc->mhc_active == NULL, ("pending active msg hypercall")); + mhc->mhc_active = mh; + mtx_unlock(&mhc->mhc_active_lock); + + error = vmbus_msghc_exec_noresult(mh); + if (error) { + mtx_lock(&mhc->mhc_active_lock); + KASSERT(mhc->mhc_active == mh, ("msghc mismatch")); + mhc->mhc_active = NULL; + mtx_unlock(&mhc->mhc_active_lock); + } + return error; +} + +const struct vmbus_message * +vmbus_msghc_wait_result(struct vmbus_softc *sc, struct vmbus_msghc *mh) +{ + struct vmbus_msghc_ctx *mhc = sc->vmbus_msg_hc; + + mtx_lock(&mhc->mhc_active_lock); + + KASSERT(mhc->mhc_active == mh, ("msghc mismatch")); + while (mh->mh_resp == NULL) { + mtx_sleep(&mhc->mhc_active, &mhc->mhc_active_lock, 0, + "wmsghc", 0); + } + mhc->mhc_active = NULL; + + mtx_unlock(&mhc->mhc_active_lock); + + return mh->mh_resp; +} + +void +vmbus_msghc_wakeup(struct vmbus_softc *sc, const struct vmbus_message *msg) +{ + struct vmbus_msghc_ctx *mhc = sc->vmbus_msg_hc; + struct vmbus_msghc *mh; + + mtx_lock(&mhc->mhc_active_lock); + + mh = mhc->mhc_active; + KASSERT(mh != NULL, ("no pending msg hypercall")); + memcpy(&mh->mh_resp0, msg, sizeof(mh->mh_resp0)); + mh->mh_resp = &mh->mh_resp0; + + mtx_unlock(&mhc->mhc_active_lock); + wakeup(&mhc->mhc_active); +} + +static int +vmbus_init_contact(struct vmbus_softc *sc, uint32_t version) +{ + struct vmbus_chanmsg_init_contact *req; + const struct vmbus_chanmsg_version_resp *resp; + const struct vmbus_message *msg; + struct vmbus_msghc *mh; + int error, supp = 0; + + mh = vmbus_msghc_get(sc, sizeof(*req)); + if (mh == NULL) + return ENXIO; + + req = vmbus_msghc_dataptr(mh); + req->chm_hdr.chm_type = VMBUS_CHANMSG_TYPE_INIT_CONTACT; + req->chm_ver = version; + req->chm_evtflags = sc->vmbus_evtflags_dma.hv_paddr; + req->chm_mnf1 = sc->vmbus_mnf1_dma.hv_paddr; + req->chm_mnf2 = sc->vmbus_mnf2_dma.hv_paddr; + + error = vmbus_msghc_exec(sc, mh); + if (error) { + vmbus_msghc_put(sc, mh); + return error; + } + + msg = vmbus_msghc_wait_result(sc, mh); + resp = (const struct vmbus_chanmsg_version_resp *)msg->msg_data; + supp = resp->chm_supp; + + vmbus_msghc_put(sc, mh); + + return (supp ? 0 : EOPNOTSUPP); +} + +static int +vmbus_init(struct vmbus_softc *sc) +{ + int i; + + for (i = 0; i < nitems(vmbus_version); ++i) { + int error; + + error = vmbus_init_contact(sc, vmbus_version[i]); + if (!error) { + hv_vmbus_protocal_version = vmbus_version[i]; + device_printf(sc->vmbus_dev, "version %u.%u\n", + (hv_vmbus_protocal_version >> 16), + (hv_vmbus_protocal_version & 0xffff)); + return 0; + } + } + return ENXIO; +} + static void vmbus_msg_task(void *xsc, int pending __unused) { @@ -81,19 +425,19 @@ vmbus_msg_task(void *xsc, int pending __ msg = VMBUS_PCPU_GET(sc, message, curcpu) + VMBUS_SINT_MESSAGE; for (;;) { - if (msg->msg_type == VMBUS_MSGTYPE_NONE) { + if (msg->msg_type == HYPERV_MSGTYPE_NONE) { /* No message */ break; - } else if (msg->msg_type == VMBUS_MSGTYPE_CHANNEL) { + } else if (msg->msg_type == HYPERV_MSGTYPE_CHANNEL) { /* Channel message */ vmbus_chan_msgproc(sc, __DEVOLATILE(const struct vmbus_message *, msg)); } - msg->msg_type = VMBUS_MSGTYPE_NONE; + msg->msg_type = HYPERV_MSGTYPE_NONE; /* * Make sure the write to msg_type (i.e. set to - * VMBUS_MSGTYPE_NONE) happens before we read the + * HYPERV_MSGTYPE_NONE) happens before we read the * msg_flags and EOMing. Otherwise, the EOMing will * not deliver any more messages since there is no * empty slot @@ -127,14 +471,14 @@ vmbus_handle_intr1(struct vmbus_softc *s * TODO: move this to independent IDT vector. */ msg = msg_base + VMBUS_SINT_TIMER; - if (msg->msg_type == VMBUS_MSGTYPE_TIMER_EXPIRED) { - msg->msg_type = VMBUS_MSGTYPE_NONE; + if (msg->msg_type == HYPERV_MSGTYPE_TIMER_EXPIRED) { + msg->msg_type = HYPERV_MSGTYPE_NONE; vmbus_et_intr(frame); /* * Make sure the write to msg_type (i.e. set to - * VMBUS_MSGTYPE_NONE) happens before we read the + * HYPERV_MSGTYPE_NONE) happens before we read the * msg_flags and EOMing. Otherwise, the EOMing will * not deliver any more messages since there is no * empty slot @@ -166,7 +510,7 @@ vmbus_handle_intr1(struct vmbus_softc *s * Check messages. Mainly management stuffs; ultra low rate. */ msg = msg_base + VMBUS_SINT_MESSAGE; - if (__predict_false(msg->msg_type != VMBUS_MSGTYPE_NONE)) { + if (__predict_false(msg->msg_type != HYPERV_MSGTYPE_NONE)) { taskqueue_enqueue(VMBUS_PCPU_GET(sc, message_tq, cpu), VMBUS_PCPU_PTR(sc, message_task, cpu)); } @@ -620,6 +964,16 @@ vmbus_bus_init(void) sc->vmbus_flags |= VMBUS_FLAG_ATTACHED; /* + * Create context for "post message" Hypercalls + */ + sc->vmbus_msg_hc = vmbus_msghc_ctx_create( + bus_get_dma_tag(sc->vmbus_dev)); + if (sc->vmbus_msg_hc == NULL) { + ret = ENXIO; + goto cleanup; + } + + /* * Allocate DMA stuffs. */ ret = vmbus_dma_alloc(sc); @@ -648,6 +1002,10 @@ vmbus_bus_init(void) if (ret != 0) goto cleanup; + ret = vmbus_init(sc); + if (ret != 0) + goto cleanup; + if (hv_vmbus_protocal_version == HV_VMBUS_VERSION_WS2008 || hv_vmbus_protocal_version == HV_VMBUS_VERSION_WIN7) sc->vmbus_event_proc = vmbus_event_proc_compat; @@ -665,6 +1023,10 @@ vmbus_bus_init(void) cleanup: vmbus_intr_teardown(sc); vmbus_dma_free(sc); + if (sc->vmbus_msg_hc != NULL) { + vmbus_msghc_ctx_destroy(sc->vmbus_msg_hc); + sc->vmbus_msg_hc = NULL; + } return (ret); } @@ -737,6 +1099,11 @@ vmbus_detach(device_t dev) vmbus_intr_teardown(sc); vmbus_dma_free(sc); + if (sc->vmbus_msg_hc != NULL) { + vmbus_msghc_ctx_destroy(sc->vmbus_msg_hc); + sc->vmbus_msg_hc = NULL; + } + return (0); } Modified: stable/11/sys/dev/hyperv/vmbus/vmbus_reg.h ============================================================================== --- stable/11/sys/dev/hyperv/vmbus/vmbus_reg.h Fri Oct 14 07:26:19 2016 (r307277) +++ stable/11/sys/dev/hyperv/vmbus/vmbus_reg.h Fri Oct 14 07:27:29 2016 (r307278) @@ -39,7 +39,7 @@ #define VMBUS_MSG_SIZE 256 struct vmbus_message { - uint32_t msg_type; /* VMBUS_MSGTYPE_ */ + uint32_t msg_type; /* HYPERV_MSGTYPE_ */ uint8_t msg_dsize; /* data size */ uint8_t msg_flags; /* VMBUS_MSGFLAG_ */ uint16_t msg_rsvd; @@ -48,10 +48,6 @@ struct vmbus_message { } __packed; CTASSERT(sizeof(struct vmbus_message) == VMBUS_MSG_SIZE); -#define VMBUS_MSGTYPE_NONE 0 -#define VMBUS_MSGTYPE_CHANNEL 1 -#define VMBUS_MSGTYPE_TIMER_EXPIRED 0x80000010 - #define VMBUS_MSGFLAG_PENDING 0x01 /* @@ -81,4 +77,34 @@ CTASSERT(sizeof(struct vmbus_evtflags) = #define VMBUS_CHAN_MAX_COMPAT 256 #define VMBUS_CHAN_MAX (VMBUS_EVTFLAG_LEN * VMBUS_EVTFLAGS_MAX) +/* + * Channel messages + * - Embedded in vmbus_message.msg_data, e.g. response. + * - Embedded in hypercall_postmsg_in.hc_data, e.g. request. + */ + +#define VMBUS_CHANMSG_TYPE_INIT_CONTACT 14 /* REQ */ +#define VMBUS_CHANMSG_TYPE_VERSION_RESP 15 /* RESP */ + +struct vmbus_chanmsg_hdr { + uint32_t chm_type; /* VMBUS_CHANMSG_TYPE_ */ + uint32_t chm_rsvd; +} __packed; + +/* VMBUS_CHANMSG_TYPE_INIT_CONTACT */ +struct vmbus_chanmsg_init_contact { + struct vmbus_chanmsg_hdr chm_hdr; + uint32_t chm_ver; + uint32_t chm_rsvd; + uint64_t chm_evtflags; + uint64_t chm_mnf1; + uint64_t chm_mnf2; +} __packed; *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-all@freebsd.org Fri Oct 14 07:27:43 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id ACACBC118AD; Fri, 14 Oct 2016 07:27:43 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id F1ADD7E3; Fri, 14 Oct 2016 07:27:42 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9E7Rgss065215; Fri, 14 Oct 2016 07:27:42 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9E7Rfi9065204; Fri, 14 Oct 2016 07:27:41 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201610140727.u9E7Rfi9065204@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Fri, 14 Oct 2016 07:27:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307279 - in stable/10/sys/cddl/contrib/opensolaris/uts/common: fs/zfs fs/zfs/sys sys/fs X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Oct 2016 07:27:43 -0000 Author: mav Date: Fri Oct 14 07:27:40 2016 New Revision: 307279 URL: https://svnweb.freebsd.org/changeset/base/307279 Log: MFC r305331: MFV r304155: 7090 zfs should improve allocation order and throttle allocations illumos/illumos-gate@0f7643c7376dd69a08acbfc9d1d7d548b10c846a https://github.com/illumos/illumos-gate/commit/0f7643c7376dd69a08acbfc9d1d7d548b 10c846a https://www.illumos.org/issues/7090 When write I/Os are issued, they are issued in block order but the ZIO pipelin e will drive them asynchronously through the allocation stage which can result i n blocks being allocated out-of-order. It would be nice to preserve as much of the logical order as possible. In addition, the allocations are equally scattered across all top-level VDEVs but not all top-level VDEVs are created equally. The pipeline should be able t o detect devices that are more capable of handling allocations and should allocate more blocks to those devices. This allows for dynamic allocation distribution when devices are imbalanced as fuller devices will tend to be slower than empty devices. The change includes a new pool-wide allocation queue which would throttle and order allocations in the ZIO pipeline. The queue would be ordered by issued time and offset and would provide an initial amount of allocation of work to each top-level vdev. The allocation logic utilizes a reservation system to reserve allocations that will be performed by the allocator. Once an allocatio n is successfully completed it's scheduled on a given top-level vdev. Each top- level vdev maintains a maximum number of allocations that it can handle (mg_alloc_queue_depth). The pool-wide reserved allocations (top-levels * mg_alloc_queue_depth) are distributed across the top-level vdevs metaslab groups and round robin across all eligible metaslab groups to distribute the work. As top-levels complete their work, they receive additional work from the pool-wide allocation queue until the allocation queue is emptied. Reviewed by: Adam Leventhal Reviewed by: Alex Reece Reviewed by: Christopher Siden Reviewed by: Dan Kimmel Reviewed by: Matthew Ahrens Reviewed by: Paul Dagnelie Reviewed by: Prakash Surya Reviewed by: Sebastien Roy Approved by: Robert Mustacchi Author: George Wilson Modified: stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/metaslab.c stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/refcount.c stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_misc.c stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/metaslab.h stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/metaslab_impl.h stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/refcount.h stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/spa_impl.h stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/vdev_impl.h stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zio.h stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zio_impl.h stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev.c stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_cache.c stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_mirror.c stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_queue.c stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zio.c stable/10/sys/cddl/contrib/opensolaris/uts/common/sys/fs/zfs.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/metaslab.c ============================================================================== --- stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/metaslab.c Fri Oct 14 07:27:29 2016 (r307278) +++ stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/metaslab.c Fri Oct 14 07:27:40 2016 (r307279) @@ -38,17 +38,8 @@ SYSCTL_DECL(_vfs_zfs); SYSCTL_NODE(_vfs_zfs, OID_AUTO, metaslab, CTLFLAG_RW, 0, "ZFS metaslab"); -/* - * Allow allocations to switch to gang blocks quickly. We do this to - * avoid having to load lots of space_maps in a given txg. There are, - * however, some cases where we want to avoid "fast" ganging and instead - * we want to do an exhaustive search of all metaslabs on this device. - * Currently we don't allow any gang, slog, or dump device related allocations - * to "fast" gang. - */ -#define CAN_FASTGANG(flags) \ - (!((flags) & (METASLAB_GANG_CHILD | METASLAB_GANG_HEADER | \ - METASLAB_GANG_AVOID))) +#define GANG_ALLOCATION(flags) \ + ((flags) & (METASLAB_GANG_CHILD | METASLAB_GANG_HEADER)) #define METASLAB_WEIGHT_PRIMARY (1ULL << 63) #define METASLAB_WEIGHT_SECONDARY (1ULL << 62) @@ -277,6 +268,8 @@ metaslab_class_create(spa_t *spa, metasl mc->mc_spa = spa; mc->mc_rotor = NULL; mc->mc_ops = ops; + mutex_init(&mc->mc_lock, NULL, MUTEX_DEFAULT, NULL); + refcount_create_tracked(&mc->mc_alloc_slots); return (mc); } @@ -290,6 +283,8 @@ metaslab_class_destroy(metaslab_class_t ASSERT(mc->mc_space == 0); ASSERT(mc->mc_dspace == 0); + refcount_destroy(&mc->mc_alloc_slots); + mutex_destroy(&mc->mc_lock); kmem_free(mc, sizeof (metaslab_class_t)); } @@ -533,9 +528,10 @@ metaslab_compare(const void *x1, const v /* * Update the allocatable flag and the metaslab group's capacity. * The allocatable flag is set to true if the capacity is below - * the zfs_mg_noalloc_threshold. If a metaslab group transitions - * from allocatable to non-allocatable or vice versa then the metaslab - * group's class is updated to reflect the transition. + * the zfs_mg_noalloc_threshold or has a fragmentation value that is + * greater than zfs_mg_fragmentation_threshold. If a metaslab group + * transitions from allocatable to non-allocatable or vice versa then the + * metaslab group's class is updated to reflect the transition. */ static void metaslab_group_alloc_update(metaslab_group_t *mg) @@ -544,22 +540,45 @@ metaslab_group_alloc_update(metaslab_gro metaslab_class_t *mc = mg->mg_class; vdev_stat_t *vs = &vd->vdev_stat; boolean_t was_allocatable; + boolean_t was_initialized; ASSERT(vd == vd->vdev_top); mutex_enter(&mg->mg_lock); was_allocatable = mg->mg_allocatable; + was_initialized = mg->mg_initialized; mg->mg_free_capacity = ((vs->vs_space - vs->vs_alloc) * 100) / (vs->vs_space + 1); + mutex_enter(&mc->mc_lock); + + /* + * If the metaslab group was just added then it won't + * have any space until we finish syncing out this txg. + * At that point we will consider it initialized and available + * for allocations. We also don't consider non-activated + * metaslab groups (e.g. vdevs that are in the middle of being removed) + * to be initialized, because they can't be used for allocation. + */ + mg->mg_initialized = metaslab_group_initialized(mg); + if (!was_initialized && mg->mg_initialized) { + mc->mc_groups++; + } else if (was_initialized && !mg->mg_initialized) { + ASSERT3U(mc->mc_groups, >, 0); + mc->mc_groups--; + } + if (mg->mg_initialized) + mg->mg_no_free_space = B_FALSE; + /* * A metaslab group is considered allocatable if it has plenty * of free space or is not heavily fragmented. We only take * fragmentation into account if the metaslab group has a valid * fragmentation metric (i.e. a value between 0 and 100). */ - mg->mg_allocatable = (mg->mg_free_capacity > zfs_mg_noalloc_threshold && + mg->mg_allocatable = (mg->mg_activation_count > 0 && + mg->mg_free_capacity > zfs_mg_noalloc_threshold && (mg->mg_fragmentation == ZFS_FRAG_INVALID || mg->mg_fragmentation <= zfs_mg_fragmentation_threshold)); @@ -582,6 +601,7 @@ metaslab_group_alloc_update(metaslab_gro mc->mc_alloc_groups--; else if (!was_allocatable && mg->mg_allocatable) mc->mc_alloc_groups++; + mutex_exit(&mc->mc_lock); mutex_exit(&mg->mg_lock); } @@ -598,6 +618,9 @@ metaslab_group_create(metaslab_class_t * mg->mg_vd = vd; mg->mg_class = mc; mg->mg_activation_count = 0; + mg->mg_initialized = B_FALSE; + mg->mg_no_free_space = B_TRUE; + refcount_create_tracked(&mg->mg_alloc_queue_depth); mg->mg_taskq = taskq_create("metaslab_group_taskq", metaslab_load_pct, minclsyspri, 10, INT_MAX, TASKQ_THREADS_CPU_PCT); @@ -620,6 +643,7 @@ metaslab_group_destroy(metaslab_group_t taskq_destroy(mg->mg_taskq); avl_destroy(&mg->mg_metaslab_tree); mutex_destroy(&mg->mg_lock); + refcount_destroy(&mg->mg_alloc_queue_depth); kmem_free(mg, sizeof (metaslab_group_t)); } @@ -691,6 +715,15 @@ metaslab_group_passivate(metaslab_group_ metaslab_class_minblocksize_update(mc); } +boolean_t +metaslab_group_initialized(metaslab_group_t *mg) +{ + vdev_t *vd = mg->mg_vd; + vdev_stat_t *vs = &vd->vdev_stat; + + return (vs->vs_space != 0 && mg->mg_activation_count > 0); +} + uint64_t metaslab_group_get_space(metaslab_group_t *mg) { @@ -860,30 +893,97 @@ metaslab_group_fragmentation(metaslab_gr * group should avoid allocations if its free capacity is less than the * zfs_mg_noalloc_threshold or its fragmentation metric is greater than * zfs_mg_fragmentation_threshold and there is at least one metaslab group - * that can still handle allocations. + * that can still handle allocations. If the allocation throttle is enabled + * then we skip allocations to devices that have reached their maximum + * allocation queue depth unless the selected metaslab group is the only + * eligible group remaining. */ static boolean_t -metaslab_group_allocatable(metaslab_group_t *mg) +metaslab_group_allocatable(metaslab_group_t *mg, metaslab_group_t *rotor, + uint64_t psize) { - vdev_t *vd = mg->mg_vd; - spa_t *spa = vd->vdev_spa; + spa_t *spa = mg->mg_vd->vdev_spa; metaslab_class_t *mc = mg->mg_class; /* - * We use two key metrics to determine if a metaslab group is - * considered allocatable -- free space and fragmentation. If - * the free space is greater than the free space threshold and - * the fragmentation is less than the fragmentation threshold then - * consider the group allocatable. There are two case when we will - * not consider these key metrics. The first is if the group is - * associated with a slog device and the second is if all groups - * in this metaslab class have already been consider ineligible + * We can only consider skipping this metaslab group if it's + * in the normal metaslab class and there are other metaslab + * groups to select from. Otherwise, we always consider it eligible * for allocations. */ - return ((mg->mg_free_capacity > zfs_mg_noalloc_threshold && - (mg->mg_fragmentation == ZFS_FRAG_INVALID || - mg->mg_fragmentation <= zfs_mg_fragmentation_threshold)) || - mc != spa_normal_class(spa) || mc->mc_alloc_groups == 0); + if (mc != spa_normal_class(spa) || mc->mc_groups <= 1) + return (B_TRUE); + + /* + * If the metaslab group's mg_allocatable flag is set (see comments + * in metaslab_group_alloc_update() for more information) and + * the allocation throttle is disabled then allow allocations to this + * device. However, if the allocation throttle is enabled then + * check if we have reached our allocation limit (mg_alloc_queue_depth) + * to determine if we should allow allocations to this metaslab group. + * If all metaslab groups are no longer considered allocatable + * (mc_alloc_groups == 0) or we're trying to allocate the smallest + * gang block size then we allow allocations on this metaslab group + * regardless of the mg_allocatable or throttle settings. + */ + if (mg->mg_allocatable) { + metaslab_group_t *mgp; + int64_t qdepth; + uint64_t qmax = mg->mg_max_alloc_queue_depth; + + if (!mc->mc_alloc_throttle_enabled) + return (B_TRUE); + + /* + * If this metaslab group does not have any free space, then + * there is no point in looking further. + */ + if (mg->mg_no_free_space) + return (B_FALSE); + + qdepth = refcount_count(&mg->mg_alloc_queue_depth); + + /* + * If this metaslab group is below its qmax or it's + * the only allocatable metasable group, then attempt + * to allocate from it. + */ + if (qdepth < qmax || mc->mc_alloc_groups == 1) + return (B_TRUE); + ASSERT3U(mc->mc_alloc_groups, >, 1); + + /* + * Since this metaslab group is at or over its qmax, we + * need to determine if there are metaslab groups after this + * one that might be able to handle this allocation. This is + * racy since we can't hold the locks for all metaslab + * groups at the same time when we make this check. + */ + for (mgp = mg->mg_next; mgp != rotor; mgp = mgp->mg_next) { + qmax = mgp->mg_max_alloc_queue_depth; + + qdepth = refcount_count(&mgp->mg_alloc_queue_depth); + + /* + * If there is another metaslab group that + * might be able to handle the allocation, then + * we return false so that we skip this group. + */ + if (qdepth < qmax && !mgp->mg_no_free_space) + return (B_FALSE); + } + + /* + * We didn't find another group to handle the allocation + * so we can't skip this metaslab group even though + * we are at or over our qmax. + */ + return (B_TRUE); + + } else if (mc->mc_alloc_groups == 0 || psize == SPA_MINBLOCKSIZE) { + return (B_TRUE); + } + return (B_FALSE); } /* @@ -2151,8 +2251,57 @@ metaslab_distance(metaslab_t *msp, dva_t return (0); } +/* + * ========================================================================== + * Metaslab block operations + * ========================================================================== + */ + +static void +metaslab_group_alloc_increment(spa_t *spa, uint64_t vdev, void *tag, int flags) +{ + if (!(flags & METASLAB_ASYNC_ALLOC) || + flags & METASLAB_DONT_THROTTLE) + return; + + metaslab_group_t *mg = vdev_lookup_top(spa, vdev)->vdev_mg; + if (!mg->mg_class->mc_alloc_throttle_enabled) + return; + + (void) refcount_add(&mg->mg_alloc_queue_depth, tag); +} + +void +metaslab_group_alloc_decrement(spa_t *spa, uint64_t vdev, void *tag, int flags) +{ + if (!(flags & METASLAB_ASYNC_ALLOC) || + flags & METASLAB_DONT_THROTTLE) + return; + + metaslab_group_t *mg = vdev_lookup_top(spa, vdev)->vdev_mg; + if (!mg->mg_class->mc_alloc_throttle_enabled) + return; + + (void) refcount_remove(&mg->mg_alloc_queue_depth, tag); +} + +void +metaslab_group_alloc_verify(spa_t *spa, const blkptr_t *bp, void *tag) +{ +#ifdef ZFS_DEBUG + const dva_t *dva = bp->blk_dva; + int ndvas = BP_GET_NDVAS(bp); + + for (int d = 0; d < ndvas; d++) { + uint64_t vdev = DVA_GET_VDEV(&dva[d]); + metaslab_group_t *mg = vdev_lookup_top(spa, vdev)->vdev_mg; + VERIFY(refcount_not_held(&mg->mg_alloc_queue_depth, tag)); + } +#endif +} + static uint64_t -metaslab_group_alloc(metaslab_group_t *mg, uint64_t psize, uint64_t asize, +metaslab_group_alloc(metaslab_group_t *mg, uint64_t asize, uint64_t txg, uint64_t min_distance, dva_t *dva, int d) { spa_t *spa = mg->mg_vd->vdev_spa; @@ -2179,10 +2328,10 @@ metaslab_group_alloc(metaslab_group_t *m if (msp->ms_weight < asize) { spa_dbgmsg(spa, "%s: failed to meet weight " "requirement: vdev %llu, txg %llu, mg %p, " - "msp %p, psize %llu, asize %llu, " + "msp %p, asize %llu, " "weight %llu", spa_name(spa), mg->mg_vd->vdev_id, txg, - mg, msp, psize, asize, msp->ms_weight); + mg, msp, asize, msp->ms_weight); mutex_exit(&mg->mg_lock); return (-1ULL); } @@ -2264,7 +2413,6 @@ metaslab_group_alloc(metaslab_group_t *m msp->ms_access_txg = txg + metaslab_unload_delay; mutex_exit(&msp->ms_lock); - return (offset); } @@ -2281,7 +2429,6 @@ metaslab_alloc_dva(spa_t *spa, metaslab_ int all_zero; int zio_lock = B_FALSE; boolean_t allocatable; - uint64_t offset = -1ULL; uint64_t asize; uint64_t distance; @@ -2351,7 +2498,6 @@ top: all_zero = B_TRUE; do { ASSERT(mg->mg_activation_count == 1); - vd = mg->mg_vd; /* @@ -2367,24 +2513,23 @@ top: /* * Determine if the selected metaslab group is eligible - * for allocations. If we're ganging or have requested - * an allocation for the smallest gang block size - * then we don't want to avoid allocating to the this - * metaslab group. If we're in this condition we should - * try to allocate from any device possible so that we - * don't inadvertently return ENOSPC and suspend the pool + * for allocations. If we're ganging then don't allow + * this metaslab group to skip allocations since that would + * inadvertently return ENOSPC and suspend the pool * even though space is still available. */ - if (allocatable && CAN_FASTGANG(flags) && - psize > SPA_GANGBLOCKSIZE) - allocatable = metaslab_group_allocatable(mg); + if (allocatable && !GANG_ALLOCATION(flags) && !zio_lock) { + allocatable = metaslab_group_allocatable(mg, rotor, + psize); + } if (!allocatable) goto next; + ASSERT(mg->mg_initialized); + /* - * Avoid writing single-copy data to a failing vdev - * unless the user instructs us that it is okay. + * Avoid writing single-copy data to a failing vdev. */ if ((vd->vdev_stat.vs_write_errors > 0 || vd->vdev_state < VDEV_STATE_HEALTHY) && @@ -2404,8 +2549,32 @@ top: asize = vdev_psize_to_asize(vd, psize); ASSERT(P2PHASE(asize, 1ULL << vd->vdev_ashift) == 0); - offset = metaslab_group_alloc(mg, psize, asize, txg, distance, - dva, d); + uint64_t offset = metaslab_group_alloc(mg, asize, txg, + distance, dva, d); + + mutex_enter(&mg->mg_lock); + if (offset == -1ULL) { + mg->mg_failed_allocations++; + if (asize == SPA_GANGBLOCKSIZE) { + /* + * This metaslab group was unable to allocate + * the minimum gang block size so it must be + * out of space. We must notify the allocation + * throttle to start skipping allocation + * attempts to this metaslab group until more + * space becomes available. + * + * Note: this failure cannot be caused by the + * allocation throttle since the allocation + * throttle is only responsible for skipping + * devices and not failing block allocations. + */ + mg->mg_no_free_space = B_TRUE; + } + } + mg->mg_allocations++; + mutex_exit(&mg->mg_lock); + if (offset != -1ULL) { /* * If we've just selected this metaslab group, @@ -2586,9 +2755,57 @@ metaslab_claim_dva(spa_t *spa, const dva return (0); } +/* + * Reserve some allocation slots. The reservation system must be called + * before we call into the allocator. If there aren't any available slots + * then the I/O will be throttled until an I/O completes and its slots are + * freed up. The function returns true if it was successful in placing + * the reservation. + */ +boolean_t +metaslab_class_throttle_reserve(metaslab_class_t *mc, int slots, zio_t *zio, + int flags) +{ + uint64_t available_slots = 0; + boolean_t slot_reserved = B_FALSE; + + ASSERT(mc->mc_alloc_throttle_enabled); + mutex_enter(&mc->mc_lock); + + uint64_t reserved_slots = refcount_count(&mc->mc_alloc_slots); + if (reserved_slots < mc->mc_alloc_max_slots) + available_slots = mc->mc_alloc_max_slots - reserved_slots; + + if (slots <= available_slots || GANG_ALLOCATION(flags)) { + /* + * We reserve the slots individually so that we can unreserve + * them individually when an I/O completes. + */ + for (int d = 0; d < slots; d++) { + reserved_slots = refcount_add(&mc->mc_alloc_slots, zio); + } + zio->io_flags |= ZIO_FLAG_IO_ALLOCATING; + slot_reserved = B_TRUE; + } + + mutex_exit(&mc->mc_lock); + return (slot_reserved); +} + +void +metaslab_class_throttle_unreserve(metaslab_class_t *mc, int slots, zio_t *zio) +{ + ASSERT(mc->mc_alloc_throttle_enabled); + mutex_enter(&mc->mc_lock); + for (int d = 0; d < slots; d++) { + (void) refcount_remove(&mc->mc_alloc_slots, zio); + } + mutex_exit(&mc->mc_lock); +} + int metaslab_alloc(spa_t *spa, metaslab_class_t *mc, uint64_t psize, blkptr_t *bp, - int ndvas, uint64_t txg, blkptr_t *hintbp, int flags) + int ndvas, uint64_t txg, blkptr_t *hintbp, int flags, zio_t *zio) { dva_t *dva = bp->blk_dva; dva_t *hintdva = hintbp->blk_dva; @@ -2614,11 +2831,21 @@ metaslab_alloc(spa_t *spa, metaslab_clas if (error != 0) { for (d--; d >= 0; d--) { metaslab_free_dva(spa, &dva[d], txg, B_TRUE); + metaslab_group_alloc_decrement(spa, + DVA_GET_VDEV(&dva[d]), zio, flags); bzero(&dva[d], sizeof (dva_t)); } spa_config_exit(spa, SCL_ALLOC, FTAG); return (error); + } else { + /* + * Update the metaslab group's queue depth + * based on the newly allocated dva. + */ + metaslab_group_alloc_increment(spa, + DVA_GET_VDEV(&dva[d]), zio, flags); } + } ASSERT(error == 0); ASSERT(BP_GET_NDVAS(bp) == ndvas); Modified: stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/refcount.c ============================================================================== --- stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/refcount.c Fri Oct 14 07:27:29 2016 (r307278) +++ stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/refcount.c Fri Oct 14 07:27:40 2016 (r307279) @@ -20,7 +20,7 @@ */ /* * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2012 by Delphix. All rights reserved. + * Copyright (c) 2012, 2015 by Delphix. All rights reserved. */ #include @@ -74,6 +74,13 @@ refcount_create(refcount_t *rc) } void +refcount_create_tracked(refcount_t *rc) +{ + refcount_create(rc); + rc->rc_tracked = B_TRUE; +} + +void refcount_create_untracked(refcount_t *rc) { refcount_create(rc); @@ -256,4 +263,60 @@ refcount_transfer_ownership(refcount_t * ASSERT(found); mutex_exit(&rc->rc_mtx); } + +/* + * If tracking is enabled, return true if a reference exists that matches + * the "holder" tag. If tracking is disabled, then return true if a reference + * might be held. + */ +boolean_t +refcount_held(refcount_t *rc, void *holder) +{ + reference_t *ref; + + mutex_enter(&rc->rc_mtx); + + if (!rc->rc_tracked) { + mutex_exit(&rc->rc_mtx); + return (rc->rc_count > 0); + } + + for (ref = list_head(&rc->rc_list); ref; + ref = list_next(&rc->rc_list, ref)) { + if (ref->ref_holder == holder) { + mutex_exit(&rc->rc_mtx); + return (B_TRUE); + } + } + mutex_exit(&rc->rc_mtx); + return (B_FALSE); +} + +/* + * If tracking is enabled, return true if a reference does not exist that + * matches the "holder" tag. If tracking is disabled, always return true + * since the reference might not be held. + */ +boolean_t +refcount_not_held(refcount_t *rc, void *holder) +{ + reference_t *ref; + + mutex_enter(&rc->rc_mtx); + + if (!rc->rc_tracked) { + mutex_exit(&rc->rc_mtx); + return (B_TRUE); + } + + for (ref = list_head(&rc->rc_list); ref; + ref = list_next(&rc->rc_list, ref)) { + if (ref->ref_holder == holder) { + mutex_exit(&rc->rc_mtx); + return (B_FALSE); + } + } + mutex_exit(&rc->rc_mtx); + return (B_TRUE); +} #endif /* ZFS_DEBUG */ Modified: stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c ============================================================================== --- stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c Fri Oct 14 07:27:29 2016 (r307278) +++ stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c Fri Oct 14 07:27:40 2016 (r307279) @@ -1333,7 +1333,6 @@ spa_unload(spa_t *spa) ddt_unload(spa); - /* * Drop and purge level 2 cache */ @@ -3638,6 +3637,7 @@ spa_create(const char *pool, nvlist_t *n spa->spa_uberblock.ub_txg = txg - 1; spa->spa_uberblock.ub_version = version; spa->spa_ubsync = spa->spa_uberblock; + spa->spa_load_state = SPA_LOAD_CREATE; /* * Create "The Godfather" zio to hold all async IOs @@ -3823,6 +3823,7 @@ spa_create(const char *pool, nvlist_t *n */ spa_evicting_os_wait(spa); spa->spa_minref = refcount_count(&spa->spa_refcount); + spa->spa_load_state = SPA_LOAD_NONE; mutex_exit(&spa_namespace_lock); @@ -5522,7 +5523,7 @@ spa_nvlist_lookup_by_guid(nvlist_t **nvp static void spa_vdev_remove_aux(nvlist_t *config, char *name, nvlist_t **dev, int count, - nvlist_t *dev_to_remove) + nvlist_t *dev_to_remove) { nvlist_t **newdev = NULL; @@ -6635,6 +6636,8 @@ spa_sync(spa_t *spa, uint64_t txg) vdev_t *vd; dmu_tx_t *tx; int error; + uint32_t max_queue_depth = zfs_vdev_async_write_max_active * + zfs_vdev_queue_depth_pct / 100; VERIFY(spa_writeable(spa)); @@ -6646,6 +6649,10 @@ spa_sync(spa_t *spa, uint64_t txg) spa->spa_syncing_txg = txg; spa->spa_sync_pass = 0; + mutex_enter(&spa->spa_alloc_lock); + VERIFY0(avl_numnodes(&spa->spa_alloc_tree)); + mutex_exit(&spa->spa_alloc_lock); + /* * If there are any pending vdev state changes, convert them * into config changes that go out with this transaction group. @@ -6705,6 +6712,38 @@ spa_sync(spa_t *spa, uint64_t txg) } /* + * Set the top-level vdev's max queue depth. Evaluate each + * top-level's async write queue depth in case it changed. + * The max queue depth will not change in the middle of syncing + * out this txg. + */ + uint64_t queue_depth_total = 0; + for (int c = 0; c < rvd->vdev_children; c++) { + vdev_t *tvd = rvd->vdev_child[c]; + metaslab_group_t *mg = tvd->vdev_mg; + + if (mg == NULL || mg->mg_class != spa_normal_class(spa) || + !metaslab_group_initialized(mg)) + continue; + + /* + * It is safe to do a lock-free check here because only async + * allocations look at mg_max_alloc_queue_depth, and async + * allocations all happen from spa_sync(). + */ + ASSERT0(refcount_count(&mg->mg_alloc_queue_depth)); + mg->mg_max_alloc_queue_depth = max_queue_depth; + queue_depth_total += mg->mg_max_alloc_queue_depth; + } + metaslab_class_t *mc = spa_normal_class(spa); + ASSERT0(refcount_count(&mc->mc_alloc_slots)); + mc->mc_alloc_max_slots = queue_depth_total; + mc->mc_alloc_throttle_enabled = zio_dva_throttle_enabled; + + ASSERT3U(mc->mc_alloc_max_slots, <=, + max_queue_depth * rvd->vdev_children); + + /* * Iterate to convergence. */ do { @@ -6846,6 +6885,10 @@ spa_sync(spa_t *spa, uint64_t txg) dsl_pool_sync_done(dp, txg); + mutex_enter(&spa->spa_alloc_lock); + VERIFY0(avl_numnodes(&spa->spa_alloc_tree)); + mutex_exit(&spa->spa_alloc_lock); + /* * Update usable space statistics. */ Modified: stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_misc.c ============================================================================== --- stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_misc.c Fri Oct 14 07:27:29 2016 (r307278) +++ stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_misc.c Fri Oct 14 07:27:40 2016 (r307279) @@ -657,6 +657,7 @@ spa_add(const char *name, nvlist_t *conf mutex_init(&spa->spa_scrub_lock, NULL, MUTEX_DEFAULT, NULL); mutex_init(&spa->spa_suspend_lock, NULL, MUTEX_DEFAULT, NULL); mutex_init(&spa->spa_vdev_top_lock, NULL, MUTEX_DEFAULT, NULL); + mutex_init(&spa->spa_alloc_lock, NULL, MUTEX_DEFAULT, NULL); cv_init(&spa->spa_async_cv, NULL, CV_DEFAULT, NULL); cv_init(&spa->spa_evicting_os_cv, NULL, CV_DEFAULT, NULL); @@ -713,6 +714,9 @@ spa_add(const char *name, nvlist_t *conf spa_active_count++; } + avl_create(&spa->spa_alloc_tree, zio_timestamp_compare, + sizeof (zio_t), offsetof(zio_t, io_alloc_node)); + /* * Every pool starts with the default cachefile */ @@ -791,6 +795,7 @@ spa_remove(spa_t *spa) kmem_free(dp, sizeof (spa_config_dirent_t)); } + avl_destroy(&spa->spa_alloc_tree); list_destroy(&spa->spa_config_list); nvlist_free(spa->spa_label_features); @@ -824,6 +829,7 @@ spa_remove(spa_t *spa) cv_destroy(&spa->spa_scrub_io_cv); cv_destroy(&spa->spa_suspend_cv); + mutex_destroy(&spa->spa_alloc_lock); mutex_destroy(&spa->spa_async_lock); mutex_destroy(&spa->spa_errlist_lock); mutex_destroy(&spa->spa_errlog_lock); Modified: stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/metaslab.h ============================================================================== --- stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/metaslab.h Fri Oct 14 07:27:29 2016 (r307278) +++ stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/metaslab.h Fri Oct 14 07:27:40 2016 (r307279) @@ -20,7 +20,7 @@ */ /* * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2011, 2014 by Delphix. All rights reserved. + * Copyright (c) 2011, 2015 by Delphix. All rights reserved. */ #ifndef _SYS_METASLAB_H @@ -55,14 +55,15 @@ void metaslab_sync_done(metaslab_t *, ui void metaslab_sync_reassess(metaslab_group_t *); uint64_t metaslab_block_maxsize(metaslab_t *); -#define METASLAB_HINTBP_FAVOR 0x0 -#define METASLAB_HINTBP_AVOID 0x1 -#define METASLAB_GANG_HEADER 0x2 -#define METASLAB_GANG_CHILD 0x4 -#define METASLAB_GANG_AVOID 0x8 +#define METASLAB_HINTBP_FAVOR 0x0 +#define METASLAB_HINTBP_AVOID 0x1 +#define METASLAB_GANG_HEADER 0x2 +#define METASLAB_GANG_CHILD 0x4 +#define METASLAB_ASYNC_ALLOC 0x8 +#define METASLAB_DONT_THROTTLE 0x10 int metaslab_alloc(spa_t *, metaslab_class_t *, uint64_t, - blkptr_t *, int, uint64_t, blkptr_t *, int); + blkptr_t *, int, uint64_t, blkptr_t *, int, zio_t *); void metaslab_free(spa_t *, const blkptr_t *, uint64_t, boolean_t); int metaslab_claim(spa_t *, const blkptr_t *, uint64_t); void metaslab_check_free(spa_t *, const blkptr_t *); @@ -73,6 +74,9 @@ int metaslab_class_validate(metaslab_cla void metaslab_class_histogram_verify(metaslab_class_t *); uint64_t metaslab_class_fragmentation(metaslab_class_t *); uint64_t metaslab_class_expandable_space(metaslab_class_t *); +boolean_t metaslab_class_throttle_reserve(metaslab_class_t *, int, + zio_t *, int); +void metaslab_class_throttle_unreserve(metaslab_class_t *, int, zio_t *); void metaslab_class_space_update(metaslab_class_t *, int64_t, int64_t, int64_t, int64_t); @@ -86,10 +90,13 @@ metaslab_group_t *metaslab_group_create( void metaslab_group_destroy(metaslab_group_t *); void metaslab_group_activate(metaslab_group_t *); void metaslab_group_passivate(metaslab_group_t *); +boolean_t metaslab_group_initialized(metaslab_group_t *); uint64_t metaslab_group_get_space(metaslab_group_t *); void metaslab_group_histogram_verify(metaslab_group_t *); uint64_t metaslab_group_fragmentation(metaslab_group_t *); void metaslab_group_histogram_remove(metaslab_group_t *, metaslab_t *); +void metaslab_group_alloc_decrement(spa_t *, uint64_t, void *, int); +void metaslab_group_alloc_verify(spa_t *, const blkptr_t *, void *); #ifdef __cplusplus } Modified: stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/metaslab_impl.h ============================================================================== --- stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/metaslab_impl.h Fri Oct 14 07:27:29 2016 (r307278) +++ stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/metaslab_impl.h Fri Oct 14 07:27:40 2016 (r307279) @@ -24,7 +24,7 @@ */ /* - * Copyright (c) 2011, 2014 by Delphix. All rights reserved. + * Copyright (c) 2011, 2015 by Delphix. All rights reserved. */ #ifndef _SYS_METASLAB_IMPL_H @@ -59,11 +59,42 @@ extern "C" { * to use a block allocator that best suits that class. */ struct metaslab_class { + kmutex_t mc_lock; spa_t *mc_spa; metaslab_group_t *mc_rotor; metaslab_ops_t *mc_ops; uint64_t mc_aliquot; + + /* + * Track the number of metaslab groups that have been initialized + * and can accept allocations. An initialized metaslab group is + * one has been completely added to the config (i.e. we have + * updated the MOS config and the space has been added to the pool). + */ + uint64_t mc_groups; + + /* + * Toggle to enable/disable the allocation throttle. + */ + boolean_t mc_alloc_throttle_enabled; + + /* + * The allocation throttle works on a reservation system. Whenever + * an asynchronous zio wants to perform an allocation it must + * first reserve the number of blocks that it wants to allocate. + * If there aren't sufficient slots available for the pending zio + * then that I/O is throttled until more slots free up. The current + * number of reserved allocations is maintained by the mc_alloc_slots + * refcount. The mc_alloc_max_slots value determines the maximum + * number of allocations that the system allows. Gang blocks are + * allowed to reserve slots even if we've reached the maximum + * number of allocations allowed. + */ + uint64_t mc_alloc_max_slots; + refcount_t mc_alloc_slots; + uint64_t mc_alloc_groups; /* # of allocatable groups */ + uint64_t mc_alloc; /* total allocated space */ uint64_t mc_deferred; /* total deferred frees */ uint64_t mc_space; /* total space (alloc + free) */ @@ -86,6 +117,15 @@ struct metaslab_group { avl_tree_t mg_metaslab_tree; uint64_t mg_aliquot; boolean_t mg_allocatable; /* can we allocate? */ + + /* + * A metaslab group is considered to be initialized only after + * we have updated the MOS config and added the space to the pool. + * We only allow allocation attempts to a metaslab group if it + * has been initialized. + */ + boolean_t mg_initialized; + uint64_t mg_free_capacity; /* percentage free */ int64_t mg_bias; int64_t mg_activation_count; @@ -94,6 +134,27 @@ struct metaslab_group { taskq_t *mg_taskq; metaslab_group_t *mg_prev; metaslab_group_t *mg_next; + + /* + * Each metaslab group can handle mg_max_alloc_queue_depth allocations + * which are tracked by mg_alloc_queue_depth. It's possible for a + * metaslab group to handle more allocations than its max. This + * can occur when gang blocks are required or when other groups + * are unable to handle their share of allocations. + */ + uint64_t mg_max_alloc_queue_depth; + refcount_t mg_alloc_queue_depth; + + /* + * A metalab group that can no longer allocate the minimum block + * size will set mg_no_free_space. Once a metaslab group is out + * of space then its share of work must be distributed to other + * groups. + */ + boolean_t mg_no_free_space; + + uint64_t mg_allocations; + uint64_t mg_failed_allocations; uint64_t mg_fragmentation; uint64_t mg_histogram[RANGE_TREE_HISTOGRAM_SIZE]; }; Modified: stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/refcount.h ============================================================================== --- stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/refcount.h Fri Oct 14 07:27:29 2016 (r307278) +++ stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/refcount.h Fri Oct 14 07:27:40 2016 (r307279) @@ -20,7 +20,7 @@ */ /* * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2012 by Delphix. All rights reserved. + * Copyright (c) 2012, 2015 by Delphix. All rights reserved. */ #ifndef _SYS_REFCOUNT_H @@ -64,6 +64,7 @@ typedef struct refcount { void refcount_create(refcount_t *rc); void refcount_create_untracked(refcount_t *rc); +void refcount_create_tracked(refcount_t *rc); void refcount_destroy(refcount_t *rc); void refcount_destroy_many(refcount_t *rc, uint64_t number); int refcount_is_zero(refcount_t *rc); @@ -74,6 +75,8 @@ int64_t refcount_add_many(refcount_t *rc int64_t refcount_remove_many(refcount_t *rc, uint64_t number, void *holder_tag); void refcount_transfer(refcount_t *dst, refcount_t *src); void refcount_transfer_ownership(refcount_t *, void *, void *); +boolean_t refcount_held(refcount_t *, void *); +boolean_t refcount_not_held(refcount_t *, void *); void refcount_sysinit(void); void refcount_fini(void); @@ -86,6 +89,7 @@ typedef struct refcount { #define refcount_create(rc) ((rc)->rc_count = 0) #define refcount_create_untracked(rc) ((rc)->rc_count = 0) +#define refcount_create_tracked(rc) ((rc)->rc_count = 0) #define refcount_destroy(rc) ((rc)->rc_count = 0) #define refcount_destroy_many(rc, number) ((rc)->rc_count = 0) #define refcount_is_zero(rc) ((rc)->rc_count == 0) @@ -102,6 +106,8 @@ typedef struct refcount { atomic_add_64(&(dst)->rc_count, __tmp); \ } #define refcount_transfer_ownership(rc, current_holder, new_holder) +#define refcount_held(rc, holder) ((rc)->rc_count > 0) +#define refcount_not_held(rc, holder) (B_TRUE) #define refcount_sysinit() #define refcount_fini() Modified: stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/spa_impl.h ============================================================================== --- stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/spa_impl.h Fri Oct 14 07:27:29 2016 (r307278) +++ stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/spa_impl.h Fri Oct 14 07:27:40 2016 (r307279) @@ -159,6 +159,8 @@ struct spa { uint64_t spa_last_synced_guid; /* last synced guid */ list_t spa_config_dirty_list; /* vdevs with dirty config */ list_t spa_state_dirty_list; /* vdevs with dirty state */ + kmutex_t spa_alloc_lock; + avl_tree_t spa_alloc_tree; spa_aux_vdev_t spa_spares; /* hot spares */ spa_aux_vdev_t spa_l2cache; /* L2ARC cache devices */ nvlist_t *spa_label_features; /* Features for reading MOS */ Modified: stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/vdev_impl.h ============================================================================== --- stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/vdev_impl.h Fri Oct 14 07:27:29 2016 (r307278) +++ stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/vdev_impl.h Fri Oct 14 07:27:40 2016 (r307279) @@ -53,6 +53,9 @@ typedef struct vdev_queue vdev_queue_t; typedef struct vdev_cache vdev_cache_t; typedef struct vdev_cache_entry vdev_cache_entry_t; +extern int zfs_vdev_queue_depth_pct; +extern uint32_t zfs_vdev_async_write_max_active; + /* * Virtual device operations */ @@ -190,7 +193,18 @@ struct vdev { uint64_t vdev_deflate_ratio; /* deflation ratio (x512) */ uint64_t vdev_islog; /* is an intent log device */ uint64_t vdev_removing; /* device is being removed? */ - boolean_t vdev_ishole; /* is a hole in the namespace */ + boolean_t vdev_ishole; /* is a hole in the namespace */ + kmutex_t vdev_queue_lock; /* protects vdev_queue_depth */ + + /* + * The queue depth parameters determine how many async writes are + * still pending (i.e. allocated by net yet issued to disk) per + * top-level (vdev_async_write_queue_depth) and the maximum allowed + * (vdev_max_async_write_queue_depth). These values only apply to + * top-level vdevs. + */ + uint64_t vdev_async_write_queue_depth; + uint64_t vdev_max_async_write_queue_depth; /* * Leaf vdev state. Modified: stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zio.h ============================================================================== --- stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zio.h Fri Oct 14 07:27:29 2016 (r307278) +++ stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zio.h Fri Oct 14 07:27:40 2016 (r307279) @@ -175,6 +175,7 @@ enum zio_flag { ZIO_FLAG_DONT_CACHE = 1 << 11, ZIO_FLAG_NODATA = 1 << 12, ZIO_FLAG_INDUCE_DAMAGE = 1 << 13, + ZIO_FLAG_IO_ALLOCATING = 1 << 14, #define ZIO_FLAG_DDT_INHERIT (ZIO_FLAG_IO_RETRY - 1) #define ZIO_FLAG_GANG_INHERIT (ZIO_FLAG_IO_RETRY - 1) @@ -182,27 +183,27 @@ enum zio_flag { /* * Flags inherited by vdev children. */ - ZIO_FLAG_IO_RETRY = 1 << 14, /* must be first for INHERIT */ - ZIO_FLAG_PROBE = 1 << 15, - ZIO_FLAG_TRYHARD = 1 << 16, - ZIO_FLAG_OPTIONAL = 1 << 17, + ZIO_FLAG_IO_RETRY = 1 << 15, /* must be first for INHERIT */ + ZIO_FLAG_PROBE = 1 << 16, + ZIO_FLAG_TRYHARD = 1 << 17, + ZIO_FLAG_OPTIONAL = 1 << 18, #define ZIO_FLAG_VDEV_INHERIT (ZIO_FLAG_DONT_QUEUE - 1) /* *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-all@freebsd.org Fri Oct 14 07:28:45 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 1B648C1194D; Fri, 14 Oct 2016 07:28:45 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id E5CE29A9; Fri, 14 Oct 2016 07:28:44 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9E7ShVv065312; Fri, 14 Oct 2016 07:28:43 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9E7SheF065311; Fri, 14 Oct 2016 07:28:43 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201610140728.u9E7SheF065311@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Fri, 14 Oct 2016 07:28:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307280 - stable/11/cddl/contrib/opensolaris/cmd/zdb X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Oct 2016 07:28:45 -0000 Author: mav Date: Fri Oct 14 07:28:43 2016 New Revision: 307280 URL: https://svnweb.freebsd.org/changeset/base/307280 Log: MFC r305332: MFV r304159: 7277 zdb should be able to print zfs_dbgmsg's illumos/illumos-gate@29bdd2f916366ece37c4748bca6b3d61f57a223b https://github.com/illumos/illumos-gate/commit/29bdd2f916366ece37c4748bca6b3d61f 57a223b https://www.illumos.org/issues/7277 ztest always prints the debug messages (zfs_dbgmsg()) by calling zfs_dbgmsg_print(). We should add a flag to zdb to make it do this as well before exiting. Reviewed by: George Wilson Reviewed by: Matthew Ahrens Reviewed by: Igor Kozhukhov Approved by: Dan McDonald Author: Pavel Zakharov Modified: stable/11/cddl/contrib/opensolaris/cmd/zdb/zdb.c Directory Properties: stable/11/ (props changed) Modified: stable/11/cddl/contrib/opensolaris/cmd/zdb/zdb.c ============================================================================== --- stable/11/cddl/contrib/opensolaris/cmd/zdb/zdb.c Fri Oct 14 07:27:40 2016 (r307279) +++ stable/11/cddl/contrib/opensolaris/cmd/zdb/zdb.c Fri Oct 14 07:28:43 2016 (r307280) @@ -21,7 +21,7 @@ /* * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2011, 2015 by Delphix. All rights reserved. + * Copyright (c) 2011, 2016 by Delphix. All rights reserved. * Copyright (c) 2014 Integros [integros.com] */ @@ -117,7 +117,7 @@ static void usage(void) { (void) fprintf(stderr, - "Usage: %s [-CumMdibcsDvhLXFPA] [-t txg] [-e [-p path...]] " + "Usage: %s [-CumMdibcsDvhLXFPAG] [-t txg] [-e [-p path...]] " "[-U config] [-I inflight I/Os] [-x dumpdir] poolname [object...]\n" " %s [-divPA] [-e -p path...] [-U config] dataset " "[object...]\n" @@ -178,12 +178,23 @@ usage(void) (void) fprintf(stderr, " -I -- " "specify the maximum number of " "checksumming I/Os [default is 200]\n"); + (void) fprintf(stderr, " -G dump zfs_dbgmsg buffer before " + "exiting\n"); (void) fprintf(stderr, "Specify an option more than once (e.g. -bb) " "to make only that option verbose\n"); (void) fprintf(stderr, "Default is to dump everything non-verbosely\n"); exit(1); } +static void +dump_debug_buffer() +{ + if (dump_opt['G']) { + (void) printf("\n"); + zfs_dbgmsg_print("zdb"); + } +} + /* * Called for usage errors that are discovered after a call to spa_open(), * dmu_bonus_hold(), or pool_match(). abort() is called for other errors. @@ -200,6 +211,8 @@ fatal(const char *fmt, ...) va_end(ap); (void) fprintf(stderr, "\n"); + dump_debug_buffer(); + exit(1); } @@ -3103,8 +3116,10 @@ dump_zpool(spa_t *spa) if (dump_opt['h']) dump_history(spa); - if (rc != 0) + if (rc != 0) { + dump_debug_buffer(); exit(rc); + } } #define ZDB_FLAG_CHECKSUM 0x0001 @@ -3575,7 +3590,7 @@ main(int argc, char **argv) spa_config_path = spa_config_path_env; while ((c = getopt(argc, argv, - "bcdhilmMI:suCDRSAFLXx:evp:t:U:P")) != -1) { + "bcdhilmMI:suCDRSAFLXx:evp:t:U:PG")) != -1) { switch (c) { case 'b': case 'c': @@ -3591,6 +3606,7 @@ main(int argc, char **argv) case 'M': case 'R': case 'S': + case 'G': dump_opt[c]++; dump_all = 0; break; @@ -3826,6 +3842,8 @@ main(int argc, char **argv) fuid_table_destroy(); sa_loaded = B_FALSE; + dump_debug_buffer(); + libzfs_fini(g_zfs); kernel_fini(); From owner-svn-src-all@freebsd.org Fri Oct 14 07:29:24 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 73985C119AA; Fri, 14 Oct 2016 07:29:24 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4F4BCB13; Fri, 14 Oct 2016 07:29:24 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9E7TNpW065392; Fri, 14 Oct 2016 07:29:23 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9E7TNH7065391; Fri, 14 Oct 2016 07:29:23 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201610140729.u9E7TNH7065391@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Fri, 14 Oct 2016 07:29:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307281 - stable/10/cddl/contrib/opensolaris/cmd/zdb X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Oct 2016 07:29:24 -0000 Author: mav Date: Fri Oct 14 07:29:23 2016 New Revision: 307281 URL: https://svnweb.freebsd.org/changeset/base/307281 Log: MFC r305332: MFV r304159: 7277 zdb should be able to print zfs_dbgmsg's illumos/illumos-gate@29bdd2f916366ece37c4748bca6b3d61f57a223b https://github.com/illumos/illumos-gate/commit/29bdd2f916366ece37c4748bca6b3d61f 57a223b https://www.illumos.org/issues/7277 ztest always prints the debug messages (zfs_dbgmsg()) by calling zfs_dbgmsg_print(). We should add a flag to zdb to make it do this as well before exiting. Reviewed by: George Wilson Reviewed by: Matthew Ahrens Reviewed by: Igor Kozhukhov Approved by: Dan McDonald Author: Pavel Zakharov Modified: stable/10/cddl/contrib/opensolaris/cmd/zdb/zdb.c Directory Properties: stable/10/ (props changed) Modified: stable/10/cddl/contrib/opensolaris/cmd/zdb/zdb.c ============================================================================== --- stable/10/cddl/contrib/opensolaris/cmd/zdb/zdb.c Fri Oct 14 07:28:43 2016 (r307280) +++ stable/10/cddl/contrib/opensolaris/cmd/zdb/zdb.c Fri Oct 14 07:29:23 2016 (r307281) @@ -21,7 +21,7 @@ /* * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2011, 2015 by Delphix. All rights reserved. + * Copyright (c) 2011, 2016 by Delphix. All rights reserved. * Copyright (c) 2014 Integros [integros.com] */ @@ -117,7 +117,7 @@ static void usage(void) { (void) fprintf(stderr, - "Usage: %s [-CumMdibcsDvhLXFPA] [-t txg] [-e [-p path...]] " + "Usage: %s [-CumMdibcsDvhLXFPAG] [-t txg] [-e [-p path...]] " "[-U config] [-I inflight I/Os] [-x dumpdir] poolname [object...]\n" " %s [-divPA] [-e -p path...] [-U config] dataset " "[object...]\n" @@ -178,12 +178,23 @@ usage(void) (void) fprintf(stderr, " -I -- " "specify the maximum number of " "checksumming I/Os [default is 200]\n"); + (void) fprintf(stderr, " -G dump zfs_dbgmsg buffer before " + "exiting\n"); (void) fprintf(stderr, "Specify an option more than once (e.g. -bb) " "to make only that option verbose\n"); (void) fprintf(stderr, "Default is to dump everything non-verbosely\n"); exit(1); } +static void +dump_debug_buffer() +{ + if (dump_opt['G']) { + (void) printf("\n"); + zfs_dbgmsg_print("zdb"); + } +} + /* * Called for usage errors that are discovered after a call to spa_open(), * dmu_bonus_hold(), or pool_match(). abort() is called for other errors. @@ -200,6 +211,8 @@ fatal(const char *fmt, ...) va_end(ap); (void) fprintf(stderr, "\n"); + dump_debug_buffer(); + exit(1); } @@ -3104,8 +3117,10 @@ dump_zpool(spa_t *spa) if (dump_opt['h']) dump_history(spa); - if (rc != 0) + if (rc != 0) { + dump_debug_buffer(); exit(rc); + } } #define ZDB_FLAG_CHECKSUM 0x0001 @@ -3576,7 +3591,7 @@ main(int argc, char **argv) spa_config_path = spa_config_path_env; while ((c = getopt(argc, argv, - "bcdhilmMI:suCDRSAFLXx:evp:t:U:P")) != -1) { + "bcdhilmMI:suCDRSAFLXx:evp:t:U:PG")) != -1) { switch (c) { case 'b': case 'c': @@ -3592,6 +3607,7 @@ main(int argc, char **argv) case 'M': case 'R': case 'S': + case 'G': dump_opt[c]++; dump_all = 0; break; @@ -3827,6 +3843,8 @@ main(int argc, char **argv) fuid_table_destroy(); sa_loaded = B_FALSE; + dump_debug_buffer(); + libzfs_fini(g_zfs); kernel_fini(); From owner-svn-src-all@freebsd.org Fri Oct 14 07:30:17 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 95B08C11A16; Fri, 14 Oct 2016 07:30:17 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 49C81C7D; Fri, 14 Oct 2016 07:30:17 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9E7UGhT065504; Fri, 14 Oct 2016 07:30:16 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9E7UGiw065502; Fri, 14 Oct 2016 07:30:16 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201610140730.u9E7UGiw065502@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Fri, 14 Oct 2016 07:30:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307282 - in stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs: . sys X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Oct 2016 07:30:17 -0000 Author: mav Date: Fri Oct 14 07:30:16 2016 New Revision: 307282 URL: https://svnweb.freebsd.org/changeset/base/307282 Log: MFC r305333: MFV r304156: 7235 remove unused func dsl_dataset_set_blkptr illumos/illumos-gate@bd56f80007857b960e0981ed0797ad8ec844a96b https://github.com/illumos/illumos-gate/commit/bd56f80007857b960e0981ed0797ad8ec 844a96b https://www.illumos.org/issues/7235 The function dsl_dataset_set_blkptr() is unused. We should remove it. Reviewed by: George Wilson Reviewed by: Alex Reece Reviewed by: Prakash Surya Reviewed by: Igor Kozhukhov Approved by: Robert Mustacchi Author: Matthew Ahrens Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_dataset.c stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dsl_dataset.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_dataset.c ============================================================================== --- stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_dataset.c Fri Oct 14 07:29:23 2016 (r307281) +++ stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_dataset.c Fri Oct 14 07:30:16 2016 (r307282) @@ -1060,19 +1060,6 @@ dsl_dataset_get_blkptr(dsl_dataset_t *ds return (&dsl_dataset_phys(ds)->ds_bp); } -void -dsl_dataset_set_blkptr(dsl_dataset_t *ds, blkptr_t *bp, dmu_tx_t *tx) -{ - ASSERT(dmu_tx_is_syncing(tx)); - /* If it's the meta-objset, set dp_meta_rootbp */ - if (ds == NULL) { - tx->tx_pool->dp_meta_rootbp = *bp; - } else { - dmu_buf_will_dirty(ds->ds_dbuf, tx); - dsl_dataset_phys(ds)->ds_bp = *bp; - } -} - spa_t * dsl_dataset_get_spa(dsl_dataset_t *ds) { Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dsl_dataset.h ============================================================================== --- stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dsl_dataset.h Fri Oct 14 07:29:23 2016 (r307281) +++ stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dsl_dataset.h Fri Oct 14 07:30:16 2016 (r307282) @@ -272,7 +272,6 @@ int dsl_dataset_snapshot_tmp(const char minor_t cleanup_minor, const char *htag); blkptr_t *dsl_dataset_get_blkptr(dsl_dataset_t *ds); -void dsl_dataset_set_blkptr(dsl_dataset_t *ds, blkptr_t *bp, dmu_tx_t *tx); spa_t *dsl_dataset_get_spa(dsl_dataset_t *ds); From owner-svn-src-all@freebsd.org Fri Oct 14 07:30:56 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 06E81C11B28; Fri, 14 Oct 2016 07:30:56 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id ABFA9EE0; Fri, 14 Oct 2016 07:30:55 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9E7Us9P067602; Fri, 14 Oct 2016 07:30:54 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9E7UsoM067600; Fri, 14 Oct 2016 07:30:54 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201610140730.u9E7UsoM067600@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Fri, 14 Oct 2016 07:30:54 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307283 - in stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs: . sys X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Oct 2016 07:30:56 -0000 Author: mav Date: Fri Oct 14 07:30:54 2016 New Revision: 307283 URL: https://svnweb.freebsd.org/changeset/base/307283 Log: MFC r305333: MFV r304156: 7235 remove unused func dsl_dataset_set_blkptr illumos/illumos-gate@bd56f80007857b960e0981ed0797ad8ec844a96b https://github.com/illumos/illumos-gate/commit/bd56f80007857b960e0981ed0797ad8ec 844a96b https://www.illumos.org/issues/7235 The function dsl_dataset_set_blkptr() is unused. We should remove it. Reviewed by: George Wilson Reviewed by: Alex Reece Reviewed by: Prakash Surya Reviewed by: Igor Kozhukhov Approved by: Robert Mustacchi Author: Matthew Ahrens Modified: stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_dataset.c stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dsl_dataset.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_dataset.c ============================================================================== --- stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_dataset.c Fri Oct 14 07:30:16 2016 (r307282) +++ stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_dataset.c Fri Oct 14 07:30:54 2016 (r307283) @@ -1060,19 +1060,6 @@ dsl_dataset_get_blkptr(dsl_dataset_t *ds return (&dsl_dataset_phys(ds)->ds_bp); } -void -dsl_dataset_set_blkptr(dsl_dataset_t *ds, blkptr_t *bp, dmu_tx_t *tx) -{ - ASSERT(dmu_tx_is_syncing(tx)); - /* If it's the meta-objset, set dp_meta_rootbp */ - if (ds == NULL) { - tx->tx_pool->dp_meta_rootbp = *bp; - } else { - dmu_buf_will_dirty(ds->ds_dbuf, tx); - dsl_dataset_phys(ds)->ds_bp = *bp; - } -} - spa_t * dsl_dataset_get_spa(dsl_dataset_t *ds) { Modified: stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dsl_dataset.h ============================================================================== --- stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dsl_dataset.h Fri Oct 14 07:30:16 2016 (r307282) +++ stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dsl_dataset.h Fri Oct 14 07:30:54 2016 (r307283) @@ -272,7 +272,6 @@ int dsl_dataset_snapshot_tmp(const char minor_t cleanup_minor, const char *htag); blkptr_t *dsl_dataset_get_blkptr(dsl_dataset_t *ds); -void dsl_dataset_set_blkptr(dsl_dataset_t *ds, blkptr_t *bp, dmu_tx_t *tx); spa_t *dsl_dataset_get_spa(dsl_dataset_t *ds); From owner-svn-src-all@freebsd.org Fri Oct 14 07:31:48 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id CD6AEC11B8E; Fri, 14 Oct 2016 07:31:48 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id A68E810C5; Fri, 14 Oct 2016 07:31:48 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9E7VlIM068970; Fri, 14 Oct 2016 07:31:47 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9E7VlE0068956; Fri, 14 Oct 2016 07:31:47 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201610140731.u9E7VlE0068956@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Fri, 14 Oct 2016 07:31:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307284 - in stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs: . sys X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Oct 2016 07:31:48 -0000 Author: mav Date: Fri Oct 14 07:31:47 2016 New Revision: 307284 URL: https://svnweb.freebsd.org/changeset/base/307284 Log: MFC r305334: MFV r304157: 7230 add assertions to dmu_send_impl() to verify that stream includes BEGIN and END records illumos/illumos-gate@12b90ee2d3b10689fc45f4930d2392f5fe1d9cfa https://github.com/illumos/illumos-gate/commit/12b90ee2d3b10689fc45f4930d2392f5f e1d9cfa https://www.illumos.org/issues/7230 A test failure occurred where a send stream had only a BEGIN record. This should not be possible if the send returns without error. Prevented this from happening in the future by adding an assertion to dmu_send_impl() to verify that if the function returns 0 (success) both a BEGIN and END record are present. Did this by adding flags to dmu_sendarg_t (indicating whether BEGIN o r END records sent), having dump_record() set flags appropriately, adding VERIFY statement to dmu_send_impl(). Reviewed by: Matthew Ahrens Reviewed by: Paul Dagnelie Reviewed by: Igor Kozhukhov Approved by: Robert Mustacchi Author: Matt Krantz Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_send.c stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dmu_impl.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_send.c ============================================================================== --- stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_send.c Fri Oct 14 07:30:54 2016 (r307283) +++ stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_send.c Fri Oct 14 07:31:47 2016 (r307284) @@ -160,11 +160,16 @@ dump_record(dmu_sendarg_t *dsp, void *pa fletcher_4_incremental_native(dsp->dsa_drr, offsetof(dmu_replay_record_t, drr_u.drr_checksum.drr_checksum), &dsp->dsa_zc); - if (dsp->dsa_drr->drr_type != DRR_BEGIN) { + if (dsp->dsa_drr->drr_type == DRR_BEGIN) { + dsp->dsa_sent_begin = B_TRUE; + } else { ASSERT(ZIO_CHECKSUM_IS_ZERO(&dsp->dsa_drr->drr_u. drr_checksum.drr_checksum)); dsp->dsa_drr->drr_u.drr_checksum.drr_checksum = dsp->dsa_zc; } + if (dsp->dsa_drr->drr_type == DRR_END) { + dsp->dsa_sent_end = B_TRUE; + } fletcher_4_incremental_native(&dsp->dsa_drr-> drr_u.drr_checksum.drr_checksum, sizeof (zio_cksum_t), &dsp->dsa_zc); @@ -912,6 +917,8 @@ out: list_remove(&to_ds->ds_sendstreams, dsp); mutex_exit(&to_ds->ds_sendstream_lock); + VERIFY(err != 0 || (dsp->dsa_sent_begin && dsp->dsa_sent_end)); + kmem_free(drr, sizeof (dmu_replay_record_t)); kmem_free(dsp, sizeof (dmu_sendarg_t)); Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dmu_impl.h ============================================================================== --- stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dmu_impl.h Fri Oct 14 07:30:54 2016 (r307283) +++ stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dmu_impl.h Fri Oct 14 07:31:47 2016 (r307284) @@ -301,6 +301,8 @@ typedef struct dmu_sendarg { uint64_t dsa_last_data_offset; uint64_t dsa_resume_object; uint64_t dsa_resume_offset; + boolean_t dsa_sent_begin; + boolean_t dsa_sent_end; } dmu_sendarg_t; void dmu_object_zapify(objset_t *, uint64_t, dmu_object_type_t, dmu_tx_t *); From owner-svn-src-all@freebsd.org Fri Oct 14 07:32:25 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 6C91FC11BE0; Fri, 14 Oct 2016 07:32:25 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 480FD128C; Fri, 14 Oct 2016 07:32:25 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9E7WOl1069060; Fri, 14 Oct 2016 07:32:24 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9E7WO30069058; Fri, 14 Oct 2016 07:32:24 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201610140732.u9E7WO30069058@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Fri, 14 Oct 2016 07:32:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307285 - in stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs: . sys X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Oct 2016 07:32:25 -0000 Author: mav Date: Fri Oct 14 07:32:24 2016 New Revision: 307285 URL: https://svnweb.freebsd.org/changeset/base/307285 Log: MFC r305334: MFV r304157: 7230 add assertions to dmu_send_impl() to verify that stream includes BEGIN and END records illumos/illumos-gate@12b90ee2d3b10689fc45f4930d2392f5fe1d9cfa https://github.com/illumos/illumos-gate/commit/12b90ee2d3b10689fc45f4930d2392f5f e1d9cfa https://www.illumos.org/issues/7230 A test failure occurred where a send stream had only a BEGIN record. This should not be possible if the send returns without error. Prevented this from happening in the future by adding an assertion to dmu_send_impl() to verify that if the function returns 0 (success) both a BEGIN and END record are present. Did this by adding flags to dmu_sendarg_t (indicating whether BEGIN o r END records sent), having dump_record() set flags appropriately, adding VERIFY statement to dmu_send_impl(). Reviewed by: Matthew Ahrens Reviewed by: Paul Dagnelie Reviewed by: Igor Kozhukhov Approved by: Robert Mustacchi Author: Matt Krantz Modified: stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_send.c stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dmu_impl.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_send.c ============================================================================== --- stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_send.c Fri Oct 14 07:31:47 2016 (r307284) +++ stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_send.c Fri Oct 14 07:32:24 2016 (r307285) @@ -160,11 +160,16 @@ dump_record(dmu_sendarg_t *dsp, void *pa fletcher_4_incremental_native(dsp->dsa_drr, offsetof(dmu_replay_record_t, drr_u.drr_checksum.drr_checksum), &dsp->dsa_zc); - if (dsp->dsa_drr->drr_type != DRR_BEGIN) { + if (dsp->dsa_drr->drr_type == DRR_BEGIN) { + dsp->dsa_sent_begin = B_TRUE; + } else { ASSERT(ZIO_CHECKSUM_IS_ZERO(&dsp->dsa_drr->drr_u. drr_checksum.drr_checksum)); dsp->dsa_drr->drr_u.drr_checksum.drr_checksum = dsp->dsa_zc; } + if (dsp->dsa_drr->drr_type == DRR_END) { + dsp->dsa_sent_end = B_TRUE; + } fletcher_4_incremental_native(&dsp->dsa_drr-> drr_u.drr_checksum.drr_checksum, sizeof (zio_cksum_t), &dsp->dsa_zc); @@ -912,6 +917,8 @@ out: list_remove(&to_ds->ds_sendstreams, dsp); mutex_exit(&to_ds->ds_sendstream_lock); + VERIFY(err != 0 || (dsp->dsa_sent_begin && dsp->dsa_sent_end)); + kmem_free(drr, sizeof (dmu_replay_record_t)); kmem_free(dsp, sizeof (dmu_sendarg_t)); Modified: stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dmu_impl.h ============================================================================== --- stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dmu_impl.h Fri Oct 14 07:31:47 2016 (r307284) +++ stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dmu_impl.h Fri Oct 14 07:32:24 2016 (r307285) @@ -301,6 +301,8 @@ typedef struct dmu_sendarg { uint64_t dsa_last_data_offset; uint64_t dsa_resume_object; uint64_t dsa_resume_offset; + boolean_t dsa_sent_begin; + boolean_t dsa_sent_end; } dmu_sendarg_t; void dmu_object_zapify(objset_t *, uint64_t, dmu_object_type_t, dmu_tx_t *); From owner-svn-src-all@freebsd.org Fri Oct 14 07:33:37 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id EF30BC11CA5; Fri, 14 Oct 2016 07:33:37 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id B8EF21497; Fri, 14 Oct 2016 07:33:37 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9E7Xa4R069192; Fri, 14 Oct 2016 07:33:36 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9E7XaKp069186; Fri, 14 Oct 2016 07:33:36 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201610140733.u9E7XaKp069186@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Fri, 14 Oct 2016 07:33:36 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307286 - in stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs: . sys X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Oct 2016 07:33:38 -0000 Author: mav Date: Fri Oct 14 07:33:36 2016 New Revision: 307286 URL: https://svnweb.freebsd.org/changeset/base/307286 Log: MFC r305338: MFV r305335: 7003 zap_lockdir() should tag hold zap_lockdir() / zap_unlockdir() should take a "void *tag" argument which tags the hold on the zap. This will help diagnose programming errors which misuse the hold on the ZAP. Sponsored by: Intel Corp. Closes #108 Reviewed by: Pavel Zakharov Reviewed by: Steve Gonczi Reviewed by: George Wilson Reviewed by: Brian Behlendorf Author: Matthew Ahrens openzfs/openzfs@0780b3eab5a2c13e04328b39ecd2a6d0d3c4f7cb Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dbuf.c stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dmu.h stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zap_impl.h stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zap.c stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zap_micro.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dbuf.c ============================================================================== --- stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dbuf.c Fri Oct 14 07:32:24 2016 (r307285) +++ stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dbuf.c Fri Oct 14 07:33:36 2016 (r307286) @@ -21,7 +21,7 @@ /* * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright 2011 Nexenta Systems, Inc. All rights reserved. - * Copyright (c) 2012, 2015 by Delphix. All rights reserved. + * Copyright (c) 2012, 2016 by Delphix. All rights reserved. * Copyright (c) 2013 by Saso Kiselkov. All rights reserved. * Copyright (c) 2013, Joyent, Inc. All rights reserved. * Copyright (c) 2014 Spectra Logic Corporation, All rights reserved. @@ -2903,6 +2903,13 @@ dmu_buf_get_blkptr(dmu_buf_t *db) return (dbi->db_blkptr); } +objset_t * +dmu_buf_get_objset(dmu_buf_t *db) +{ + dmu_buf_impl_t *dbi = (dmu_buf_impl_t *)db; + return (dbi->db_objset); +} + static void dbuf_check_blkptr(dnode_t *dn, dmu_buf_impl_t *db) { Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dmu.h ============================================================================== --- stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dmu.h Fri Oct 14 07:32:24 2016 (r307285) +++ stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dmu.h Fri Oct 14 07:33:36 2016 (r307286) @@ -21,7 +21,7 @@ /* * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2011, 2014 by Delphix. All rights reserved. + * Copyright (c) 2011, 2016 by Delphix. All rights reserved. * Copyright 2011 Nexenta Systems, Inc. All rights reserved. * Copyright (c) 2012, Joyent, Inc. All rights reserved. * Copyright 2013 DEY Storage Systems, Inc. @@ -617,6 +617,8 @@ void *dmu_buf_remove_user(dmu_buf_t *db, */ void *dmu_buf_get_user(dmu_buf_t *db); +objset_t *dmu_buf_get_objset(dmu_buf_t *db); + /* Block until any in-progress dmu buf user evictions complete. */ void dmu_buf_user_evict_wait(void); Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zap_impl.h ============================================================================== --- stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zap_impl.h Fri Oct 14 07:32:24 2016 (r307285) +++ stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zap_impl.h Fri Oct 14 07:33:36 2016 (r307286) @@ -20,7 +20,7 @@ */ /* * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2013, 2015 by Delphix. All rights reserved. + * Copyright (c) 2013, 2016 by Delphix. All rights reserved. * Copyright (c) 2014 Spectra Logic Corporation, All rights reserved. * Copyright (c) 2014 Integros [integros.com] */ @@ -197,8 +197,8 @@ typedef struct zap_name { boolean_t zap_match(zap_name_t *zn, const char *matchname); int zap_lockdir(objset_t *os, uint64_t obj, dmu_tx_t *tx, - krw_t lti, boolean_t fatreader, boolean_t adding, zap_t **zapp); -void zap_unlockdir(zap_t *zap); + krw_t lti, boolean_t fatreader, boolean_t adding, void *tag, zap_t **zapp); +void zap_unlockdir(zap_t *zap, void *tag); void zap_evict(void *dbu); zap_name_t *zap_name_alloc(zap_t *zap, const char *key, matchtype_t mt); void zap_name_free(zap_name_t *zn); @@ -217,9 +217,10 @@ void fzap_prefetch(zap_name_t *zn); int fzap_count_write(zap_name_t *zn, int add, refcount_t *towrite, refcount_t *tooverwrite); int fzap_add(zap_name_t *zn, uint64_t integer_size, uint64_t num_integers, - const void *val, dmu_tx_t *tx); + const void *val, void *tag, dmu_tx_t *tx); int fzap_update(zap_name_t *zn, - int integer_size, uint64_t num_integers, const void *val, dmu_tx_t *tx); + int integer_size, uint64_t num_integers, const void *val, + void *tag, dmu_tx_t *tx); int fzap_length(zap_name_t *zn, uint64_t *integer_size, uint64_t *num_integers); int fzap_remove(zap_name_t *zn, dmu_tx_t *tx); @@ -229,7 +230,7 @@ void zap_put_leaf(struct zap_leaf *l); int fzap_add_cd(zap_name_t *zn, uint64_t integer_size, uint64_t num_integers, - const void *val, uint32_t cd, dmu_tx_t *tx); + const void *val, uint32_t cd, void *tag, dmu_tx_t *tx); void fzap_upgrade(zap_t *zap, dmu_tx_t *tx, zap_flags_t flags); int fzap_cursor_move_to_key(zap_cursor_t *zc, zap_name_t *zn); Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zap.c ============================================================================== --- stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zap.c Fri Oct 14 07:32:24 2016 (r307285) +++ stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zap.c Fri Oct 14 07:33:36 2016 (r307286) @@ -20,7 +20,7 @@ */ /* * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2012, 2015 by Delphix. All rights reserved. + * Copyright (c) 2012, 2016 by Delphix. All rights reserved. * Copyright (c) 2014 Spectra Logic Corporation, All rights reserved. */ @@ -596,7 +596,8 @@ zap_deref_leaf(zap_t *zap, uint64_t h, d } static int -zap_expand_leaf(zap_name_t *zn, zap_leaf_t *l, dmu_tx_t *tx, zap_leaf_t **lp) +zap_expand_leaf(zap_name_t *zn, zap_leaf_t *l, + void *tag, dmu_tx_t *tx, zap_leaf_t **lp) { zap_t *zap = zn->zn_zap; uint64_t hash = zn->zn_hash; @@ -618,9 +619,9 @@ zap_expand_leaf(zap_name_t *zn, zap_leaf uint64_t object = zap->zap_object; zap_put_leaf(l); - zap_unlockdir(zap); + zap_unlockdir(zap, tag); err = zap_lockdir(os, object, tx, RW_WRITER, - FALSE, FALSE, &zn->zn_zap); + FALSE, FALSE, tag, &zn->zn_zap); zap = zn->zn_zap; if (err) return (err); @@ -683,7 +684,8 @@ zap_expand_leaf(zap_name_t *zn, zap_leaf } static void -zap_put_leaf_maybe_grow_ptrtbl(zap_name_t *zn, zap_leaf_t *l, dmu_tx_t *tx) +zap_put_leaf_maybe_grow_ptrtbl(zap_name_t *zn, zap_leaf_t *l, + void *tag, dmu_tx_t *tx) { zap_t *zap = zn->zn_zap; int shift = zap_f_phys(zap)->zap_ptrtbl.zt_shift; @@ -703,9 +705,9 @@ zap_put_leaf_maybe_grow_ptrtbl(zap_name_ objset_t *os = zap->zap_objset; uint64_t zapobj = zap->zap_object; - zap_unlockdir(zap); + zap_unlockdir(zap, tag); err = zap_lockdir(os, zapobj, tx, - RW_WRITER, FALSE, FALSE, &zn->zn_zap); + RW_WRITER, FALSE, FALSE, tag, &zn->zn_zap); zap = zn->zn_zap; if (err) return; @@ -795,7 +797,7 @@ fzap_lookup(zap_name_t *zn, int fzap_add_cd(zap_name_t *zn, uint64_t integer_size, uint64_t num_integers, - const void *val, uint32_t cd, dmu_tx_t *tx) + const void *val, uint32_t cd, void *tag, dmu_tx_t *tx) { zap_leaf_t *l; int err; @@ -824,7 +826,7 @@ retry: if (err == 0) { zap_increment_num_entries(zap, 1, tx); } else if (err == EAGAIN) { - err = zap_expand_leaf(zn, l, tx, &l); + err = zap_expand_leaf(zn, l, tag, tx, &l); zap = zn->zn_zap; /* zap_expand_leaf() may change zap */ if (err == 0) goto retry; @@ -832,26 +834,27 @@ retry: out: if (zap != NULL) - zap_put_leaf_maybe_grow_ptrtbl(zn, l, tx); + zap_put_leaf_maybe_grow_ptrtbl(zn, l, tag, tx); return (err); } int fzap_add(zap_name_t *zn, uint64_t integer_size, uint64_t num_integers, - const void *val, dmu_tx_t *tx) + const void *val, void *tag, dmu_tx_t *tx) { int err = fzap_check(zn, integer_size, num_integers); if (err != 0) return (err); return (fzap_add_cd(zn, integer_size, num_integers, - val, ZAP_NEED_CD, tx)); + val, ZAP_NEED_CD, tag, tx)); } int fzap_update(zap_name_t *zn, - int integer_size, uint64_t num_integers, const void *val, dmu_tx_t *tx) + int integer_size, uint64_t num_integers, const void *val, + void *tag, dmu_tx_t *tx) { zap_leaf_t *l; int err, create; @@ -881,14 +884,14 @@ retry: } if (err == EAGAIN) { - err = zap_expand_leaf(zn, l, tx, &l); + err = zap_expand_leaf(zn, l, tag, tx, &l); zap = zn->zn_zap; /* zap_expand_leaf() may change zap */ if (err == 0) goto retry; } if (zap != NULL) - zap_put_leaf_maybe_grow_ptrtbl(zn, l, tx); + zap_put_leaf_maybe_grow_ptrtbl(zn, l, tag, tx); return (err); } Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zap_micro.c ============================================================================== --- stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zap_micro.c Fri Oct 14 07:32:24 2016 (r307285) +++ stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zap_micro.c Fri Oct 14 07:33:36 2016 (r307286) @@ -20,7 +20,7 @@ */ /* * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2011, 2015 by Delphix. All rights reserved. + * Copyright (c) 2011, 2016 by Delphix. All rights reserved. * Copyright (c) 2014 Spectra Logic Corporation, All rights reserved. * Copyright (c) 2014 Integros [integros.com] */ @@ -43,7 +43,8 @@ extern inline mzap_phys_t *zap_m_phys(zap_t *zap); -static int mzap_upgrade(zap_t **zapp, dmu_tx_t *tx, zap_flags_t flags); +static int mzap_upgrade(zap_t **zapp, + void *tag, dmu_tx_t *tx, zap_flags_t flags); uint64_t zap_getflags(zap_t *zap) @@ -468,20 +469,18 @@ handle_winner: return (winner); } -int -zap_lockdir(objset_t *os, uint64_t obj, dmu_tx_t *tx, +static int +zap_lockdir_impl(dmu_buf_t *db, void *tag, dmu_tx_t *tx, krw_t lti, boolean_t fatreader, boolean_t adding, zap_t **zapp) { zap_t *zap; - dmu_buf_t *db; krw_t lt; - int err; - *zapp = NULL; + ASSERT0(db->db_offset); + objset_t *os = dmu_buf_get_objset(db); + uint64_t obj = db->db_object; - err = dmu_buf_hold(os, obj, 0, NULL, &db, DMU_READ_NO_PREFETCH); - if (err) - return (err); + *zapp = NULL; #ifdef ZFS_DEBUG { @@ -499,7 +498,6 @@ zap_lockdir(objset_t *os, uint64_t obj, * mzap_open() didn't like what it saw on-disk. * Check for corruption! */ - dmu_buf_rele(db, NULL); return (SET_ERROR(EIO)); } } @@ -538,10 +536,12 @@ zap_lockdir(objset_t *os, uint64_t obj, dprintf("upgrading obj %llu: num_entries=%u\n", obj, zap->zap_m.zap_num_entries); *zapp = zap; - return (mzap_upgrade(zapp, tx, 0)); + int err = mzap_upgrade(zapp, tag, tx, 0); + if (err != 0) + rw_exit(&zap->zap_rwlock); + return (err); } - err = dmu_object_set_blocksize(os, obj, newsz, 0, tx); - ASSERT0(err); + VERIFY0(dmu_object_set_blocksize(os, obj, newsz, 0, tx)); zap->zap_m.zap_num_chunks = db->db_size / MZAP_ENT_LEN - 1; } @@ -550,15 +550,31 @@ zap_lockdir(objset_t *os, uint64_t obj, return (0); } +int +zap_lockdir(objset_t *os, uint64_t obj, dmu_tx_t *tx, + krw_t lti, boolean_t fatreader, boolean_t adding, void *tag, zap_t **zapp) +{ + dmu_buf_t *db; + int err; + + err = dmu_buf_hold(os, obj, 0, tag, &db, DMU_READ_NO_PREFETCH); + if (err != 0) + return (err); + err = zap_lockdir_impl(db, tag, tx, lti, fatreader, adding, zapp); + if (err != 0) + dmu_buf_rele(db, tag); + return (err); +} + void -zap_unlockdir(zap_t *zap) +zap_unlockdir(zap_t *zap, void *tag) { rw_exit(&zap->zap_rwlock); - dmu_buf_rele(zap->zap_dbuf, NULL); + dmu_buf_rele(zap->zap_dbuf, tag); } static int -mzap_upgrade(zap_t **zapp, dmu_tx_t *tx, zap_flags_t flags) +mzap_upgrade(zap_t **zapp, void *tag, dmu_tx_t *tx, zap_flags_t flags) { mzap_phys_t *mzp; int i, sz, nchunks; @@ -596,7 +612,8 @@ mzap_upgrade(zap_t **zapp, dmu_tx_t *tx, dprintf("adding %s=%llu\n", mze->mze_name, mze->mze_value); zn = zap_name_alloc(zap, mze->mze_name, MT_EXACT); - err = fzap_add_cd(zn, 8, 1, &mze->mze_value, mze->mze_cd, tx); + err = fzap_add_cd(zn, 8, 1, &mze->mze_value, mze->mze_cd, + tag, tx); zap = zn->zn_zap; /* fzap_add_cd() may change zap */ zap_name_free(zn); if (err) @@ -635,9 +652,9 @@ mzap_create_impl(objset_t *os, uint64_t zap_t *zap; /* Only fat zap supports flags; upgrade immediately. */ VERIFY(0 == zap_lockdir(os, obj, tx, RW_WRITER, - B_FALSE, B_FALSE, &zap)); - VERIFY3U(0, ==, mzap_upgrade(&zap, tx, flags)); - zap_unlockdir(zap); + B_FALSE, B_FALSE, FTAG, &zap)); + VERIFY3U(0, ==, mzap_upgrade(&zap, FTAG, tx, flags)); + zap_unlockdir(zap, FTAG); } } @@ -732,7 +749,7 @@ zap_count(objset_t *os, uint64_t zapobj, zap_t *zap; int err; - err = zap_lockdir(os, zapobj, NULL, RW_READER, TRUE, FALSE, &zap); + err = zap_lockdir(os, zapobj, NULL, RW_READER, TRUE, FALSE, FTAG, &zap); if (err) return (err); if (!zap->zap_ismicro) { @@ -740,7 +757,7 @@ zap_count(objset_t *os, uint64_t zapobj, } else { *count = zap->zap_m.zap_num_entries; } - zap_unlockdir(zap); + zap_unlockdir(zap, FTAG); return (err); } @@ -797,25 +814,19 @@ zap_lookup(objset_t *os, uint64_t zapobj num_integers, buf, MT_EXACT, NULL, 0, NULL)); } -int -zap_lookup_norm(objset_t *os, uint64_t zapobj, const char *name, +static int +zap_lookup_impl(zap_t *zap, const char *name, uint64_t integer_size, uint64_t num_integers, void *buf, matchtype_t mt, char *realname, int rn_len, boolean_t *ncp) { - zap_t *zap; - int err; + int err = 0; mzap_ent_t *mze; zap_name_t *zn; - err = zap_lockdir(os, zapobj, NULL, RW_READER, TRUE, FALSE, &zap); - if (err) - return (err); zn = zap_name_alloc(zap, name, mt); - if (zn == NULL) { - zap_unlockdir(zap); + if (zn == NULL) return (SET_ERROR(ENOTSUP)); - } if (!zap->zap_ismicro) { err = fzap_lookup(zn, integer_size, num_integers, buf, @@ -842,7 +853,24 @@ zap_lookup_norm(objset_t *os, uint64_t z } } zap_name_free(zn); - zap_unlockdir(zap); + return (err); +} + +int +zap_lookup_norm(objset_t *os, uint64_t zapobj, const char *name, + uint64_t integer_size, uint64_t num_integers, void *buf, + matchtype_t mt, char *realname, int rn_len, + boolean_t *ncp) +{ + zap_t *zap; + int err; + + err = zap_lockdir(os, zapobj, NULL, RW_READER, TRUE, FALSE, FTAG, &zap); + if (err != 0) + return (err); + err = zap_lookup_impl(zap, name, integer_size, + num_integers, buf, mt, realname, rn_len, ncp); + zap_unlockdir(zap, FTAG); return (err); } @@ -854,18 +882,18 @@ zap_prefetch_uint64(objset_t *os, uint64 int err; zap_name_t *zn; - err = zap_lockdir(os, zapobj, NULL, RW_READER, TRUE, FALSE, &zap); + err = zap_lockdir(os, zapobj, NULL, RW_READER, TRUE, FALSE, FTAG, &zap); if (err) return (err); zn = zap_name_alloc_uint64(zap, key, key_numints); if (zn == NULL) { - zap_unlockdir(zap); + zap_unlockdir(zap, FTAG); return (SET_ERROR(ENOTSUP)); } fzap_prefetch(zn); zap_name_free(zn); - zap_unlockdir(zap); + zap_unlockdir(zap, FTAG); return (err); } @@ -877,19 +905,19 @@ zap_lookup_uint64(objset_t *os, uint64_t int err; zap_name_t *zn; - err = zap_lockdir(os, zapobj, NULL, RW_READER, TRUE, FALSE, &zap); + err = zap_lockdir(os, zapobj, NULL, RW_READER, TRUE, FALSE, FTAG, &zap); if (err) return (err); zn = zap_name_alloc_uint64(zap, key, key_numints); if (zn == NULL) { - zap_unlockdir(zap); + zap_unlockdir(zap, FTAG); return (SET_ERROR(ENOTSUP)); } err = fzap_lookup(zn, integer_size, num_integers, buf, NULL, 0, NULL); zap_name_free(zn); - zap_unlockdir(zap); + zap_unlockdir(zap, FTAG); return (err); } @@ -912,12 +940,12 @@ zap_length(objset_t *os, uint64_t zapobj mzap_ent_t *mze; zap_name_t *zn; - err = zap_lockdir(os, zapobj, NULL, RW_READER, TRUE, FALSE, &zap); + err = zap_lockdir(os, zapobj, NULL, RW_READER, TRUE, FALSE, FTAG, &zap); if (err) return (err); zn = zap_name_alloc(zap, name, MT_EXACT); if (zn == NULL) { - zap_unlockdir(zap); + zap_unlockdir(zap, FTAG); return (SET_ERROR(ENOTSUP)); } if (!zap->zap_ismicro) { @@ -934,7 +962,7 @@ zap_length(objset_t *os, uint64_t zapobj } } zap_name_free(zn); - zap_unlockdir(zap); + zap_unlockdir(zap, FTAG); return (err); } @@ -946,17 +974,17 @@ zap_length_uint64(objset_t *os, uint64_t int err; zap_name_t *zn; - err = zap_lockdir(os, zapobj, NULL, RW_READER, TRUE, FALSE, &zap); + err = zap_lockdir(os, zapobj, NULL, RW_READER, TRUE, FALSE, FTAG, &zap); if (err) return (err); zn = zap_name_alloc_uint64(zap, key, key_numints); if (zn == NULL) { - zap_unlockdir(zap); + zap_unlockdir(zap, FTAG); return (SET_ERROR(ENOTSUP)); } err = fzap_length(zn, integer_size, num_integers); zap_name_free(zn); - zap_unlockdir(zap); + zap_unlockdir(zap, FTAG); return (err); } @@ -1015,22 +1043,24 @@ zap_add(objset_t *os, uint64_t zapobj, c const uint64_t *intval = val; zap_name_t *zn; - err = zap_lockdir(os, zapobj, tx, RW_WRITER, TRUE, TRUE, &zap); + err = zap_lockdir(os, zapobj, tx, RW_WRITER, TRUE, TRUE, FTAG, &zap); if (err) return (err); zn = zap_name_alloc(zap, key, MT_EXACT); if (zn == NULL) { - zap_unlockdir(zap); + zap_unlockdir(zap, FTAG); return (SET_ERROR(ENOTSUP)); } if (!zap->zap_ismicro) { - err = fzap_add(zn, integer_size, num_integers, val, tx); + err = fzap_add(zn, integer_size, num_integers, val, FTAG, tx); zap = zn->zn_zap; /* fzap_add() may change zap */ } else if (integer_size != 8 || num_integers != 1 || strlen(key) >= MZAP_NAME_LEN) { - err = mzap_upgrade(&zn->zn_zap, tx, 0); - if (err == 0) - err = fzap_add(zn, integer_size, num_integers, val, tx); + err = mzap_upgrade(&zn->zn_zap, FTAG, tx, 0); + if (err == 0) { + err = fzap_add(zn, integer_size, num_integers, val, + FTAG, tx); + } zap = zn->zn_zap; /* fzap_add() may change zap */ } else { mze = mze_find(zn); @@ -1043,7 +1073,7 @@ zap_add(objset_t *os, uint64_t zapobj, c ASSERT(zap == zn->zn_zap); zap_name_free(zn); if (zap != NULL) /* may be NULL if fzap_add() failed */ - zap_unlockdir(zap); + zap_unlockdir(zap, FTAG); return (err); } @@ -1056,19 +1086,19 @@ zap_add_uint64(objset_t *os, uint64_t za int err; zap_name_t *zn; - err = zap_lockdir(os, zapobj, tx, RW_WRITER, TRUE, TRUE, &zap); + err = zap_lockdir(os, zapobj, tx, RW_WRITER, TRUE, TRUE, FTAG, &zap); if (err) return (err); zn = zap_name_alloc_uint64(zap, key, key_numints); if (zn == NULL) { - zap_unlockdir(zap); + zap_unlockdir(zap, FTAG); return (SET_ERROR(ENOTSUP)); } - err = fzap_add(zn, integer_size, num_integers, val, tx); + err = fzap_add(zn, integer_size, num_integers, val, FTAG, tx); zap = zn->zn_zap; /* fzap_add() may change zap */ zap_name_free(zn); if (zap != NULL) /* may be NULL if fzap_add() failed */ - zap_unlockdir(zap); + zap_unlockdir(zap, FTAG); return (err); } @@ -1092,25 +1122,27 @@ zap_update(objset_t *os, uint64_t zapobj (void) zap_lookup(os, zapobj, name, 8, 1, &oldval); #endif - err = zap_lockdir(os, zapobj, tx, RW_WRITER, TRUE, TRUE, &zap); + err = zap_lockdir(os, zapobj, tx, RW_WRITER, TRUE, TRUE, FTAG, &zap); if (err) return (err); zn = zap_name_alloc(zap, name, MT_EXACT); if (zn == NULL) { - zap_unlockdir(zap); + zap_unlockdir(zap, FTAG); return (SET_ERROR(ENOTSUP)); } if (!zap->zap_ismicro) { - err = fzap_update(zn, integer_size, num_integers, val, tx); + err = fzap_update(zn, integer_size, num_integers, val, + FTAG, tx); zap = zn->zn_zap; /* fzap_update() may change zap */ } else if (integer_size != 8 || num_integers != 1 || strlen(name) >= MZAP_NAME_LEN) { dprintf("upgrading obj %llu: intsz=%u numint=%llu name=%s\n", zapobj, integer_size, num_integers, name); - err = mzap_upgrade(&zn->zn_zap, tx, 0); - if (err == 0) + err = mzap_upgrade(&zn->zn_zap, FTAG, tx, 0); + if (err == 0) { err = fzap_update(zn, integer_size, num_integers, - val, tx); + val, FTAG, tx); + } zap = zn->zn_zap; /* fzap_update() may change zap */ } else { mze = mze_find(zn); @@ -1124,7 +1156,7 @@ zap_update(objset_t *os, uint64_t zapobj ASSERT(zap == zn->zn_zap); zap_name_free(zn); if (zap != NULL) /* may be NULL if fzap_upgrade() failed */ - zap_unlockdir(zap); + zap_unlockdir(zap, FTAG); return (err); } @@ -1137,19 +1169,19 @@ zap_update_uint64(objset_t *os, uint64_t zap_name_t *zn; int err; - err = zap_lockdir(os, zapobj, tx, RW_WRITER, TRUE, TRUE, &zap); + err = zap_lockdir(os, zapobj, tx, RW_WRITER, TRUE, TRUE, FTAG, &zap); if (err) return (err); zn = zap_name_alloc_uint64(zap, key, key_numints); if (zn == NULL) { - zap_unlockdir(zap); + zap_unlockdir(zap, FTAG); return (SET_ERROR(ENOTSUP)); } - err = fzap_update(zn, integer_size, num_integers, val, tx); + err = fzap_update(zn, integer_size, num_integers, val, FTAG, tx); zap = zn->zn_zap; /* fzap_update() may change zap */ zap_name_free(zn); if (zap != NULL) /* may be NULL if fzap_upgrade() failed */ - zap_unlockdir(zap); + zap_unlockdir(zap, FTAG); return (err); } @@ -1168,12 +1200,12 @@ zap_remove_norm(objset_t *os, uint64_t z mzap_ent_t *mze; zap_name_t *zn; - err = zap_lockdir(os, zapobj, tx, RW_WRITER, TRUE, FALSE, &zap); + err = zap_lockdir(os, zapobj, tx, RW_WRITER, TRUE, FALSE, FTAG, &zap); if (err) return (err); zn = zap_name_alloc(zap, name, mt); if (zn == NULL) { - zap_unlockdir(zap); + zap_unlockdir(zap, FTAG); return (SET_ERROR(ENOTSUP)); } if (!zap->zap_ismicro) { @@ -1190,7 +1222,7 @@ zap_remove_norm(objset_t *os, uint64_t z } } zap_name_free(zn); - zap_unlockdir(zap); + zap_unlockdir(zap, FTAG); return (err); } @@ -1202,17 +1234,17 @@ zap_remove_uint64(objset_t *os, uint64_t int err; zap_name_t *zn; - err = zap_lockdir(os, zapobj, tx, RW_WRITER, TRUE, FALSE, &zap); + err = zap_lockdir(os, zapobj, tx, RW_WRITER, TRUE, FALSE, FTAG, &zap); if (err) return (err); zn = zap_name_alloc_uint64(zap, key, key_numints); if (zn == NULL) { - zap_unlockdir(zap); + zap_unlockdir(zap, FTAG); return (SET_ERROR(ENOTSUP)); } err = fzap_remove(zn, tx); zap_name_free(zn); - zap_unlockdir(zap); + zap_unlockdir(zap, FTAG); return (err); } @@ -1244,7 +1276,7 @@ zap_cursor_fini(zap_cursor_t *zc) { if (zc->zc_zap) { rw_enter(&zc->zc_zap->zap_rwlock, RW_READER); - zap_unlockdir(zc->zc_zap); + zap_unlockdir(zc->zc_zap, NULL); zc->zc_zap = NULL; } if (zc->zc_leaf) { @@ -1291,7 +1323,7 @@ zap_cursor_retrieve(zap_cursor_t *zc, za if (zc->zc_zap == NULL) { int hb; err = zap_lockdir(zc->zc_objset, zc->zc_zapobj, NULL, - RW_READER, TRUE, FALSE, &zc->zc_zap); + RW_READER, TRUE, FALSE, NULL, &zc->zc_zap); if (err) return (err); @@ -1395,7 +1427,7 @@ zap_get_stats(objset_t *os, uint64_t zap int err; zap_t *zap; - err = zap_lockdir(os, zapobj, NULL, RW_READER, TRUE, FALSE, &zap); + err = zap_lockdir(os, zapobj, NULL, RW_READER, TRUE, FALSE, FTAG, &zap); if (err) return (err); @@ -1408,7 +1440,7 @@ zap_get_stats(objset_t *os, uint64_t zap } else { fzap_get_stats(zap, zs); } - zap_unlockdir(zap); + zap_unlockdir(zap, FTAG); return (0); } @@ -1427,7 +1459,7 @@ zap_count_write(objset_t *os, uint64_t z * - 2 blocks for possibly split leaves, * - 2 grown ptrtbl blocks * - * This also accomodates the case where an add operation to a fairly + * This also accommodates the case where an add operation to a fairly * large microzap results in a promotion to fatzap. */ if (name == NULL) { @@ -1440,10 +1472,11 @@ zap_count_write(objset_t *os, uint64_t z * We lock the zap with adding == FALSE. Because, if we pass * the actual value of add, it could trigger a mzap_upgrade(). * At present we are just evaluating the possibility of this operation - * and hence we donot want to trigger an upgrade. + * and hence we do not want to trigger an upgrade. */ - err = zap_lockdir(os, zapobj, NULL, RW_READER, TRUE, FALSE, &zap); - if (err) + err = zap_lockdir(os, zapobj, NULL, RW_READER, TRUE, FALSE, + FTAG, &zap); + if (err != 0) return (err); if (!zap->zap_ismicro) { @@ -1489,6 +1522,6 @@ zap_count_write(objset_t *os, uint64_t z } } - zap_unlockdir(zap); + zap_unlockdir(zap, FTAG); return (err); } From owner-svn-src-all@freebsd.org Fri Oct 14 07:35:45 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 37490C11D87; Fri, 14 Oct 2016 07:35:45 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id F28C716F1; Fri, 14 Oct 2016 07:35:44 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9E7Zip5069375; Fri, 14 Oct 2016 07:35:44 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9E7ZhN6069369; Fri, 14 Oct 2016 07:35:43 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201610140735.u9E7ZhN6069369@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Fri, 14 Oct 2016 07:35:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307287 - in stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs: . sys X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Oct 2016 07:35:45 -0000 Author: mav Date: Fri Oct 14 07:35:43 2016 New Revision: 307287 URL: https://svnweb.freebsd.org/changeset/base/307287 Log: MFC r305338: MFV r305335: 7003 zap_lockdir() should tag hold zap_lockdir() / zap_unlockdir() should take a "void *tag" argument which tags the hold on the zap. This will help diagnose programming errors which misuse the hold on the ZAP. Sponsored by: Intel Corp. Closes #108 Reviewed by: Pavel Zakharov Reviewed by: Steve Gonczi Reviewed by: George Wilson Reviewed by: Brian Behlendorf Author: Matthew Ahrens openzfs/openzfs@0780b3eab5a2c13e04328b39ecd2a6d0d3c4f7cb Modified: stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dbuf.c stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dmu.h stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zap_impl.h stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zap.c stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zap_micro.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dbuf.c ============================================================================== --- stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dbuf.c Fri Oct 14 07:33:36 2016 (r307286) +++ stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dbuf.c Fri Oct 14 07:35:43 2016 (r307287) @@ -21,7 +21,7 @@ /* * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright 2011 Nexenta Systems, Inc. All rights reserved. - * Copyright (c) 2012, 2015 by Delphix. All rights reserved. + * Copyright (c) 2012, 2016 by Delphix. All rights reserved. * Copyright (c) 2013 by Saso Kiselkov. All rights reserved. * Copyright (c) 2013, Joyent, Inc. All rights reserved. * Copyright (c) 2014 Spectra Logic Corporation, All rights reserved. @@ -2896,6 +2896,13 @@ dmu_buf_get_blkptr(dmu_buf_t *db) return (dbi->db_blkptr); } +objset_t * +dmu_buf_get_objset(dmu_buf_t *db) +{ + dmu_buf_impl_t *dbi = (dmu_buf_impl_t *)db; + return (dbi->db_objset); +} + static void dbuf_check_blkptr(dnode_t *dn, dmu_buf_impl_t *db) { Modified: stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dmu.h ============================================================================== --- stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dmu.h Fri Oct 14 07:33:36 2016 (r307286) +++ stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dmu.h Fri Oct 14 07:35:43 2016 (r307287) @@ -21,7 +21,7 @@ /* * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2011, 2014 by Delphix. All rights reserved. + * Copyright (c) 2011, 2016 by Delphix. All rights reserved. * Copyright 2011 Nexenta Systems, Inc. All rights reserved. * Copyright (c) 2012, Joyent, Inc. All rights reserved. * Copyright 2013 DEY Storage Systems, Inc. @@ -616,6 +616,8 @@ void *dmu_buf_remove_user(dmu_buf_t *db, */ void *dmu_buf_get_user(dmu_buf_t *db); +objset_t *dmu_buf_get_objset(dmu_buf_t *db); + /* Block until any in-progress dmu buf user evictions complete. */ void dmu_buf_user_evict_wait(void); Modified: stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zap_impl.h ============================================================================== --- stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zap_impl.h Fri Oct 14 07:33:36 2016 (r307286) +++ stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zap_impl.h Fri Oct 14 07:35:43 2016 (r307287) @@ -20,7 +20,7 @@ */ /* * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2013, 2015 by Delphix. All rights reserved. + * Copyright (c) 2013, 2016 by Delphix. All rights reserved. * Copyright (c) 2014 Spectra Logic Corporation, All rights reserved. * Copyright (c) 2014 Integros [integros.com] */ @@ -197,8 +197,8 @@ typedef struct zap_name { boolean_t zap_match(zap_name_t *zn, const char *matchname); int zap_lockdir(objset_t *os, uint64_t obj, dmu_tx_t *tx, - krw_t lti, boolean_t fatreader, boolean_t adding, zap_t **zapp); -void zap_unlockdir(zap_t *zap); + krw_t lti, boolean_t fatreader, boolean_t adding, void *tag, zap_t **zapp); +void zap_unlockdir(zap_t *zap, void *tag); void zap_evict(void *dbu); zap_name_t *zap_name_alloc(zap_t *zap, const char *key, matchtype_t mt); void zap_name_free(zap_name_t *zn); @@ -217,9 +217,10 @@ void fzap_prefetch(zap_name_t *zn); int fzap_count_write(zap_name_t *zn, int add, refcount_t *towrite, refcount_t *tooverwrite); int fzap_add(zap_name_t *zn, uint64_t integer_size, uint64_t num_integers, - const void *val, dmu_tx_t *tx); + const void *val, void *tag, dmu_tx_t *tx); int fzap_update(zap_name_t *zn, - int integer_size, uint64_t num_integers, const void *val, dmu_tx_t *tx); + int integer_size, uint64_t num_integers, const void *val, + void *tag, dmu_tx_t *tx); int fzap_length(zap_name_t *zn, uint64_t *integer_size, uint64_t *num_integers); int fzap_remove(zap_name_t *zn, dmu_tx_t *tx); @@ -229,7 +230,7 @@ void zap_put_leaf(struct zap_leaf *l); int fzap_add_cd(zap_name_t *zn, uint64_t integer_size, uint64_t num_integers, - const void *val, uint32_t cd, dmu_tx_t *tx); + const void *val, uint32_t cd, void *tag, dmu_tx_t *tx); void fzap_upgrade(zap_t *zap, dmu_tx_t *tx, zap_flags_t flags); int fzap_cursor_move_to_key(zap_cursor_t *zc, zap_name_t *zn); Modified: stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zap.c ============================================================================== --- stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zap.c Fri Oct 14 07:33:36 2016 (r307286) +++ stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zap.c Fri Oct 14 07:35:43 2016 (r307287) @@ -20,7 +20,7 @@ */ /* * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2012, 2014 by Delphix. All rights reserved. + * Copyright (c) 2012, 2016 by Delphix. All rights reserved. * Copyright (c) 2014 Spectra Logic Corporation, All rights reserved. */ @@ -589,7 +589,8 @@ zap_deref_leaf(zap_t *zap, uint64_t h, d } static int -zap_expand_leaf(zap_name_t *zn, zap_leaf_t *l, dmu_tx_t *tx, zap_leaf_t **lp) +zap_expand_leaf(zap_name_t *zn, zap_leaf_t *l, + void *tag, dmu_tx_t *tx, zap_leaf_t **lp) { zap_t *zap = zn->zn_zap; uint64_t hash = zn->zn_hash; @@ -611,9 +612,9 @@ zap_expand_leaf(zap_name_t *zn, zap_leaf uint64_t object = zap->zap_object; zap_put_leaf(l); - zap_unlockdir(zap); + zap_unlockdir(zap, tag); err = zap_lockdir(os, object, tx, RW_WRITER, - FALSE, FALSE, &zn->zn_zap); + FALSE, FALSE, tag, &zn->zn_zap); zap = zn->zn_zap; if (err) return (err); @@ -676,7 +677,8 @@ zap_expand_leaf(zap_name_t *zn, zap_leaf } static void -zap_put_leaf_maybe_grow_ptrtbl(zap_name_t *zn, zap_leaf_t *l, dmu_tx_t *tx) +zap_put_leaf_maybe_grow_ptrtbl(zap_name_t *zn, zap_leaf_t *l, + void *tag, dmu_tx_t *tx) { zap_t *zap = zn->zn_zap; int shift = zap_f_phys(zap)->zap_ptrtbl.zt_shift; @@ -696,9 +698,9 @@ zap_put_leaf_maybe_grow_ptrtbl(zap_name_ objset_t *os = zap->zap_objset; uint64_t zapobj = zap->zap_object; - zap_unlockdir(zap); + zap_unlockdir(zap, tag); err = zap_lockdir(os, zapobj, tx, - RW_WRITER, FALSE, FALSE, &zn->zn_zap); + RW_WRITER, FALSE, FALSE, tag, &zn->zn_zap); zap = zn->zn_zap; if (err) return; @@ -788,7 +790,7 @@ fzap_lookup(zap_name_t *zn, int fzap_add_cd(zap_name_t *zn, uint64_t integer_size, uint64_t num_integers, - const void *val, uint32_t cd, dmu_tx_t *tx) + const void *val, uint32_t cd, void *tag, dmu_tx_t *tx) { zap_leaf_t *l; int err; @@ -817,7 +819,7 @@ retry: if (err == 0) { zap_increment_num_entries(zap, 1, tx); } else if (err == EAGAIN) { - err = zap_expand_leaf(zn, l, tx, &l); + err = zap_expand_leaf(zn, l, tag, tx, &l); zap = zn->zn_zap; /* zap_expand_leaf() may change zap */ if (err == 0) goto retry; @@ -825,26 +827,27 @@ retry: out: if (zap != NULL) - zap_put_leaf_maybe_grow_ptrtbl(zn, l, tx); + zap_put_leaf_maybe_grow_ptrtbl(zn, l, tag, tx); return (err); } int fzap_add(zap_name_t *zn, uint64_t integer_size, uint64_t num_integers, - const void *val, dmu_tx_t *tx) + const void *val, void *tag, dmu_tx_t *tx) { int err = fzap_check(zn, integer_size, num_integers); if (err != 0) return (err); return (fzap_add_cd(zn, integer_size, num_integers, - val, ZAP_NEED_CD, tx)); + val, ZAP_NEED_CD, tag, tx)); } int fzap_update(zap_name_t *zn, - int integer_size, uint64_t num_integers, const void *val, dmu_tx_t *tx) + int integer_size, uint64_t num_integers, const void *val, + void *tag, dmu_tx_t *tx) { zap_leaf_t *l; int err, create; @@ -874,14 +877,14 @@ retry: } if (err == EAGAIN) { - err = zap_expand_leaf(zn, l, tx, &l); + err = zap_expand_leaf(zn, l, tag, tx, &l); zap = zn->zn_zap; /* zap_expand_leaf() may change zap */ if (err == 0) goto retry; } if (zap != NULL) - zap_put_leaf_maybe_grow_ptrtbl(zn, l, tx); + zap_put_leaf_maybe_grow_ptrtbl(zn, l, tag, tx); return (err); } Modified: stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zap_micro.c ============================================================================== --- stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zap_micro.c Fri Oct 14 07:33:36 2016 (r307286) +++ stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zap_micro.c Fri Oct 14 07:35:43 2016 (r307287) @@ -20,7 +20,7 @@ */ /* * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2011, 2015 by Delphix. All rights reserved. + * Copyright (c) 2011, 2016 by Delphix. All rights reserved. * Copyright (c) 2014 Spectra Logic Corporation, All rights reserved. * Copyright (c) 2014 Integros [integros.com] */ @@ -43,7 +43,8 @@ extern inline mzap_phys_t *zap_m_phys(zap_t *zap); -static int mzap_upgrade(zap_t **zapp, dmu_tx_t *tx, zap_flags_t flags); +static int mzap_upgrade(zap_t **zapp, + void *tag, dmu_tx_t *tx, zap_flags_t flags); uint64_t zap_getflags(zap_t *zap) @@ -459,20 +460,18 @@ mzap_open(objset_t *os, uint64_t obj, dm return (zap); } -int -zap_lockdir(objset_t *os, uint64_t obj, dmu_tx_t *tx, +static int +zap_lockdir_impl(dmu_buf_t *db, void *tag, dmu_tx_t *tx, krw_t lti, boolean_t fatreader, boolean_t adding, zap_t **zapp) { zap_t *zap; - dmu_buf_t *db; krw_t lt; - int err; - *zapp = NULL; + ASSERT0(db->db_offset); + objset_t *os = dmu_buf_get_objset(db); + uint64_t obj = db->db_object; - err = dmu_buf_hold(os, obj, 0, NULL, &db, DMU_READ_NO_PREFETCH); - if (err) - return (err); + *zapp = NULL; #ifdef ZFS_DEBUG { @@ -520,10 +519,12 @@ zap_lockdir(objset_t *os, uint64_t obj, dprintf("upgrading obj %llu: num_entries=%u\n", obj, zap->zap_m.zap_num_entries); *zapp = zap; - return (mzap_upgrade(zapp, tx, 0)); + int err = mzap_upgrade(zapp, tag, tx, 0); + if (err != 0) + rw_exit(&zap->zap_rwlock); + return (err); } - err = dmu_object_set_blocksize(os, obj, newsz, 0, tx); - ASSERT0(err); + VERIFY0(dmu_object_set_blocksize(os, obj, newsz, 0, tx)); zap->zap_m.zap_num_chunks = db->db_size / MZAP_ENT_LEN - 1; } @@ -532,15 +533,31 @@ zap_lockdir(objset_t *os, uint64_t obj, return (0); } +int +zap_lockdir(objset_t *os, uint64_t obj, dmu_tx_t *tx, + krw_t lti, boolean_t fatreader, boolean_t adding, void *tag, zap_t **zapp) +{ + dmu_buf_t *db; + int err; + + err = dmu_buf_hold(os, obj, 0, tag, &db, DMU_READ_NO_PREFETCH); + if (err != 0) + return (err); + err = zap_lockdir_impl(db, tag, tx, lti, fatreader, adding, zapp); + if (err != 0) + dmu_buf_rele(db, tag); + return (err); +} + void -zap_unlockdir(zap_t *zap) +zap_unlockdir(zap_t *zap, void *tag) { rw_exit(&zap->zap_rwlock); - dmu_buf_rele(zap->zap_dbuf, NULL); + dmu_buf_rele(zap->zap_dbuf, tag); } static int -mzap_upgrade(zap_t **zapp, dmu_tx_t *tx, zap_flags_t flags) +mzap_upgrade(zap_t **zapp, void *tag, dmu_tx_t *tx, zap_flags_t flags) { mzap_phys_t *mzp; int i, sz, nchunks; @@ -578,7 +595,8 @@ mzap_upgrade(zap_t **zapp, dmu_tx_t *tx, dprintf("adding %s=%llu\n", mze->mze_name, mze->mze_value); zn = zap_name_alloc(zap, mze->mze_name, MT_EXACT); - err = fzap_add_cd(zn, 8, 1, &mze->mze_value, mze->mze_cd, tx); + err = fzap_add_cd(zn, 8, 1, &mze->mze_value, mze->mze_cd, + tag, tx); zap = zn->zn_zap; /* fzap_add_cd() may change zap */ zap_name_free(zn); if (err) @@ -617,9 +635,9 @@ mzap_create_impl(objset_t *os, uint64_t zap_t *zap; /* Only fat zap supports flags; upgrade immediately. */ VERIFY(0 == zap_lockdir(os, obj, tx, RW_WRITER, - B_FALSE, B_FALSE, &zap)); - VERIFY3U(0, ==, mzap_upgrade(&zap, tx, flags)); - zap_unlockdir(zap); + B_FALSE, B_FALSE, FTAG, &zap)); + VERIFY3U(0, ==, mzap_upgrade(&zap, FTAG, tx, flags)); + zap_unlockdir(zap, FTAG); } } @@ -714,7 +732,7 @@ zap_count(objset_t *os, uint64_t zapobj, zap_t *zap; int err; - err = zap_lockdir(os, zapobj, NULL, RW_READER, TRUE, FALSE, &zap); + err = zap_lockdir(os, zapobj, NULL, RW_READER, TRUE, FALSE, FTAG, &zap); if (err) return (err); if (!zap->zap_ismicro) { @@ -722,7 +740,7 @@ zap_count(objset_t *os, uint64_t zapobj, } else { *count = zap->zap_m.zap_num_entries; } - zap_unlockdir(zap); + zap_unlockdir(zap, FTAG); return (err); } @@ -779,25 +797,19 @@ zap_lookup(objset_t *os, uint64_t zapobj num_integers, buf, MT_EXACT, NULL, 0, NULL)); } -int -zap_lookup_norm(objset_t *os, uint64_t zapobj, const char *name, +static int +zap_lookup_impl(zap_t *zap, const char *name, uint64_t integer_size, uint64_t num_integers, void *buf, matchtype_t mt, char *realname, int rn_len, boolean_t *ncp) { - zap_t *zap; - int err; + int err = 0; mzap_ent_t *mze; zap_name_t *zn; - err = zap_lockdir(os, zapobj, NULL, RW_READER, TRUE, FALSE, &zap); - if (err) - return (err); zn = zap_name_alloc(zap, name, mt); - if (zn == NULL) { - zap_unlockdir(zap); + if (zn == NULL) return (SET_ERROR(ENOTSUP)); - } if (!zap->zap_ismicro) { err = fzap_lookup(zn, integer_size, num_integers, buf, @@ -824,7 +836,24 @@ zap_lookup_norm(objset_t *os, uint64_t z } } zap_name_free(zn); - zap_unlockdir(zap); + return (err); +} + +int +zap_lookup_norm(objset_t *os, uint64_t zapobj, const char *name, + uint64_t integer_size, uint64_t num_integers, void *buf, + matchtype_t mt, char *realname, int rn_len, + boolean_t *ncp) +{ + zap_t *zap; + int err; + + err = zap_lockdir(os, zapobj, NULL, RW_READER, TRUE, FALSE, FTAG, &zap); + if (err != 0) + return (err); + err = zap_lookup_impl(zap, name, integer_size, + num_integers, buf, mt, realname, rn_len, ncp); + zap_unlockdir(zap, FTAG); return (err); } @@ -836,18 +865,18 @@ zap_prefetch_uint64(objset_t *os, uint64 int err; zap_name_t *zn; - err = zap_lockdir(os, zapobj, NULL, RW_READER, TRUE, FALSE, &zap); + err = zap_lockdir(os, zapobj, NULL, RW_READER, TRUE, FALSE, FTAG, &zap); if (err) return (err); zn = zap_name_alloc_uint64(zap, key, key_numints); if (zn == NULL) { - zap_unlockdir(zap); + zap_unlockdir(zap, FTAG); return (SET_ERROR(ENOTSUP)); } fzap_prefetch(zn); zap_name_free(zn); - zap_unlockdir(zap); + zap_unlockdir(zap, FTAG); return (err); } @@ -859,19 +888,19 @@ zap_lookup_uint64(objset_t *os, uint64_t int err; zap_name_t *zn; - err = zap_lockdir(os, zapobj, NULL, RW_READER, TRUE, FALSE, &zap); + err = zap_lockdir(os, zapobj, NULL, RW_READER, TRUE, FALSE, FTAG, &zap); if (err) return (err); zn = zap_name_alloc_uint64(zap, key, key_numints); if (zn == NULL) { - zap_unlockdir(zap); + zap_unlockdir(zap, FTAG); return (SET_ERROR(ENOTSUP)); } err = fzap_lookup(zn, integer_size, num_integers, buf, NULL, 0, NULL); zap_name_free(zn); - zap_unlockdir(zap); + zap_unlockdir(zap, FTAG); return (err); } @@ -894,12 +923,12 @@ zap_length(objset_t *os, uint64_t zapobj mzap_ent_t *mze; zap_name_t *zn; - err = zap_lockdir(os, zapobj, NULL, RW_READER, TRUE, FALSE, &zap); + err = zap_lockdir(os, zapobj, NULL, RW_READER, TRUE, FALSE, FTAG, &zap); if (err) return (err); zn = zap_name_alloc(zap, name, MT_EXACT); if (zn == NULL) { - zap_unlockdir(zap); + zap_unlockdir(zap, FTAG); return (SET_ERROR(ENOTSUP)); } if (!zap->zap_ismicro) { @@ -916,7 +945,7 @@ zap_length(objset_t *os, uint64_t zapobj } } zap_name_free(zn); - zap_unlockdir(zap); + zap_unlockdir(zap, FTAG); return (err); } @@ -928,17 +957,17 @@ zap_length_uint64(objset_t *os, uint64_t int err; zap_name_t *zn; - err = zap_lockdir(os, zapobj, NULL, RW_READER, TRUE, FALSE, &zap); + err = zap_lockdir(os, zapobj, NULL, RW_READER, TRUE, FALSE, FTAG, &zap); if (err) return (err); zn = zap_name_alloc_uint64(zap, key, key_numints); if (zn == NULL) { - zap_unlockdir(zap); + zap_unlockdir(zap, FTAG); return (SET_ERROR(ENOTSUP)); } err = fzap_length(zn, integer_size, num_integers); zap_name_free(zn); - zap_unlockdir(zap); + zap_unlockdir(zap, FTAG); return (err); } @@ -997,22 +1026,24 @@ zap_add(objset_t *os, uint64_t zapobj, c const uint64_t *intval = val; zap_name_t *zn; - err = zap_lockdir(os, zapobj, tx, RW_WRITER, TRUE, TRUE, &zap); + err = zap_lockdir(os, zapobj, tx, RW_WRITER, TRUE, TRUE, FTAG, &zap); if (err) return (err); zn = zap_name_alloc(zap, key, MT_EXACT); if (zn == NULL) { - zap_unlockdir(zap); + zap_unlockdir(zap, FTAG); return (SET_ERROR(ENOTSUP)); } if (!zap->zap_ismicro) { - err = fzap_add(zn, integer_size, num_integers, val, tx); + err = fzap_add(zn, integer_size, num_integers, val, FTAG, tx); zap = zn->zn_zap; /* fzap_add() may change zap */ } else if (integer_size != 8 || num_integers != 1 || strlen(key) >= MZAP_NAME_LEN) { - err = mzap_upgrade(&zn->zn_zap, tx, 0); - if (err == 0) - err = fzap_add(zn, integer_size, num_integers, val, tx); + err = mzap_upgrade(&zn->zn_zap, FTAG, tx, 0); + if (err == 0) { + err = fzap_add(zn, integer_size, num_integers, val, + FTAG, tx); + } zap = zn->zn_zap; /* fzap_add() may change zap */ } else { mze = mze_find(zn); @@ -1025,7 +1056,7 @@ zap_add(objset_t *os, uint64_t zapobj, c ASSERT(zap == zn->zn_zap); zap_name_free(zn); if (zap != NULL) /* may be NULL if fzap_add() failed */ - zap_unlockdir(zap); + zap_unlockdir(zap, FTAG); return (err); } @@ -1038,19 +1069,19 @@ zap_add_uint64(objset_t *os, uint64_t za int err; zap_name_t *zn; - err = zap_lockdir(os, zapobj, tx, RW_WRITER, TRUE, TRUE, &zap); + err = zap_lockdir(os, zapobj, tx, RW_WRITER, TRUE, TRUE, FTAG, &zap); if (err) return (err); zn = zap_name_alloc_uint64(zap, key, key_numints); if (zn == NULL) { - zap_unlockdir(zap); + zap_unlockdir(zap, FTAG); return (SET_ERROR(ENOTSUP)); } - err = fzap_add(zn, integer_size, num_integers, val, tx); + err = fzap_add(zn, integer_size, num_integers, val, FTAG, tx); zap = zn->zn_zap; /* fzap_add() may change zap */ zap_name_free(zn); if (zap != NULL) /* may be NULL if fzap_add() failed */ - zap_unlockdir(zap); + zap_unlockdir(zap, FTAG); return (err); } @@ -1074,25 +1105,27 @@ zap_update(objset_t *os, uint64_t zapobj (void) zap_lookup(os, zapobj, name, 8, 1, &oldval); #endif - err = zap_lockdir(os, zapobj, tx, RW_WRITER, TRUE, TRUE, &zap); + err = zap_lockdir(os, zapobj, tx, RW_WRITER, TRUE, TRUE, FTAG, &zap); if (err) return (err); zn = zap_name_alloc(zap, name, MT_EXACT); if (zn == NULL) { - zap_unlockdir(zap); + zap_unlockdir(zap, FTAG); return (SET_ERROR(ENOTSUP)); } if (!zap->zap_ismicro) { - err = fzap_update(zn, integer_size, num_integers, val, tx); + err = fzap_update(zn, integer_size, num_integers, val, + FTAG, tx); zap = zn->zn_zap; /* fzap_update() may change zap */ } else if (integer_size != 8 || num_integers != 1 || strlen(name) >= MZAP_NAME_LEN) { dprintf("upgrading obj %llu: intsz=%u numint=%llu name=%s\n", zapobj, integer_size, num_integers, name); - err = mzap_upgrade(&zn->zn_zap, tx, 0); - if (err == 0) + err = mzap_upgrade(&zn->zn_zap, FTAG, tx, 0); + if (err == 0) { err = fzap_update(zn, integer_size, num_integers, - val, tx); + val, FTAG, tx); + } zap = zn->zn_zap; /* fzap_update() may change zap */ } else { mze = mze_find(zn); @@ -1106,7 +1139,7 @@ zap_update(objset_t *os, uint64_t zapobj ASSERT(zap == zn->zn_zap); zap_name_free(zn); if (zap != NULL) /* may be NULL if fzap_upgrade() failed */ - zap_unlockdir(zap); + zap_unlockdir(zap, FTAG); return (err); } @@ -1119,19 +1152,19 @@ zap_update_uint64(objset_t *os, uint64_t zap_name_t *zn; int err; - err = zap_lockdir(os, zapobj, tx, RW_WRITER, TRUE, TRUE, &zap); + err = zap_lockdir(os, zapobj, tx, RW_WRITER, TRUE, TRUE, FTAG, &zap); if (err) return (err); zn = zap_name_alloc_uint64(zap, key, key_numints); if (zn == NULL) { - zap_unlockdir(zap); + zap_unlockdir(zap, FTAG); return (SET_ERROR(ENOTSUP)); } - err = fzap_update(zn, integer_size, num_integers, val, tx); + err = fzap_update(zn, integer_size, num_integers, val, FTAG, tx); zap = zn->zn_zap; /* fzap_update() may change zap */ zap_name_free(zn); if (zap != NULL) /* may be NULL if fzap_upgrade() failed */ - zap_unlockdir(zap); + zap_unlockdir(zap, FTAG); return (err); } @@ -1150,12 +1183,12 @@ zap_remove_norm(objset_t *os, uint64_t z mzap_ent_t *mze; zap_name_t *zn; - err = zap_lockdir(os, zapobj, tx, RW_WRITER, TRUE, FALSE, &zap); + err = zap_lockdir(os, zapobj, tx, RW_WRITER, TRUE, FALSE, FTAG, &zap); if (err) return (err); zn = zap_name_alloc(zap, name, mt); if (zn == NULL) { - zap_unlockdir(zap); + zap_unlockdir(zap, FTAG); return (SET_ERROR(ENOTSUP)); } if (!zap->zap_ismicro) { @@ -1172,7 +1205,7 @@ zap_remove_norm(objset_t *os, uint64_t z } } zap_name_free(zn); - zap_unlockdir(zap); + zap_unlockdir(zap, FTAG); return (err); } @@ -1184,17 +1217,17 @@ zap_remove_uint64(objset_t *os, uint64_t int err; zap_name_t *zn; - err = zap_lockdir(os, zapobj, tx, RW_WRITER, TRUE, FALSE, &zap); + err = zap_lockdir(os, zapobj, tx, RW_WRITER, TRUE, FALSE, FTAG, &zap); if (err) return (err); zn = zap_name_alloc_uint64(zap, key, key_numints); if (zn == NULL) { - zap_unlockdir(zap); + zap_unlockdir(zap, FTAG); return (SET_ERROR(ENOTSUP)); } err = fzap_remove(zn, tx); zap_name_free(zn); - zap_unlockdir(zap); + zap_unlockdir(zap, FTAG); return (err); } @@ -1226,7 +1259,7 @@ zap_cursor_fini(zap_cursor_t *zc) { if (zc->zc_zap) { rw_enter(&zc->zc_zap->zap_rwlock, RW_READER); - zap_unlockdir(zc->zc_zap); + zap_unlockdir(zc->zc_zap, NULL); zc->zc_zap = NULL; } if (zc->zc_leaf) { @@ -1273,7 +1306,7 @@ zap_cursor_retrieve(zap_cursor_t *zc, za if (zc->zc_zap == NULL) { int hb; err = zap_lockdir(zc->zc_objset, zc->zc_zapobj, NULL, - RW_READER, TRUE, FALSE, &zc->zc_zap); + RW_READER, TRUE, FALSE, NULL, &zc->zc_zap); if (err) return (err); @@ -1377,7 +1410,7 @@ zap_get_stats(objset_t *os, uint64_t zap int err; zap_t *zap; - err = zap_lockdir(os, zapobj, NULL, RW_READER, TRUE, FALSE, &zap); + err = zap_lockdir(os, zapobj, NULL, RW_READER, TRUE, FALSE, FTAG, &zap); if (err) return (err); @@ -1390,7 +1423,7 @@ zap_get_stats(objset_t *os, uint64_t zap } else { fzap_get_stats(zap, zs); } - zap_unlockdir(zap); + zap_unlockdir(zap, FTAG); return (0); } @@ -1409,7 +1442,7 @@ zap_count_write(objset_t *os, uint64_t z * - 2 blocks for possibly split leaves, * - 2 grown ptrtbl blocks * - * This also accomodates the case where an add operation to a fairly + * This also accommodates the case where an add operation to a fairly * large microzap results in a promotion to fatzap. */ if (name == NULL) { @@ -1422,10 +1455,11 @@ zap_count_write(objset_t *os, uint64_t z * We lock the zap with adding == FALSE. Because, if we pass * the actual value of add, it could trigger a mzap_upgrade(). * At present we are just evaluating the possibility of this operation - * and hence we donot want to trigger an upgrade. + * and hence we do not want to trigger an upgrade. */ - err = zap_lockdir(os, zapobj, NULL, RW_READER, TRUE, FALSE, &zap); - if (err) + err = zap_lockdir(os, zapobj, NULL, RW_READER, TRUE, FALSE, + FTAG, &zap); + if (err != 0) return (err); if (!zap->zap_ismicro) { @@ -1471,6 +1505,6 @@ zap_count_write(objset_t *os, uint64_t z } } - zap_unlockdir(zap); + zap_unlockdir(zap, FTAG); return (err); } From owner-svn-src-all@freebsd.org Fri Oct 14 07:36:33 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id AD377C11E1F; Fri, 14 Oct 2016 07:36:33 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 890EC188E; Fri, 14 Oct 2016 07:36:33 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9E7aWmK069464; Fri, 14 Oct 2016 07:36:32 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9E7aWfh069463; Fri, 14 Oct 2016 07:36:32 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201610140736.u9E7aWfh069463@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Fri, 14 Oct 2016 07:36:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307288 - stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Oct 2016 07:36:33 -0000 Author: mav Date: Fri Oct 14 07:36:32 2016 New Revision: 307288 URL: https://svnweb.freebsd.org/changeset/base/307288 Log: MFC r305339: MFV r305336: 7247 zfs receive of deduplicated stream fails This resolves two 'zfs recv' issues. First, when receiving into an existing filesystem, a snapshot created during the receive process is not added to the guid->dataset map for the stream, resulting in failed lookups for deduped streams when a WRITE_BYREF record refers to a snapshot received earlier in the stream. Second, the newly created snapshot was also not set properly, referencing the snapshot before the new receiving dataset rather than the existing filesystem. Closes #159 Reviewed by: Matthew Ahrens Reviewed by: Dan Kimmel Author: Chris Williamson openzfs/openzfs@b09697c8c18be68abfe538de9809938239402ae8 Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_send.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_send.c ============================================================================== --- stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_send.c Fri Oct 14 07:35:43 2016 (r307287) +++ stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_send.c Fri Oct 14 07:36:32 2016 (r307288) @@ -3113,6 +3113,9 @@ dmu_recv_end_sync(void *arg, dmu_tx_t *t dsl_dataset_phys(origin_head)->ds_flags &= ~DS_FLAG_INCONSISTENT; + drc->drc_newsnapobj = + dsl_dataset_phys(origin_head)->ds_prev_snap_obj; + dsl_dataset_rele(origin_head, FTAG); dsl_destroy_head_sync_impl(drc->drc_ds, tx); @@ -3148,8 +3151,9 @@ dmu_recv_end_sync(void *arg, dmu_tx_t *t (void) zap_remove(dp->dp_meta_objset, ds->ds_object, DS_FIELD_RESUME_TONAME, tx); } + drc->drc_newsnapobj = + dsl_dataset_phys(drc->drc_ds)->ds_prev_snap_obj; } - drc->drc_newsnapobj = dsl_dataset_phys(drc->drc_ds)->ds_prev_snap_obj; /* * Release the hold from dmu_recv_begin. This must be done before * we return to open context, so that when we free the dataset's dnode, @@ -3191,8 +3195,6 @@ static int dmu_recv_end_modified_blocks static int dmu_recv_existing_end(dmu_recv_cookie_t *drc) { - int error; - #ifdef _KERNEL /* * We will be destroying the ds; make sure its origin is unmounted if @@ -3203,23 +3205,30 @@ dmu_recv_existing_end(dmu_recv_cookie_t zfs_destroy_unmount_origin(name); #endif - error = dsl_sync_task(drc->drc_tofs, + return (dsl_sync_task(drc->drc_tofs, dmu_recv_end_check, dmu_recv_end_sync, drc, - dmu_recv_end_modified_blocks, ZFS_SPACE_CHECK_NORMAL); - - if (error != 0) - dmu_recv_cleanup_ds(drc); - return (error); + dmu_recv_end_modified_blocks, ZFS_SPACE_CHECK_NORMAL)); } static int dmu_recv_new_end(dmu_recv_cookie_t *drc) { + return (dsl_sync_task(drc->drc_tofs, + dmu_recv_end_check, dmu_recv_end_sync, drc, + dmu_recv_end_modified_blocks, ZFS_SPACE_CHECK_NORMAL)); +} + +int +dmu_recv_end(dmu_recv_cookie_t *drc, void *owner) +{ int error; - error = dsl_sync_task(drc->drc_tofs, - dmu_recv_end_check, dmu_recv_end_sync, drc, - dmu_recv_end_modified_blocks, ZFS_SPACE_CHECK_NORMAL); + drc->drc_owner = owner; + + if (drc->drc_newfs) + error = dmu_recv_new_end(drc); + else + error = dmu_recv_existing_end(drc); if (error != 0) { dmu_recv_cleanup_ds(drc); @@ -3231,17 +3240,6 @@ dmu_recv_new_end(dmu_recv_cookie_t *drc) return (error); } -int -dmu_recv_end(dmu_recv_cookie_t *drc, void *owner) -{ - drc->drc_owner = owner; - - if (drc->drc_newfs) - return (dmu_recv_new_end(drc)); - else - return (dmu_recv_existing_end(drc)); -} - /* * Return TRUE if this objset is currently being received into. */ From owner-svn-src-all@freebsd.org Fri Oct 14 07:37:09 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 93553C11E7C; Fri, 14 Oct 2016 07:37:09 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 6C41E19E6; Fri, 14 Oct 2016 07:37:09 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9E7b8S3069548; Fri, 14 Oct 2016 07:37:08 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9E7b8At069547; Fri, 14 Oct 2016 07:37:08 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201610140737.u9E7b8At069547@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Fri, 14 Oct 2016 07:37:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307289 - stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Oct 2016 07:37:09 -0000 Author: mav Date: Fri Oct 14 07:37:08 2016 New Revision: 307289 URL: https://svnweb.freebsd.org/changeset/base/307289 Log: MFC r305339: MFV r305336: 7247 zfs receive of deduplicated stream fails This resolves two 'zfs recv' issues. First, when receiving into an existing filesystem, a snapshot created during the receive process is not added to the guid->dataset map for the stream, resulting in failed lookups for deduped streams when a WRITE_BYREF record refers to a snapshot received earlier in the stream. Second, the newly created snapshot was also not set properly, referencing the snapshot before the new receiving dataset rather than the existing filesystem. Closes #159 Reviewed by: Matthew Ahrens Reviewed by: Dan Kimmel Author: Chris Williamson openzfs/openzfs@b09697c8c18be68abfe538de9809938239402ae8 Modified: stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_send.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_send.c ============================================================================== --- stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_send.c Fri Oct 14 07:36:32 2016 (r307288) +++ stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_send.c Fri Oct 14 07:37:08 2016 (r307289) @@ -3113,6 +3113,9 @@ dmu_recv_end_sync(void *arg, dmu_tx_t *t dsl_dataset_phys(origin_head)->ds_flags &= ~DS_FLAG_INCONSISTENT; + drc->drc_newsnapobj = + dsl_dataset_phys(origin_head)->ds_prev_snap_obj; + dsl_dataset_rele(origin_head, FTAG); dsl_destroy_head_sync_impl(drc->drc_ds, tx); @@ -3148,8 +3151,9 @@ dmu_recv_end_sync(void *arg, dmu_tx_t *t (void) zap_remove(dp->dp_meta_objset, ds->ds_object, DS_FIELD_RESUME_TONAME, tx); } + drc->drc_newsnapobj = + dsl_dataset_phys(drc->drc_ds)->ds_prev_snap_obj; } - drc->drc_newsnapobj = dsl_dataset_phys(drc->drc_ds)->ds_prev_snap_obj; /* * Release the hold from dmu_recv_begin. This must be done before * we return to open context, so that when we free the dataset's dnode, @@ -3191,8 +3195,6 @@ static int dmu_recv_end_modified_blocks static int dmu_recv_existing_end(dmu_recv_cookie_t *drc) { - int error; - #ifdef _KERNEL /* * We will be destroying the ds; make sure its origin is unmounted if @@ -3203,23 +3205,30 @@ dmu_recv_existing_end(dmu_recv_cookie_t zfs_destroy_unmount_origin(name); #endif - error = dsl_sync_task(drc->drc_tofs, + return (dsl_sync_task(drc->drc_tofs, dmu_recv_end_check, dmu_recv_end_sync, drc, - dmu_recv_end_modified_blocks, ZFS_SPACE_CHECK_NORMAL); - - if (error != 0) - dmu_recv_cleanup_ds(drc); - return (error); + dmu_recv_end_modified_blocks, ZFS_SPACE_CHECK_NORMAL)); } static int dmu_recv_new_end(dmu_recv_cookie_t *drc) { + return (dsl_sync_task(drc->drc_tofs, + dmu_recv_end_check, dmu_recv_end_sync, drc, + dmu_recv_end_modified_blocks, ZFS_SPACE_CHECK_NORMAL)); +} + +int +dmu_recv_end(dmu_recv_cookie_t *drc, void *owner) +{ int error; - error = dsl_sync_task(drc->drc_tofs, - dmu_recv_end_check, dmu_recv_end_sync, drc, - dmu_recv_end_modified_blocks, ZFS_SPACE_CHECK_NORMAL); + drc->drc_owner = owner; + + if (drc->drc_newfs) + error = dmu_recv_new_end(drc); + else + error = dmu_recv_existing_end(drc); if (error != 0) { dmu_recv_cleanup_ds(drc); @@ -3231,17 +3240,6 @@ dmu_recv_new_end(dmu_recv_cookie_t *drc) return (error); } -int -dmu_recv_end(dmu_recv_cookie_t *drc, void *owner) -{ - drc->drc_owner = owner; - - if (drc->drc_newfs) - return (dmu_recv_new_end(drc)); - else - return (dmu_recv_existing_end(drc)); -} - /* * Return TRUE if this objset is currently being received into. */ From owner-svn-src-all@freebsd.org Fri Oct 14 07:39:36 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id BEA08C11EEF; Fri, 14 Oct 2016 07:39:36 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 850201BC5; Fri, 14 Oct 2016 07:39:36 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9E7dZwW069705; Fri, 14 Oct 2016 07:39:35 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9E7dYoH069697; Fri, 14 Oct 2016 07:39:34 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201610140739.u9E7dYoH069697@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Fri, 14 Oct 2016 07:39:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307290 - in stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs: . sys X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Oct 2016 07:39:36 -0000 Author: mav Date: Fri Oct 14 07:39:34 2016 New Revision: 307290 URL: https://svnweb.freebsd.org/changeset/base/307290 Log: MFC r305340: MFC r305337: 7004 dmu_tx_hold_zap() does dnode_hold() 7x on same object Using a benchmark which has 32 threads creating 2 million files in the same directory, on a machine with 16 CPU cores, I observed poor performance. I noticed that dmu_tx_hold_zap() was using about 30% of all CPU, and doing dnode_hold() 7 times on the same object (the ZAP object that is being held). dmu_tx_hold_zap() keeps a hold on the dnode_t the entire time it is running, in dmu_tx_hold_t:txh_dnode, so it would be nice to use the dnode_t that we already have in hand, rather than repeatedly calling dnode_hold(). To do this, we need to pass the dnode_t down through all the intermediate calls that dmu_tx_hold_zap() makes, making these routines take the dnode_t* rather than an objset_t* and a uint64_t object number. In particular, the following routines will need to have analogous *_by_dnode() variants created: dmu_buf_hold_noread() dmu_buf_hold() zap_lookup() zap_lookup_norm() zap_count_write() zap_lockdir() zap_count_write() This can improve performance on the benchmark described above by 100%, from 30,000 file creations per second to 60,000. (This improvement is on top of that provided by working around the object allocation issue. Peak performance of ~90,000 creations per second was observed with 8 CPUs; adding CPUs past that decreased performance due to lock contention.) The CPU used by dmu_tx_hold_zap() was reduced by 88%, from 340 CPU-seconds to 40 CPU-seconds. Sponsored by: Intel Corp. Closes #109 Reviewed by: Steve Gonczi Reviewed by: George Wilson Reviewed by: Pavel Zakharov Reviewed by: Ned Bass Reviewed by: Brian Behlendorf Author: Matthew Ahrens openzfs/openzfs@d3e523d489a169ab36f9ec1b2a111a60a5563a9f Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dbuf.c stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu.c stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_tx.c stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dmu.h stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dnode.h stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zap.h stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zap.c stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zap_micro.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dbuf.c ============================================================================== --- stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dbuf.c Fri Oct 14 07:37:08 2016 (r307289) +++ stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dbuf.c Fri Oct 14 07:39:34 2016 (r307290) @@ -2910,6 +2910,21 @@ dmu_buf_get_objset(dmu_buf_t *db) return (dbi->db_objset); } +dnode_t * +dmu_buf_dnode_enter(dmu_buf_t *db) +{ + dmu_buf_impl_t *dbi = (dmu_buf_impl_t *)db; + DB_DNODE_ENTER(dbi); + return (DB_DNODE(dbi)); +} + +void +dmu_buf_dnode_exit(dmu_buf_t *db) +{ + dmu_buf_impl_t *dbi = (dmu_buf_impl_t *)db; + DB_DNODE_EXIT(dbi); +} + static void dbuf_check_blkptr(dnode_t *dn, dmu_buf_impl_t *db) { Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu.c ============================================================================== --- stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu.c Fri Oct 14 07:37:08 2016 (r307289) +++ stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu.c Fri Oct 14 07:39:34 2016 (r307290) @@ -131,6 +131,26 @@ const dmu_object_byteswap_info_t dmu_ot_ }; int +dmu_buf_hold_noread_by_dnode(dnode_t *dn, uint64_t offset, + void *tag, dmu_buf_t **dbp) +{ + uint64_t blkid; + dmu_buf_impl_t *db; + + blkid = dbuf_whichblock(dn, 0, offset); + rw_enter(&dn->dn_struct_rwlock, RW_READER); + db = dbuf_hold(dn, blkid, tag); + rw_exit(&dn->dn_struct_rwlock); + + if (db == NULL) { + *dbp = NULL; + return (SET_ERROR(EIO)); + } + + *dbp = &db->db; + return (0); +} +int dmu_buf_hold_noread(objset_t *os, uint64_t object, uint64_t offset, void *tag, dmu_buf_t **dbp) { @@ -158,6 +178,29 @@ dmu_buf_hold_noread(objset_t *os, uint64 } int +dmu_buf_hold_by_dnode(dnode_t *dn, uint64_t offset, + void *tag, dmu_buf_t **dbp, int flags) +{ + int err; + int db_flags = DB_RF_CANFAIL; + + if (flags & DMU_READ_NO_PREFETCH) + db_flags |= DB_RF_NOPREFETCH; + + err = dmu_buf_hold_noread_by_dnode(dn, offset, tag, dbp); + if (err == 0) { + dmu_buf_impl_t *db = (dmu_buf_impl_t *)(*dbp); + err = dbuf_read(db, NULL, db_flags); + if (err != 0) { + dbuf_rele(db, tag); + *dbp = NULL; + } + } + + return (err); +} + +int dmu_buf_hold(objset_t *os, uint64_t object, uint64_t offset, void *tag, dmu_buf_t **dbp, int flags) { Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_tx.c ============================================================================== --- stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_tx.c Fri Oct 14 07:37:08 2016 (r307289) +++ stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_tx.c Fri Oct 14 07:39:34 2016 (r307290) @@ -21,7 +21,7 @@ /* * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright 2011 Nexenta Systems, Inc. All rights reserved. - * Copyright (c) 2012, 2015 by Delphix. All rights reserved. + * Copyright (c) 2012, 2016 by Delphix. All rights reserved. * Copyright (c) 2014 Integros [integros.com] */ @@ -808,15 +808,14 @@ dmu_tx_hold_zap(dmu_tx_t *tx, uint64_t o * access the name in this fat-zap so that we'll check * for i/o errors to the leaf blocks, etc. */ - err = zap_lookup(dn->dn_objset, dn->dn_object, name, - 8, 0, NULL); + err = zap_lookup_by_dnode(dn, name, 8, 0, NULL); if (err == EIO) { tx->tx_err = err; return; } } - err = zap_count_write(dn->dn_objset, dn->dn_object, name, add, + err = zap_count_write_by_dnode(dn, name, add, &txh->txh_space_towrite, &txh->txh_space_tooverwrite); /* Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dmu.h ============================================================================== --- stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dmu.h Fri Oct 14 07:37:08 2016 (r307289) +++ stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dmu.h Fri Oct 14 07:39:34 2016 (r307290) @@ -78,6 +78,7 @@ struct file; typedef struct objset objset_t; typedef struct dmu_tx dmu_tx_t; typedef struct dsl_dir dsl_dir_t; +typedef struct dnode dnode_t; typedef enum dmu_object_byteswap { DMU_BSWAP_UINT8, @@ -419,7 +420,7 @@ dmu_write_embedded(objset_t *os, uint64_ #define WP_DMU_SYNC 0x2 #define WP_SPILL 0x4 -void dmu_write_policy(objset_t *os, struct dnode *dn, int level, int wp, +void dmu_write_policy(objset_t *os, dnode_t *dn, int level, int wp, struct zio_prop *zp); /* * The bonus data is accessed more or less like a regular buffer. @@ -445,7 +446,7 @@ int dmu_rm_spill(objset_t *, uint64_t, d */ int dmu_spill_hold_by_bonus(dmu_buf_t *bonus, void *tag, dmu_buf_t **dbp); -int dmu_spill_hold_by_dnode(struct dnode *dn, uint32_t flags, +int dmu_spill_hold_by_dnode(dnode_t *dn, uint32_t flags, void *tag, dmu_buf_t **dbp); int dmu_spill_hold_existing(dmu_buf_t *bonus, void *tag, dmu_buf_t **dbp); @@ -465,6 +466,8 @@ int dmu_spill_hold_existing(dmu_buf_t *b */ int dmu_buf_hold(objset_t *os, uint64_t object, uint64_t offset, void *tag, dmu_buf_t **, int flags); +int dmu_buf_hold_by_dnode(dnode_t *dn, uint64_t offset, + void *tag, dmu_buf_t **dbp, int flags); /* * Add a reference to a dmu buffer that has already been held via @@ -618,6 +621,8 @@ void *dmu_buf_remove_user(dmu_buf_t *db, void *dmu_buf_get_user(dmu_buf_t *db); objset_t *dmu_buf_get_objset(dmu_buf_t *db); +dnode_t *dmu_buf_dnode_enter(dmu_buf_t *db); +void dmu_buf_dnode_exit(dmu_buf_t *db); /* Block until any in-progress dmu buf user evictions complete. */ void dmu_buf_user_evict_wait(void); @@ -801,7 +806,7 @@ extern const dmu_object_byteswap_info_t */ int dmu_object_info(objset_t *os, uint64_t object, dmu_object_info_t *doi); /* Like dmu_object_info, but faster if you have a held dnode in hand. */ -void dmu_object_info_from_dnode(struct dnode *dn, dmu_object_info_t *doi); +void dmu_object_info_from_dnode(dnode_t *dn, dmu_object_info_t *doi); /* Like dmu_object_info, but faster if you have a held dbuf in hand. */ void dmu_object_info_from_db(dmu_buf_t *db, dmu_object_info_t *doi); /* Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dnode.h ============================================================================== --- stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dnode.h Fri Oct 14 07:37:08 2016 (r307289) +++ stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dnode.h Fri Oct 14 07:39:34 2016 (r307290) @@ -20,7 +20,7 @@ */ /* * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2012, 2014 by Delphix. All rights reserved. + * Copyright (c) 2012, 2016 by Delphix. All rights reserved. * Copyright (c) 2014 Spectra Logic Corporation, All rights reserved. */ @@ -149,7 +149,7 @@ typedef struct dnode_phys { blkptr_t dn_spill; } dnode_phys_t; -typedef struct dnode { +struct dnode { /* * Protects the structure of the dnode, including the number of levels * of indirection (dn_nlevels), dn_maxblkid, and dn_next_* @@ -247,7 +247,7 @@ typedef struct dnode { /* holds prefetch structure */ struct zfetch dn_zfetch; -} dnode_t; +}; /* * Adds a level of indirection between the dbuf and the dnode to avoid Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zap.h ============================================================================== --- stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zap.h Fri Oct 14 07:37:08 2016 (r307289) +++ stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zap.h Fri Oct 14 07:39:34 2016 (r307290) @@ -20,7 +20,7 @@ */ /* * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2012, 2015 by Delphix. All rights reserved. + * Copyright (c) 2012, 2016 by Delphix. All rights reserved. */ #ifndef _SYS_ZAP_H @@ -216,8 +216,14 @@ int zap_lookup_uint64(objset_t *os, uint int zap_contains(objset_t *ds, uint64_t zapobj, const char *name); int zap_prefetch_uint64(objset_t *os, uint64_t zapobj, const uint64_t *key, int key_numints); +int zap_lookup_by_dnode(dnode_t *dn, const char *name, + uint64_t integer_size, uint64_t num_integers, void *buf); +int zap_lookup_norm_by_dnode(dnode_t *dn, const char *name, + uint64_t integer_size, uint64_t num_integers, void *buf, + matchtype_t mt, char *realname, int rn_len, + boolean_t *ncp); -int zap_count_write(objset_t *os, uint64_t zapobj, const char *name, +int zap_count_write_by_dnode(dnode_t *dn, const char *name, int add, refcount_t *towrite, refcount_t *tooverwrite); /* Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zap.c ============================================================================== --- stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zap.c Fri Oct 14 07:37:08 2016 (r307289) +++ stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zap.c Fri Oct 14 07:39:34 2016 (r307290) @@ -270,6 +270,7 @@ zap_table_load(zap_t *zap, zap_table_phy uint64_t blk, off; int err; dmu_buf_t *db; + dnode_t *dn; int bs = FZAP_BLOCK_SHIFT(zap); ASSERT(RW_LOCK_HELD(&zap->zap_rwlock)); @@ -277,8 +278,15 @@ zap_table_load(zap_t *zap, zap_table_phy blk = idx >> (bs-3); off = idx & ((1<<(bs-3))-1); - err = dmu_buf_hold(zap->zap_objset, zap->zap_object, + /* + * Note: this is equivalent to dmu_buf_hold(), but we use + * _dnode_enter / _by_dnode because it's faster because we don't + * have to hold the dnode. + */ + dn = dmu_buf_dnode_enter(zap->zap_dbuf); + err = dmu_buf_hold_by_dnode(dn, (tbl->zt_blk + blk) << bs, FTAG, &db, DMU_READ_NO_PREFETCH); + dmu_buf_dnode_exit(zap->zap_dbuf); if (err) return (err); *valp = ((uint64_t *)db->db_data)[off]; @@ -292,9 +300,11 @@ zap_table_load(zap_t *zap, zap_table_phy */ blk = (idx*2) >> (bs-3); - err = dmu_buf_hold(zap->zap_objset, zap->zap_object, + dn = dmu_buf_dnode_enter(zap->zap_dbuf); + err = dmu_buf_hold_by_dnode(dn, (tbl->zt_nextblk + blk) << bs, FTAG, &db, DMU_READ_NO_PREFETCH); + dmu_buf_dnode_exit(zap->zap_dbuf); if (err == 0) dmu_buf_rele(db, FTAG); } @@ -505,8 +515,10 @@ zap_get_leaf_byblk(zap_t *zap, uint64_t ASSERT(RW_LOCK_HELD(&zap->zap_rwlock)); - err = dmu_buf_hold(zap->zap_objset, zap->zap_object, + dnode_t *dn = dmu_buf_dnode_enter(zap->zap_dbuf); + err = dmu_buf_hold_by_dnode(dn, blkid << bs, NULL, &db, DMU_READ_NO_PREFETCH); + dmu_buf_dnode_exit(zap->zap_dbuf); if (err) return (err); Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zap_micro.c ============================================================================== --- stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zap_micro.c Fri Oct 14 07:37:08 2016 (r307289) +++ stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zap_micro.c Fri Oct 14 07:39:34 2016 (r307290) @@ -550,6 +550,24 @@ zap_lockdir_impl(dmu_buf_t *db, void *ta return (0); } +static int +zap_lockdir_by_dnode(dnode_t *dn, dmu_tx_t *tx, + krw_t lti, boolean_t fatreader, boolean_t adding, void *tag, zap_t **zapp) +{ + dmu_buf_t *db; + int err; + + err = dmu_buf_hold_by_dnode(dn, 0, tag, &db, DMU_READ_NO_PREFETCH); + if (err != 0) { + return (err); + } + err = zap_lockdir_impl(db, tag, tx, lti, fatreader, adding, zapp); + if (err != 0) { + dmu_buf_rele(db, tag); + } + return (err); +} + int zap_lockdir(objset_t *os, uint64_t obj, dmu_tx_t *tx, krw_t lti, boolean_t fatreader, boolean_t adding, void *tag, zap_t **zapp) @@ -875,6 +893,33 @@ zap_lookup_norm(objset_t *os, uint64_t z } int +zap_lookup_by_dnode(dnode_t *dn, const char *name, + uint64_t integer_size, uint64_t num_integers, void *buf) +{ + return (zap_lookup_norm_by_dnode(dn, name, integer_size, + num_integers, buf, MT_EXACT, NULL, 0, NULL)); +} + +int +zap_lookup_norm_by_dnode(dnode_t *dn, const char *name, + uint64_t integer_size, uint64_t num_integers, void *buf, + matchtype_t mt, char *realname, int rn_len, + boolean_t *ncp) +{ + zap_t *zap; + int err; + + err = zap_lockdir_by_dnode(dn, NULL, RW_READER, TRUE, FALSE, + FTAG, &zap); + if (err != 0) + return (err); + err = zap_lookup_impl(zap, name, integer_size, + num_integers, buf, mt, realname, rn_len, ncp); + zap_unlockdir(zap, FTAG); + return (err); +} + +int zap_prefetch_uint64(objset_t *os, uint64_t zapobj, const uint64_t *key, int key_numints) { @@ -1445,7 +1490,7 @@ zap_get_stats(objset_t *os, uint64_t zap } int -zap_count_write(objset_t *os, uint64_t zapobj, const char *name, int add, +zap_count_write_by_dnode(dnode_t *dn, const char *name, int add, refcount_t *towrite, refcount_t *tooverwrite) { zap_t *zap; @@ -1474,7 +1519,7 @@ zap_count_write(objset_t *os, uint64_t z * At present we are just evaluating the possibility of this operation * and hence we do not want to trigger an upgrade. */ - err = zap_lockdir(os, zapobj, NULL, RW_READER, TRUE, FALSE, + err = zap_lockdir_by_dnode(dn, NULL, RW_READER, TRUE, FALSE, FTAG, &zap); if (err != 0) return (err); From owner-svn-src-all@freebsd.org Fri Oct 14 07:40:07 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 34BA6C11F77; Fri, 14 Oct 2016 07:40:07 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id C49A61D73; Fri, 14 Oct 2016 07:40:06 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9E7e5Sv069809; Fri, 14 Oct 2016 07:40:05 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9E7e5Ts069800; Fri, 14 Oct 2016 07:40:05 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610140740.u9E7e5Ts069800@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Fri, 14 Oct 2016 07:40:05 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307291 - in stable/11/sys/dev/hyperv: include netvsc vmbus X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Oct 2016 07:40:07 -0000 Author: sephe Date: Fri Oct 14 07:40:04 2016 New Revision: 307291 URL: https://svnweb.freebsd.org/changeset/base/307291 Log: MFC 302543-302545,302547,302549,302554,302556,302557,302559,302606 302543 hyperv/vmbus: Use post message Hypercall APIs for channel request Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D6831 302544 hyperv/hn: Add tunable to allow tcp_lro_queue_mbuf() Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D6841 302545 hyperv/vmbus: Function renaming. And pass vmbus_softc to vmbus_doattach() Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D6842 302547 hyperv/vmbus: Explicitly assign channel message process array. While I'm here, remove the useless message type from message process array, which is not used and serves no purposes at all. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D6858 302549 hyperv/vmbus: Add sysctl to expose vmbus version. Requested by: Hongxiong Xian Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D6860 302554 hyperv/vmbus: Use post message Hypercall APIs for unload Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D6861 302556 hyperv/vmbus: Create channel synchronously. The device probe/attach has been move to a different thread, so the reasons to create the channel asynchronously are no longer valid. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D6862 302557 hyperv/vmbus: Save vmbus softc to channels. So that we don't need to access the global vmbus softc. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D6863 302559 hyperv/vmbus: Embed channel detach task in channel itself. GC work queue stuffs. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D6864 302606 hyperv/vmbus: Reorganize vmbus scan process. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D6875 Modified: stable/11/sys/dev/hyperv/include/hyperv.h stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c stable/11/sys/dev/hyperv/vmbus/hv_channel.c stable/11/sys/dev/hyperv/vmbus/hv_channel_mgmt.c stable/11/sys/dev/hyperv/vmbus/hv_connection.c stable/11/sys/dev/hyperv/vmbus/hv_vmbus_priv.h stable/11/sys/dev/hyperv/vmbus/vmbus.c stable/11/sys/dev/hyperv/vmbus/vmbus_reg.h stable/11/sys/dev/hyperv/vmbus/vmbus_var.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/hyperv/include/hyperv.h ============================================================================== --- stable/11/sys/dev/hyperv/include/hyperv.h Fri Oct 14 07:39:34 2016 (r307290) +++ stable/11/sys/dev/hyperv/include/hyperv.h Fri Oct 14 07:40:04 2016 (r307291) @@ -713,6 +713,7 @@ typedef struct { typedef struct hv_vmbus_channel { TAILQ_ENTRY(hv_vmbus_channel) list_entry; struct hv_device* device; + struct vmbus_softc *vmbus_sc; hv_vmbus_channel_state state; hv_vmbus_channel_offer_channel offer_msg; /* @@ -808,6 +809,8 @@ typedef struct hv_vmbus_channel { void *hv_chan_priv1; void *hv_chan_priv2; void *hv_chan_priv3; + + struct task ch_detach_task; } hv_vmbus_channel; #define HV_VMBUS_CHAN_ISPRIMARY(chan) ((chan)->primary_channel == NULL) Modified: stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Fri Oct 14 07:39:34 2016 (r307290) +++ stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Fri Oct 14 07:40:04 2016 (r307291) @@ -299,6 +299,12 @@ static int hn_tx_swq_depth = 0; SYSCTL_INT(_hw_hn, OID_AUTO, tx_swq_depth, CTLFLAG_RDTUN, &hn_tx_swq_depth, 0, "Depth of IFQ or BUFRING"); +#if __FreeBSD_version >= 1100095 +static u_int hn_lro_mbufq_depth = 0; +SYSCTL_UINT(_hw_hn, OID_AUTO, lro_mbufq_depth, CTLFLAG_RDTUN, + &hn_lro_mbufq_depth, 0, "Depth of LRO mbuf queue"); +#endif + static u_int hn_cpu_index; /* @@ -1283,6 +1289,19 @@ hv_m_append(struct mbuf *m0, int len, c_ return (remainder == 0); } +#if defined(INET) || defined(INET6) +static __inline int +hn_lro_rx(struct lro_ctrl *lc, struct mbuf *m) +{ +#if __FreeBSD_version >= 1100095 + if (hn_lro_mbufq_depth) { + tcp_lro_queue_mbuf(lc, m); + return 0; + } +#endif + return tcp_lro_rx(lc, m, 0); +} +#endif /* * Called when we receive a data packet from the "wire" on the @@ -1488,7 +1507,7 @@ skip: if (lro->lro_cnt) { rxr->hn_lro_tried++; - if (tcp_lro_rx(lro, m_new, 0) == 0) { + if (hn_lro_rx(lro, m_new) == 0) { /* DONE! */ return 0; } @@ -2223,7 +2242,8 @@ hn_create_rx_data(struct hn_softc *sc, i */ #if defined(INET) || defined(INET6) #if __FreeBSD_version >= 1100095 - tcp_lro_init_args(&rxr->hn_lro, sc->hn_ifp, lroent_cnt, 0); + tcp_lro_init_args(&rxr->hn_lro, sc->hn_ifp, lroent_cnt, + hn_lro_mbufq_depth); #else tcp_lro_init(&rxr->hn_lro); rxr->hn_lro.ifp = sc->hn_ifp; Modified: stable/11/sys/dev/hyperv/vmbus/hv_channel.c ============================================================================== --- stable/11/sys/dev/hyperv/vmbus/hv_channel.c Fri Oct 14 07:39:34 2016 (r307290) +++ stable/11/sys/dev/hyperv/vmbus/hv_channel.c Fri Oct 14 07:40:04 2016 (r307291) @@ -67,7 +67,7 @@ static void vmbus_channel_set_event(hv_vmbus_channel *channel) { if (channel->offer_msg.monitor_allocated) { - struct vmbus_softc *sc = vmbus_get_softc(); + struct vmbus_softc *sc = channel->vmbus_sc; hv_vmbus_monitor_page *monitor_page; uint32_t chanid = channel->offer_msg.child_rel_id; @@ -205,7 +205,7 @@ hv_vmbus_channel_open( vmbus_on_channel_open(new_channel); - new_channel->rxq = VMBUS_PCPU_GET(vmbus_get_softc(), event_tq, + new_channel->rxq = VMBUS_PCPU_GET(new_channel->vmbus_sc, event_tq, new_channel->target_cpu); TASK_INIT(&new_channel->channel_task, 0, VmbusProcessChannelEvent, new_channel); Modified: stable/11/sys/dev/hyperv/vmbus/hv_channel_mgmt.c ============================================================================== --- stable/11/sys/dev/hyperv/vmbus/hv_channel_mgmt.c Fri Oct 14 07:39:34 2016 (r307290) +++ stable/11/sys/dev/hyperv/vmbus/hv_channel_mgmt.c Fri Oct 14 07:40:04 2016 (r307291) @@ -36,19 +36,13 @@ #include #include -/* - * Internal functions - */ +typedef void (*vmbus_chanmsg_proc_t) + (struct vmbus_softc *, const struct vmbus_message *); -typedef struct hv_vmbus_channel_msg_table_entry { - hv_vmbus_channel_msg_type messageType; - void (*messageHandler) - (struct vmbus_softc *sc, - const struct vmbus_message *msg); -} hv_vmbus_channel_msg_table_entry; - -static void vmbus_channel_on_offer_internal(void *context); -static void vmbus_channel_on_offer_rescind_internal(void *context); +static struct hv_vmbus_channel *hv_vmbus_allocate_channel(struct vmbus_softc *); +static void vmbus_channel_on_offer_internal(struct vmbus_softc *, + const hv_vmbus_channel_offer_channel *offer); +static void vmbus_chan_detach_task(void *, int); static void vmbus_channel_on_offer(struct vmbus_softc *, const struct vmbus_message *); @@ -68,108 +62,38 @@ static void vmbus_channel_on_version_res /** * Channel message dispatch table */ -static const hv_vmbus_channel_msg_table_entry - g_channel_message_table[HV_CHANNEL_MESSAGE_COUNT] = { - { HV_CHANNEL_MESSAGE_INVALID, - NULL }, - { HV_CHANNEL_MESSAGE_OFFER_CHANNEL, - vmbus_channel_on_offer }, - { HV_CHANNEL_MESSAGE_RESCIND_CHANNEL_OFFER, - vmbus_channel_on_offer_rescind }, - { HV_CHANNEL_MESSAGE_REQUEST_OFFERS, - NULL }, - { HV_CHANNEL_MESSAGE_ALL_OFFERS_DELIVERED, - vmbus_channel_on_offers_delivered }, - { HV_CHANNEL_MESSAGE_OPEN_CHANNEL, - NULL }, - { HV_CHANNEL_MESSAGE_OPEN_CHANNEL_RESULT, - vmbus_channel_on_open_result }, - { HV_CHANNEL_MESSAGE_CLOSE_CHANNEL, - NULL }, - { HV_CHANNEL_MESSAGEL_GPADL_HEADER, - NULL }, - { HV_CHANNEL_MESSAGE_GPADL_BODY, - NULL }, - { HV_CHANNEL_MESSAGE_GPADL_CREATED, - vmbus_channel_on_gpadl_created }, - { HV_CHANNEL_MESSAGE_GPADL_TEARDOWN, - NULL }, - { HV_CHANNEL_MESSAGE_GPADL_TORNDOWN, - vmbus_channel_on_gpadl_torndown }, - { HV_CHANNEL_MESSAGE_REL_ID_RELEASED, - NULL }, - { HV_CHANNEL_MESSAGE_INITIATED_CONTACT, - NULL }, - { HV_CHANNEL_MESSAGE_VERSION_RESPONSE, - vmbus_channel_on_version_response }, - { HV_CHANNEL_MESSAGE_UNLOAD, - NULL } +static const vmbus_chanmsg_proc_t +vmbus_chanmsg_process[HV_CHANNEL_MESSAGE_COUNT] = { + [HV_CHANNEL_MESSAGE_OFFER_CHANNEL] = + vmbus_channel_on_offer, + [HV_CHANNEL_MESSAGE_RESCIND_CHANNEL_OFFER] = + vmbus_channel_on_offer_rescind, + [HV_CHANNEL_MESSAGE_ALL_OFFERS_DELIVERED] = + vmbus_channel_on_offers_delivered, + [HV_CHANNEL_MESSAGE_OPEN_CHANNEL_RESULT] = + vmbus_channel_on_open_result, + [HV_CHANNEL_MESSAGE_GPADL_CREATED] = + vmbus_channel_on_gpadl_created, + [HV_CHANNEL_MESSAGE_GPADL_TORNDOWN] = + vmbus_channel_on_gpadl_torndown, + [HV_CHANNEL_MESSAGE_VERSION_RESPONSE] = + vmbus_channel_on_version_response }; -typedef struct hv_work_item { - struct task work; - void (*callback)(void *); - void* context; -} hv_work_item; - -static struct mtx vmbus_chwait_lock; -MTX_SYSINIT(vmbus_chwait_lk, &vmbus_chwait_lock, "vmbus primarych wait lock", - MTX_DEF); -static uint32_t vmbus_chancnt; -static uint32_t vmbus_devcnt; - -#define VMBUS_CHANCNT_DONE 0x80000000 - -/** - * Implementation of the work abstraction. - */ -static void -work_item_callback(void *work, int pending) -{ - struct hv_work_item *w = (struct hv_work_item *)work; - - w->callback(w->context); - - free(w, M_DEVBUF); -} - -/** - * @brief Create work item - */ -static int -hv_queue_work_item( - void (*callback)(void *), void *context) -{ - struct hv_work_item *w = malloc(sizeof(struct hv_work_item), - M_DEVBUF, M_NOWAIT); - KASSERT(w != NULL, ("Error VMBUS: Failed to allocate WorkItem\n")); - if (w == NULL) - return (ENOMEM); - - w->callback = callback; - w->context = context; - - TASK_INIT(&w->work, 0, work_item_callback, w); - - return (taskqueue_enqueue(taskqueue_thread, &w->work)); -} - - /** * @brief Allocate and initialize a vmbus channel object */ -hv_vmbus_channel* -hv_vmbus_allocate_channel(void) +static struct hv_vmbus_channel * +hv_vmbus_allocate_channel(struct vmbus_softc *sc) { - hv_vmbus_channel* channel; + struct hv_vmbus_channel *channel; - channel = (hv_vmbus_channel*) malloc( - sizeof(hv_vmbus_channel), - M_DEVBUF, - M_WAITOK | M_ZERO); + channel = malloc(sizeof(*channel), M_DEVBUF, M_WAITOK | M_ZERO); + channel->vmbus_sc = sc; mtx_init(&channel->sc_lock, "vmbus multi channel", NULL, MTX_DEF); TAILQ_INIT(&channel->sc_list_anchor); + TASK_INIT(&channel->ch_detach_task, 0, vmbus_chan_detach_task, channel); return (channel); } @@ -192,7 +116,6 @@ static void vmbus_channel_process_offer(hv_vmbus_channel *new_channel) { hv_vmbus_channel* channel; - int ret; uint32_t relid; relid = new_channel->offer_msg.child_rel_id; @@ -297,19 +220,8 @@ vmbus_channel_process_offer(hv_vmbus_cha * binding which eventually invokes the device driver's AddDevice() * method. */ - ret = hv_vmbus_child_device_register(new_channel->device); - if (ret != 0) { - mtx_lock(&hv_vmbus_g_connection.channel_lock); - TAILQ_REMOVE(&hv_vmbus_g_connection.channel_anchor, - new_channel, list_entry); - mtx_unlock(&hv_vmbus_g_connection.channel_lock); - hv_vmbus_free_vmbus_channel(new_channel); - } - - mtx_lock(&vmbus_chwait_lock); - vmbus_devcnt++; - mtx_unlock(&vmbus_chwait_lock); - wakeup(&vmbus_devcnt); + hv_vmbus_child_device_register(new_channel->vmbus_sc, + new_channel->device); } void @@ -324,7 +236,7 @@ vmbus_channel_cpu_set(struct hv_vmbus_ch } chan->target_cpu = cpu; - chan->target_vcpu = VMBUS_PCPU_GET(vmbus_get_softc(), vcpuid, cpu); + chan->target_vcpu = VMBUS_PCPU_GET(chan->vmbus_sc, vcpuid, cpu); if (bootverbose) { printf("vmbus_chan%u: assigned to cpu%u [vcpu%u]\n", @@ -393,46 +305,28 @@ vmbus_channel_select_defcpu(struct hv_vm /** * @brief Handler for channel offers from Hyper-V/Azure * - * Handler for channel offers from vmbus in parent partition. We ignore - * all offers except network and storage offers. For each network and storage - * offers, we create a channel object and queue a work item to the channel - * object to process the offer synchronously + * Handler for channel offers from vmbus in parent partition. */ static void vmbus_channel_on_offer(struct vmbus_softc *sc, const struct vmbus_message *msg) { - const hv_vmbus_channel_msg_header *hdr = - (const hv_vmbus_channel_msg_header *)msg->msg_data; - const hv_vmbus_channel_offer_channel *offer; - hv_vmbus_channel_offer_channel *copied; - offer = (const hv_vmbus_channel_offer_channel *)hdr; + /* New channel is offered by vmbus */ + vmbus_scan_newchan(sc); - // copy offer data - copied = malloc(sizeof(*copied), M_DEVBUF, M_NOWAIT); - if (copied == NULL) { - printf("fail to allocate memory\n"); - return; - } - - memcpy(copied, hdr, sizeof(*copied)); - hv_queue_work_item(vmbus_channel_on_offer_internal, copied); - - mtx_lock(&vmbus_chwait_lock); - if ((vmbus_chancnt & VMBUS_CHANCNT_DONE) == 0) - vmbus_chancnt++; - mtx_unlock(&vmbus_chwait_lock); + offer = (const hv_vmbus_channel_offer_channel *)msg->msg_data; + vmbus_channel_on_offer_internal(sc, offer); } static void -vmbus_channel_on_offer_internal(void* context) +vmbus_channel_on_offer_internal(struct vmbus_softc *sc, + const hv_vmbus_channel_offer_channel *offer) { hv_vmbus_channel* new_channel; - hv_vmbus_channel_offer_channel* offer = (hv_vmbus_channel_offer_channel*)context; /* Allocate the channel object and save this offer */ - new_channel = hv_vmbus_allocate_channel(); + new_channel = hv_vmbus_allocate_channel(sc); /* * By default we setup state to enable batched @@ -469,45 +363,41 @@ vmbus_channel_on_offer_internal(void* co vmbus_channel_select_defcpu(new_channel); vmbus_channel_process_offer(new_channel); - - free(offer, M_DEVBUF); } /** * @brief Rescind offer handler. * * We queue a work item to process this offer - * synchronously + * synchronously. + * + * XXX pretty broken; need rework. */ static void vmbus_channel_on_offer_rescind(struct vmbus_softc *sc, const struct vmbus_message *msg) { - const hv_vmbus_channel_msg_header *hdr = - (const hv_vmbus_channel_msg_header *)msg->msg_data; - const hv_vmbus_channel_rescind_offer *rescind; hv_vmbus_channel* channel; - rescind = (const hv_vmbus_channel_rescind_offer *)hdr; + rescind = (const hv_vmbus_channel_rescind_offer *)msg->msg_data; channel = hv_vmbus_g_connection.channels[rescind->child_rel_id]; if (channel == NULL) return; - - hv_queue_work_item(vmbus_channel_on_offer_rescind_internal, channel); hv_vmbus_g_connection.channels[rescind->child_rel_id] = NULL; + + taskqueue_enqueue(taskqueue_thread, &channel->ch_detach_task); } static void -vmbus_channel_on_offer_rescind_internal(void *context) +vmbus_chan_detach_task(void *xchan, int pending __unused) { - hv_vmbus_channel* channel; + struct hv_vmbus_channel *chan = xchan; - channel = (hv_vmbus_channel*)context; - if (HV_VMBUS_CHAN_ISPRIMARY(channel)) { + if (HV_VMBUS_CHAN_ISPRIMARY(chan)) { /* Only primary channel owns the hv_device */ - hv_vmbus_child_device_unregister(channel->device); + hv_vmbus_child_device_unregister(chan->device); } } @@ -516,14 +406,12 @@ vmbus_channel_on_offer_rescind_internal( * @brief Invoked when all offers have been delivered. */ static void -vmbus_channel_on_offers_delivered(struct vmbus_softc *sc __unused, +vmbus_channel_on_offers_delivered(struct vmbus_softc *sc, const struct vmbus_message *msg __unused) { - mtx_lock(&vmbus_chwait_lock); - vmbus_chancnt |= VMBUS_CHANCNT_DONE; - mtx_unlock(&vmbus_chwait_lock); - wakeup(&vmbus_chancnt); + /* No more new channels for the channel request. */ + vmbus_scan_done(sc); } /** @@ -675,36 +563,6 @@ vmbus_channel_on_version_response(struct } /** - * @brief Send a request to get all our pending offers. - */ -int -hv_vmbus_request_channel_offers(void) -{ - int ret; - hv_vmbus_channel_msg_header* msg; - hv_vmbus_channel_msg_info* msg_info; - - msg_info = (hv_vmbus_channel_msg_info *) - malloc(sizeof(hv_vmbus_channel_msg_info) - + sizeof(hv_vmbus_channel_msg_header), M_DEVBUF, M_NOWAIT); - - if (msg_info == NULL) { - if(bootverbose) - printf("Error VMBUS: malloc failed for Request Offers\n"); - return (ENOMEM); - } - - msg = (hv_vmbus_channel_msg_header*) msg_info->msg; - msg->message_type = HV_CHANNEL_MESSAGE_REQUEST_OFFERS; - - ret = hv_vmbus_post_message(msg, sizeof(hv_vmbus_channel_msg_header)); - - free(msg_info, M_DEVBUF); - - return (ret); -} - -/** * @brief Release channels that are unattached/unconnected (i.e., no drivers associated) */ void @@ -757,7 +615,7 @@ vmbus_select_outgoing_channel(struct hv_ return outgoing_channel; } - cur_vcpu = VMBUS_PCPU_GET(vmbus_get_softc(), vcpuid, smp_pro_id); + cur_vcpu = VMBUS_PCPU_GET(primary->vmbus_sc, vcpuid, smp_pro_id); TAILQ_FOREACH(new_channel, &primary->sc_list_anchor, sc_list_entry) { if (new_channel->state != HV_CHANNEL_OPENED_STATE){ @@ -786,21 +644,6 @@ vmbus_select_outgoing_channel(struct hv_ return(outgoing_channel); } -void -vmbus_scan(void) -{ - uint32_t chancnt; - - mtx_lock(&vmbus_chwait_lock); - while ((vmbus_chancnt & VMBUS_CHANCNT_DONE) == 0) - mtx_sleep(&vmbus_chancnt, &vmbus_chwait_lock, 0, "waitch", 0); - chancnt = vmbus_chancnt & ~VMBUS_CHANCNT_DONE; - - while (vmbus_devcnt != chancnt) - mtx_sleep(&vmbus_devcnt, &vmbus_chwait_lock, 0, "waitdev", 0); - mtx_unlock(&vmbus_chwait_lock); -} - struct hv_vmbus_channel ** vmbus_get_subchan(struct hv_vmbus_channel *pri_chan, int subchan_cnt) { @@ -842,20 +685,17 @@ vmbus_rel_subchan(struct hv_vmbus_channe void vmbus_chan_msgproc(struct vmbus_softc *sc, const struct vmbus_message *msg) { - const hv_vmbus_channel_msg_table_entry *entry; - const hv_vmbus_channel_msg_header *hdr; - hv_vmbus_channel_msg_type msg_type; - - hdr = (const hv_vmbus_channel_msg_header *)msg->msg_data; - msg_type = hdr->message_type; + vmbus_chanmsg_proc_t msg_proc; + uint32_t msg_type; + msg_type = ((const struct vmbus_chanmsg_hdr *)msg->msg_data)->chm_type; if (msg_type >= HV_CHANNEL_MESSAGE_COUNT) { device_printf(sc->vmbus_dev, "unknown message type 0x%x\n", msg_type); return; } - entry = &g_channel_message_table[msg_type]; - if (entry->messageHandler) - entry->messageHandler(sc, msg); + msg_proc = vmbus_chanmsg_process[msg_type]; + if (msg_proc != NULL) + msg_proc(sc, msg); } Modified: stable/11/sys/dev/hyperv/vmbus/hv_connection.c ============================================================================== --- stable/11/sys/dev/hyperv/vmbus/hv_connection.c Fri Oct 14 07:39:34 2016 (r307290) +++ stable/11/sys/dev/hyperv/vmbus/hv_connection.c Fri Oct 14 07:40:04 2016 (r307291) @@ -92,19 +92,13 @@ hv_vmbus_connect(struct vmbus_softc *sc) int hv_vmbus_disconnect(void) { - int ret = 0; - hv_vmbus_channel_unload msg; - - msg.message_type = HV_CHANNEL_MESSAGE_UNLOAD; - - ret = hv_vmbus_post_message(&msg, sizeof(hv_vmbus_channel_unload)); mtx_destroy(&hv_vmbus_g_connection.channel_msg_lock); free(hv_vmbus_g_connection.channels, M_DEVBUF); hv_vmbus_g_connection.connect_state = HV_DISCONNECTED; - return (ret); + return (0); } static __inline void @@ -210,7 +204,7 @@ int hv_vmbus_post_message(void *buffer, int hv_vmbus_set_event(hv_vmbus_channel *channel) { - struct vmbus_softc *sc = vmbus_get_softc(); + struct vmbus_softc *sc = channel->vmbus_sc; int ret = 0; uint32_t chanid = channel->offer_msg.child_rel_id; @@ -228,7 +222,7 @@ vmbus_on_channel_open(const struct hv_vm int flag_cnt; flag_cnt = (chan->offer_msg.child_rel_id / VMBUS_EVTFLAG_LEN) + 1; - flag_cnt_ptr = VMBUS_PCPU_PTR(vmbus_get_softc(), event_flags_cnt, + flag_cnt_ptr = VMBUS_PCPU_PTR(chan->vmbus_sc, event_flags_cnt, chan->target_cpu); for (;;) { Modified: stable/11/sys/dev/hyperv/vmbus/hv_vmbus_priv.h ============================================================================== --- stable/11/sys/dev/hyperv/vmbus/hv_vmbus_priv.h Fri Oct 14 07:39:34 2016 (r307290) +++ stable/11/sys/dev/hyperv/vmbus/hv_vmbus_priv.h Fri Oct 14 07:40:04 2016 (r307291) @@ -395,9 +395,7 @@ void hv_ring_buffer_read_begin( uint32_t hv_ring_buffer_read_end( hv_vmbus_ring_buffer_info *ring_info); -hv_vmbus_channel* hv_vmbus_allocate_channel(void); void hv_vmbus_free_vmbus_channel(hv_vmbus_channel *channel); -int hv_vmbus_request_channel_offers(void); void hv_vmbus_release_unattached_channels(void); uint16_t hv_vmbus_post_msg_via_msg_ipc( @@ -413,7 +411,9 @@ struct hv_device* hv_vmbus_child_device_ hv_guid device_instance, hv_vmbus_channel *channel); -int hv_vmbus_child_device_register( +struct vmbus_softc; + +void hv_vmbus_child_device_register(struct vmbus_softc *, struct hv_device *child_dev); int hv_vmbus_child_device_unregister( struct hv_device *child_dev); @@ -421,13 +421,9 @@ int hv_vmbus_child_device_unregister( /** * Connection interfaces */ -struct vmbus_softc; int hv_vmbus_connect(struct vmbus_softc *); int hv_vmbus_disconnect(void); int hv_vmbus_post_message(void *buffer, size_t buf_size); int hv_vmbus_set_event(hv_vmbus_channel *channel); -/* Wait for device creation */ -void vmbus_scan(void); - #endif /* __HYPERV_PRIV_H__ */ Modified: stable/11/sys/dev/hyperv/vmbus/vmbus.c ============================================================================== --- stable/11/sys/dev/hyperv/vmbus/vmbus.c Fri Oct 14 07:39:34 2016 (r307290) +++ stable/11/sys/dev/hyperv/vmbus/vmbus.c Fri Oct 14 07:40:04 2016 (r307291) @@ -98,6 +98,13 @@ struct vmbus_msghc_ctx { static int vmbus_init(struct vmbus_softc *); static int vmbus_init_contact(struct vmbus_softc *, uint32_t); +static int vmbus_req_channels(struct vmbus_softc *sc); +static void vmbus_uninit(struct vmbus_softc *); +static int vmbus_scan(struct vmbus_softc *); +static void vmbus_scan_wait(struct vmbus_softc *); +static void vmbus_scan_newdev(struct vmbus_softc *); + +static int vmbus_sysctl_version(SYSCTL_HANDLER_ARGS); static struct vmbus_msghc_ctx *vmbus_msghc_ctx_create(bus_dma_tag_t); static void vmbus_msghc_ctx_destroy( @@ -418,6 +425,131 @@ vmbus_init(struct vmbus_softc *sc) } static void +vmbus_uninit(struct vmbus_softc *sc) +{ + struct vmbus_chanmsg_unload *req; + struct vmbus_msghc *mh; + int error; + + mh = vmbus_msghc_get(sc, sizeof(*req)); + if (mh == NULL) { + device_printf(sc->vmbus_dev, + "can not get msg hypercall for unload\n"); + return; + } + + req = vmbus_msghc_dataptr(mh); + req->chm_hdr.chm_type = VMBUS_CHANMSG_TYPE_UNLOAD; + + error = vmbus_msghc_exec_noresult(mh); + vmbus_msghc_put(sc, mh); + + if (error) { + device_printf(sc->vmbus_dev, + "unload msg hypercall failed\n"); + } +} + +static int +vmbus_req_channels(struct vmbus_softc *sc) +{ + struct vmbus_chanmsg_channel_req *req; + struct vmbus_msghc *mh; + int error; + + mh = vmbus_msghc_get(sc, sizeof(*req)); + if (mh == NULL) + return ENXIO; + + req = vmbus_msghc_dataptr(mh); + req->chm_hdr.chm_type = VMBUS_CHANMSG_TYPE_CHANNEL_REQ; + + error = vmbus_msghc_exec_noresult(mh); + vmbus_msghc_put(sc, mh); + + return error; +} + +void +vmbus_scan_newchan(struct vmbus_softc *sc) +{ + mtx_lock(&sc->vmbus_scan_lock); + if ((sc->vmbus_scan_chcnt & VMBUS_SCAN_CHCNT_DONE) == 0) + sc->vmbus_scan_chcnt++; + mtx_unlock(&sc->vmbus_scan_lock); +} + +void +vmbus_scan_done(struct vmbus_softc *sc) +{ + mtx_lock(&sc->vmbus_scan_lock); + sc->vmbus_scan_chcnt |= VMBUS_SCAN_CHCNT_DONE; + mtx_unlock(&sc->vmbus_scan_lock); + wakeup(&sc->vmbus_scan_chcnt); +} + +static void +vmbus_scan_newdev(struct vmbus_softc *sc) +{ + mtx_lock(&sc->vmbus_scan_lock); + sc->vmbus_scan_devcnt++; + mtx_unlock(&sc->vmbus_scan_lock); + wakeup(&sc->vmbus_scan_devcnt); +} + +static void +vmbus_scan_wait(struct vmbus_softc *sc) +{ + uint32_t chancnt; + + mtx_lock(&sc->vmbus_scan_lock); + while ((sc->vmbus_scan_chcnt & VMBUS_SCAN_CHCNT_DONE) == 0) { + mtx_sleep(&sc->vmbus_scan_chcnt, &sc->vmbus_scan_lock, 0, + "waitch", 0); + } + chancnt = sc->vmbus_scan_chcnt & ~VMBUS_SCAN_CHCNT_DONE; + + while (sc->vmbus_scan_devcnt != chancnt) { + mtx_sleep(&sc->vmbus_scan_devcnt, &sc->vmbus_scan_lock, 0, + "waitdev", 0); + } + mtx_unlock(&sc->vmbus_scan_lock); +} + +static int +vmbus_scan(struct vmbus_softc *sc) +{ + int error; + + /* + * Start vmbus scanning. + */ + error = vmbus_req_channels(sc); + if (error) { + device_printf(sc->vmbus_dev, "channel request failed: %d\n", + error); + return error; + } + + /* + * Wait for all devices are added to vmbus. + */ + vmbus_scan_wait(sc); + + /* + * Identify, probe and attach. + */ + bus_generic_probe(sc->vmbus_dev); + bus_generic_attach(sc->vmbus_dev); + + if (bootverbose) { + device_printf(sc->vmbus_dev, "device scan, probe and attach " + "done\n"); + } + return 0; +} + +static void vmbus_msg_task(void *xsc, int pending __unused) { struct vmbus_softc *sc = xsc; @@ -892,12 +1024,13 @@ hv_vmbus_child_device_create(hv_guid typ return (child_dev); } -int -hv_vmbus_child_device_register(struct hv_device *child_dev) +void +hv_vmbus_child_device_register(struct vmbus_softc *sc, + struct hv_device *child_dev) { device_t child, parent; - parent = vmbus_get_device(); + parent = sc->vmbus_dev; if (bootverbose) { char name[HYPERV_GUID_STRLEN]; @@ -909,7 +1042,8 @@ hv_vmbus_child_device_register(struct hv child_dev->device = child; device_set_ivars(child, child_dev); - return (0); + /* New device was added to vmbus */ + vmbus_scan_newdev(sc); } int @@ -927,6 +1061,17 @@ hv_vmbus_child_device_unregister(struct } static int +vmbus_sysctl_version(SYSCTL_HANDLER_ARGS) +{ + char verstr[16]; + + snprintf(verstr, sizeof(verstr), "%u.%u", + hv_vmbus_protocal_version >> 16, + hv_vmbus_protocal_version & 0xffff); + return sysctl_handle_string(oidp, verstr, sizeof(verstr), req); +} + +static int vmbus_probe(device_t dev) { char *id[] = { "VMBUS", NULL }; @@ -954,15 +1099,18 @@ vmbus_probe(device_t dev) * - retrieve the channel offers */ static int -vmbus_bus_init(void) +vmbus_doattach(struct vmbus_softc *sc) { - struct vmbus_softc *sc = vmbus_get_softc(); + struct sysctl_oid_list *child; + struct sysctl_ctx_list *ctx; int ret; if (sc->vmbus_flags & VMBUS_FLAG_ATTACHED) return (0); sc->vmbus_flags |= VMBUS_FLAG_ATTACHED; + mtx_init(&sc->vmbus_scan_lock, "vmbus scan", NULL, MTX_DEF); + /* * Create context for "post message" Hypercalls */ @@ -1012,11 +1160,15 @@ vmbus_bus_init(void) else sc->vmbus_event_proc = vmbus_event_proc; - hv_vmbus_request_channel_offers(); + ret = vmbus_scan(sc); + if (ret != 0) + goto cleanup; - vmbus_scan(); - bus_generic_attach(sc->vmbus_dev); - device_printf(sc->vmbus_dev, "device scan, probe and attach done\n"); + ctx = device_get_sysctl_ctx(sc->vmbus_dev); + child = SYSCTL_CHILDREN(device_get_sysctl_tree(sc->vmbus_dev)); + SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "version", + CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, NULL, 0, + vmbus_sysctl_version, "A", "vmbus version"); return (ret); @@ -1027,6 +1179,7 @@ cleanup: vmbus_msghc_ctx_destroy(sc->vmbus_msg_hc); sc->vmbus_msg_hc = NULL; } + mtx_destroy(&sc->vmbus_scan_lock); return (ret); } @@ -1059,16 +1212,17 @@ vmbus_attach(device_t dev) */ if (!cold) #endif - vmbus_bus_init(); + vmbus_doattach(vmbus_sc); - bus_generic_probe(dev); return (0); } static void vmbus_sysinit(void *arg __unused) { - if (vm_guest != VM_GUEST_HV || vmbus_get_softc() == NULL) + struct vmbus_softc *sc = vmbus_get_softc(); + + if (vm_guest != VM_GUEST_HV || sc == NULL) return; #ifndef EARLY_AP_STARTUP @@ -1080,7 +1234,7 @@ vmbus_sysinit(void *arg __unused) */ if (!cold) #endif - vmbus_bus_init(); + vmbus_doattach(sc); } static int @@ -1089,6 +1243,8 @@ vmbus_detach(device_t dev) struct vmbus_softc *sc = device_get_softc(dev); hv_vmbus_release_unattached_channels(); + + vmbus_uninit(sc); hv_vmbus_disconnect(); if (sc->vmbus_flags & VMBUS_FLAG_SYNIC) { @@ -1104,6 +1260,7 @@ vmbus_detach(device_t dev) sc->vmbus_msg_hc = NULL; } + mtx_destroy(&sc->vmbus_scan_lock); return (0); } Modified: stable/11/sys/dev/hyperv/vmbus/vmbus_reg.h ============================================================================== --- stable/11/sys/dev/hyperv/vmbus/vmbus_reg.h Fri Oct 14 07:39:34 2016 (r307290) +++ stable/11/sys/dev/hyperv/vmbus/vmbus_reg.h Fri Oct 14 07:40:04 2016 (r307291) @@ -83,8 +83,10 @@ CTASSERT(sizeof(struct vmbus_evtflags) = * - Embedded in hypercall_postmsg_in.hc_data, e.g. request. */ +#define VMBUS_CHANMSG_TYPE_CHANNEL_REQ 3 /* REQ */ #define VMBUS_CHANMSG_TYPE_INIT_CONTACT 14 /* REQ */ #define VMBUS_CHANMSG_TYPE_VERSION_RESP 15 /* RESP */ +#define VMBUS_CHANMSG_TYPE_UNLOAD 16 /* REQ */ struct vmbus_chanmsg_hdr { uint32_t chm_type; /* VMBUS_CHANMSG_TYPE_ */ @@ -107,4 +109,14 @@ struct vmbus_chanmsg_version_resp { uint8_t chm_supp; } __packed; +/* VMBUS_CHANMSG_TYPE_CHANNEL_REQ */ +struct vmbus_chanmsg_channel_req { + struct vmbus_chanmsg_hdr chm_hdr; +} __packed; + +/* VMBUS_CHANMSG_TYPE_UNLOAD */ +struct vmbus_chanmsg_unload { + struct vmbus_chanmsg_hdr chm_hdr; +} __packed; + #endif /* !_VMBUS_REG_H_ */ Modified: stable/11/sys/dev/hyperv/vmbus/vmbus_var.h ============================================================================== --- stable/11/sys/dev/hyperv/vmbus/vmbus_var.h Fri Oct 14 07:39:34 2016 (r307290) +++ stable/11/sys/dev/hyperv/vmbus/vmbus_var.h Fri Oct 14 07:40:04 2016 (r307291) @@ -84,6 +84,11 @@ struct vmbus_softc { void *vmbus_mnf1; /* monitored by VM, unused */ struct hyperv_dma vmbus_mnf1_dma; struct hyperv_dma vmbus_mnf2_dma; + + struct mtx vmbus_scan_lock; + uint32_t vmbus_scan_chcnt; +#define VMBUS_SCAN_CHCNT_DONE 0x80000000 + uint32_t vmbus_scan_devcnt; }; #define VMBUS_FLAG_ATTACHED 0x0001 /* vmbus was attached */ @@ -129,4 +134,7 @@ const struct vmbus_message *vmbus_msghc_ struct vmbus_msghc *); void vmbus_msghc_wakeup(struct vmbus_softc *, const struct vmbus_message *); +void vmbus_scan_done(struct vmbus_softc *); +void vmbus_scan_newchan(struct vmbus_softc *); + #endif /* !_VMBUS_VAR_H_ */ From owner-svn-src-all@freebsd.org Fri Oct 14 07:40:22 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 362A2C11FE9; Fri, 14 Oct 2016 07:40:22 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id F1E0A1ED6; Fri, 14 Oct 2016 07:40:21 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9E7eLJ8069869; Fri, 14 Oct 2016 07:40:21 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9E7eKHc069861; Fri, 14 Oct 2016 07:40:20 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201610140740.u9E7eKHc069861@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Fri, 14 Oct 2016 07:40:20 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307292 - in stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs: . sys X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Oct 2016 07:40:22 -0000 Author: mav Date: Fri Oct 14 07:40:20 2016 New Revision: 307292 URL: https://svnweb.freebsd.org/changeset/base/307292 Log: MFC r305340: MFC r305337: 7004 dmu_tx_hold_zap() does dnode_hold() 7x on same object Using a benchmark which has 32 threads creating 2 million files in the same directory, on a machine with 16 CPU cores, I observed poor performance. I noticed that dmu_tx_hold_zap() was using about 30% of all CPU, and doing dnode_hold() 7 times on the same object (the ZAP object that is being held). dmu_tx_hold_zap() keeps a hold on the dnode_t the entire time it is running, in dmu_tx_hold_t:txh_dnode, so it would be nice to use the dnode_t that we already have in hand, rather than repeatedly calling dnode_hold(). To do this, we need to pass the dnode_t down through all the intermediate calls that dmu_tx_hold_zap() makes, making these routines take the dnode_t* rather than an objset_t* and a uint64_t object number. In particular, the following routines will need to have analogous *_by_dnode() variants created: dmu_buf_hold_noread() dmu_buf_hold() zap_lookup() zap_lookup_norm() zap_count_write() zap_lockdir() zap_count_write() This can improve performance on the benchmark described above by 100%, from 30,000 file creations per second to 60,000. (This improvement is on top of that provided by working around the object allocation issue. Peak performance of ~90,000 creations per second was observed with 8 CPUs; adding CPUs past that decreased performance due to lock contention.) The CPU used by dmu_tx_hold_zap() was reduced by 88%, from 340 CPU-seconds to 40 CPU-seconds. Sponsored by: Intel Corp. Closes #109 Reviewed by: Steve Gonczi Reviewed by: George Wilson Reviewed by: Pavel Zakharov Reviewed by: Ned Bass Reviewed by: Brian Behlendorf Author: Matthew Ahrens openzfs/openzfs@d3e523d489a169ab36f9ec1b2a111a60a5563a9f Modified: stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dbuf.c stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu.c stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_tx.c stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dmu.h stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dnode.h stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zap.h stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zap.c stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zap_micro.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dbuf.c ============================================================================== --- stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dbuf.c Fri Oct 14 07:40:04 2016 (r307291) +++ stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dbuf.c Fri Oct 14 07:40:20 2016 (r307292) @@ -2903,6 +2903,21 @@ dmu_buf_get_objset(dmu_buf_t *db) return (dbi->db_objset); } +dnode_t * +dmu_buf_dnode_enter(dmu_buf_t *db) +{ + dmu_buf_impl_t *dbi = (dmu_buf_impl_t *)db; + DB_DNODE_ENTER(dbi); + return (DB_DNODE(dbi)); +} + +void +dmu_buf_dnode_exit(dmu_buf_t *db) +{ + dmu_buf_impl_t *dbi = (dmu_buf_impl_t *)db; + DB_DNODE_EXIT(dbi); +} + static void dbuf_check_blkptr(dnode_t *dn, dmu_buf_impl_t *db) { Modified: stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu.c ============================================================================== --- stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu.c Fri Oct 14 07:40:04 2016 (r307291) +++ stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu.c Fri Oct 14 07:40:20 2016 (r307292) @@ -131,6 +131,26 @@ const dmu_object_byteswap_info_t dmu_ot_ }; int +dmu_buf_hold_noread_by_dnode(dnode_t *dn, uint64_t offset, + void *tag, dmu_buf_t **dbp) +{ + uint64_t blkid; + dmu_buf_impl_t *db; + + blkid = dbuf_whichblock(dn, 0, offset); + rw_enter(&dn->dn_struct_rwlock, RW_READER); + db = dbuf_hold(dn, blkid, tag); + rw_exit(&dn->dn_struct_rwlock); + + if (db == NULL) { + *dbp = NULL; + return (SET_ERROR(EIO)); + } + + *dbp = &db->db; + return (0); +} +int dmu_buf_hold_noread(objset_t *os, uint64_t object, uint64_t offset, void *tag, dmu_buf_t **dbp) { @@ -158,6 +178,29 @@ dmu_buf_hold_noread(objset_t *os, uint64 } int +dmu_buf_hold_by_dnode(dnode_t *dn, uint64_t offset, + void *tag, dmu_buf_t **dbp, int flags) +{ + int err; + int db_flags = DB_RF_CANFAIL; + + if (flags & DMU_READ_NO_PREFETCH) + db_flags |= DB_RF_NOPREFETCH; + + err = dmu_buf_hold_noread_by_dnode(dn, offset, tag, dbp); + if (err == 0) { + dmu_buf_impl_t *db = (dmu_buf_impl_t *)(*dbp); + err = dbuf_read(db, NULL, db_flags); + if (err != 0) { + dbuf_rele(db, tag); + *dbp = NULL; + } + } + + return (err); +} + +int dmu_buf_hold(objset_t *os, uint64_t object, uint64_t offset, void *tag, dmu_buf_t **dbp, int flags) { Modified: stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_tx.c ============================================================================== --- stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_tx.c Fri Oct 14 07:40:04 2016 (r307291) +++ stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_tx.c Fri Oct 14 07:40:20 2016 (r307292) @@ -21,7 +21,7 @@ /* * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright 2011 Nexenta Systems, Inc. All rights reserved. - * Copyright (c) 2012, 2015 by Delphix. All rights reserved. + * Copyright (c) 2012, 2016 by Delphix. All rights reserved. * Copyright (c) 2014 Integros [integros.com] */ @@ -808,15 +808,14 @@ dmu_tx_hold_zap(dmu_tx_t *tx, uint64_t o * access the name in this fat-zap so that we'll check * for i/o errors to the leaf blocks, etc. */ - err = zap_lookup(dn->dn_objset, dn->dn_object, name, - 8, 0, NULL); + err = zap_lookup_by_dnode(dn, name, 8, 0, NULL); if (err == EIO) { tx->tx_err = err; return; } } - err = zap_count_write(dn->dn_objset, dn->dn_object, name, add, + err = zap_count_write_by_dnode(dn, name, add, &txh->txh_space_towrite, &txh->txh_space_tooverwrite); /* Modified: stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dmu.h ============================================================================== --- stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dmu.h Fri Oct 14 07:40:04 2016 (r307291) +++ stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dmu.h Fri Oct 14 07:40:20 2016 (r307292) @@ -78,6 +78,7 @@ struct file; typedef struct objset objset_t; typedef struct dmu_tx dmu_tx_t; typedef struct dsl_dir dsl_dir_t; +typedef struct dnode dnode_t; typedef enum dmu_object_byteswap { DMU_BSWAP_UINT8, @@ -418,7 +419,7 @@ dmu_write_embedded(objset_t *os, uint64_ #define WP_DMU_SYNC 0x2 #define WP_SPILL 0x4 -void dmu_write_policy(objset_t *os, struct dnode *dn, int level, int wp, +void dmu_write_policy(objset_t *os, dnode_t *dn, int level, int wp, struct zio_prop *zp); /* * The bonus data is accessed more or less like a regular buffer. @@ -444,7 +445,7 @@ int dmu_rm_spill(objset_t *, uint64_t, d */ int dmu_spill_hold_by_bonus(dmu_buf_t *bonus, void *tag, dmu_buf_t **dbp); -int dmu_spill_hold_by_dnode(struct dnode *dn, uint32_t flags, +int dmu_spill_hold_by_dnode(dnode_t *dn, uint32_t flags, void *tag, dmu_buf_t **dbp); int dmu_spill_hold_existing(dmu_buf_t *bonus, void *tag, dmu_buf_t **dbp); @@ -464,6 +465,8 @@ int dmu_spill_hold_existing(dmu_buf_t *b */ int dmu_buf_hold(objset_t *os, uint64_t object, uint64_t offset, void *tag, dmu_buf_t **, int flags); +int dmu_buf_hold_by_dnode(dnode_t *dn, uint64_t offset, + void *tag, dmu_buf_t **dbp, int flags); /* * Add a reference to a dmu buffer that has already been held via @@ -617,6 +620,8 @@ void *dmu_buf_remove_user(dmu_buf_t *db, void *dmu_buf_get_user(dmu_buf_t *db); objset_t *dmu_buf_get_objset(dmu_buf_t *db); +dnode_t *dmu_buf_dnode_enter(dmu_buf_t *db); +void dmu_buf_dnode_exit(dmu_buf_t *db); /* Block until any in-progress dmu buf user evictions complete. */ void dmu_buf_user_evict_wait(void); @@ -800,7 +805,7 @@ extern const dmu_object_byteswap_info_t */ int dmu_object_info(objset_t *os, uint64_t object, dmu_object_info_t *doi); /* Like dmu_object_info, but faster if you have a held dnode in hand. */ -void dmu_object_info_from_dnode(struct dnode *dn, dmu_object_info_t *doi); +void dmu_object_info_from_dnode(dnode_t *dn, dmu_object_info_t *doi); /* Like dmu_object_info, but faster if you have a held dbuf in hand. */ void dmu_object_info_from_db(dmu_buf_t *db, dmu_object_info_t *doi); /* Modified: stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dnode.h ============================================================================== --- stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dnode.h Fri Oct 14 07:40:04 2016 (r307291) +++ stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dnode.h Fri Oct 14 07:40:20 2016 (r307292) @@ -20,7 +20,7 @@ */ /* * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2012, 2014 by Delphix. All rights reserved. + * Copyright (c) 2012, 2016 by Delphix. All rights reserved. * Copyright (c) 2014 Spectra Logic Corporation, All rights reserved. */ @@ -149,7 +149,7 @@ typedef struct dnode_phys { blkptr_t dn_spill; } dnode_phys_t; -typedef struct dnode { +struct dnode { /* * Protects the structure of the dnode, including the number of levels * of indirection (dn_nlevels), dn_maxblkid, and dn_next_* @@ -247,7 +247,7 @@ typedef struct dnode { /* holds prefetch structure */ struct zfetch dn_zfetch; -} dnode_t; +}; /* * Adds a level of indirection between the dbuf and the dnode to avoid Modified: stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zap.h ============================================================================== --- stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zap.h Fri Oct 14 07:40:04 2016 (r307291) +++ stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zap.h Fri Oct 14 07:40:20 2016 (r307292) @@ -20,7 +20,7 @@ */ /* * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2012, 2015 by Delphix. All rights reserved. + * Copyright (c) 2012, 2016 by Delphix. All rights reserved. */ #ifndef _SYS_ZAP_H @@ -216,8 +216,14 @@ int zap_lookup_uint64(objset_t *os, uint int zap_contains(objset_t *ds, uint64_t zapobj, const char *name); int zap_prefetch_uint64(objset_t *os, uint64_t zapobj, const uint64_t *key, int key_numints); +int zap_lookup_by_dnode(dnode_t *dn, const char *name, + uint64_t integer_size, uint64_t num_integers, void *buf); +int zap_lookup_norm_by_dnode(dnode_t *dn, const char *name, + uint64_t integer_size, uint64_t num_integers, void *buf, + matchtype_t mt, char *realname, int rn_len, + boolean_t *ncp); -int zap_count_write(objset_t *os, uint64_t zapobj, const char *name, +int zap_count_write_by_dnode(dnode_t *dn, const char *name, int add, refcount_t *towrite, refcount_t *tooverwrite); /* Modified: stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zap.c ============================================================================== --- stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zap.c Fri Oct 14 07:40:04 2016 (r307291) +++ stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zap.c Fri Oct 14 07:40:20 2016 (r307292) @@ -270,6 +270,7 @@ zap_table_load(zap_t *zap, zap_table_phy uint64_t blk, off; int err; dmu_buf_t *db; + dnode_t *dn; int bs = FZAP_BLOCK_SHIFT(zap); ASSERT(RW_LOCK_HELD(&zap->zap_rwlock)); @@ -277,8 +278,15 @@ zap_table_load(zap_t *zap, zap_table_phy blk = idx >> (bs-3); off = idx & ((1<<(bs-3))-1); - err = dmu_buf_hold(zap->zap_objset, zap->zap_object, + /* + * Note: this is equivalent to dmu_buf_hold(), but we use + * _dnode_enter / _by_dnode because it's faster because we don't + * have to hold the dnode. + */ + dn = dmu_buf_dnode_enter(zap->zap_dbuf); + err = dmu_buf_hold_by_dnode(dn, (tbl->zt_blk + blk) << bs, FTAG, &db, DMU_READ_NO_PREFETCH); + dmu_buf_dnode_exit(zap->zap_dbuf); if (err) return (err); *valp = ((uint64_t *)db->db_data)[off]; @@ -292,9 +300,11 @@ zap_table_load(zap_t *zap, zap_table_phy */ blk = (idx*2) >> (bs-3); - err = dmu_buf_hold(zap->zap_objset, zap->zap_object, + dn = dmu_buf_dnode_enter(zap->zap_dbuf); + err = dmu_buf_hold_by_dnode(dn, (tbl->zt_nextblk + blk) << bs, FTAG, &db, DMU_READ_NO_PREFETCH); + dmu_buf_dnode_exit(zap->zap_dbuf); if (err == 0) dmu_buf_rele(db, FTAG); } @@ -505,8 +515,10 @@ zap_get_leaf_byblk(zap_t *zap, uint64_t ASSERT(RW_LOCK_HELD(&zap->zap_rwlock)); - err = dmu_buf_hold(zap->zap_objset, zap->zap_object, + dnode_t *dn = dmu_buf_dnode_enter(zap->zap_dbuf); + err = dmu_buf_hold_by_dnode(dn, blkid << bs, NULL, &db, DMU_READ_NO_PREFETCH); + dmu_buf_dnode_exit(zap->zap_dbuf); if (err) return (err); Modified: stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zap_micro.c ============================================================================== --- stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zap_micro.c Fri Oct 14 07:40:04 2016 (r307291) +++ stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zap_micro.c Fri Oct 14 07:40:20 2016 (r307292) @@ -533,6 +533,24 @@ zap_lockdir_impl(dmu_buf_t *db, void *ta return (0); } +static int +zap_lockdir_by_dnode(dnode_t *dn, dmu_tx_t *tx, + krw_t lti, boolean_t fatreader, boolean_t adding, void *tag, zap_t **zapp) +{ + dmu_buf_t *db; + int err; + + err = dmu_buf_hold_by_dnode(dn, 0, tag, &db, DMU_READ_NO_PREFETCH); + if (err != 0) { + return (err); + } + err = zap_lockdir_impl(db, tag, tx, lti, fatreader, adding, zapp); + if (err != 0) { + dmu_buf_rele(db, tag); + } + return (err); +} + int zap_lockdir(objset_t *os, uint64_t obj, dmu_tx_t *tx, krw_t lti, boolean_t fatreader, boolean_t adding, void *tag, zap_t **zapp) @@ -858,6 +876,33 @@ zap_lookup_norm(objset_t *os, uint64_t z } int +zap_lookup_by_dnode(dnode_t *dn, const char *name, + uint64_t integer_size, uint64_t num_integers, void *buf) +{ + return (zap_lookup_norm_by_dnode(dn, name, integer_size, + num_integers, buf, MT_EXACT, NULL, 0, NULL)); +} + +int +zap_lookup_norm_by_dnode(dnode_t *dn, const char *name, + uint64_t integer_size, uint64_t num_integers, void *buf, + matchtype_t mt, char *realname, int rn_len, + boolean_t *ncp) +{ + zap_t *zap; + int err; + + err = zap_lockdir_by_dnode(dn, NULL, RW_READER, TRUE, FALSE, + FTAG, &zap); + if (err != 0) + return (err); + err = zap_lookup_impl(zap, name, integer_size, + num_integers, buf, mt, realname, rn_len, ncp); + zap_unlockdir(zap, FTAG); + return (err); +} + +int zap_prefetch_uint64(objset_t *os, uint64_t zapobj, const uint64_t *key, int key_numints) { @@ -1428,7 +1473,7 @@ zap_get_stats(objset_t *os, uint64_t zap } int -zap_count_write(objset_t *os, uint64_t zapobj, const char *name, int add, +zap_count_write_by_dnode(dnode_t *dn, const char *name, int add, refcount_t *towrite, refcount_t *tooverwrite) { zap_t *zap; @@ -1457,7 +1502,7 @@ zap_count_write(objset_t *os, uint64_t z * At present we are just evaluating the possibility of this operation * and hence we do not want to trigger an upgrade. */ - err = zap_lockdir(os, zapobj, NULL, RW_READER, TRUE, FALSE, + err = zap_lockdir_by_dnode(dn, NULL, RW_READER, TRUE, FALSE, FTAG, &zap); if (err != 0) return (err); From owner-svn-src-all@freebsd.org Fri Oct 14 07:41:13 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 29D99C11074; Fri, 14 Oct 2016 07:41:13 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id E890E10C; Fri, 14 Oct 2016 07:41:12 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9E7fC2x073341; Fri, 14 Oct 2016 07:41:12 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9E7fCKs073340; Fri, 14 Oct 2016 07:41:12 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201610140741.u9E7fCKs073340@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Fri, 14 Oct 2016 07:41:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307293 - stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Oct 2016 07:41:13 -0000 Author: mav Date: Fri Oct 14 07:41:11 2016 New Revision: 307293 URL: https://svnweb.freebsd.org/changeset/base/307293 Log: MFC r305342: Missed FreeBSD-specific piece of r305338. Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zap_micro.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zap_micro.c ============================================================================== --- stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zap_micro.c Fri Oct 14 07:40:20 2016 (r307292) +++ stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zap_micro.c Fri Oct 14 07:41:11 2016 (r307293) @@ -1435,7 +1435,7 @@ zap_cursor_move_to_key(zap_cursor_t *zc, if (zc->zc_zap == NULL) { err = zap_lockdir(zc->zc_objset, zc->zc_zapobj, NULL, - RW_READER, TRUE, FALSE, &zc->zc_zap); + RW_READER, TRUE, FALSE, FTAG, &zc->zc_zap); if (err) return (err); } else { From owner-svn-src-all@freebsd.org Fri Oct 14 07:41:45 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 8D1CBC110CF; Fri, 14 Oct 2016 07:41:45 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 5D55E2E9; Fri, 14 Oct 2016 07:41:45 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9E7fiqE073427; Fri, 14 Oct 2016 07:41:44 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9E7fiWa073426; Fri, 14 Oct 2016 07:41:44 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201610140741.u9E7fiWa073426@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Fri, 14 Oct 2016 07:41:44 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307294 - stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Oct 2016 07:41:45 -0000 Author: mav Date: Fri Oct 14 07:41:44 2016 New Revision: 307294 URL: https://svnweb.freebsd.org/changeset/base/307294 Log: MFC r305342: Missed FreeBSD-specific piece of r305338. Modified: stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zap_micro.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zap_micro.c ============================================================================== --- stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zap_micro.c Fri Oct 14 07:41:11 2016 (r307293) +++ stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zap_micro.c Fri Oct 14 07:41:44 2016 (r307294) @@ -1418,7 +1418,7 @@ zap_cursor_move_to_key(zap_cursor_t *zc, if (zc->zc_zap == NULL) { err = zap_lockdir(zc->zc_objset, zc->zc_zapobj, NULL, - RW_READER, TRUE, FALSE, &zc->zc_zap); + RW_READER, TRUE, FALSE, FTAG, &zc->zc_zap); if (err) return (err); } else { From owner-svn-src-all@freebsd.org Fri Oct 14 07:42:54 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E0E39C11227; Fri, 14 Oct 2016 07:42:54 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id AB98F90A; Fri, 14 Oct 2016 07:42:54 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9E7grfY073519; Fri, 14 Oct 2016 07:42:53 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9E7grUL073518; Fri, 14 Oct 2016 07:42:53 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201610140742.u9E7grUL073518@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Fri, 14 Oct 2016 07:42:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307295 - stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Oct 2016 07:42:55 -0000 Author: mav Date: Fri Oct 14 07:42:53 2016 New Revision: 307295 URL: https://svnweb.freebsd.org/changeset/base/307295 Log: MFC r305456 (by avg): fix zfs pool creation accidentally broken by r305331 The upstream change introduced a new load state, SPA_LOAD_CREATE, and vdev_geom code needs to be aware of it. Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c ============================================================================== --- stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c Fri Oct 14 07:41:44 2016 (r307294) +++ stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c Fri Oct 14 07:42:53 2016 (r307295) @@ -777,7 +777,8 @@ vdev_geom_open(vdev_t *vd, uint64_t *psi if (vd->vdev_spa->spa_splitting_newspa || (vd->vdev_prevstate == VDEV_STATE_UNKNOWN && - vd->vdev_spa->spa_load_state == SPA_LOAD_NONE)) { + vd->vdev_spa->spa_load_state == SPA_LOAD_NONE || + vd->vdev_spa->spa_load_state == SPA_LOAD_CREATE)) { /* * We are dealing with a vdev that hasn't been previously * opened (since boot), and we are not loading an From owner-svn-src-all@freebsd.org Fri Oct 14 07:43:30 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 168FCC1127C; Fri, 14 Oct 2016 07:43:30 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id DA76EA5F; Fri, 14 Oct 2016 07:43:29 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9E7hTPi073610; Fri, 14 Oct 2016 07:43:29 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9E7hTil073609; Fri, 14 Oct 2016 07:43:29 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201610140743.u9E7hTil073609@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Fri, 14 Oct 2016 07:43:29 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307296 - stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Oct 2016 07:43:30 -0000 Author: mav Date: Fri Oct 14 07:43:28 2016 New Revision: 307296 URL: https://svnweb.freebsd.org/changeset/base/307296 Log: MFC r305456 (by avg): fix zfs pool creation accidentally broken by r305331 The upstream change introduced a new load state, SPA_LOAD_CREATE, and vdev_geom code needs to be aware of it. Modified: stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c ============================================================================== --- stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c Fri Oct 14 07:42:53 2016 (r307295) +++ stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c Fri Oct 14 07:43:28 2016 (r307296) @@ -730,7 +730,8 @@ vdev_geom_open(vdev_t *vd, uint64_t *psi if (vd->vdev_spa->spa_splitting_newspa || (vd->vdev_prevstate == VDEV_STATE_UNKNOWN && - vd->vdev_spa->spa_load_state == SPA_LOAD_NONE)) { + vd->vdev_spa->spa_load_state == SPA_LOAD_NONE || + vd->vdev_spa->spa_load_state == SPA_LOAD_CREATE)) { /* * We are dealing with a vdev that hasn't been previously * opened (since boot), and we are not loading an From owner-svn-src-all@freebsd.org Fri Oct 14 07:44:26 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 2C6EFC112E4; Fri, 14 Oct 2016 07:44:26 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id E98C2BC8; Fri, 14 Oct 2016 07:44:25 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9E7iPIi073734; Fri, 14 Oct 2016 07:44:25 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9E7iPSu073733; Fri, 14 Oct 2016 07:44:25 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201610140744.u9E7iPSu073733@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Fri, 14 Oct 2016 07:44:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307297 - stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Oct 2016 07:44:26 -0000 Author: mav Date: Fri Oct 14 07:44:24 2016 New Revision: 307297 URL: https://svnweb.freebsd.org/changeset/base/307297 Log: MFC r305561: MFV r305560: 7278 tuning zfs_arc_max does not impact arc_c_min When changing zfs_arc_max (e.g. as zdb does), it may be set to less than the default arc_c_min. arc_c_min should decrease to not be more than arc_c_max, but it doesn't; therefore tuning of arc_c_max is ineffective. Reviewed by: Dan Kimmel Reviewed by: Paul Dagnelie Reviewed by: Prakash Surya Reviewed by: Igor Kozhukhov Author: Matthew Ahrens openzfs/openzfs@608764beadaf4bb71c5d8fe1818e8392ac66a61b Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c ============================================================================== --- stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c Fri Oct 14 07:43:28 2016 (r307296) +++ stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c Fri Oct 14 07:44:24 2016 (r307297) @@ -6062,8 +6062,10 @@ arc_init(void) * Allow the tunables to override our calculations if they are * reasonable. */ - if (zfs_arc_max > arc_abs_min && zfs_arc_max < kmem_size()) + if (zfs_arc_max > arc_abs_min && zfs_arc_max < kmem_size()) { arc_c_max = zfs_arc_max; + arc_c_min = MIN(arc_c_min, arc_c_max); + } if (zfs_arc_min > arc_abs_min && zfs_arc_min <= arc_c_max) arc_c_min = zfs_arc_min; #endif From owner-svn-src-all@freebsd.org Fri Oct 14 07:45:11 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 72733C11387; Fri, 14 Oct 2016 07:45:11 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 3D003D81; Fri, 14 Oct 2016 07:45:11 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9E7jAG7073841; Fri, 14 Oct 2016 07:45:10 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9E7jAbQ073840; Fri, 14 Oct 2016 07:45:10 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201610140745.u9E7jAbQ073840@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Fri, 14 Oct 2016 07:45:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307298 - stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Oct 2016 07:45:11 -0000 Author: mav Date: Fri Oct 14 07:45:10 2016 New Revision: 307298 URL: https://svnweb.freebsd.org/changeset/base/307298 Log: MFC r305561: MFV r305560: 7278 tuning zfs_arc_max does not impact arc_c_min When changing zfs_arc_max (e.g. as zdb does), it may be set to less than the default arc_c_min. arc_c_min should decrease to not be more than arc_c_max, but it doesn't; therefore tuning of arc_c_max is ineffective. Reviewed by: Dan Kimmel Reviewed by: Paul Dagnelie Reviewed by: Prakash Surya Reviewed by: Igor Kozhukhov Author: Matthew Ahrens openzfs/openzfs@608764beadaf4bb71c5d8fe1818e8392ac66a61b Modified: stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c ============================================================================== --- stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c Fri Oct 14 07:44:24 2016 (r307297) +++ stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c Fri Oct 14 07:45:10 2016 (r307298) @@ -5998,8 +5998,10 @@ arc_init(void) * Allow the tunables to override our calculations if they are * reasonable. */ - if (zfs_arc_max > arc_abs_min && zfs_arc_max < kmem_size()) + if (zfs_arc_max > arc_abs_min && zfs_arc_max < kmem_size()) { arc_c_max = zfs_arc_max; + arc_c_min = MIN(arc_c_min, arc_c_max); + } if (zfs_arc_min > arc_abs_min && zfs_arc_min <= arc_c_max) arc_c_min = zfs_arc_min; #endif From owner-svn-src-all@freebsd.org Fri Oct 14 07:46:10 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id CBCB5C11418; Fri, 14 Oct 2016 07:46:10 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 801CDF13; Fri, 14 Oct 2016 07:46:10 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9E7k9Ag073942; Fri, 14 Oct 2016 07:46:09 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9E7k9jo073941; Fri, 14 Oct 2016 07:46:09 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201610140746.u9E7k9jo073941@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Fri, 14 Oct 2016 07:46:09 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307299 - stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Oct 2016 07:46:10 -0000 Author: mav Date: Fri Oct 14 07:46:09 2016 New Revision: 307299 URL: https://svnweb.freebsd.org/changeset/base/307299 Log: MFC r305563: MFV r305562: 7259 DS_FIELD_LARGE_BLOCKS is unused The DS_FIELD_LARGE_BLOCKS macro has been unused since the integration of this patch: commit ca0cc3918a1789fa839194af2a9245f801a06b1a Author: Matthew Ahrens Date: Fri Jul 24 09:53:55 2015 -0700 5959 clean up per-dataset feature count code Reviewed by: Toomas Soome Reviewed by: George Wilson Reviewed by: Alex Reece Approved by: Richard Lowe This patch simply removes this macro from dsl_dataset.h. Reviewed by: Dan Kimmel Reviewed by: Prakash Surya Reviewed by: Dan McDonald Reviewed by: Igor Kozhukhov Author: Matthew Ahrens Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dsl_dataset.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dsl_dataset.h ============================================================================== --- stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dsl_dataset.h Fri Oct 14 07:45:10 2016 (r307298) +++ stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dsl_dataset.h Fri Oct 14 07:46:09 2016 (r307299) @@ -86,13 +86,6 @@ struct dsl_pool; #define DS_FIELD_BOOKMARK_NAMES "com.delphix:bookmarks" /* - * This field is present (with value=0) if this dataset may contain large - * blocks (>128KB). If it is present, then this dataset - * is counted in the refcount of the SPA_FEATURE_LARGE_BLOCKS feature. - */ -#define DS_FIELD_LARGE_BLOCKS "org.open-zfs:large_blocks" - -/* * These fields are set on datasets that are in the middle of a resumable * receive, and allow the sender to resume the send if it is interrupted. */ From owner-svn-src-all@freebsd.org Fri Oct 14 07:47:09 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 141BCC11475; Fri, 14 Oct 2016 07:47:09 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id BE884D7; Fri, 14 Oct 2016 07:47:08 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9E7l771074044; Fri, 14 Oct 2016 07:47:07 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9E7l7PC074043; Fri, 14 Oct 2016 07:47:07 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201610140747.u9E7l7PC074043@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Fri, 14 Oct 2016 07:47:07 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307300 - stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Oct 2016 07:47:09 -0000 Author: mav Date: Fri Oct 14 07:47:07 2016 New Revision: 307300 URL: https://svnweb.freebsd.org/changeset/base/307300 Log: MFC r305563: MFV r305562: 7259 DS_FIELD_LARGE_BLOCKS is unused The DS_FIELD_LARGE_BLOCKS macro has been unused since the integration of this patch: commit ca0cc3918a1789fa839194af2a9245f801a06b1a Author: Matthew Ahrens Date: Fri Jul 24 09:53:55 2015 -0700 5959 clean up per-dataset feature count code Reviewed by: Toomas Soome Reviewed by: George Wilson Reviewed by: Alex Reece Approved by: Richard Lowe This patch simply removes this macro from dsl_dataset.h. Reviewed by: Dan Kimmel Reviewed by: Prakash Surya Reviewed by: Dan McDonald Reviewed by: Igor Kozhukhov Author: Matthew Ahrens Modified: stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dsl_dataset.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dsl_dataset.h ============================================================================== --- stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dsl_dataset.h Fri Oct 14 07:46:09 2016 (r307299) +++ stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dsl_dataset.h Fri Oct 14 07:47:07 2016 (r307300) @@ -86,13 +86,6 @@ struct dsl_pool; #define DS_FIELD_BOOKMARK_NAMES "com.delphix:bookmarks" /* - * This field is present (with value=0) if this dataset may contain large - * blocks (>128KB). If it is present, then this dataset - * is counted in the refcount of the SPA_FEATURE_LARGE_BLOCKS feature. - */ -#define DS_FIELD_LARGE_BLOCKS "org.open-zfs:large_blocks" - -/* * These fields are set on datasets that are in the middle of a resumable * receive, and allow the sender to resume the send if it is interrupted. */ From owner-svn-src-all@freebsd.org Fri Oct 14 07:47:37 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 2DB67C114D7; Fri, 14 Oct 2016 07:47:37 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id BBD88273; Fri, 14 Oct 2016 07:47:36 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9E7lZ3n074112; Fri, 14 Oct 2016 07:47:35 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9E7lZKa074108; Fri, 14 Oct 2016 07:47:35 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610140747.u9E7lZKa074108@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Fri, 14 Oct 2016 07:47:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307301 - in stable/11/sys/dev/hyperv: include vmbus X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Oct 2016 07:47:37 -0000 Author: sephe Date: Fri Oct 14 07:47:35 2016 New Revision: 307301 URL: https://svnweb.freebsd.org/changeset/base/307301 Log: MFC 302607-302612 302607 hyperv/vmbus: Use post message Hypercall APIs for channel open Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D6876 302608 hyperv/vmbus: Remove unnecessary check and unapplied comment Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D6877 302609 hyperv/vmbus: Use post message Hypercall APIs for GPADL connect. This also fixes memory leakge if sub-connect messages are needed. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D6878 302610 hyperv/vmbus: Use post message Hypercall APIs for channel close Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D6906 302611 hyperv/vmbus: Use post message Hypercall APIs for GPA disconnect Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D6912 302612 hyperv: Nuke unused stuffs Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D6913 Modified: stable/11/sys/dev/hyperv/include/hyperv.h stable/11/sys/dev/hyperv/vmbus/hv_channel.c stable/11/sys/dev/hyperv/vmbus/hv_channel_mgmt.c stable/11/sys/dev/hyperv/vmbus/hv_connection.c stable/11/sys/dev/hyperv/vmbus/hv_vmbus_priv.h stable/11/sys/dev/hyperv/vmbus/hyperv.c stable/11/sys/dev/hyperv/vmbus/vmbus.c stable/11/sys/dev/hyperv/vmbus/vmbus_reg.h stable/11/sys/dev/hyperv/vmbus/vmbus_var.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/hyperv/include/hyperv.h ============================================================================== --- stable/11/sys/dev/hyperv/include/hyperv.h Fri Oct 14 07:47:07 2016 (r307300) +++ stable/11/sys/dev/hyperv/include/hyperv.h Fri Oct 14 07:47:35 2016 (r307301) @@ -179,8 +179,6 @@ typedef struct hv_vmbus_channel_offer { } __packed hv_vmbus_channel_offer; -typedef uint32_t hv_gpadl_handle; - typedef struct { uint16_t type; uint16_t data_offset8; @@ -352,14 +350,6 @@ typedef struct { } __packed hv_vmbus_channel_query_vmbus_version; /* - * VMBus Version Supported parameters - */ -typedef struct { - hv_vmbus_channel_msg_header header; - hv_bool_uint8_t version_supported; -} __packed hv_vmbus_channel_version_supported; - -/* * Channel Offer parameters */ typedef struct { @@ -397,171 +387,13 @@ typedef struct uint32_t child_rel_id; } __packed hv_vmbus_channel_rescind_offer; - -/* - * Request Offer -- no parameters, SynIC message contains the partition ID - * - * Set Snoop -- no parameters, SynIC message contains the partition ID - * - * Clear Snoop -- no parameters, SynIC message contains the partition ID - * - * All Offers Delivered -- no parameters, SynIC message contains the - * partition ID - * - * Flush Client -- no parameters, SynIC message contains the partition ID - */ - - -/* - * Open Channel parameters - */ -typedef struct -{ - hv_vmbus_channel_msg_header header; - - /* - * Identifies the specific VMBus channel that is being opened. - */ - uint32_t child_rel_id; - - /* - * ID making a particular open request at a channel offer unique. - */ - uint32_t open_id; - - /* - * GPADL for the channel's ring buffer. - */ - hv_gpadl_handle ring_buffer_gpadl_handle; - - /* - * Before win8, all incoming channel interrupts are only - * delivered on cpu 0. Setting this value to 0 would - * preserve the earlier behavior. - */ - uint32_t target_vcpu; - - /* - * The upstream ring buffer begins at offset zero in the memory described - * by ring_buffer_gpadl_handle. The downstream ring buffer follows it at - * this offset (in pages). - */ - uint32_t downstream_ring_buffer_page_offset; - - /* - * User-specific data to be passed along to the server endpoint. - */ - uint8_t user_data[HV_MAX_USER_DEFINED_BYTES]; - -} __packed hv_vmbus_channel_open_channel; - -typedef uint32_t hv_nt_status; - -/* - * Open Channel Result parameters - */ -typedef struct -{ - hv_vmbus_channel_msg_header header; - uint32_t child_rel_id; - uint32_t open_id; - hv_nt_status status; -} __packed hv_vmbus_channel_open_result; - -/* - * Close channel parameters - */ -typedef struct -{ - hv_vmbus_channel_msg_header header; - uint32_t child_rel_id; -} __packed hv_vmbus_channel_close_channel; - -/* - * Channel Message GPADL - */ -#define HV_GPADL_TYPE_RING_BUFFER 1 -#define HV_GPADL_TYPE_SERVER_SAVE_AREA 2 -#define HV_GPADL_TYPE_TRANSACTION 8 - -/* - * The number of PFNs in a GPADL message is defined by the number of pages - * that would be spanned by byte_count and byte_offset. If the implied number - * of PFNs won't fit in this packet, there will be a follow-up packet that - * contains more - */ - -typedef struct { - hv_vmbus_channel_msg_header header; - uint32_t child_rel_id; - uint32_t gpadl; - uint16_t range_buf_len; - uint16_t range_count; - hv_gpa_range range[0]; -} __packed hv_vmbus_channel_gpadl_header; - -/* - * This is the follow-up packet that contains more PFNs - */ -typedef struct { - hv_vmbus_channel_msg_header header; - uint32_t message_number; - uint32_t gpadl; - uint64_t pfn[0]; -} __packed hv_vmbus_channel_gpadl_body; - -typedef struct { - hv_vmbus_channel_msg_header header; - uint32_t child_rel_id; - uint32_t gpadl; - uint32_t creation_status; -} __packed hv_vmbus_channel_gpadl_created; - -typedef struct { - hv_vmbus_channel_msg_header header; - uint32_t child_rel_id; - uint32_t gpadl; -} __packed hv_vmbus_channel_gpadl_teardown; - -typedef struct { - hv_vmbus_channel_msg_header header; - uint32_t gpadl; -} __packed hv_vmbus_channel_gpadl_torndown; - typedef struct { hv_vmbus_channel_msg_header header; uint32_t child_rel_id; } __packed hv_vmbus_channel_relid_released; -typedef hv_vmbus_channel_msg_header hv_vmbus_channel_unload; - #define HW_MACADDR_LEN 6 -/* - * Fixme: Added to quiet "typeof" errors involving hv_vmbus.h when - * the including C file was compiled with "-std=c99". - */ -#ifndef typeof -#define typeof __typeof -#endif - -#ifndef NULL -#define NULL (void *)0 -#endif - -typedef void *hv_vmbus_handle; - -#ifndef CONTAINING_RECORD -#define CONTAINING_RECORD(address, type, field) ((type *)( \ - (uint8_t *)(address) - \ - (uint8_t *)(&((type *)0)->field))) -#endif /* CONTAINING_RECORD */ - - -#define container_of(ptr, type, member) ({ \ - __typeof__( ((type *)0)->member ) *__mptr = (ptr); \ - (type *)( (char *)__mptr - offsetof(type,member) );}) - enum { HV_VMBUS_IVAR_TYPE, HV_VMBUS_IVAR_INSTANCE, Modified: stable/11/sys/dev/hyperv/vmbus/hv_channel.c ============================================================================== --- stable/11/sys/dev/hyperv/vmbus/hv_channel.c Fri Oct 14 07:47:07 2016 (r307300) +++ stable/11/sys/dev/hyperv/vmbus/hv_channel.c Fri Oct 14 07:47:35 2016 (r307301) @@ -49,14 +49,6 @@ __FBSDID("$FreeBSD$"); #include #include -static int vmbus_channel_create_gpadl_header( - /* must be phys and virt contiguous*/ - void* contig_buffer, - /* page-size multiple */ - uint32_t size, - hv_vmbus_channel_msg_info** msg_info, - uint32_t* message_count); - static void vmbus_channel_set_event(hv_vmbus_channel* channel); static void VmbusProcessChannelEvent(void* channel, int pending); @@ -182,11 +174,21 @@ hv_vmbus_channel_open( hv_vmbus_pfn_channel_callback pfn_on_channel_callback, void* context) { - + struct vmbus_softc *sc = new_channel->vmbus_sc; + const struct vmbus_chanmsg_chopen_resp *resp; + const struct vmbus_message *msg; + struct vmbus_chanmsg_chopen *req; + struct vmbus_msghc *mh; + uint32_t status; int ret = 0; void *in, *out; - hv_vmbus_channel_open_channel* open_msg; - hv_vmbus_channel_msg_info* open_info; + + if (user_data_len > VMBUS_CHANMSG_CHOPEN_UDATA_SIZE) { + device_printf(sc->vmbus_dev, + "invalid udata len %u for chan%u\n", + user_data_len, new_channel->offer_msg.child_rel_id); + return EINVAL; + } mtx_lock(&new_channel->sc_lock); if (new_channel->state == HV_CHANNEL_OPEN_STATE) { @@ -248,381 +250,231 @@ hv_vmbus_channel_open( send_ring_buffer_size + recv_ring_buffer_size, &new_channel->ring_buffer_gpadl_handle); - /** - * Create and init the channel open message + /* + * Open channel w/ the bufring GPADL on the target CPU. */ - open_info = (hv_vmbus_channel_msg_info*) malloc( - sizeof(hv_vmbus_channel_msg_info) + - sizeof(hv_vmbus_channel_open_channel), - M_DEVBUF, - M_NOWAIT); - KASSERT(open_info != NULL, - ("Error VMBUS: malloc failed to allocate Open Channel message!")); - - if (open_info == NULL) - return (ENOMEM); - - sema_init(&open_info->wait_sema, 0, "Open Info Sema"); - - open_msg = (hv_vmbus_channel_open_channel*) open_info->msg; - open_msg->header.message_type = HV_CHANNEL_MESSAGE_OPEN_CHANNEL; - open_msg->open_id = new_channel->offer_msg.child_rel_id; - open_msg->child_rel_id = new_channel->offer_msg.child_rel_id; - open_msg->ring_buffer_gpadl_handle = - new_channel->ring_buffer_gpadl_handle; - open_msg->downstream_ring_buffer_page_offset = send_ring_buffer_size - >> PAGE_SHIFT; - open_msg->target_vcpu = new_channel->target_vcpu; - + mh = vmbus_msghc_get(sc, sizeof(*req)); + if (mh == NULL) { + device_printf(sc->vmbus_dev, + "can not get msg hypercall for chopen(chan%u)\n", + new_channel->offer_msg.child_rel_id); + return ENXIO; + } + + req = vmbus_msghc_dataptr(mh); + req->chm_hdr.chm_type = VMBUS_CHANMSG_TYPE_CHOPEN; + req->chm_chanid = new_channel->offer_msg.child_rel_id; + req->chm_openid = new_channel->offer_msg.child_rel_id; + req->chm_gpadl = new_channel->ring_buffer_gpadl_handle; + req->chm_vcpuid = new_channel->target_vcpu; + req->chm_rxbr_pgofs = send_ring_buffer_size >> PAGE_SHIFT; if (user_data_len) - memcpy(open_msg->user_data, user_data, user_data_len); - - mtx_lock(&hv_vmbus_g_connection.channel_msg_lock); - TAILQ_INSERT_TAIL( - &hv_vmbus_g_connection.channel_msg_anchor, - open_info, - msg_list_entry); - mtx_unlock(&hv_vmbus_g_connection.channel_msg_lock); - - ret = hv_vmbus_post_message( - open_msg, sizeof(hv_vmbus_channel_open_channel)); + memcpy(req->chm_udata, user_data, user_data_len); - if (ret != 0) - goto cleanup; - - ret = sema_timedwait(&open_info->wait_sema, 5 * hz); /* KYS 5 seconds */ - - if (ret) { - if(bootverbose) - printf("VMBUS: channel <%p> open timeout.\n", new_channel); - goto cleanup; + ret = vmbus_msghc_exec(sc, mh); + if (ret != 0) { + device_printf(sc->vmbus_dev, + "chopen(chan%u) msg hypercall exec failed: %d\n", + new_channel->offer_msg.child_rel_id, ret); + vmbus_msghc_put(sc, mh); + return ret; } - if (open_info->response.open_result.status == 0) { - new_channel->state = HV_CHANNEL_OPENED_STATE; - if(bootverbose) - printf("VMBUS: channel <%p> open success.\n", new_channel); + msg = vmbus_msghc_wait_result(sc, mh); + resp = (const struct vmbus_chanmsg_chopen_resp *)msg->msg_data; + status = resp->chm_status; + + vmbus_msghc_put(sc, mh); + + if (status == 0) { + new_channel->state = HV_CHANNEL_OPENED_STATE; + if (bootverbose) { + device_printf(sc->vmbus_dev, "chan%u opened\n", + new_channel->offer_msg.child_rel_id); + } } else { - if(bootverbose) - printf("Error VMBUS: channel <%p> open failed - %d!\n", - new_channel, open_info->response.open_result.status); + device_printf(sc->vmbus_dev, "failed to open chan%u\n", + new_channel->offer_msg.child_rel_id); + ret = ENXIO; } - - cleanup: - mtx_lock(&hv_vmbus_g_connection.channel_msg_lock); - TAILQ_REMOVE( - &hv_vmbus_g_connection.channel_msg_anchor, - open_info, - msg_list_entry); - mtx_unlock(&hv_vmbus_g_connection.channel_msg_lock); - sema_destroy(&open_info->wait_sema); - free(open_info, M_DEVBUF); - return (ret); } /** - * @brief Create a gpadl for the specified buffer - */ -static int -vmbus_channel_create_gpadl_header( - void* contig_buffer, - uint32_t size, /* page-size multiple */ - hv_vmbus_channel_msg_info** msg_info, - uint32_t* message_count) -{ - int i; - int page_count; - unsigned long long pfn; - uint32_t msg_size; - hv_vmbus_channel_gpadl_header* gpa_header; - hv_vmbus_channel_gpadl_body* gpadl_body; - hv_vmbus_channel_msg_info* msg_header; - hv_vmbus_channel_msg_info* msg_body; - - int pfnSum, pfnCount, pfnLeft, pfnCurr, pfnSize; - - page_count = size >> PAGE_SHIFT; - pfn = hv_get_phys_addr(contig_buffer) >> PAGE_SHIFT; - - /*do we need a gpadl body msg */ - pfnSize = HV_MAX_SIZE_CHANNEL_MESSAGE - - sizeof(hv_vmbus_channel_gpadl_header) - - sizeof(hv_gpa_range); - pfnCount = pfnSize / sizeof(uint64_t); - - if (page_count > pfnCount) { /* if(we need a gpadl body) */ - /* fill in the header */ - msg_size = sizeof(hv_vmbus_channel_msg_info) - + sizeof(hv_vmbus_channel_gpadl_header) - + sizeof(hv_gpa_range) - + pfnCount * sizeof(uint64_t); - msg_header = malloc(msg_size, M_DEVBUF, M_NOWAIT | M_ZERO); - KASSERT( - msg_header != NULL, - ("Error VMBUS: malloc failed to allocate Gpadl Message!")); - if (msg_header == NULL) - return (ENOMEM); - - TAILQ_INIT(&msg_header->sub_msg_list_anchor); - msg_header->message_size = msg_size; - - gpa_header = (hv_vmbus_channel_gpadl_header*) msg_header->msg; - gpa_header->range_count = 1; - gpa_header->range_buf_len = sizeof(hv_gpa_range) - + page_count * sizeof(uint64_t); - gpa_header->range[0].byte_offset = 0; - gpa_header->range[0].byte_count = size; - for (i = 0; i < pfnCount; i++) { - gpa_header->range[0].pfn_array[i] = pfn + i; - } - *msg_info = msg_header; - *message_count = 1; - - pfnSum = pfnCount; - pfnLeft = page_count - pfnCount; - - /* - * figure out how many pfns we can fit - */ - pfnSize = HV_MAX_SIZE_CHANNEL_MESSAGE - - sizeof(hv_vmbus_channel_gpadl_body); - pfnCount = pfnSize / sizeof(uint64_t); - - /* - * fill in the body - */ - while (pfnLeft) { - if (pfnLeft > pfnCount) { - pfnCurr = pfnCount; - } else { - pfnCurr = pfnLeft; - } - - msg_size = sizeof(hv_vmbus_channel_msg_info) + - sizeof(hv_vmbus_channel_gpadl_body) + - pfnCurr * sizeof(uint64_t); - msg_body = malloc(msg_size, M_DEVBUF, M_NOWAIT | M_ZERO); - KASSERT( - msg_body != NULL, - ("Error VMBUS: malloc failed to allocate Gpadl msg_body!")); - if (msg_body == NULL) - return (ENOMEM); - - msg_body->message_size = msg_size; - (*message_count)++; - gpadl_body = - (hv_vmbus_channel_gpadl_body*) msg_body->msg; - /* - * gpadl_body->gpadl = kbuffer; - */ - for (i = 0; i < pfnCurr; i++) { - gpadl_body->pfn[i] = pfn + pfnSum + i; - } - - TAILQ_INSERT_TAIL( - &msg_header->sub_msg_list_anchor, - msg_body, - msg_list_entry); - pfnSum += pfnCurr; - pfnLeft -= pfnCurr; - } - } else { /* else everything fits in a header */ - - msg_size = sizeof(hv_vmbus_channel_msg_info) + - sizeof(hv_vmbus_channel_gpadl_header) + - sizeof(hv_gpa_range) + - page_count * sizeof(uint64_t); - msg_header = malloc(msg_size, M_DEVBUF, M_NOWAIT | M_ZERO); - KASSERT( - msg_header != NULL, - ("Error VMBUS: malloc failed to allocate Gpadl Message!")); - if (msg_header == NULL) - return (ENOMEM); - - msg_header->message_size = msg_size; - - gpa_header = (hv_vmbus_channel_gpadl_header*) msg_header->msg; - gpa_header->range_count = 1; - gpa_header->range_buf_len = sizeof(hv_gpa_range) + - page_count * sizeof(uint64_t); - gpa_header->range[0].byte_offset = 0; - gpa_header->range[0].byte_count = size; - for (i = 0; i < page_count; i++) { - gpa_header->range[0].pfn_array[i] = pfn + i; - } - - *msg_info = msg_header; - *message_count = 1; - } - - return (0); -} - -/** * @brief Establish a GPADL for the specified buffer */ int -hv_vmbus_channel_establish_gpadl( - hv_vmbus_channel* channel, - void* contig_buffer, - uint32_t size, /* page-size multiple */ - uint32_t* gpadl_handle) - +hv_vmbus_channel_establish_gpadl(struct hv_vmbus_channel *channel, + void *contig_buffer, uint32_t size, uint32_t *gpadl0) { - int ret = 0; - hv_vmbus_channel_gpadl_header* gpadl_msg; - hv_vmbus_channel_gpadl_body* gpadl_body; - hv_vmbus_channel_msg_info* msg_info; - hv_vmbus_channel_msg_info* sub_msg_info; - uint32_t msg_count; - hv_vmbus_channel_msg_info* curr; - uint32_t next_gpadl_handle; - - next_gpadl_handle = atomic_fetchadd_int( - &hv_vmbus_g_connection.next_gpadl_handle, 1); - - ret = vmbus_channel_create_gpadl_header( - contig_buffer, size, &msg_info, &msg_count); + struct vmbus_softc *sc = channel->vmbus_sc; + struct vmbus_msghc *mh; + struct vmbus_chanmsg_gpadl_conn *req; + const struct vmbus_message *msg; + size_t reqsz; + uint32_t gpadl, status; + int page_count, range_len, i, cnt, error; + uint64_t page_id, paddr; - if(ret != 0) { - /* - * XXX - * We can _not_ even revert the above incremental, - * if multiple GPADL establishments are running - * parallelly, decrement the global next_gpadl_handle - * is calling for _big_ trouble. A better solution - * is to have a 0-based GPADL id bitmap ... - */ - return ret; - } + /* + * Preliminary checks. + */ - sema_init(&msg_info->wait_sema, 0, "Open Info Sema"); - gpadl_msg = (hv_vmbus_channel_gpadl_header*) msg_info->msg; - gpadl_msg->header.message_type = HV_CHANNEL_MESSAGEL_GPADL_HEADER; - gpadl_msg->child_rel_id = channel->offer_msg.child_rel_id; - gpadl_msg->gpadl = next_gpadl_handle; - - mtx_lock(&hv_vmbus_g_connection.channel_msg_lock); - TAILQ_INSERT_TAIL( - &hv_vmbus_g_connection.channel_msg_anchor, - msg_info, - msg_list_entry); - - mtx_unlock(&hv_vmbus_g_connection.channel_msg_lock); - - ret = hv_vmbus_post_message( - gpadl_msg, - msg_info->message_size - - (uint32_t) sizeof(hv_vmbus_channel_msg_info)); + KASSERT((size & PAGE_MASK) == 0, + ("invalid GPA size %u, not multiple page size", size)); + page_count = size >> PAGE_SHIFT; - if (ret != 0) - goto cleanup; + paddr = hv_get_phys_addr(contig_buffer); + KASSERT((paddr & PAGE_MASK) == 0, + ("GPA is not page aligned %jx", (uintmax_t)paddr)); + page_id = paddr >> PAGE_SHIFT; - if (msg_count > 1) { - TAILQ_FOREACH(curr, - &msg_info->sub_msg_list_anchor, msg_list_entry) { - sub_msg_info = curr; - gpadl_body = - (hv_vmbus_channel_gpadl_body*) sub_msg_info->msg; - - gpadl_body->header.message_type = - HV_CHANNEL_MESSAGE_GPADL_BODY; - gpadl_body->gpadl = next_gpadl_handle; - - ret = hv_vmbus_post_message( - gpadl_body, - sub_msg_info->message_size - - (uint32_t) sizeof(hv_vmbus_channel_msg_info)); - /* if (the post message failed) give up and clean up */ - if(ret != 0) - goto cleanup; - } + range_len = __offsetof(struct vmbus_gpa_range, gpa_page[page_count]); + /* + * We don't support multiple GPA ranges. + */ + if (range_len > UINT16_MAX) { + device_printf(sc->vmbus_dev, "GPA too large, %d pages\n", + page_count); + return EOPNOTSUPP; } - ret = sema_timedwait(&msg_info->wait_sema, 5 * hz); /* KYS 5 seconds*/ - if (ret != 0) - goto cleanup; - - *gpadl_handle = gpadl_msg->gpadl; - -cleanup: - - mtx_lock(&hv_vmbus_g_connection.channel_msg_lock); - TAILQ_REMOVE(&hv_vmbus_g_connection.channel_msg_anchor, - msg_info, msg_list_entry); - mtx_unlock(&hv_vmbus_g_connection.channel_msg_lock); - - sema_destroy(&msg_info->wait_sema); - free(msg_info, M_DEVBUF); + /* + * Allocate GPADL id. + */ + gpadl = atomic_fetchadd_int( + &hv_vmbus_g_connection.next_gpadl_handle, 1); + *gpadl0 = gpadl; - return (ret); + /* + * Connect this GPADL to the target channel. + * + * NOTE: + * Since each message can only hold small set of page + * addresses, several messages may be required to + * complete the connection. + */ + if (page_count > VMBUS_CHANMSG_GPADL_CONN_PGMAX) + cnt = VMBUS_CHANMSG_GPADL_CONN_PGMAX; + else + cnt = page_count; + page_count -= cnt; + + reqsz = __offsetof(struct vmbus_chanmsg_gpadl_conn, + chm_range.gpa_page[cnt]); + mh = vmbus_msghc_get(sc, reqsz); + if (mh == NULL) { + device_printf(sc->vmbus_dev, + "can not get msg hypercall for gpadl->chan%u\n", + channel->offer_msg.child_rel_id); + return EIO; + } + + req = vmbus_msghc_dataptr(mh); + req->chm_hdr.chm_type = VMBUS_CHANMSG_TYPE_GPADL_CONN; + req->chm_chanid = channel->offer_msg.child_rel_id; + req->chm_gpadl = gpadl; + req->chm_range_len = range_len; + req->chm_range_cnt = 1; + req->chm_range.gpa_len = size; + req->chm_range.gpa_ofs = 0; + for (i = 0; i < cnt; ++i) + req->chm_range.gpa_page[i] = page_id++; + + error = vmbus_msghc_exec(sc, mh); + if (error) { + device_printf(sc->vmbus_dev, + "gpadl->chan%u msg hypercall exec failed: %d\n", + channel->offer_msg.child_rel_id, error); + vmbus_msghc_put(sc, mh); + return error; + } + + while (page_count > 0) { + struct vmbus_chanmsg_gpadl_subconn *subreq; + + if (page_count > VMBUS_CHANMSG_GPADL_SUBCONN_PGMAX) + cnt = VMBUS_CHANMSG_GPADL_SUBCONN_PGMAX; + else + cnt = page_count; + page_count -= cnt; + + reqsz = __offsetof(struct vmbus_chanmsg_gpadl_subconn, + chm_gpa_page[cnt]); + vmbus_msghc_reset(mh, reqsz); + + subreq = vmbus_msghc_dataptr(mh); + subreq->chm_hdr.chm_type = VMBUS_CHANMSG_TYPE_GPADL_SUBCONN; + subreq->chm_gpadl = gpadl; + for (i = 0; i < cnt; ++i) + subreq->chm_gpa_page[i] = page_id++; + + vmbus_msghc_exec_noresult(mh); + } + KASSERT(page_count == 0, ("invalid page count %d", page_count)); + + msg = vmbus_msghc_wait_result(sc, mh); + status = ((const struct vmbus_chanmsg_gpadl_connresp *) + msg->msg_data)->chm_status; + + vmbus_msghc_put(sc, mh); + + if (status != 0) { + device_printf(sc->vmbus_dev, "gpadl->chan%u failed: " + "status %u\n", channel->offer_msg.child_rel_id, status); + return EIO; + } + return 0; } -/** - * @brief Teardown the specified GPADL handle +/* + * Disconnect the GPA from the target channel */ int -hv_vmbus_channel_teardown_gpdal( - hv_vmbus_channel* channel, - uint32_t gpadl_handle) +hv_vmbus_channel_teardown_gpdal(struct hv_vmbus_channel *chan, uint32_t gpadl) { - int ret = 0; - hv_vmbus_channel_gpadl_teardown* msg; - hv_vmbus_channel_msg_info* info; - - info = (hv_vmbus_channel_msg_info *) - malloc( sizeof(hv_vmbus_channel_msg_info) + - sizeof(hv_vmbus_channel_gpadl_teardown), - M_DEVBUF, M_NOWAIT); - KASSERT(info != NULL, - ("Error VMBUS: malloc failed to allocate Gpadl Teardown Msg!")); - if (info == NULL) { - ret = ENOMEM; - goto cleanup; - } - - sema_init(&info->wait_sema, 0, "Open Info Sema"); - - msg = (hv_vmbus_channel_gpadl_teardown*) info->msg; - - msg->header.message_type = HV_CHANNEL_MESSAGE_GPADL_TEARDOWN; - msg->child_rel_id = channel->offer_msg.child_rel_id; - msg->gpadl = gpadl_handle; - - mtx_lock(&hv_vmbus_g_connection.channel_msg_lock); - TAILQ_INSERT_TAIL(&hv_vmbus_g_connection.channel_msg_anchor, - info, msg_list_entry); - mtx_unlock(&hv_vmbus_g_connection.channel_msg_lock); - - ret = hv_vmbus_post_message(msg, - sizeof(hv_vmbus_channel_gpadl_teardown)); - if (ret != 0) - goto cleanup; - - ret = sema_timedwait(&info->wait_sema, 5 * hz); /* KYS 5 seconds */ - -cleanup: - /* - * Received a torndown response - */ - mtx_lock(&hv_vmbus_g_connection.channel_msg_lock); - TAILQ_REMOVE(&hv_vmbus_g_connection.channel_msg_anchor, - info, msg_list_entry); - mtx_unlock(&hv_vmbus_g_connection.channel_msg_lock); - sema_destroy(&info->wait_sema); - free(info, M_DEVBUF); + struct vmbus_softc *sc = chan->vmbus_sc; + struct vmbus_msghc *mh; + struct vmbus_chanmsg_gpadl_disconn *req; + int error; + + mh = vmbus_msghc_get(sc, sizeof(*req)); + if (mh == NULL) { + device_printf(sc->vmbus_dev, + "can not get msg hypercall for gpa x->chan%u\n", + chan->offer_msg.child_rel_id); + return EBUSY; + } + + req = vmbus_msghc_dataptr(mh); + req->chm_hdr.chm_type = VMBUS_CHANMSG_TYPE_GPADL_DISCONN; + req->chm_chanid = chan->offer_msg.child_rel_id; + req->chm_gpadl = gpadl; + + error = vmbus_msghc_exec(sc, mh); + if (error) { + device_printf(sc->vmbus_dev, + "gpa x->chan%u msg hypercall exec failed: %d\n", + chan->offer_msg.child_rel_id, error); + vmbus_msghc_put(sc, mh); + return error; + } + + vmbus_msghc_wait_result(sc, mh); + /* Discard result; no useful information */ + vmbus_msghc_put(sc, mh); - return (ret); + return 0; } static void hv_vmbus_channel_close_internal(hv_vmbus_channel *channel) { - int ret = 0; + struct vmbus_softc *sc = channel->vmbus_sc; + struct vmbus_msghc *mh; + struct vmbus_chanmsg_chclose *req; struct taskqueue *rxq = channel->rxq; - hv_vmbus_channel_close_channel* msg; - hv_vmbus_channel_msg_info* info; + int error; channel->state = HV_CHANNEL_OPEN_STATE; @@ -636,20 +488,31 @@ hv_vmbus_channel_close_internal(hv_vmbus /** * Send a closing message */ - info = (hv_vmbus_channel_msg_info *) - malloc( sizeof(hv_vmbus_channel_msg_info) + - sizeof(hv_vmbus_channel_close_channel), - M_DEVBUF, M_NOWAIT); - KASSERT(info != NULL, ("VMBUS: malloc failed hv_vmbus_channel_close!")); - if(info == NULL) - return; - - msg = (hv_vmbus_channel_close_channel*) info->msg; - msg->header.message_type = HV_CHANNEL_MESSAGE_CLOSE_CHANNEL; - msg->child_rel_id = channel->offer_msg.child_rel_id; - ret = hv_vmbus_post_message( - msg, sizeof(hv_vmbus_channel_close_channel)); + mh = vmbus_msghc_get(sc, sizeof(*req)); + if (mh == NULL) { + device_printf(sc->vmbus_dev, + "can not get msg hypercall for chclose(chan%u)\n", + channel->offer_msg.child_rel_id); + return; + } + + req = vmbus_msghc_dataptr(mh); + req->chm_hdr.chm_type = VMBUS_CHANMSG_TYPE_CHCLOSE; + req->chm_chanid = channel->offer_msg.child_rel_id; + + error = vmbus_msghc_exec_noresult(mh); + vmbus_msghc_put(sc, mh); + + if (error) { + device_printf(sc->vmbus_dev, + "chclose(chan%u) msg hypercall exec failed: %d\n", + channel->offer_msg.child_rel_id, error); + return; + } else if (bootverbose) { + device_printf(sc->vmbus_dev, "close chan%u\n", + channel->offer_msg.child_rel_id); + } /* Tear down the gpadl for the channel's ring buffer */ if (channel->ring_buffer_gpadl_handle) { @@ -665,8 +528,6 @@ hv_vmbus_channel_close_internal(hv_vmbus contigfree(channel->ring_buffer_pages, channel->ring_buffer_size, M_DEVBUF); - - free(info, M_DEVBUF); } /** @@ -988,23 +849,6 @@ VmbusProcessChannelEvent(void* context, hv_vmbus_channel* channel = (hv_vmbus_channel*)context; boolean_t is_batched_reading; - /** - * Find the channel based on this relid and invokes - * the channel callback to process the event - */ - - if (channel == NULL) { - return; - } - /** - * To deal with the race condition where we might - * receive a packet while the relevant driver is - * being unloaded, dispatch the callback while - * holding the channel lock. The unloading driver - * will acquire the same channel lock to set the - * callback to NULL. This closes the window. - */ - if (channel->on_channel_callback != NULL) { arg = channel->channel_callback_context; is_batched_reading = channel->batched_reading; Modified: stable/11/sys/dev/hyperv/vmbus/hv_channel_mgmt.c ============================================================================== --- stable/11/sys/dev/hyperv/vmbus/hv_channel_mgmt.c Fri Oct 14 07:47:07 2016 (r307300) +++ stable/11/sys/dev/hyperv/vmbus/hv_channel_mgmt.c Fri Oct 14 07:47:35 2016 (r307301) @@ -418,46 +418,13 @@ vmbus_channel_on_offers_delivered(struct * @brief Open result handler. * * This is invoked when we received a response - * to our channel open request. Find the matching request, copy the - * response and signal the requesting thread. + * to our channel open request. */ static void vmbus_channel_on_open_result(struct vmbus_softc *sc, const struct vmbus_message *msg) { - const hv_vmbus_channel_msg_header *hdr = - (const hv_vmbus_channel_msg_header *)msg->msg_data; - - const hv_vmbus_channel_open_result *result; - hv_vmbus_channel_msg_info* msg_info; - hv_vmbus_channel_msg_header* requestHeader; - hv_vmbus_channel_open_channel* openMsg; - - result = (const hv_vmbus_channel_open_result *)hdr; - - /* - * Find the open msg, copy the result and signal/unblock the wait event - */ - mtx_lock(&hv_vmbus_g_connection.channel_msg_lock); - - TAILQ_FOREACH(msg_info, &hv_vmbus_g_connection.channel_msg_anchor, - msg_list_entry) { - requestHeader = (hv_vmbus_channel_msg_header*) msg_info->msg; - - if (requestHeader->message_type == - HV_CHANNEL_MESSAGE_OPEN_CHANNEL) { - openMsg = (hv_vmbus_channel_open_channel*) msg_info->msg; - if (openMsg->child_rel_id == result->child_rel_id - && openMsg->open_id == result->open_id) { - memcpy(&msg_info->response.open_result, result, - sizeof(hv_vmbus_channel_open_result)); - sema_post(&msg_info->wait_sema); - break; - } - } - } - mtx_unlock(&hv_vmbus_g_connection.channel_msg_lock); - + vmbus_msghc_wakeup(sc, msg); } /** @@ -471,39 +438,7 @@ static void vmbus_channel_on_gpadl_created(struct vmbus_softc *sc, const struct vmbus_message *msg) { - const hv_vmbus_channel_msg_header *hdr = - (const hv_vmbus_channel_msg_header *)msg->msg_data; - - const hv_vmbus_channel_gpadl_created *gpadl_created; - hv_vmbus_channel_msg_info* msg_info; - hv_vmbus_channel_msg_header* request_header; - hv_vmbus_channel_gpadl_header* gpadl_header; - - gpadl_created = (const hv_vmbus_channel_gpadl_created *)hdr; - - /* Find the establish msg, copy the result and signal/unblock - * the wait event - */ - mtx_lock(&hv_vmbus_g_connection.channel_msg_lock); - TAILQ_FOREACH(msg_info, &hv_vmbus_g_connection.channel_msg_anchor, - msg_list_entry) { - request_header = (hv_vmbus_channel_msg_header*) msg_info->msg; - if (request_header->message_type == - HV_CHANNEL_MESSAGEL_GPADL_HEADER) { - gpadl_header = - (hv_vmbus_channel_gpadl_header*) request_header; - - if ((gpadl_created->child_rel_id == gpadl_header->child_rel_id) - && (gpadl_created->gpadl == gpadl_header->gpadl)) { - memcpy(&msg_info->response.gpadl_created, - gpadl_created, - sizeof(hv_vmbus_channel_gpadl_created)); - sema_post(&msg_info->wait_sema); - break; - } - } - } - mtx_unlock(&hv_vmbus_g_connection.channel_msg_lock); + vmbus_msghc_wakeup(sc, msg); } /** @@ -517,42 +452,7 @@ static void vmbus_channel_on_gpadl_torndown(struct vmbus_softc *sc, const struct vmbus_message *msg) { - const hv_vmbus_channel_msg_header *hdr = - (const hv_vmbus_channel_msg_header *)msg->msg_data; - - const hv_vmbus_channel_gpadl_torndown *gpadl_torndown; - hv_vmbus_channel_msg_info* msg_info; - hv_vmbus_channel_msg_header* requestHeader; - hv_vmbus_channel_gpadl_teardown* gpadlTeardown; - - gpadl_torndown = (const hv_vmbus_channel_gpadl_torndown *)hdr; - - /* - * Find the open msg, copy the result and signal/unblock the - * wait event. *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-all@freebsd.org Fri Oct 14 08:02:40 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 91734C11BB3; Fri, 14 Oct 2016 08:02:40 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 5432BFC1; Fri, 14 Oct 2016 08:02:40 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9E82dNO081739; Fri, 14 Oct 2016 08:02:39 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9E82cjl081723; Fri, 14 Oct 2016 08:02:38 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610140802.u9E82cjl081723@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Fri, 14 Oct 2016 08:02:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307302 - in stable/11/sys: conf dev/hyperv/include dev/hyperv/netvsc dev/hyperv/storvsc dev/hyperv/vmbus modules/hyperv/netvsc modules/hyperv/storvsc modules/hyperv/vmbus X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Oct 2016 08:02:40 -0000 Author: sephe Date: Fri Oct 14 08:02:37 2016 New Revision: 307302 URL: https://svnweb.freebsd.org/changeset/base/307302 Log: MFC 302617-302621,302623,302629-302631 302617 hyperv/vmbus: Flatten channel message response processing. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D6914 302618 hyperv/vmbus: Avoid tx_evtflags setting code duplication. MFC after: 1 week Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D6915 302619 hyperv/vmbus: Busdma-fy Hypercall signal event input parameter. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D6916 302620 hyperv: Nuke unused stuffs Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D6917 302621 hyperv/vmbus: Don't be oversmart in default cpu selection. Pin the channel to cpu0 by default. Drivers having special channel-cpu mapping requirement should call vmbus_channel_cpu_{set,rr}() themselves. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D6918 302623 hyperv/vmbus: Minor renaming Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D6919 302629 hyperv/vmbus: Rework vmbus version accessing. Instead of global variable, vmbus version is accessed through a vmbus DEVMETHOD now. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D6953 302630 hyperv/vmbus: Move GPADL index into vmbus_softc Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D6954 302631 hyperv/vmbus: Move channel list to vmbus_softc Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D6956 Added: stable/11/sys/dev/hyperv/vmbus/vmbus_if.m - copied unchanged from r302629, head/sys/dev/hyperv/vmbus/vmbus_if.m Modified: stable/11/sys/conf/files.amd64 stable/11/sys/conf/files.i386 stable/11/sys/dev/hyperv/include/hyperv.h stable/11/sys/dev/hyperv/include/hyperv_busdma.h stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c stable/11/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c stable/11/sys/dev/hyperv/vmbus/hv_channel.c stable/11/sys/dev/hyperv/vmbus/hv_channel_mgmt.c stable/11/sys/dev/hyperv/vmbus/hv_connection.c stable/11/sys/dev/hyperv/vmbus/hv_vmbus_priv.h stable/11/sys/dev/hyperv/vmbus/hyperv.c stable/11/sys/dev/hyperv/vmbus/hyperv_reg.h stable/11/sys/dev/hyperv/vmbus/hyperv_var.h stable/11/sys/dev/hyperv/vmbus/vmbus.c stable/11/sys/dev/hyperv/vmbus/vmbus_reg.h stable/11/sys/dev/hyperv/vmbus/vmbus_var.h stable/11/sys/modules/hyperv/netvsc/Makefile stable/11/sys/modules/hyperv/storvsc/Makefile stable/11/sys/modules/hyperv/vmbus/Makefile Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/conf/files.amd64 ============================================================================== --- stable/11/sys/conf/files.amd64 Fri Oct 14 07:47:35 2016 (r307301) +++ stable/11/sys/conf/files.amd64 Fri Oct 14 08:02:37 2016 (r307302) @@ -309,6 +309,7 @@ dev/hyperv/vmbus/hyperv.c optional hy dev/hyperv/vmbus/hyperv_busdma.c optional hyperv dev/hyperv/vmbus/vmbus.c optional hyperv dev/hyperv/vmbus/vmbus_et.c optional hyperv +dev/hyperv/vmbus/vmbus_if.m optional hyperv dev/hyperv/vmbus/amd64/hyperv_machdep.c optional hyperv dev/hyperv/vmbus/amd64/vmbus_vector.S optional hyperv dev/nfe/if_nfe.c optional nfe pci Modified: stable/11/sys/conf/files.i386 ============================================================================== --- stable/11/sys/conf/files.i386 Fri Oct 14 07:47:35 2016 (r307301) +++ stable/11/sys/conf/files.i386 Fri Oct 14 08:02:37 2016 (r307302) @@ -266,6 +266,7 @@ dev/hyperv/vmbus/hyperv.c optional hy dev/hyperv/vmbus/hyperv_busdma.c optional hyperv dev/hyperv/vmbus/vmbus.c optional hyperv dev/hyperv/vmbus/vmbus_et.c optional hyperv +dev/hyperv/vmbus/vmbus_if.m optional hyperv dev/hyperv/vmbus/i386/hyperv_machdep.c optional hyperv dev/hyperv/vmbus/i386/vmbus_vector.S optional hyperv dev/ichwd/ichwd.c optional ichwd Modified: stable/11/sys/dev/hyperv/include/hyperv.h ============================================================================== --- stable/11/sys/dev/hyperv/include/hyperv.h Fri Oct 14 07:47:35 2016 (r307301) +++ stable/11/sys/dev/hyperv/include/hyperv.h Fri Oct 14 08:02:37 2016 (r307302) @@ -55,6 +55,7 @@ #include #include +#include typedef uint8_t hv_bool_uint8_t; @@ -72,10 +73,13 @@ typedef uint8_t hv_bool_uint8_t; * 2.4 -- Windows 8 * 3.0 -- Windows 8.1 */ -#define HV_VMBUS_VERSION_WS2008 ((0 << 16) | (13)) -#define HV_VMBUS_VERSION_WIN7 ((1 << 16) | (1)) -#define HV_VMBUS_VERSION_WIN8 ((2 << 16) | (4)) -#define HV_VMBUS_VERSION_WIN8_1 ((3 << 16) | (0)) +#define VMBUS_VERSION_WS2008 ((0 << 16) | (13)) +#define VMBUS_VERSION_WIN7 ((1 << 16) | (1)) +#define VMBUS_VERSION_WIN8 ((2 << 16) | (4)) +#define VMBUS_VERSION_WIN8_1 ((3 << 16) | (0)) + +#define VMBUS_VERSION_MAJOR(ver) (((uint32_t)(ver)) >> 16) +#define VMBUS_VERSION_MINOR(ver) (((uint32_t)(ver)) & 0xffff) /* * Make maximum size of pipe payload of 16K @@ -528,22 +532,7 @@ typedef union { } __packed hv_vmbus_connection_id; -/* - * Definition of the hv_vmbus_signal_event hypercall input structure - */ -typedef struct { - hv_vmbus_connection_id connection_id; - uint16_t flag_number; - uint16_t rsvd_z; -} __packed hv_vmbus_input_signal_event; - -typedef struct { - uint64_t align8; - hv_vmbus_input_signal_event event; -} __packed hv_vmbus_input_signal_event_buffer; - typedef struct hv_vmbus_channel { - TAILQ_ENTRY(hv_vmbus_channel) list_entry; struct hv_device* device; struct vmbus_softc *vmbus_sc; hv_vmbus_channel_state state; @@ -589,14 +578,8 @@ typedef struct hv_vmbus_channel { boolean_t is_dedicated_interrupt; - /* - * Used as an input param for HV_CALL_SIGNAL_EVENT hypercall. - */ - hv_vmbus_input_signal_event_buffer signal_event_buffer; - /* - * 8-bytes aligned of the buffer above - */ - hv_vmbus_input_signal_event *signal_event_param; + struct hypercall_sigevt_in *ch_sigevt; + struct hyperv_dma ch_sigevt_dma; /* * From Win8, this field specifies the target virtual process @@ -643,6 +626,7 @@ typedef struct hv_vmbus_channel { void *hv_chan_priv3; struct task ch_detach_task; + TAILQ_ENTRY(hv_vmbus_channel) ch_link; } hv_vmbus_channel; #define HV_VMBUS_CHAN_ISPRIMARY(chan) ((chan)->primary_channel == NULL) @@ -726,6 +710,7 @@ int hv_vmbus_channel_teardown_gpdal( struct hv_vmbus_channel* vmbus_select_outgoing_channel(struct hv_vmbus_channel *promary); void vmbus_channel_cpu_set(struct hv_vmbus_channel *chan, int cpu); +void vmbus_channel_cpu_rr(struct hv_vmbus_channel *chan); struct hv_vmbus_channel ** vmbus_get_subchan(struct hv_vmbus_channel *pri_chan, int subchan_cnt); void vmbus_rel_subchan(struct hv_vmbus_channel **subchan, int subchan_cnt); @@ -741,5 +726,4 @@ hv_get_phys_addr(void *virt) return (ret); } -extern uint32_t hv_vmbus_protocal_version; #endif /* __HYPERV_H__ */ Modified: stable/11/sys/dev/hyperv/include/hyperv_busdma.h ============================================================================== --- stable/11/sys/dev/hyperv/include/hyperv_busdma.h Fri Oct 14 07:47:35 2016 (r307301) +++ stable/11/sys/dev/hyperv/include/hyperv_busdma.h Fri Oct 14 08:02:37 2016 (r307302) @@ -29,6 +29,10 @@ #ifndef _HYPERV_BUSDMA_H_ #define _HYPERV_BUSDMA_H_ +#include +#include +#include + struct hyperv_dma { bus_addr_t hv_paddr; bus_dma_tag_t hv_dtag; Modified: stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Fri Oct 14 07:47:35 2016 (r307301) +++ stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Fri Oct 14 08:02:37 2016 (r307302) @@ -114,9 +114,11 @@ __FBSDID("$FreeBSD$"); #include #include + #include "hv_net_vsc.h" #include "hv_rndis.h" #include "hv_rndis_filter.h" +#include "vmbus_if.h" #define hv_chan_rxr hv_chan_priv1 #define hv_chan_txr hv_chan_priv2 @@ -2369,8 +2371,10 @@ static int hn_create_tx_ring(struct hn_softc *sc, int id) { struct hn_tx_ring *txr = &sc->hn_tx_ring[id]; + device_t dev = sc->hn_dev; bus_dma_tag_t parent_dtag; int error, i; + uint32_t version; txr->hn_sc = sc; txr->hn_tx_idx = id; @@ -2409,10 +2413,18 @@ hn_create_tx_ring(struct hn_softc *sc, i } txr->hn_direct_tx_size = hn_direct_tx_size; - if (hv_vmbus_protocal_version >= HV_VMBUS_VERSION_WIN8_1) + version = VMBUS_GET_VERSION(device_get_parent(dev), dev); + if (version >= VMBUS_VERSION_WIN8_1) { txr->hn_csum_assist = HN_CSUM_ASSIST; - else + } else { txr->hn_csum_assist = HN_CSUM_ASSIST_WIN8; + if (id == 0) { + device_printf(dev, "bus version %u.%u, " + "no UDP checksum offloading\n", + VMBUS_VERSION_MAJOR(version), + VMBUS_VERSION_MINOR(version)); + } + } /* * Always schedule transmission instead of trying to do direct @@ -2420,7 +2432,7 @@ hn_create_tx_ring(struct hn_softc *sc, i */ txr->hn_sched_tx = 1; - parent_dtag = bus_get_dma_tag(sc->hn_dev); + parent_dtag = bus_get_dma_tag(dev); /* DMA tag for RNDIS messages. */ error = bus_dma_tag_create(parent_dtag, /* parent */ @@ -2437,7 +2449,7 @@ hn_create_tx_ring(struct hn_softc *sc, i NULL, /* lockfuncarg */ &txr->hn_tx_rndis_dtag); if (error) { - device_printf(sc->hn_dev, "failed to create rndis dmatag\n"); + device_printf(dev, "failed to create rndis dmatag\n"); return error; } @@ -2456,7 +2468,7 @@ hn_create_tx_ring(struct hn_softc *sc, i NULL, /* lockfuncarg */ &txr->hn_tx_data_dtag); if (error) { - device_printf(sc->hn_dev, "failed to create data dmatag\n"); + device_printf(dev, "failed to create data dmatag\n"); return error; } @@ -2473,7 +2485,7 @@ hn_create_tx_ring(struct hn_softc *sc, i BUS_DMA_WAITOK | BUS_DMA_COHERENT, &txd->rndis_msg_dmap); if (error) { - device_printf(sc->hn_dev, + device_printf(dev, "failed to allocate rndis_msg, %d\n", i); return error; } @@ -2484,7 +2496,7 @@ hn_create_tx_ring(struct hn_softc *sc, i hyperv_dma_map_paddr, &txd->rndis_msg_paddr, BUS_DMA_NOWAIT); if (error) { - device_printf(sc->hn_dev, + device_printf(dev, "failed to load rndis_msg, %d\n", i); bus_dmamem_free(txr->hn_tx_rndis_dtag, txd->rndis_msg, txd->rndis_msg_dmap); @@ -2495,7 +2507,7 @@ hn_create_tx_ring(struct hn_softc *sc, i error = bus_dmamap_create(txr->hn_tx_data_dtag, 0, &txd->data_dmap); if (error) { - device_printf(sc->hn_dev, + device_printf(dev, "failed to allocate tx data dmamap\n"); bus_dmamap_unload(txr->hn_tx_rndis_dtag, txd->rndis_msg_dmap); @@ -2523,7 +2535,7 @@ hn_create_tx_ring(struct hn_softc *sc, i * Create per TX ring sysctl tree: * dev.hn.UNIT.tx.RINGID */ - ctx = device_get_sysctl_ctx(sc->hn_dev); + ctx = device_get_sysctl_ctx(dev); child = SYSCTL_CHILDREN(sc->hn_tx_sysctl_tree); snprintf(name, sizeof(name), "%d", id); Modified: stable/11/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c ============================================================================== --- stable/11/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c Fri Oct 14 07:47:35 2016 (r307301) +++ stable/11/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c Fri Oct 14 08:02:37 2016 (r307302) @@ -72,7 +72,9 @@ __FBSDID("$FreeBSD$"); #include #include + #include "hv_vstorage.h" +#include "vmbus_if.h" #define STORVSC_RINGBUFFER_SIZE (20*PAGE_SIZE) #define STORVSC_MAX_LUNS_PER_TARGET (64) @@ -361,6 +363,7 @@ storvsc_subchan_attach(struct hv_vmbus_c memset(&props, 0, sizeof(props)); + vmbus_channel_cpu_rr(new_channel); ret = hv_vmbus_channel_open(new_channel, sc->hs_drv_props->drv_ringbuffer_size, sc->hs_drv_props->drv_ringbuffer_size, @@ -464,6 +467,7 @@ hv_storvsc_channel_init(struct hv_device struct storvsc_softc *sc; uint16_t max_chans = 0; boolean_t support_multichannel = FALSE; + uint32_t version; max_chans = 0; support_multichannel = FALSE; @@ -588,8 +592,9 @@ hv_storvsc_channel_init(struct hv_device /* multi-channels feature is supported by WIN8 and above version */ max_chans = vstor_packet->u.chan_props.max_channel_cnt; - if ((hv_vmbus_protocal_version != HV_VMBUS_VERSION_WIN7) && - (hv_vmbus_protocal_version != HV_VMBUS_VERSION_WS2008) && + version = VMBUS_GET_VERSION(device_get_parent(dev->device), + dev->device); + if (version != VMBUS_VERSION_WIN7 && version != VMBUS_VERSION_WS2008 && (vstor_packet->u.chan_props.flags & HV_STORAGE_SUPPORTS_MULTI_CHANNEL)) { support_multichannel = TRUE; @@ -655,7 +660,7 @@ hv_storvsc_connect_vsp(struct hv_device /* * Open the channel */ - + vmbus_channel_cpu_rr(dev->channel); ret = hv_vmbus_channel_open( dev->channel, sc->hs_drv_props->drv_ringbuffer_size, Modified: stable/11/sys/dev/hyperv/vmbus/hv_channel.c ============================================================================== --- stable/11/sys/dev/hyperv/vmbus/hv_channel.c Fri Oct 14 07:47:35 2016 (r307301) +++ stable/11/sys/dev/hyperv/vmbus/hv_channel.c Fri Oct 14 08:02:37 2016 (r307302) @@ -46,6 +46,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include @@ -58,21 +59,21 @@ static void VmbusProcessChannelEvent(voi static void vmbus_channel_set_event(hv_vmbus_channel *channel) { + struct vmbus_softc *sc = channel->vmbus_sc; + uint32_t chanid = channel->offer_msg.child_rel_id; + + atomic_set_long(&sc->vmbus_tx_evtflags[chanid >> VMBUS_EVTFLAG_SHIFT], + 1UL << (chanid & VMBUS_EVTFLAG_MASK)); + if (channel->offer_msg.monitor_allocated) { - struct vmbus_softc *sc = channel->vmbus_sc; hv_vmbus_monitor_page *monitor_page; - uint32_t chanid = channel->offer_msg.child_rel_id; - - atomic_set_long( - &sc->vmbus_tx_evtflags[chanid >> VMBUS_EVTFLAG_SHIFT], - 1UL << (chanid & VMBUS_EVTFLAG_MASK)); monitor_page = sc->vmbus_mnf2; synch_set_bit(channel->monitor_bit, (uint32_t *)&monitor_page-> trigger_group[channel->monitor_group].u.pending); } else { - hv_vmbus_set_event(channel); + hypercall_signal_event(channel->ch_sigevt_dma.hv_paddr); } } @@ -342,8 +343,7 @@ hv_vmbus_channel_establish_gpadl(struct /* * Allocate GPADL id. */ - gpadl = atomic_fetchadd_int( - &hv_vmbus_g_connection.next_gpadl_handle, 1); + gpadl = vmbus_gpadl_alloc(sc); *gpadl0 = gpadl; /* Modified: stable/11/sys/dev/hyperv/vmbus/hv_channel_mgmt.c ============================================================================== --- stable/11/sys/dev/hyperv/vmbus/hv_channel_mgmt.c Fri Oct 14 07:47:35 2016 (r307301) +++ stable/11/sys/dev/hyperv/vmbus/hv_channel_mgmt.c Fri Oct 14 08:02:37 2016 (r307302) @@ -32,6 +32,7 @@ #include #include +#include #include #include #include @@ -46,18 +47,10 @@ static void vmbus_chan_detach_task(void static void vmbus_channel_on_offer(struct vmbus_softc *, const struct vmbus_message *); -static void vmbus_channel_on_open_result(struct vmbus_softc *, - const struct vmbus_message *); static void vmbus_channel_on_offer_rescind(struct vmbus_softc *, const struct vmbus_message *); -static void vmbus_channel_on_gpadl_created(struct vmbus_softc *, - const struct vmbus_message *); -static void vmbus_channel_on_gpadl_torndown(struct vmbus_softc *, - const struct vmbus_message *); static void vmbus_channel_on_offers_delivered(struct vmbus_softc *, const struct vmbus_message *); -static void vmbus_channel_on_version_response(struct vmbus_softc *, - const struct vmbus_message *); /** * Channel message dispatch table @@ -71,13 +64,13 @@ vmbus_chanmsg_process[HV_CHANNEL_MESSAGE [HV_CHANNEL_MESSAGE_ALL_OFFERS_DELIVERED] = vmbus_channel_on_offers_delivered, [HV_CHANNEL_MESSAGE_OPEN_CHANNEL_RESULT] = - vmbus_channel_on_open_result, + vmbus_msghc_wakeup, [HV_CHANNEL_MESSAGE_GPADL_CREATED] = - vmbus_channel_on_gpadl_created, + vmbus_msghc_wakeup, [HV_CHANNEL_MESSAGE_GPADL_TORNDOWN] = - vmbus_channel_on_gpadl_torndown, + vmbus_msghc_wakeup, [HV_CHANNEL_MESSAGE_VERSION_RESPONSE] = - vmbus_channel_on_version_response + vmbus_msghc_wakeup }; /** @@ -115,6 +108,7 @@ hv_vmbus_free_vmbus_channel(hv_vmbus_cha static void vmbus_channel_process_offer(hv_vmbus_channel *new_channel) { + struct vmbus_softc *sc = new_channel->vmbus_sc; hv_vmbus_channel* channel; uint32_t relid; @@ -122,7 +116,7 @@ vmbus_channel_process_offer(hv_vmbus_cha /* * Make sure this is a new offer */ - mtx_lock(&hv_vmbus_g_connection.channel_lock); + mtx_lock(&sc->vmbus_chlist_lock); if (relid == 0) { /* * XXX channel0 will not be processed; skip it. @@ -132,8 +126,7 @@ vmbus_channel_process_offer(hv_vmbus_cha hv_vmbus_g_connection.channels[relid] = new_channel; } - TAILQ_FOREACH(channel, &hv_vmbus_g_connection.channel_anchor, - list_entry) { + TAILQ_FOREACH(channel, &sc->vmbus_chlist, ch_link) { if (memcmp(&channel->offer_msg.offer.interface_type, &new_channel->offer_msg.offer.interface_type, sizeof(hv_guid)) == 0 && @@ -145,10 +138,9 @@ vmbus_channel_process_offer(hv_vmbus_cha if (channel == NULL) { /* Install the new primary channel */ - TAILQ_INSERT_TAIL(&hv_vmbus_g_connection.channel_anchor, - new_channel, list_entry); + TAILQ_INSERT_TAIL(&sc->vmbus_chlist, new_channel, ch_link); } - mtx_unlock(&hv_vmbus_g_connection.channel_lock); + mtx_unlock(&sc->vmbus_chlist_lock); if (channel != NULL) { /* @@ -172,11 +164,19 @@ vmbus_channel_process_offer(hv_vmbus_cha new_channel->offer_msg.offer.sub_channel_index); } - /* Insert new channel into channel_anchor. */ - mtx_lock(&hv_vmbus_g_connection.channel_lock); - TAILQ_INSERT_TAIL(&hv_vmbus_g_connection.channel_anchor, - new_channel, list_entry); - mtx_unlock(&hv_vmbus_g_connection.channel_lock); + /* + * Insert the new channel to the end of the global + * channel list. + * + * NOTE: + * The new sub-channel MUST be inserted AFTER it's + * primary channel, so that the primary channel will + * be found in the above loop for its baby siblings. + */ + mtx_lock(&sc->vmbus_chlist_lock); + TAILQ_INSERT_TAIL(&sc->vmbus_chlist, new_channel, + ch_link); + mtx_unlock(&sc->vmbus_chlist_lock); if(bootverbose) printf("VMBUS: new multi-channel offer <%p>, " @@ -229,8 +229,8 @@ vmbus_channel_cpu_set(struct hv_vmbus_ch { KASSERT(cpu >= 0 && cpu < mp_ncpus, ("invalid cpu %d", cpu)); - if (hv_vmbus_protocal_version == HV_VMBUS_VERSION_WS2008 || - hv_vmbus_protocal_version == HV_VMBUS_VERSION_WIN7) { + if (chan->vmbus_sc->vmbus_version == VMBUS_VERSION_WS2008 || + chan->vmbus_sc->vmbus_version == VMBUS_VERSION_WIN7) { /* Only cpu0 is supported */ cpu = 0; } @@ -245,61 +245,25 @@ vmbus_channel_cpu_set(struct hv_vmbus_ch } } -/** - * Array of device guids that are performance critical. We try to distribute - * the interrupt load for these devices across all online cpus. - */ -static const hv_guid high_perf_devices[] = { - {HV_NIC_GUID, }, - {HV_IDE_GUID, }, - {HV_SCSI_GUID, }, -}; - -enum { - PERF_CHN_NIC = 0, - PERF_CHN_IDE, - PERF_CHN_SCSI, - MAX_PERF_CHN, -}; +void +vmbus_channel_cpu_rr(struct hv_vmbus_channel *chan) +{ + static uint32_t vmbus_chan_nextcpu; + int cpu; -/* - * We use this static number to distribute the channel interrupt load. - */ -static uint32_t next_vcpu; + cpu = atomic_fetchadd_int(&vmbus_chan_nextcpu, 1) % mp_ncpus; + vmbus_channel_cpu_set(chan, cpu); +} -/** - * Starting with Win8, we can statically distribute the incoming - * channel interrupt load by binding a channel to VCPU. We - * implement here a simple round robin scheme for distributing - * the interrupt load. - * We will bind channels that are not performance critical to cpu 0 and - * performance critical channels (IDE, SCSI and Network) will be uniformly - * distributed across all available CPUs. - */ static void -vmbus_channel_select_defcpu(struct hv_vmbus_channel *channel) +vmbus_channel_select_defcpu(struct hv_vmbus_channel *chan) { - uint32_t current_cpu; - int i; - boolean_t is_perf_channel = FALSE; - const hv_guid *guid = &channel->offer_msg.offer.interface_type; - - for (i = PERF_CHN_NIC; i < MAX_PERF_CHN; i++) { - if (memcmp(guid->data, high_perf_devices[i].data, - sizeof(hv_guid)) == 0) { - is_perf_channel = TRUE; - break; - } - } - - if (!is_perf_channel) { - /* Stick to cpu0 */ - vmbus_channel_cpu_set(channel, 0); - return; - } - /* mp_ncpus should have the number cpus currently online */ - current_cpu = (++next_vcpu % mp_ncpus); - vmbus_channel_cpu_set(channel, current_cpu); + /* + * By default, pin the channel to cpu0. Devices having + * special channel-cpu mapping requirement should call + * vmbus_channel_cpu_{set,rr}(). + */ + vmbus_channel_cpu_set(chan, 0); } /** @@ -335,23 +299,23 @@ vmbus_channel_on_offer_internal(struct v */ new_channel->batched_reading = TRUE; - new_channel->signal_event_param = - (hv_vmbus_input_signal_event *) - (HV_ALIGN_UP((unsigned long) - &new_channel->signal_event_buffer, - HV_HYPERCALL_PARAM_ALIGN)); - - new_channel->signal_event_param->connection_id.as_uint32_t = 0; - new_channel->signal_event_param->connection_id.u.id = - HV_VMBUS_EVENT_CONNECTION_ID; - new_channel->signal_event_param->flag_number = 0; - new_channel->signal_event_param->rsvd_z = 0; + new_channel->ch_sigevt = hyperv_dmamem_alloc( + bus_get_dma_tag(sc->vmbus_dev), + HYPERCALL_SIGEVTIN_ALIGN, 0, sizeof(struct hypercall_sigevt_in), + &new_channel->ch_sigevt_dma, BUS_DMA_WAITOK | BUS_DMA_ZERO); + if (new_channel->ch_sigevt == NULL) { + device_printf(sc->vmbus_dev, "sigevt alloc failed\n"); + /* XXX */ + mtx_destroy(&new_channel->sc_lock); + free(new_channel, M_DEVBUF); + return; + } + new_channel->ch_sigevt->hc_connid = VMBUS_CONNID_EVENT; - if (hv_vmbus_protocal_version != HV_VMBUS_VERSION_WS2008) { + if (sc->vmbus_version != VMBUS_VERSION_WS2008) { new_channel->is_dedicated_interrupt = (offer->is_dedicated_interrupt != 0); - new_channel->signal_event_param->connection_id.u.id = - offer->connection_id; + new_channel->ch_sigevt->hc_connid = offer->connection_id; } memcpy(&new_channel->offer_msg, offer, @@ -415,67 +379,18 @@ vmbus_channel_on_offers_delivered(struct } /** - * @brief Open result handler. - * - * This is invoked when we received a response - * to our channel open request. - */ -static void -vmbus_channel_on_open_result(struct vmbus_softc *sc, - const struct vmbus_message *msg) -{ - vmbus_msghc_wakeup(sc, msg); -} - -/** - * @brief GPADL created handler. - * - * This is invoked when we received a response - * to our gpadl create request. Find the matching request, copy the - * response and signal the requesting thread. - */ -static void -vmbus_channel_on_gpadl_created(struct vmbus_softc *sc, - const struct vmbus_message *msg) -{ - vmbus_msghc_wakeup(sc, msg); -} - -/** - * @brief GPADL torndown handler. - * - * This is invoked when we received a respons - * to our gpadl teardown request. Find the matching request, copy the - * response and signal the requesting thread - */ -static void -vmbus_channel_on_gpadl_torndown(struct vmbus_softc *sc, - const struct vmbus_message *msg) -{ - vmbus_msghc_wakeup(sc, msg); -} - -static void -vmbus_channel_on_version_response(struct vmbus_softc *sc, - const struct vmbus_message *msg) -{ - vmbus_msghc_wakeup(sc, msg); -} - -/** * @brief Release channels that are unattached/unconnected (i.e., no drivers associated) */ void -hv_vmbus_release_unattached_channels(void) +hv_vmbus_release_unattached_channels(struct vmbus_softc *sc) { hv_vmbus_channel *channel; - mtx_lock(&hv_vmbus_g_connection.channel_lock); + mtx_lock(&sc->vmbus_chlist_lock); - while (!TAILQ_EMPTY(&hv_vmbus_g_connection.channel_anchor)) { - channel = TAILQ_FIRST(&hv_vmbus_g_connection.channel_anchor); - TAILQ_REMOVE(&hv_vmbus_g_connection.channel_anchor, - channel, list_entry); + while (!TAILQ_EMPTY(&sc->vmbus_chlist)) { + channel = TAILQ_FIRST(&sc->vmbus_chlist); + TAILQ_REMOVE(&sc->vmbus_chlist, channel, ch_link); if (HV_VMBUS_CHAN_ISPRIMARY(channel)) { /* Only primary channel owns the hv_device */ @@ -485,7 +400,8 @@ hv_vmbus_release_unattached_channels(voi } bzero(hv_vmbus_g_connection.channels, sizeof(hv_vmbus_channel*) * VMBUS_CHAN_MAX); - mtx_unlock(&hv_vmbus_g_connection.channel_lock); + + mtx_unlock(&sc->vmbus_chlist_lock); } /** Modified: stable/11/sys/dev/hyperv/vmbus/hv_connection.c ============================================================================== --- stable/11/sys/dev/hyperv/vmbus/hv_connection.c Fri Oct 14 07:47:35 2016 (r307301) +++ stable/11/sys/dev/hyperv/vmbus/hv_connection.c Fri Oct 14 08:02:37 2016 (r307302) @@ -47,10 +47,7 @@ * Globals */ hv_vmbus_connection hv_vmbus_g_connection = - { .connect_state = HV_DISCONNECTED, - .next_gpadl_handle = 0xE1E10, }; - -uint32_t hv_vmbus_protocal_version; + { .connect_state = HV_DISCONNECTED }; /** * Send a connect request on the partition service connection @@ -70,10 +67,6 @@ hv_vmbus_connect(struct vmbus_softc *sc) */ hv_vmbus_g_connection.connect_state = HV_CONNECTING; - TAILQ_INIT(&hv_vmbus_g_connection.channel_anchor); - mtx_init(&hv_vmbus_g_connection.channel_lock, "vmbus channel", - NULL, MTX_DEF); - hv_vmbus_g_connection.channels = malloc(sizeof(hv_vmbus_channel*) * VMBUS_CHAN_MAX, M_DEVBUF, M_WAITOK | M_ZERO); @@ -158,23 +151,6 @@ vmbus_event_proc_compat(struct vmbus_sof } } -/** - * Send an event notification to the parent - */ -int -hv_vmbus_set_event(hv_vmbus_channel *channel) -{ - struct vmbus_softc *sc = channel->vmbus_sc; - int ret = 0; - uint32_t chanid = channel->offer_msg.child_rel_id; - - atomic_set_long(&sc->vmbus_tx_evtflags[chanid >> VMBUS_EVTFLAG_SHIFT], - 1UL << (chanid & VMBUS_EVTFLAG_MASK)); - ret = hv_vmbus_signal_event(channel->signal_event_param); - - return (ret); -} - void vmbus_on_channel_open(const struct hv_vmbus_channel *chan) { Modified: stable/11/sys/dev/hyperv/vmbus/hv_vmbus_priv.h ============================================================================== --- stable/11/sys/dev/hyperv/vmbus/hv_vmbus_priv.h Fri Oct 14 07:47:35 2016 (r307301) +++ stable/11/sys/dev/hyperv/vmbus/hv_vmbus_priv.h Fri Oct 14 08:02:37 2016 (r307302) @@ -38,28 +38,7 @@ #include - -/* - * Status codes for hypervisor operations. - */ - -typedef uint16_t hv_vmbus_status; - -#define HV_MESSAGE_SIZE (256) -#define HV_MESSAGE_PAYLOAD_BYTE_COUNT (240) -#define HV_MESSAGE_PAYLOAD_QWORD_COUNT (30) -#define HV_ANY_VP (0xFFFFFFFF) - -/* - * MessageId: HV_STATUS_INSUFFICIENT_BUFFERS - * MessageText: - * You did not supply enough message buffers to send a message. - */ - -#define HV_STATUS_SUCCESS ((uint16_t)0) -#define HV_STATUS_INSUFFICIENT_BUFFERS ((uint16_t)0x0013) - -typedef void (*hv_vmbus_channel_callback)(void *context); +struct vmbus_softc; typedef struct { void* data; @@ -118,74 +97,6 @@ typedef struct hv_vmbus_channel_packet_m hv_vmbus_multipage_buffer range; } __packed hv_vmbus_channel_packet_multipage_buffer; -enum { - HV_VMBUS_MESSAGE_CONNECTION_ID = 1, - HV_VMBUS_MESSAGE_PORT_ID = 1, - HV_VMBUS_EVENT_CONNECTION_ID = 2, - HV_VMBUS_EVENT_PORT_ID = 2, - HV_VMBUS_MONITOR_CONNECTION_ID = 3, - HV_VMBUS_MONITOR_PORT_ID = 3, -}; - -#define HV_PRESENT_BIT 0x80000000 - -#define HV_HYPERCALL_PARAM_ALIGN sizeof(uint64_t) - -/* - * Define hypervisor message types - */ -typedef enum { - - HV_MESSAGE_TYPE_NONE = 0x00000000, - - /* - * Memory access messages - */ - HV_MESSAGE_TYPE_UNMAPPED_GPA = 0x80000000, - HV_MESSAGE_TYPE_GPA_INTERCEPT = 0x80000001, - - /* - * Timer notification messages - */ - HV_MESSAGE_TIMER_EXPIRED = 0x80000010, - - /* - * Error messages - */ - HV_MESSAGE_TYPE_INVALID_VP_REGISTER_VALUE = 0x80000020, - HV_MESSAGE_TYPE_UNRECOVERABLE_EXCEPTION = 0x80000021, - HV_MESSAGE_TYPE_UNSUPPORTED_FEATURE = 0x80000022, - - /* - * Trace buffer complete messages - */ - HV_MESSAGE_TYPE_EVENT_LOG_BUFFER_COMPLETE = 0x80000040, - - /* - * Platform-specific processor intercept messages - */ - HV_MESSAGE_TYPE_X64_IO_PORT_INTERCEPT = 0x80010000, - HV_MESSAGE_TYPE_X64_MSR_INTERCEPT = 0x80010001, - HV_MESSAGE_TYPE_X64_CPU_INTERCEPT = 0x80010002, - HV_MESSAGE_TYPE_X64_EXCEPTION_INTERCEPT = 0x80010003, - HV_MESSAGE_TYPE_X64_APIC_EOI = 0x80010004, - HV_MESSAGE_TYPE_X64_LEGACY_FP_ERROR = 0x80010005 - -} hv_vmbus_msg_type; - -/* - * Define port identifier type - */ -typedef union _hv_vmbus_port_id { - uint32_t as_uint32_t; - struct { - uint32_t id:24; - uint32_t reserved:8; - } u ; -} hv_vmbus_port_id; - -typedef uint64_t hv_vmbus_partition_id; - /* * VM Bus connection states */ @@ -196,19 +107,8 @@ typedef enum { HV_DISCONNECTING } hv_vmbus_connect_state; -#define HV_MAX_SIZE_CHANNEL_MESSAGE HV_MESSAGE_PAYLOAD_BYTE_COUNT - - typedef struct { hv_vmbus_connect_state connect_state; - uint32_t next_gpadl_handle; - - /** - * List of primary channels. Sub channels will be linked - * under their primary channel. - */ - TAILQ_HEAD(, hv_vmbus_channel) channel_anchor; - struct mtx channel_lock; /** * channel table for fast lookup through id. @@ -277,14 +177,6 @@ typedef struct { uint8_t rsvd_z4[1984]; } hv_vmbus_monitor_page; -/* - * Declare the various hypercall operations - */ -typedef enum { - HV_CALL_POST_MESSAGE = 0x005c, - HV_CALL_SIGNAL_EVENT = 0x005d, -} hv_vmbus_call_code; - /** * Global variables */ @@ -342,17 +234,14 @@ uint32_t hv_ring_buffer_read_end( hv_vmbus_ring_buffer_info *ring_info); void hv_vmbus_free_vmbus_channel(hv_vmbus_channel *channel); -void hv_vmbus_release_unattached_channels(void); - -uint16_t hv_vmbus_signal_event(void *con_id); +void hv_vmbus_release_unattached_channels( + struct vmbus_softc *); struct hv_device* hv_vmbus_child_device_create( hv_guid device_type, hv_guid device_instance, hv_vmbus_channel *channel); -struct vmbus_softc; - void hv_vmbus_child_device_register(struct vmbus_softc *, struct hv_device *child_dev); int hv_vmbus_child_device_unregister( @@ -363,6 +252,5 @@ int hv_vmbus_child_device_unregister( */ int hv_vmbus_connect(struct vmbus_softc *); int hv_vmbus_disconnect(void); -int hv_vmbus_set_event(hv_vmbus_channel *channel); #endif /* __HYPERV_PRIV_H__ */ Modified: stable/11/sys/dev/hyperv/vmbus/hyperv.c ============================================================================== --- stable/11/sys/dev/hyperv/vmbus/hyperv.c Fri Oct 14 07:47:35 2016 (r307301) +++ stable/11/sys/dev/hyperv/vmbus/hyperv.c Fri Oct 14 08:02:37 2016 (r307302) @@ -101,23 +101,6 @@ hyperv_get_timecount(struct timecounter return rdmsr(MSR_HV_TIME_REF_COUNT); } -/** - * @brief Invoke the specified hypercall - */ -static uint64_t -hv_vmbus_do_hypercall(uint64_t value, void *input, void *output) -{ - uint64_t in_paddr = 0, out_paddr = 0; - - if (input != NULL) - in_paddr = hv_get_phys_addr(input); - if (output != NULL) - out_paddr = hv_get_phys_addr(output); - - return hypercall_md(hypercall_context.hc_addr, value, - in_paddr, out_paddr); -} - uint64_t hypercall_post_message(bus_addr_t msg_paddr) { @@ -125,21 +108,11 @@ hypercall_post_message(bus_addr_t msg_pa HYPERCALL_POST_MESSAGE, msg_paddr, 0); } -/** - * @brief Signal an event on the specified connection using the hypervisor - * event IPC. (This involves a hypercall.) - */ -hv_vmbus_status -hv_vmbus_signal_event(void *con_id) -{ - hv_vmbus_status status; - - status = hv_vmbus_do_hypercall( - HV_CALL_SIGNAL_EVENT, - con_id, - 0) & 0xFFFF; - - return (status); +uint64_t +hypercall_signal_event(bus_addr_t sigevt_paddr) +{ + return hypercall_md(hypercall_context.hc_addr, + HYPERCALL_SIGNAL_EVENT, sigevt_paddr, 0); } int Modified: stable/11/sys/dev/hyperv/vmbus/hyperv_reg.h ============================================================================== --- stable/11/sys/dev/hyperv/vmbus/hyperv_reg.h Fri Oct 14 07:47:35 2016 (r307301) +++ stable/11/sys/dev/hyperv/vmbus/hyperv_reg.h Fri Oct 14 08:02:37 2016 (r307302) @@ -148,6 +148,7 @@ * Hypercall input values */ #define HYPERCALL_POST_MESSAGE 0x005c +#define HYPERCALL_SIGNAL_EVENT 0x005d /* * Hypercall input parameters @@ -169,4 +170,15 @@ struct hypercall_postmsg_in { } __packed; CTASSERT(sizeof(struct hypercall_postmsg_in) == HYPERCALL_POSTMSGIN_SIZE); +/* + * HYPERCALL_SIGNAL_EVENT + */ +#define HYPERCALL_SIGEVTIN_ALIGN 8 + +struct hypercall_sigevt_in { + uint32_t hc_connid; + uint16_t hc_evtflag_ofs; + uint16_t hc_rsvd; +} __packed; + #endif /* !_HYPERV_REG_H_ */ Modified: stable/11/sys/dev/hyperv/vmbus/hyperv_var.h ============================================================================== --- stable/11/sys/dev/hyperv/vmbus/hyperv_var.h Fri Oct 14 07:47:35 2016 (r307301) +++ stable/11/sys/dev/hyperv/vmbus/hyperv_var.h Fri Oct 14 08:02:37 2016 (r307302) @@ -39,5 +39,6 @@ extern u_int hyperv_features; extern u_int hyperv_recommends; uint64_t hypercall_post_message(bus_addr_t msg_paddr); +uint64_t hypercall_signal_event(bus_addr_t sigevt_paddr); #endif /* !_HYPERV_VAR_H_ */ Modified: stable/11/sys/dev/hyperv/vmbus/vmbus.c ============================================================================== --- stable/11/sys/dev/hyperv/vmbus/vmbus.c Fri Oct 14 07:47:35 2016 (r307301) +++ stable/11/sys/dev/hyperv/vmbus/vmbus.c Fri Oct 14 08:02:37 2016 (r307302) @@ -68,12 +68,9 @@ __FBSDID("$FreeBSD$"); #include #include "acpi_if.h" +#include "vmbus_if.h" -/* - * NOTE: DO NOT CHANGE THESE - */ -#define VMBUS_CONNID_MESSAGE 1 -#define VMBUS_CONNID_EVENT 2 +#define VMBUS_GPADL_START 0xe1e10 struct vmbus_msghc { struct hypercall_postmsg_in *mh_inprm; @@ -96,10 +93,9 @@ struct vmbus_msghc_ctx { #define VMBUS_MSGHC_CTXF_DESTROY 0x0001 static int vmbus_init(struct vmbus_softc *); -static int vmbus_init_contact(struct vmbus_softc *, - uint32_t); +static int vmbus_connect(struct vmbus_softc *, uint32_t); static int vmbus_req_channels(struct vmbus_softc *sc); -static void vmbus_uninit(struct vmbus_softc *); +static void vmbus_disconnect(struct vmbus_softc *); static int vmbus_scan(struct vmbus_softc *); static void vmbus_scan_wait(struct vmbus_softc *); static void vmbus_scan_newdev(struct vmbus_softc *); @@ -120,10 +116,10 @@ struct vmbus_softc *vmbus_sc; extern inthand_t IDTVEC(vmbus_isr); static const uint32_t vmbus_version[] = { - HV_VMBUS_VERSION_WIN8_1, - HV_VMBUS_VERSION_WIN8, - HV_VMBUS_VERSION_WIN7, - HV_VMBUS_VERSION_WS2008 + VMBUS_VERSION_WIN8_1, + VMBUS_VERSION_WIN8, + VMBUS_VERSION_WIN7, + VMBUS_VERSION_WS2008 }; *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-all@freebsd.org Fri Oct 14 08:14:52 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E73A0C11EB5; Fri, 14 Oct 2016 08:14:52 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id BD29E792; Fri, 14 Oct 2016 08:14:52 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9E8EpiG086010; Fri, 14 Oct 2016 08:14:51 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9E8EphR086005; Fri, 14 Oct 2016 08:14:51 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610140814.u9E8EphR086005@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Fri, 14 Oct 2016 08:14:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307303 - in stable/11/sys/dev/hyperv: include netvsc vmbus X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Oct 2016 08:14:53 -0000 Author: sephe Date: Fri Oct 14 08:14:51 2016 New Revision: 307303 URL: https://svnweb.freebsd.org/changeset/base/307303 Log: MFC 302632-302634 302632 hyperv/vmbus: More verbose for GPADL_connect/chan_{rescind,offer} Reviewed by: Dexuan Cui , Hongjiang Zhang Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D6976 302633 hyperv/vmbus: Free sysctl properly upon channel close. Prepare for sub-channel re-open. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D6977 302634 hyperv/vmbus: Fix sub-channel re-open support. For multi-channel devices, once the primary channel is closed, a set of 'rescind' messages for sub-channels will be delivered by Hypervisor. Sub-channel MUST be freed according to these 'rescind' messages; directly re-openning sub-channels in the same fashion as the primary channel's re-opening does NOT work at all. After the primary channel is re-opened, requested # of sub- channels will be delivered though 'channel offer' messages, and this set of newly offered channels can be opened along side with the primary channel. This unbreaks the MTU setting for hn(4), which requires re- openning all existsing channels upon MTU change. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D6978 Modified: stable/11/sys/dev/hyperv/include/hyperv.h stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c stable/11/sys/dev/hyperv/vmbus/hv_channel.c stable/11/sys/dev/hyperv/vmbus/hv_channel_mgmt.c stable/11/sys/dev/hyperv/vmbus/vmbus_reg.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/hyperv/include/hyperv.h ============================================================================== --- stable/11/sys/dev/hyperv/include/hyperv.h Fri Oct 14 08:02:37 2016 (r307302) +++ stable/11/sys/dev/hyperv/include/hyperv.h Fri Oct 14 08:14:51 2016 (r307303) @@ -49,6 +49,7 @@ #include #include #include +#include #include #include #include @@ -627,6 +628,8 @@ typedef struct hv_vmbus_channel { struct task ch_detach_task; TAILQ_ENTRY(hv_vmbus_channel) ch_link; + + struct sysctl_ctx_list ch_sysctl_ctx; } hv_vmbus_channel; #define HV_VMBUS_CHAN_ISPRIMARY(chan) ((chan)->primary_channel == NULL) @@ -714,6 +717,7 @@ void vmbus_channel_cpu_rr(struct hv_vmb struct hv_vmbus_channel ** vmbus_get_subchan(struct hv_vmbus_channel *pri_chan, int subchan_cnt); void vmbus_rel_subchan(struct hv_vmbus_channel **subchan, int subchan_cnt); +void vmbus_drain_subchan(struct hv_vmbus_channel *pri_chan); /** * @brief Get physical address from virtual Modified: stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Fri Oct 14 08:02:37 2016 (r307302) +++ stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Fri Oct 14 08:14:51 2016 (r307303) @@ -345,6 +345,7 @@ static void hn_destroy_rx_data(struct hn static void hn_set_tx_chimney_size(struct hn_softc *, int); static void hn_channel_attach(struct hn_softc *, struct hv_vmbus_channel *); static void hn_subchan_attach(struct hn_softc *, struct hv_vmbus_channel *); +static void hn_subchan_setup(struct hn_softc *); static int hn_transmit(struct ifnet *, struct mbuf *); static void hn_xmit_qflush(struct ifnet *); @@ -575,25 +576,8 @@ netvsc_attach(device_t dev) device_printf(dev, "%d TX ring, %d RX ring\n", sc->hn_tx_ring_inuse, sc->hn_rx_ring_inuse); - if (sc->net_dev->num_channel > 1) { - struct hv_vmbus_channel **subchan; - int subchan_cnt = sc->net_dev->num_channel - 1; - int i; - - /* Wait for sub-channels setup to complete. */ - subchan = vmbus_get_subchan(pri_chan, subchan_cnt); - - /* Attach the sub-channels. */ - for (i = 0; i < subchan_cnt; ++i) { - /* NOTE: Calling order is critical. */ - hn_subchan_attach(sc, subchan[i]); - hv_nv_subchan_attach(subchan[i]); - } - - /* Release the sub-channels */ - vmbus_rel_subchan(subchan, subchan_cnt); - device_printf(dev, "%d sub-channels setup done\n", subchan_cnt); - } + if (sc->net_dev->num_channel > 1) + hn_subchan_setup(sc); #if __FreeBSD_version >= 1100099 if (sc->hn_rx_ring_inuse > 1) { @@ -1620,6 +1604,10 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, NV_UNLOCK(sc); break; } + + /* Wait for subchannels to be destroyed */ + vmbus_drain_subchan(hn_dev->channel); + error = hv_rf_on_device_add(hn_dev, &device_info, sc->hn_rx_ring_inuse); if (error) { @@ -1628,6 +1616,26 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, NV_UNLOCK(sc); break; } + KASSERT(sc->hn_rx_ring_cnt == sc->net_dev->num_channel, + ("RX ring count %d and channel count %u mismatch", + sc->hn_rx_ring_cnt, sc->net_dev->num_channel)); + if (sc->net_dev->num_channel > 1) { + int r; + + /* + * Skip the rings on primary channel; they are + * handled by the hv_rf_on_device_add() above. + */ + for (r = 1; r < sc->hn_rx_ring_cnt; ++r) { + sc->hn_rx_ring[r].hn_rx_flags &= + ~HN_RX_FLAG_ATTACHED; + } + for (r = 1; r < sc->hn_tx_ring_cnt; ++r) { + sc->hn_tx_ring[r].hn_tx_flags &= + ~HN_TX_FLAG_ATTACHED; + } + hn_subchan_setup(sc); + } sc->hn_tx_chimney_max = sc->net_dev->send_section_size; if (sc->hn_tx_ring[0].hn_tx_chimney_size > @@ -2980,6 +2988,29 @@ hn_subchan_attach(struct hn_softc *sc, s } static void +hn_subchan_setup(struct hn_softc *sc) +{ + struct hv_device *device_ctx = vmbus_get_devctx(sc->hn_dev); + struct hv_vmbus_channel **subchan; + int subchan_cnt = sc->net_dev->num_channel - 1; + int i; + + /* Wait for sub-channels setup to complete. */ + subchan = vmbus_get_subchan(device_ctx->channel, subchan_cnt); + + /* Attach the sub-channels. */ + for (i = 0; i < subchan_cnt; ++i) { + /* NOTE: Calling order is critical. */ + hn_subchan_attach(sc, subchan[i]); + hv_nv_subchan_attach(subchan[i]); + } + + /* Release the sub-channels */ + vmbus_rel_subchan(subchan, subchan_cnt); + if_printf(sc->hn_ifp, "%d sub-channels setup done\n", subchan_cnt); +} + +static void hn_tx_taskq_create(void *arg __unused) { if (!hn_share_tx_taskq) Modified: stable/11/sys/dev/hyperv/vmbus/hv_channel.c ============================================================================== --- stable/11/sys/dev/hyperv/vmbus/hv_channel.c Fri Oct 14 08:02:37 2016 (r307302) +++ stable/11/sys/dev/hyperv/vmbus/hv_channel.c Fri Oct 14 08:14:51 2016 (r307303) @@ -111,7 +111,8 @@ vmbus_channel_sysctl_create(hv_vmbus_cha ch_id = primary_ch->offer_msg.child_rel_id; sub_ch_id = channel->offer_msg.offer.sub_channel_index; } - ctx = device_get_sysctl_ctx(dev); + ctx = &channel->ch_sysctl_ctx; + sysctl_ctx_init(ctx); /* This creates dev.DEVNAME.DEVUNIT.channel tree */ devch_sysctl = SYSCTL_ADD_NODE(ctx, SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), @@ -423,6 +424,11 @@ hv_vmbus_channel_establish_gpadl(struct device_printf(sc->vmbus_dev, "gpadl->chan%u failed: " "status %u\n", channel->offer_msg.child_rel_id, status); return EIO; + } else { + if (bootverbose) { + device_printf(sc->vmbus_dev, "gpadl->chan%u " + "succeeded\n", channel->offer_msg.child_rel_id); + } } return 0; } @@ -477,6 +483,7 @@ hv_vmbus_channel_close_internal(hv_vmbus int error; channel->state = HV_CHANNEL_OPEN_STATE; + sysctl_ctx_free(&channel->ch_sysctl_ctx); /* * set rxq to NULL to avoid more requests be scheduled Modified: stable/11/sys/dev/hyperv/vmbus/hv_channel_mgmt.c ============================================================================== --- stable/11/sys/dev/hyperv/vmbus/hv_channel_mgmt.c Fri Oct 14 08:02:37 2016 (r307302) +++ stable/11/sys/dev/hyperv/vmbus/hv_channel_mgmt.c Fri Oct 14 08:14:51 2016 (r307303) @@ -142,6 +142,19 @@ vmbus_channel_process_offer(hv_vmbus_cha } mtx_unlock(&sc->vmbus_chlist_lock); + if (bootverbose) { + char logstr[64]; + + logstr[0] = '\0'; + if (channel != NULL) { + snprintf(logstr, sizeof(logstr), ", primary chan%u", + channel->offer_msg.child_rel_id); + } + device_printf(sc->vmbus_dev, "chan%u subchanid%u offer%s\n", + new_channel->offer_msg.child_rel_id, + new_channel->offer_msg.offer.sub_channel_index, logstr); + } + if (channel != NULL) { /* * Check if this is a sub channel. @@ -157,13 +170,6 @@ vmbus_channel_process_offer(hv_vmbus_cha new_channel, sc_list_entry); mtx_unlock(&channel->sc_lock); - if (bootverbose) { - printf("VMBUS get multi-channel offer, " - "rel=%u, sub=%u\n", - new_channel->offer_msg.child_rel_id, - new_channel->offer_msg.offer.sub_channel_index); - } - /* * Insert the new channel to the end of the global * channel list. @@ -178,11 +184,6 @@ vmbus_channel_process_offer(hv_vmbus_cha ch_link); mtx_unlock(&sc->vmbus_chlist_lock); - if(bootverbose) - printf("VMBUS: new multi-channel offer <%p>, " - "its primary channel is <%p>.\n", - new_channel, new_channel->primary_channel); - new_channel->state = HV_CHANNEL_OPEN_STATE; /* @@ -345,6 +346,10 @@ vmbus_channel_on_offer_rescind(struct vm hv_vmbus_channel* channel; rescind = (const hv_vmbus_channel_rescind_offer *)msg->msg_data; + if (bootverbose) { + device_printf(sc->vmbus_dev, "chan%u rescind\n", + rescind->child_rel_id); + } channel = hv_vmbus_g_connection.channels[rescind->child_rel_id]; if (channel == NULL) @@ -362,6 +367,54 @@ vmbus_chan_detach_task(void *xchan, int if (HV_VMBUS_CHAN_ISPRIMARY(chan)) { /* Only primary channel owns the hv_device */ hv_vmbus_child_device_unregister(chan->device); + /* NOTE: DO NOT free primary channel for now */ + } else { + struct vmbus_softc *sc = chan->vmbus_sc; + struct hv_vmbus_channel *pri_chan = chan->primary_channel; + struct vmbus_chanmsg_chfree *req; + struct vmbus_msghc *mh; + int error; + + mh = vmbus_msghc_get(sc, sizeof(*req)); + if (mh == NULL) { + device_printf(sc->vmbus_dev, + "can not get msg hypercall for chfree(chan%u)\n", + chan->offer_msg.child_rel_id); + goto remove; + } + + req = vmbus_msghc_dataptr(mh); + req->chm_hdr.chm_type = VMBUS_CHANMSG_TYPE_CHFREE; + req->chm_chanid = chan->offer_msg.child_rel_id; + + error = vmbus_msghc_exec_noresult(mh); + vmbus_msghc_put(sc, mh); + + if (error) { + device_printf(sc->vmbus_dev, + "chfree(chan%u) failed: %d", + chan->offer_msg.child_rel_id, error); + /* NOTE: Move on! */ + } else { + if (bootverbose) { + device_printf(sc->vmbus_dev, "chan%u freed\n", + chan->offer_msg.child_rel_id); + } + } +remove: + mtx_lock(&sc->vmbus_chlist_lock); + TAILQ_REMOVE(&sc->vmbus_chlist, chan, ch_link); + mtx_unlock(&sc->vmbus_chlist_lock); + + mtx_lock(&pri_chan->sc_lock); + TAILQ_REMOVE(&pri_chan->sc_list_anchor, chan, sc_list_entry); + KASSERT(pri_chan->subchan_cnt > 0, + ("invalid subchan_cnt %d", pri_chan->subchan_cnt)); + pri_chan->subchan_cnt--; + mtx_unlock(&pri_chan->sc_lock); + wakeup(pri_chan); + + hv_vmbus_free_vmbus_channel(chan); } } @@ -499,6 +552,15 @@ vmbus_rel_subchan(struct hv_vmbus_channe } void +vmbus_drain_subchan(struct hv_vmbus_channel *pri_chan) +{ + mtx_lock(&pri_chan->sc_lock); + while (pri_chan->subchan_cnt > 0) + mtx_sleep(pri_chan, &pri_chan->sc_lock, 0, "dsubch", 0); + mtx_unlock(&pri_chan->sc_lock); +} + +void vmbus_chan_msgproc(struct vmbus_softc *sc, const struct vmbus_message *msg) { vmbus_chanmsg_proc_t msg_proc; Modified: stable/11/sys/dev/hyperv/vmbus/vmbus_reg.h ============================================================================== --- stable/11/sys/dev/hyperv/vmbus/vmbus_reg.h Fri Oct 14 08:02:37 2016 (r307302) +++ stable/11/sys/dev/hyperv/vmbus/vmbus_reg.h Fri Oct 14 08:14:51 2016 (r307303) @@ -102,6 +102,7 @@ struct vmbus_gpa_range { #define VMBUS_CHANMSG_TYPE_GPADL_CONNRESP 10 /* RESP */ #define VMBUS_CHANMSG_TYPE_GPADL_DISCONN 11 /* REQ */ #define VMBUS_CHANMSG_TYPE_GPADL_DISCONNRESP 12 /* RESP */ +#define VMBUS_CHANMSG_TYPE_CHFREE 13 /* REQ */ #define VMBUS_CHANMSG_TYPE_CONNECT 14 /* REQ */ #define VMBUS_CHANMSG_TYPE_CONNECT_RESP 15 /* RESP */ #define VMBUS_CHANMSG_TYPE_DISCONNECT 16 /* REQ */ @@ -206,4 +207,10 @@ struct vmbus_chanmsg_gpadl_disconn { uint32_t chm_gpadl; } __packed; +/* VMBUS_CHANMSG_TYPE_CHFREE */ +struct vmbus_chanmsg_chfree { + struct vmbus_chanmsg_hdr chm_hdr; + uint32_t chm_chanid; +} __packed; + #endif /* !_VMBUS_REG_H_ */ From owner-svn-src-all@freebsd.org Fri Oct 14 08:18:57 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 182CBC11FAD; Fri, 14 Oct 2016 08:18:57 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id CA7C49C4; Fri, 14 Oct 2016 08:18:56 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9E8ItEv086214; Fri, 14 Oct 2016 08:18:55 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9E8ItuE086209; Fri, 14 Oct 2016 08:18:55 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610140818.u9E8ItuE086209@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Fri, 14 Oct 2016 08:18:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307304 - stable/11/sys/dev/hyperv/vmbus X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Oct 2016 08:18:57 -0000 Author: sephe Date: Fri Oct 14 08:18:55 2016 New Revision: 307304 URL: https://svnweb.freebsd.org/changeset/base/307304 Log: MFC 302636-302638 302636 hyperv/vmbus: Move channel map to vmbus_softc Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D6982 302637 hyperv/vmbus: Remove needed bits Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7002 302638 hyperv/vmbus: Destroy channel list lock upon attach failure and detach. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7003 Modified: stable/11/sys/dev/hyperv/vmbus/hv_channel_mgmt.c stable/11/sys/dev/hyperv/vmbus/hv_connection.c stable/11/sys/dev/hyperv/vmbus/hv_vmbus_priv.h stable/11/sys/dev/hyperv/vmbus/vmbus.c stable/11/sys/dev/hyperv/vmbus/vmbus_var.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/hyperv/vmbus/hv_channel_mgmt.c ============================================================================== --- stable/11/sys/dev/hyperv/vmbus/hv_channel_mgmt.c Fri Oct 14 08:14:51 2016 (r307303) +++ stable/11/sys/dev/hyperv/vmbus/hv_channel_mgmt.c Fri Oct 14 08:18:55 2016 (r307304) @@ -123,7 +123,7 @@ vmbus_channel_process_offer(hv_vmbus_cha */ printf("VMBUS: got channel0 offer\n"); } else { - hv_vmbus_g_connection.channels[relid] = new_channel; + sc->vmbus_chmap[relid] = new_channel; } TAILQ_FOREACH(channel, &sc->vmbus_chlist, ch_link) { @@ -351,10 +351,10 @@ vmbus_channel_on_offer_rescind(struct vm rescind->child_rel_id); } - channel = hv_vmbus_g_connection.channels[rescind->child_rel_id]; + channel = sc->vmbus_chmap[rescind->child_rel_id]; if (channel == NULL) return; - hv_vmbus_g_connection.channels[rescind->child_rel_id] = NULL; + sc->vmbus_chmap[rescind->child_rel_id] = NULL; taskqueue_enqueue(taskqueue_thread, &channel->ch_detach_task); } @@ -451,8 +451,8 @@ hv_vmbus_release_unattached_channels(str } hv_vmbus_free_vmbus_channel(channel); } - bzero(hv_vmbus_g_connection.channels, - sizeof(hv_vmbus_channel*) * VMBUS_CHAN_MAX); + bzero(sc->vmbus_chmap, + sizeof(struct hv_vmbus_channel *) * VMBUS_CHAN_MAX); mtx_unlock(&sc->vmbus_chlist_lock); } Modified: stable/11/sys/dev/hyperv/vmbus/hv_connection.c ============================================================================== --- stable/11/sys/dev/hyperv/vmbus/hv_connection.c Fri Oct 14 08:14:51 2016 (r307303) +++ stable/11/sys/dev/hyperv/vmbus/hv_connection.c Fri Oct 14 08:18:55 2016 (r307304) @@ -43,53 +43,9 @@ #include #include -/* - * Globals - */ -hv_vmbus_connection hv_vmbus_g_connection = - { .connect_state = HV_DISCONNECTED }; - -/** - * Send a connect request on the partition service connection - */ -int -hv_vmbus_connect(struct vmbus_softc *sc) -{ - /** - * Make sure we are not connecting or connected - */ - if (hv_vmbus_g_connection.connect_state != HV_DISCONNECTED) { - return (-1); - } - - /** - * Initialize the vmbus connection - */ - hv_vmbus_g_connection.connect_state = HV_CONNECTING; - - hv_vmbus_g_connection.channels = malloc(sizeof(hv_vmbus_channel*) * - VMBUS_CHAN_MAX, M_DEVBUF, M_WAITOK | M_ZERO); - - hv_vmbus_g_connection.connect_state = HV_CONNECTED; - - return (0); -} - -/** - * Send a disconnect request on the partition service connection - */ -int -hv_vmbus_disconnect(void) -{ - - free(hv_vmbus_g_connection.channels, M_DEVBUF); - hv_vmbus_g_connection.connect_state = HV_DISCONNECTED; - - return (0); -} - static __inline void -vmbus_event_flags_proc(volatile u_long *event_flags, int flag_cnt) +vmbus_event_flags_proc(struct vmbus_softc *sc, volatile u_long *event_flags, + int flag_cnt) { int f; @@ -112,7 +68,7 @@ vmbus_event_flags_proc(volatile u_long * flags &= ~(1UL << bit); rel_id = rel_id_base + bit; - channel = hv_vmbus_g_connection.channels[rel_id]; + channel = sc->vmbus_chmap[rel_id]; /* if channel is closed or closing */ if (channel == NULL || channel->rxq == NULL) @@ -135,7 +91,7 @@ vmbus_event_proc(struct vmbus_softc *sc, * to get the id of the channel that has the pending interrupt. */ eventf = VMBUS_PCPU_GET(sc, event_flags, cpu) + VMBUS_SINT_MESSAGE; - vmbus_event_flags_proc(eventf->evt_flags, + vmbus_event_flags_proc(sc, eventf->evt_flags, VMBUS_PCPU_GET(sc, event_flags_cnt, cpu)); } @@ -146,7 +102,7 @@ vmbus_event_proc_compat(struct vmbus_sof eventf = VMBUS_PCPU_GET(sc, event_flags, cpu) + VMBUS_SINT_MESSAGE; if (atomic_testandclear_long(&eventf->evt_flags[0], 0)) { - vmbus_event_flags_proc(sc->vmbus_rx_evtflags, + vmbus_event_flags_proc(sc, sc->vmbus_rx_evtflags, VMBUS_CHAN_MAX_COMPAT >> VMBUS_EVTFLAG_SHIFT); } } Modified: stable/11/sys/dev/hyperv/vmbus/hv_vmbus_priv.h ============================================================================== --- stable/11/sys/dev/hyperv/vmbus/hv_vmbus_priv.h Fri Oct 14 08:14:51 2016 (r307303) +++ stable/11/sys/dev/hyperv/vmbus/hv_vmbus_priv.h Fri Oct 14 08:18:55 2016 (r307304) @@ -97,25 +97,6 @@ typedef struct hv_vmbus_channel_packet_m hv_vmbus_multipage_buffer range; } __packed hv_vmbus_channel_packet_multipage_buffer; -/* - * VM Bus connection states - */ -typedef enum { - HV_DISCONNECTED, - HV_CONNECTING, - HV_CONNECTED, - HV_DISCONNECTING -} hv_vmbus_connect_state; - -typedef struct { - hv_vmbus_connect_state connect_state; - - /** - * channel table for fast lookup through id. - */ - hv_vmbus_channel **channels; -} hv_vmbus_connection; - typedef union { uint32_t as_uint32_t; struct { @@ -177,12 +158,6 @@ typedef struct { uint8_t rsvd_z4[1984]; } hv_vmbus_monitor_page; -/** - * Global variables - */ - -extern hv_vmbus_connection hv_vmbus_g_connection; - /* * Private, VM Bus functions */ @@ -247,10 +222,4 @@ void hv_vmbus_child_device_register(st int hv_vmbus_child_device_unregister( struct hv_device *child_dev); -/** - * Connection interfaces - */ -int hv_vmbus_connect(struct vmbus_softc *); -int hv_vmbus_disconnect(void); - #endif /* __HYPERV_PRIV_H__ */ Modified: stable/11/sys/dev/hyperv/vmbus/vmbus.c ============================================================================== --- stable/11/sys/dev/hyperv/vmbus/vmbus.c Fri Oct 14 08:14:51 2016 (r307303) +++ stable/11/sys/dev/hyperv/vmbus/vmbus.c Fri Oct 14 08:18:55 2016 (r307304) @@ -1132,6 +1132,9 @@ vmbus_doattach(struct vmbus_softc *sc) sc->vmbus_gpadl = VMBUS_GPADL_START; mtx_init(&sc->vmbus_chlist_lock, "vmbus chlist", NULL, MTX_DEF); TAILQ_INIT(&sc->vmbus_chlist); + sc->vmbus_chmap = malloc( + sizeof(struct hv_vmbus_channel *) * VMBUS_CHAN_MAX, M_DEVBUF, + M_WAITOK | M_ZERO); /* * Create context for "post message" Hypercalls @@ -1166,12 +1169,8 @@ vmbus_doattach(struct vmbus_softc *sc) sc->vmbus_flags |= VMBUS_FLAG_SYNIC; /* - * Connect to VMBus in the root partition + * Initialize vmbus, e.g. connect to Hypervisor. */ - ret = hv_vmbus_connect(sc); - if (ret != 0) - goto cleanup; - ret = vmbus_init(sc); if (ret != 0) goto cleanup; @@ -1201,7 +1200,9 @@ cleanup: vmbus_msghc_ctx_destroy(sc->vmbus_msg_hc); sc->vmbus_msg_hc = NULL; } + free(sc->vmbus_chmap, M_DEVBUF); mtx_destroy(&sc->vmbus_scan_lock); + mtx_destroy(&sc->vmbus_chlist_lock); return (ret); } @@ -1267,7 +1268,6 @@ vmbus_detach(device_t dev) hv_vmbus_release_unattached_channels(sc); vmbus_disconnect(sc); - hv_vmbus_disconnect(); if (sc->vmbus_flags & VMBUS_FLAG_SYNIC) { sc->vmbus_flags &= ~VMBUS_FLAG_SYNIC; @@ -1282,7 +1282,10 @@ vmbus_detach(device_t dev) sc->vmbus_msg_hc = NULL; } + free(sc->vmbus_chmap, M_DEVBUF); mtx_destroy(&sc->vmbus_scan_lock); + mtx_destroy(&sc->vmbus_chlist_lock); + return (0); } Modified: stable/11/sys/dev/hyperv/vmbus/vmbus_var.h ============================================================================== --- stable/11/sys/dev/hyperv/vmbus/vmbus_var.h Fri Oct 14 08:14:51 2016 (r307303) +++ stable/11/sys/dev/hyperv/vmbus/vmbus_var.h Fri Oct 14 08:18:55 2016 (r307304) @@ -75,6 +75,7 @@ struct vmbus_softc { u_long *vmbus_rx_evtflags; /* compat evtflgs from host */ + struct hv_vmbus_channel **vmbus_chmap; struct vmbus_msghc_ctx *vmbus_msg_hc; struct vmbus_pcpu_data vmbus_pcpu[MAXCPU]; From owner-svn-src-all@freebsd.org Fri Oct 14 08:25:51 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 85900C10210; Fri, 14 Oct 2016 08:25:51 +0000 (UTC) (envelope-from kp@FreeBSD.org) Received: from venus.codepro.be (venus.codepro.be [IPv6:2a01:4f8:162:1127::2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "*.codepro.be", Issuer "Gandi Standard SSL CA 2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 1BF6A11B; Fri, 14 Oct 2016 08:25:51 +0000 (UTC) (envelope-from kp@FreeBSD.org) Received: from [172.16.5.2] (vega.codepro.be [IPv6:2a01:4f8:162:1127::3]) (Authenticated sender: kp) by venus.codepro.be (Postfix) with ESMTPSA id 19DBE15371; Fri, 14 Oct 2016 10:25:49 +0200 (CEST) From: "Kristof Provost" To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Cc: franco@opnsense.org Subject: Re: svn commit: r307235 - in head: sbin/pfctl share/man/man5 sys/netpfil/pf Date: Fri, 14 Oct 2016 10:25:47 +0200 Message-ID: <676A40F0-F529-4DFB-8F56-2607D000A47F@FreeBSD.org> In-Reply-To: <201610132034.u9DKYi07016276@repo.freebsd.org> References: <201610132034.u9DKYi07016276@repo.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; format=flowed X-Mailer: MailMate (2.0BETAr6058) X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Oct 2016 08:25:51 -0000 This work was done by franco_opnsense.org I forgot to credit him in the commit message. Sorry Franco. Regards, Kristof On 13 Oct 2016, at 22:34, Kristof Provost wrote: > Author: kp > Date: Thu Oct 13 20:34:44 2016 > New Revision: 307235 > URL: https://svnweb.freebsd.org/changeset/base/307235 > > Log: > pf: port extended DSCP support from OpenBSD > > Ignore the ECN bits on 'tos' and 'set-tos' and allow to use > DCSP names instead of having to embed their TOS equivalents > as plain numbers. > > Obtained from: OpenBSD > Sponsored by: OPNsense > Differential Revision: https://reviews.freebsd.org/D8165 > > Modified: > head/sbin/pfctl/parse.y > head/share/man/man5/pf.conf.5 > head/sys/netpfil/pf/pf.c > head/sys/netpfil/pf/pf_norm.c > > Modified: head/sbin/pfctl/parse.y > ============================================================================== > --- head/sbin/pfctl/parse.y Thu Oct 13 20:15:47 2016 (r307234) > +++ head/sbin/pfctl/parse.y Thu Oct 13 20:34:44 2016 (r307235) > @@ -351,6 +351,8 @@ void decide_address_family(struct node_ > void remove_invalid_hosts(struct node_host **, sa_family_t *); > int invalid_redirect(struct node_host *, sa_family_t); > u_int16_t parseicmpspec(char *, sa_family_t); > +int kw_casecmp(const void *, const void *); > +int map_tos(char *string, int *); > > static TAILQ_HEAD(loadanchorshead, loadanchors) > loadanchorshead = TAILQ_HEAD_INITIALIZER(loadanchorshead); > @@ -3584,15 +3586,17 @@ icmp6type : STRING { > ; > > tos : STRING { > - if (!strcmp($1, "lowdelay")) > - $$ = IPTOS_LOWDELAY; > - else if (!strcmp($1, "throughput")) > - $$ = IPTOS_THROUGHPUT; > - else if (!strcmp($1, "reliability")) > - $$ = IPTOS_RELIABILITY; > - else if ($1[0] == '0' && $1[1] == 'x') > - $$ = strtoul($1, NULL, 16); > - else > + int val; > + char *end; > + > + if (map_tos($1, &val)) > + $$ = val; > + else if ($1[0] == '0' && $1[1] == 'x') { > + errno = 0; > + $$ = strtoul($1, &end, 16); > + if (errno || *end != '\0') > + $$ = 256; > + } else > $$ = 256; /* flag bad argument */ > if ($$ < 0 || $$ > 255) { > yyerror("illegal tos value %s", $1); > @@ -6250,6 +6254,57 @@ pfctl_load_anchors(int dev, struct pfctl > } > > int > +kw_casecmp(const void *k, const void *e) > +{ > + return (strcasecmp(k, ((const struct keywords *)e)->k_name)); > +} > + > +int > +map_tos(char *s, int *val) > +{ > + /* DiffServ Codepoints and other TOS mappings */ > + const struct keywords toswords[] = { > + { "af11", IPTOS_DSCP_AF11 }, > + { "af12", IPTOS_DSCP_AF12 }, > + { "af13", IPTOS_DSCP_AF13 }, > + { "af21", IPTOS_DSCP_AF21 }, > + { "af22", IPTOS_DSCP_AF22 }, > + { "af23", IPTOS_DSCP_AF23 }, > + { "af31", IPTOS_DSCP_AF31 }, > + { "af32", IPTOS_DSCP_AF32 }, > + { "af33", IPTOS_DSCP_AF33 }, > + { "af41", IPTOS_DSCP_AF41 }, > + { "af42", IPTOS_DSCP_AF42 }, > + { "af43", IPTOS_DSCP_AF43 }, > + { "critical", IPTOS_PREC_CRITIC_ECP }, > + { "cs0", IPTOS_DSCP_CS0 }, > + { "cs1", IPTOS_DSCP_CS1 }, > + { "cs2", IPTOS_DSCP_CS2 }, > + { "cs3", IPTOS_DSCP_CS3 }, > + { "cs4", IPTOS_DSCP_CS4 }, > + { "cs5", IPTOS_DSCP_CS5 }, > + { "cs6", IPTOS_DSCP_CS6 }, > + { "cs7", IPTOS_DSCP_CS7 }, > + { "ef", IPTOS_DSCP_EF }, > + { "inetcontrol", IPTOS_PREC_INTERNETCONTROL }, > + { "lowdelay", IPTOS_LOWDELAY }, > + { "netcontrol", IPTOS_PREC_NETCONTROL }, > + { "reliability", IPTOS_RELIABILITY }, > + { "throughput", IPTOS_THROUGHPUT } > + }; > + const struct keywords *p; > + > + p = bsearch(s, toswords, sizeof(toswords)/sizeof(toswords[0]), > + sizeof(toswords[0]), kw_casecmp); > + > + if (p) { > + *val = p->k_val; > + return (1); > + } > + return (0); > +} > + > +int > rt_tableid_max(void) > { > #ifdef __FreeBSD__ > > Modified: head/share/man/man5/pf.conf.5 > ============================================================================== > --- head/share/man/man5/pf.conf.5 Thu Oct 13 20:15:47 2016 (r307234) > +++ head/share/man/man5/pf.conf.5 Thu Oct 13 20:34:44 2016 (r307235) > @@ -28,7 +28,7 @@ > .\" ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE > .\" POSSIBILITY OF SUCH DAMAGE. > .\" > -.Dd September 28, 2016 > +.Dd October 6, 2016 > .Dt PF.CONF 5 > .Os > .Sh NAME > @@ -648,9 +648,16 @@ for matching IP packets. > .Em TOS > may be > given as one of > +.Ar critical , > +.Ar inetcontrol , > .Ar lowdelay , > +.Ar netcontrol , > .Ar throughput , > .Ar reliability , > +or one of the DiffServ Code Points: > +.Ar ef , > +.Ar af11 No ... Ar af43 , > +.Ar cs0 No ... Ar cs7 ; > or as either hex or decimal. > .It Ar random-id > Replaces the IP identification field with random values to compensate > @@ -1697,9 +1704,16 @@ bits set. > .Em TOS > may be > given as one of > +.Ar critical , > +.Ar inetcontrol , > .Ar lowdelay , > +.Ar netcontrol , > .Ar throughput , > .Ar reliability , > +or one of the DiffServ Code Points: > +.Ar ef , > +.Ar af11 No ... Ar af43 , > +.Ar cs0 No ... Ar cs7 ; > or as either hex or decimal. > .Pp > For example, the following rules are identical: > @@ -1803,7 +1817,6 @@ pass in proto tcp to port 25 set prio 2 > pass in proto tcp to port 22 set prio (2, 5) > .Ed > .Pp > - > .It Ar tag Aq Ar string > Packets matching this rule will be tagged with the > specified string. > > Modified: head/sys/netpfil/pf/pf.c > ============================================================================== > --- head/sys/netpfil/pf/pf.c Thu Oct 13 20:15:47 2016 (r307234) > +++ head/sys/netpfil/pf/pf.c Thu Oct 13 20:34:44 2016 (r307235) > @@ -5893,7 +5893,7 @@ pf_test(int dir, struct ifnet *ifp, stru > pd.sidx = (dir == PF_IN) ? 0 : 1; > pd.didx = (dir == PF_IN) ? 1 : 0; > pd.af = AF_INET; > - pd.tos = h->ip_tos; > + pd.tos = h->ip_tos & ~IPTOS_ECN_MASK; > pd.tot_len = ntohs(h->ip_len); > > /* handle fragments that didn't get reassembled by normalization */ > > Modified: head/sys/netpfil/pf/pf_norm.c > ============================================================================== > --- head/sys/netpfil/pf/pf_norm.c Thu Oct 13 20:15:47 2016 (r307234) > +++ head/sys/netpfil/pf/pf_norm.c Thu Oct 13 20:34:44 2016 (r307235) > @@ -1811,7 +1811,7 @@ pf_scrub_ip(struct mbuf **m0, u_int32_t > u_int16_t ov, nv; > > ov = *(u_int16_t *)h; > - h->ip_tos = tos; > + h->ip_tos = tos | (h->ip_tos & IPTOS_ECN_MASK); > nv = *(u_int16_t *)h; > > h->ip_sum = pf_cksum_fixup(h->ip_sum, ov, nv, 0); > From owner-svn-src-all@freebsd.org Fri Oct 14 08:26:18 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D4F02C10267; Fri, 14 Oct 2016 08:26:18 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id ACB1E2DE; Fri, 14 Oct 2016 08:26:18 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9E8QHQ7089800; Fri, 14 Oct 2016 08:26:17 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9E8QHIk089795; Fri, 14 Oct 2016 08:26:17 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610140826.u9E8QHIk089795@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Fri, 14 Oct 2016 08:26:17 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307305 - in stable/11/sys: conf dev/hyperv/vmbus modules/hyperv/vmbus X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Oct 2016 08:26:18 -0000 Author: sephe Date: Fri Oct 14 08:26:17 2016 New Revision: 307305 URL: https://svnweb.freebsd.org/changeset/base/307305 Log: MFC 302692 hyperv/vmbus: Merge hv_connection.c into hv_channel.c Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7004 Deleted: stable/11/sys/dev/hyperv/vmbus/hv_connection.c Modified: stable/11/sys/conf/files.amd64 stable/11/sys/conf/files.i386 stable/11/sys/dev/hyperv/vmbus/hv_channel.c stable/11/sys/dev/hyperv/vmbus/vmbus_var.h stable/11/sys/modules/hyperv/vmbus/Makefile Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/conf/files.amd64 ============================================================================== --- stable/11/sys/conf/files.amd64 Fri Oct 14 08:18:55 2016 (r307304) +++ stable/11/sys/conf/files.amd64 Fri Oct 14 08:26:17 2016 (r307305) @@ -303,7 +303,6 @@ dev/hyperv/utilities/hv_timesync.c opt dev/hyperv/utilities/hv_util.c optional hyperv dev/hyperv/vmbus/hv_channel.c optional hyperv dev/hyperv/vmbus/hv_channel_mgmt.c optional hyperv -dev/hyperv/vmbus/hv_connection.c optional hyperv dev/hyperv/vmbus/hv_ring_buffer.c optional hyperv dev/hyperv/vmbus/hyperv.c optional hyperv dev/hyperv/vmbus/hyperv_busdma.c optional hyperv Modified: stable/11/sys/conf/files.i386 ============================================================================== --- stable/11/sys/conf/files.i386 Fri Oct 14 08:18:55 2016 (r307304) +++ stable/11/sys/conf/files.i386 Fri Oct 14 08:26:17 2016 (r307305) @@ -260,7 +260,6 @@ dev/hyperv/utilities/hv_timesync.c opt dev/hyperv/utilities/hv_util.c optional hyperv dev/hyperv/vmbus/hv_channel.c optional hyperv dev/hyperv/vmbus/hv_channel_mgmt.c optional hyperv -dev/hyperv/vmbus/hv_connection.c optional hyperv dev/hyperv/vmbus/hv_ring_buffer.c optional hyperv dev/hyperv/vmbus/hyperv.c optional hyperv dev/hyperv/vmbus/hyperv_busdma.c optional hyperv Modified: stable/11/sys/dev/hyperv/vmbus/hv_channel.c ============================================================================== --- stable/11/sys/dev/hyperv/vmbus/hv_channel.c Fri Oct 14 08:18:55 2016 (r307304) +++ stable/11/sys/dev/hyperv/vmbus/hv_channel.c Fri Oct 14 08:26:17 2016 (r307305) @@ -52,6 +52,8 @@ __FBSDID("$FreeBSD$"); static void vmbus_channel_set_event(hv_vmbus_channel* channel); static void VmbusProcessChannelEvent(void* channel, int pending); +static void vmbus_chan_update_evtflagcnt(struct vmbus_softc *, + const struct hv_vmbus_channel *); /** * @brief Trigger an event notification on the specified channel @@ -207,7 +209,7 @@ hv_vmbus_channel_open( new_channel->on_channel_callback = pfn_on_channel_callback; new_channel->channel_callback_context = context; - vmbus_on_channel_open(new_channel); + vmbus_chan_update_evtflagcnt(sc, new_channel); new_channel->rxq = VMBUS_PCPU_GET(new_channel->vmbus_sc, event_tq, new_channel->target_cpu); @@ -883,3 +885,95 @@ VmbusProcessChannelEvent(void* context, } while (is_batched_reading && (bytes_to_read != 0)); } } + +static __inline void +vmbus_event_flags_proc(struct vmbus_softc *sc, volatile u_long *event_flags, + int flag_cnt) +{ + int f; + + for (f = 0; f < flag_cnt; ++f) { + uint32_t rel_id_base; + u_long flags; + int bit; + + if (event_flags[f] == 0) + continue; + + flags = atomic_swap_long(&event_flags[f], 0); + rel_id_base = f << VMBUS_EVTFLAG_SHIFT; + + while ((bit = ffsl(flags)) != 0) { + struct hv_vmbus_channel *channel; + uint32_t rel_id; + + --bit; /* NOTE: ffsl is 1-based */ + flags &= ~(1UL << bit); + + rel_id = rel_id_base + bit; + channel = sc->vmbus_chmap[rel_id]; + + /* if channel is closed or closing */ + if (channel == NULL || channel->rxq == NULL) + continue; + + if (channel->batched_reading) + hv_ring_buffer_read_begin(&channel->inbound); + taskqueue_enqueue(channel->rxq, &channel->channel_task); + } + } +} + +void +vmbus_event_proc(struct vmbus_softc *sc, int cpu) +{ + struct vmbus_evtflags *eventf; + + /* + * On Host with Win8 or above, the event page can be checked directly + * to get the id of the channel that has the pending interrupt. + */ + eventf = VMBUS_PCPU_GET(sc, event_flags, cpu) + VMBUS_SINT_MESSAGE; + vmbus_event_flags_proc(sc, eventf->evt_flags, + VMBUS_PCPU_GET(sc, event_flags_cnt, cpu)); +} + +void +vmbus_event_proc_compat(struct vmbus_softc *sc, int cpu) +{ + struct vmbus_evtflags *eventf; + + eventf = VMBUS_PCPU_GET(sc, event_flags, cpu) + VMBUS_SINT_MESSAGE; + if (atomic_testandclear_long(&eventf->evt_flags[0], 0)) { + vmbus_event_flags_proc(sc, sc->vmbus_rx_evtflags, + VMBUS_CHAN_MAX_COMPAT >> VMBUS_EVTFLAG_SHIFT); + } +} + +static void +vmbus_chan_update_evtflagcnt(struct vmbus_softc *sc, + const struct hv_vmbus_channel *chan) +{ + volatile int *flag_cnt_ptr; + int flag_cnt; + + flag_cnt = (chan->offer_msg.child_rel_id / VMBUS_EVTFLAG_LEN) + 1; + flag_cnt_ptr = VMBUS_PCPU_PTR(sc, event_flags_cnt, chan->target_cpu); + + for (;;) { + int old_flag_cnt; + + old_flag_cnt = *flag_cnt_ptr; + if (old_flag_cnt >= flag_cnt) + break; + if (atomic_cmpset_int(flag_cnt_ptr, old_flag_cnt, flag_cnt)) { + if (bootverbose) { + device_printf(sc->vmbus_dev, + "channel%u update cpu%d flag_cnt to %d\n", + chan->offer_msg.child_rel_id, + chan->target_cpu, flag_cnt); + } + break; + } + } +} Modified: stable/11/sys/dev/hyperv/vmbus/vmbus_var.h ============================================================================== --- stable/11/sys/dev/hyperv/vmbus/vmbus_var.h Fri Oct 14 08:18:55 2016 (r307304) +++ stable/11/sys/dev/hyperv/vmbus/vmbus_var.h Fri Oct 14 08:26:17 2016 (r307305) @@ -131,7 +131,6 @@ struct trapframe; struct vmbus_message; struct vmbus_msghc; -void vmbus_on_channel_open(const struct hv_vmbus_channel *); void vmbus_event_proc(struct vmbus_softc *, int); void vmbus_event_proc_compat(struct vmbus_softc *, int); void vmbus_handle_intr(struct trapframe *); Modified: stable/11/sys/modules/hyperv/vmbus/Makefile ============================================================================== --- stable/11/sys/modules/hyperv/vmbus/Makefile Fri Oct 14 08:18:55 2016 (r307304) +++ stable/11/sys/modules/hyperv/vmbus/Makefile Fri Oct 14 08:26:17 2016 (r307305) @@ -6,7 +6,6 @@ KMOD= hv_vmbus SRCS= hv_channel.c \ hv_channel_mgmt.c \ - hv_connection.c \ hv_ring_buffer.c \ hyperv.c \ hyperv_busdma.c \ From owner-svn-src-all@freebsd.org Fri Oct 14 08:31:34 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 4031DC10344; Fri, 14 Oct 2016 08:31:34 +0000 (UTC) (envelope-from andrew@fubar.geek.nz) Received: from kif.fubar.geek.nz (kif.fubar.geek.nz [178.62.119.249]) by mx1.freebsd.org (Postfix) with ESMTP id 1022B8C9; Fri, 14 Oct 2016 08:31:33 +0000 (UTC) (envelope-from andrew@fubar.geek.nz) Received: from zapp (5ec3950e.skybroadband.com [94.195.149.14]) by kif.fubar.geek.nz (Postfix) with ESMTPSA id 72A77D78E6; Fri, 14 Oct 2016 08:31:26 +0000 (UTC) Date: Fri, 14 Oct 2016 09:31:23 +0100 From: Andrew Turner To: Oleksandr Tymoshenko Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r307257 - in head/sys: arm/broadcom/bcm2835 arm64/broadcom arm64/broadcom/bcm2837 arm64/conf conf Message-ID: <20161014093123.606cb8f3@zapp> In-Reply-To: <201610140337.u9E3baB7077179@repo.freebsd.org> References: <201610140337.u9E3baB7077179@repo.freebsd.org> X-Mailer: Claws Mail 3.14.0 (GTK+ 2.24.29; amd64-portbld-freebsd12.0) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Oct 2016 08:31:34 -0000 On Fri, 14 Oct 2016 03:37:36 +0000 (UTC) Oleksandr Tymoshenko wrote: > Author: gonzo > Date: Fri Oct 14 03:37:35 2016 > New Revision: 307257 > URL: https://svnweb.freebsd.org/changeset/base/307257 > > Log: > Add initial Raspberry Pi 3 support > > RPI3 kernel config builds kernel compatible with latest upstream > device tree and firmware: > https://github.com/raspberrypi/firmware/tree/master/boot As of today > it's 597c662a613df1144a6bc43e5f4505d83bd748ca > Default console is PL01x, so pi3-disable-bt dt overlay should be > configured in config.txt and stock U-Boot should be patched to use > proper serial port. > Yet unsupported: SMP, VCHIQ, RNG driver. RNG requires some work due > to upstream device tree incompatibility. > > Multiple people contributed to this work over time: db@, loos@, > manu@ > > Added: > head/sys/arm64/broadcom/ > head/sys/arm64/broadcom/bcm2837/ > head/sys/arm64/broadcom/bcm2837/files.bcm2837 (contents, props > changed) head/sys/arm64/conf/RPI3 (contents, props changed) > Modified: > head/sys/arm/broadcom/bcm2835/bcm2835_vcbus.h > head/sys/conf/options.arm64 > > Modified: head/sys/arm/broadcom/bcm2835/bcm2835_vcbus.h > ============================================================================== > --- head/sys/arm/broadcom/bcm2835/bcm2835_vcbus.h Fri Oct 14 > 03:32:20 2016 (r307256) +++ > head/sys/arm/broadcom/bcm2835/bcm2835_vcbus.h Fri Oct 14 > 03:37:35 2016 (r307257) @@ -37,7 +37,7 @@ #define > BCM2835_VCBUS_IO_BASE 0x7E000000 #define > BCM2835_VCBUS_SDRAM_UNCACHED 0xC0000000 > -#ifdef SOC_BCM2836 > +#if defined(SOC_BCM2836) || defined(SOC_BCM2837) You could reverse the logic here to: #ifdef SOC_BCM2835 <2835 macros> #else #endif > #define BCM2835_ARM_IO_BASE 0x3f000000 > #define BCM2835_VCBUS_SDRAM_BASE > BCM2835_VCBUS_SDRAM_UNCACHED #else > > Added: head/sys/arm64/broadcom/bcm2837/files.bcm2837 > ============================================================================== > --- /dev/null 00:00:00 1970 (empty, because file is > newly added) +++ head/sys/arm64/broadcom/bcm2837/files.bcm2837 > Fri Oct 14 03:37:35 2016 (r307257) @@ -0,0 +1,4 @@ > +# $FreeBSD$ > + > +arm/broadcom/bcm2835/bcm2836.c standard This should be in files.arm64 and enabled when the SOC_ option is set. > +kern/kern_clocksource.c standard This is already in files.arm64. > > Added: head/sys/arm64/conf/RPI3 Why a new kernel config and not GENERIC? ... > Modified: head/sys/conf/options.arm64 > ============================================================================== > --- head/sys/conf/options.arm64 Fri Oct 14 03:32:20 > 2016 (r307256) +++ head/sys/conf/options.arm64 Fri Oct > 14 03:37:35 2016 (r307257) @@ -9,5 +9,6 @@ > VFP opt_global.h > # SoC Support > SOC_ALLWINNER_A64 opt_soc.h > +SOC_BCM2837 opt_global.h This should be SOC_BRCM_BCM2837 (or maybe SOC_BRCM_BCM283X) and live in opt_soc.h Andrew From owner-svn-src-all@freebsd.org Fri Oct 14 08:34:46 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 7C9D7C1051F; Fri, 14 Oct 2016 08:34:46 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 40F05B53; Fri, 14 Oct 2016 08:34:46 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9E8YjTU093500; Fri, 14 Oct 2016 08:34:45 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9E8YidU093494; Fri, 14 Oct 2016 08:34:44 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610140834.u9E8YidU093494@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Fri, 14 Oct 2016 08:34:44 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307306 - in stable/11/sys/dev/hyperv: include netvsc vmbus X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Oct 2016 08:34:46 -0000 Author: sephe Date: Fri Oct 14 08:34:44 2016 New Revision: 307306 URL: https://svnweb.freebsd.org/changeset/base/307306 Log: MFC 302693-302697 302693 hyperv/vmbus: Make channel id a field of hv_vmbus_channel. This prepares to remove the unnecessary offer message embedding in hv_vmbus_channel. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7014 302694 hyperv/vmbus: Make subchan index a field of hv_vmbus_channel. This prepares to remove the unnecessary offer message embedding in hv_vmbus_channel. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7015 302695 hyperv/vmbus: Add flags field into hv_vmbus_channel for MNF indication This prepares to remove the unnecessary offer message embedding in hv_vmbus_channel. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7019 302696 hyperv/vmbus: Add type/instance guid fields into hv_vmbus_channel This prepares to remove the unnecessary offer message embedding in hv_vmbus_channel. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7020 302697 hyperv/vmbus: Remove the embedded offer message from hv_vmbus_channel Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7021 Modified: stable/11/sys/dev/hyperv/include/hyperv.h stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c stable/11/sys/dev/hyperv/vmbus/hv_channel.c stable/11/sys/dev/hyperv/vmbus/hv_channel_mgmt.c stable/11/sys/dev/hyperv/vmbus/hv_vmbus_priv.h stable/11/sys/dev/hyperv/vmbus/vmbus.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/hyperv/include/hyperv.h ============================================================================== --- stable/11/sys/dev/hyperv/include/hyperv.h Fri Oct 14 08:26:17 2016 (r307305) +++ stable/11/sys/dev/hyperv/include/hyperv.h Fri Oct 14 08:34:44 2016 (r307306) @@ -537,7 +537,8 @@ typedef struct hv_vmbus_channel { struct hv_device* device; struct vmbus_softc *vmbus_sc; hv_vmbus_channel_state state; - hv_vmbus_channel_offer_channel offer_msg; + uint32_t ch_flags; /* VMBUS_CHAN_FLAG_ */ + uint32_t ch_id; /* channel id */ /* * These are based on the offer_msg.monitor_id. * Save it here for easy access. @@ -628,12 +629,18 @@ typedef struct hv_vmbus_channel { struct task ch_detach_task; TAILQ_ENTRY(hv_vmbus_channel) ch_link; + uint32_t ch_subidx; /* subchan index */ + + struct hv_guid ch_guid_type; + struct hv_guid ch_guid_inst; struct sysctl_ctx_list ch_sysctl_ctx; } hv_vmbus_channel; #define HV_VMBUS_CHAN_ISPRIMARY(chan) ((chan)->primary_channel == NULL) +#define VMBUS_CHAN_FLAG_HASMNF 0x0001 + static inline void hv_set_channel_read_state(hv_vmbus_channel* channel, boolean_t state) { Modified: stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Fri Oct 14 08:26:17 2016 (r307305) +++ stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Fri Oct 14 08:34:44 2016 (r307306) @@ -518,9 +518,9 @@ netvsc_attach(device_t dev) */ pri_chan = device_ctx->channel; KASSERT(HV_VMBUS_CHAN_ISPRIMARY(pri_chan), ("not primary channel")); - KASSERT(pri_chan->offer_msg.offer.sub_channel_index == 0, + KASSERT(pri_chan->ch_subidx == 0, ("primary channel subidx %u", - pri_chan->offer_msg.offer.sub_channel_index)); + pri_chan->ch_subidx)); hn_channel_attach(sc, pri_chan); ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; @@ -809,8 +809,8 @@ hn_tx_done(struct hv_vmbus_channel *chan txr = txd->txr; KASSERT(txr->hn_chan == chan, ("channel mismatch, on channel%u, should be channel%u", - chan->offer_msg.offer.sub_channel_index, - txr->hn_chan->offer_msg.offer.sub_channel_index)); + chan->ch_subidx, + txr->hn_chan->ch_subidx)); txr->hn_has_txeof = 1; hn_txdesc_put(txr, txd); @@ -2940,7 +2940,7 @@ hn_channel_attach(struct hn_softc *sc, s struct hn_rx_ring *rxr; int idx; - idx = chan->offer_msg.offer.sub_channel_index; + idx = chan->ch_subidx; KASSERT(idx >= 0 && idx < sc->hn_rx_ring_inuse, ("invalid channel index %d, should > 0 && < %d", @@ -2953,7 +2953,7 @@ hn_channel_attach(struct hn_softc *sc, s chan->hv_chan_rxr = rxr; if (bootverbose) { if_printf(sc->hn_ifp, "link RX ring %d to channel%u\n", - idx, chan->offer_msg.child_rel_id); + idx, chan->ch_id); } if (idx < sc->hn_tx_ring_inuse) { @@ -2967,7 +2967,7 @@ hn_channel_attach(struct hn_softc *sc, s txr->hn_chan = chan; if (bootverbose) { if_printf(sc->hn_ifp, "link TX ring %d to channel%u\n", - idx, chan->offer_msg.child_rel_id); + idx, chan->ch_id); } } @@ -2981,9 +2981,9 @@ hn_subchan_attach(struct hn_softc *sc, s KASSERT(!HV_VMBUS_CHAN_ISPRIMARY(chan), ("subchannel callback on primary channel")); - KASSERT(chan->offer_msg.offer.sub_channel_index > 0, + KASSERT(chan->ch_subidx > 0, ("invalid channel subidx %u", - chan->offer_msg.offer.sub_channel_index)); + chan->ch_subidx)); hn_channel_attach(sc, chan); } Modified: stable/11/sys/dev/hyperv/vmbus/hv_channel.c ============================================================================== --- stable/11/sys/dev/hyperv/vmbus/hv_channel.c Fri Oct 14 08:26:17 2016 (r307305) +++ stable/11/sys/dev/hyperv/vmbus/hv_channel.c Fri Oct 14 08:34:44 2016 (r307306) @@ -62,12 +62,12 @@ static void vmbus_channel_set_event(hv_vmbus_channel *channel) { struct vmbus_softc *sc = channel->vmbus_sc; - uint32_t chanid = channel->offer_msg.child_rel_id; + uint32_t chanid = channel->ch_id; atomic_set_long(&sc->vmbus_tx_evtflags[chanid >> VMBUS_EVTFLAG_SHIFT], 1UL << (chanid & VMBUS_EVTFLAG_MASK)); - if (channel->offer_msg.monitor_allocated) { + if (channel->ch_flags & VMBUS_CHAN_FLAG_HASMNF) { hv_vmbus_monitor_page *monitor_page; monitor_page = sc->vmbus_mnf2; @@ -86,7 +86,7 @@ vmbus_channel_sysctl_monalloc(SYSCTL_HAN struct hv_vmbus_channel *chan = arg1; int alloc = 0; - if (chan->offer_msg.monitor_allocated) + if (chan->ch_flags & VMBUS_CHAN_FLAG_HASMNF) alloc = 1; return sysctl_handle_int(oidp, &alloc, 0, req); } @@ -107,11 +107,11 @@ vmbus_channel_sysctl_create(hv_vmbus_cha if (primary_ch == NULL) { dev = channel->device->device; - ch_id = channel->offer_msg.child_rel_id; + ch_id = channel->ch_id; } else { dev = primary_ch->device->device; - ch_id = primary_ch->offer_msg.child_rel_id; - sub_ch_id = channel->offer_msg.offer.sub_channel_index; + ch_id = primary_ch->ch_id; + sub_ch_id = channel->ch_subidx; } ctx = &channel->ch_sysctl_ctx; sysctl_ctx_init(ctx); @@ -136,7 +136,7 @@ vmbus_channel_sysctl_create(hv_vmbus_cha SYSCTL_ADD_UINT(ctx, SYSCTL_CHILDREN(devch_id_sysctl), OID_AUTO, "chanid", CTLFLAG_RD, - &channel->offer_msg.child_rel_id, 0, "channel id"); + &channel->ch_id, 0, "channel id"); } SYSCTL_ADD_UINT(ctx, SYSCTL_CHILDREN(devch_id_sysctl), OID_AUTO, "cpu", CTLFLAG_RD, &channel->target_cpu, 0, "owner CPU id"); @@ -190,7 +190,7 @@ hv_vmbus_channel_open( if (user_data_len > VMBUS_CHANMSG_CHOPEN_UDATA_SIZE) { device_printf(sc->vmbus_dev, "invalid udata len %u for chan%u\n", - user_data_len, new_channel->offer_msg.child_rel_id); + user_data_len, new_channel->ch_id); return EINVAL; } @@ -261,14 +261,14 @@ hv_vmbus_channel_open( if (mh == NULL) { device_printf(sc->vmbus_dev, "can not get msg hypercall for chopen(chan%u)\n", - new_channel->offer_msg.child_rel_id); + new_channel->ch_id); return ENXIO; } req = vmbus_msghc_dataptr(mh); req->chm_hdr.chm_type = VMBUS_CHANMSG_TYPE_CHOPEN; - req->chm_chanid = new_channel->offer_msg.child_rel_id; - req->chm_openid = new_channel->offer_msg.child_rel_id; + req->chm_chanid = new_channel->ch_id; + req->chm_openid = new_channel->ch_id; req->chm_gpadl = new_channel->ring_buffer_gpadl_handle; req->chm_vcpuid = new_channel->target_vcpu; req->chm_rxbr_pgofs = send_ring_buffer_size >> PAGE_SHIFT; @@ -279,7 +279,7 @@ hv_vmbus_channel_open( if (ret != 0) { device_printf(sc->vmbus_dev, "chopen(chan%u) msg hypercall exec failed: %d\n", - new_channel->offer_msg.child_rel_id, ret); + new_channel->ch_id, ret); vmbus_msghc_put(sc, mh); return ret; } @@ -294,11 +294,11 @@ hv_vmbus_channel_open( new_channel->state = HV_CHANNEL_OPENED_STATE; if (bootverbose) { device_printf(sc->vmbus_dev, "chan%u opened\n", - new_channel->offer_msg.child_rel_id); + new_channel->ch_id); } } else { device_printf(sc->vmbus_dev, "failed to open chan%u\n", - new_channel->offer_msg.child_rel_id); + new_channel->ch_id); ret = ENXIO; } return (ret); @@ -369,13 +369,13 @@ hv_vmbus_channel_establish_gpadl(struct if (mh == NULL) { device_printf(sc->vmbus_dev, "can not get msg hypercall for gpadl->chan%u\n", - channel->offer_msg.child_rel_id); + channel->ch_id); return EIO; } req = vmbus_msghc_dataptr(mh); req->chm_hdr.chm_type = VMBUS_CHANMSG_TYPE_GPADL_CONN; - req->chm_chanid = channel->offer_msg.child_rel_id; + req->chm_chanid = channel->ch_id; req->chm_gpadl = gpadl; req->chm_range_len = range_len; req->chm_range_cnt = 1; @@ -388,7 +388,7 @@ hv_vmbus_channel_establish_gpadl(struct if (error) { device_printf(sc->vmbus_dev, "gpadl->chan%u msg hypercall exec failed: %d\n", - channel->offer_msg.child_rel_id, error); + channel->ch_id, error); vmbus_msghc_put(sc, mh); return error; } @@ -424,12 +424,12 @@ hv_vmbus_channel_establish_gpadl(struct if (status != 0) { device_printf(sc->vmbus_dev, "gpadl->chan%u failed: " - "status %u\n", channel->offer_msg.child_rel_id, status); + "status %u\n", channel->ch_id, status); return EIO; } else { if (bootverbose) { device_printf(sc->vmbus_dev, "gpadl->chan%u " - "succeeded\n", channel->offer_msg.child_rel_id); + "succeeded\n", channel->ch_id); } } return 0; @@ -450,20 +450,20 @@ hv_vmbus_channel_teardown_gpdal(struct h if (mh == NULL) { device_printf(sc->vmbus_dev, "can not get msg hypercall for gpa x->chan%u\n", - chan->offer_msg.child_rel_id); + chan->ch_id); return EBUSY; } req = vmbus_msghc_dataptr(mh); req->chm_hdr.chm_type = VMBUS_CHANMSG_TYPE_GPADL_DISCONN; - req->chm_chanid = chan->offer_msg.child_rel_id; + req->chm_chanid = chan->ch_id; req->chm_gpadl = gpadl; error = vmbus_msghc_exec(sc, mh); if (error) { device_printf(sc->vmbus_dev, "gpa x->chan%u msg hypercall exec failed: %d\n", - chan->offer_msg.child_rel_id, error); + chan->ch_id, error); vmbus_msghc_put(sc, mh); return error; } @@ -502,13 +502,13 @@ hv_vmbus_channel_close_internal(hv_vmbus if (mh == NULL) { device_printf(sc->vmbus_dev, "can not get msg hypercall for chclose(chan%u)\n", - channel->offer_msg.child_rel_id); + channel->ch_id); return; } req = vmbus_msghc_dataptr(mh); req->chm_hdr.chm_type = VMBUS_CHANMSG_TYPE_CHCLOSE; - req->chm_chanid = channel->offer_msg.child_rel_id; + req->chm_chanid = channel->ch_id; error = vmbus_msghc_exec_noresult(mh); vmbus_msghc_put(sc, mh); @@ -516,11 +516,11 @@ hv_vmbus_channel_close_internal(hv_vmbus if (error) { device_printf(sc->vmbus_dev, "chclose(chan%u) msg hypercall exec failed: %d\n", - channel->offer_msg.child_rel_id, error); + channel->ch_id, error); return; } else if (bootverbose) { device_printf(sc->vmbus_dev, "close chan%u\n", - channel->offer_msg.child_rel_id); + channel->ch_id); } /* Tear down the gpadl for the channel's ring buffer */ @@ -957,7 +957,7 @@ vmbus_chan_update_evtflagcnt(struct vmbu volatile int *flag_cnt_ptr; int flag_cnt; - flag_cnt = (chan->offer_msg.child_rel_id / VMBUS_EVTFLAG_LEN) + 1; + flag_cnt = (chan->ch_id / VMBUS_EVTFLAG_LEN) + 1; flag_cnt_ptr = VMBUS_PCPU_PTR(sc, event_flags_cnt, chan->target_cpu); for (;;) { @@ -970,7 +970,7 @@ vmbus_chan_update_evtflagcnt(struct vmbu if (bootverbose) { device_printf(sc->vmbus_dev, "channel%u update cpu%d flag_cnt to %d\n", - chan->offer_msg.child_rel_id, + chan->ch_id, chan->target_cpu, flag_cnt); } break; Modified: stable/11/sys/dev/hyperv/vmbus/hv_channel_mgmt.c ============================================================================== --- stable/11/sys/dev/hyperv/vmbus/hv_channel_mgmt.c Fri Oct 14 08:26:17 2016 (r307305) +++ stable/11/sys/dev/hyperv/vmbus/hv_channel_mgmt.c Fri Oct 14 08:34:44 2016 (r307306) @@ -112,7 +112,7 @@ vmbus_channel_process_offer(hv_vmbus_cha hv_vmbus_channel* channel; uint32_t relid; - relid = new_channel->offer_msg.child_rel_id; + relid = new_channel->ch_id; /* * Make sure this is a new offer */ @@ -127,11 +127,9 @@ vmbus_channel_process_offer(hv_vmbus_cha } TAILQ_FOREACH(channel, &sc->vmbus_chlist, ch_link) { - if (memcmp(&channel->offer_msg.offer.interface_type, - &new_channel->offer_msg.offer.interface_type, + if (memcmp(&channel->ch_guid_type, &new_channel->ch_guid_type, sizeof(hv_guid)) == 0 && - memcmp(&channel->offer_msg.offer.interface_instance, - &new_channel->offer_msg.offer.interface_instance, + memcmp(&channel->ch_guid_inst, &new_channel->ch_guid_inst, sizeof(hv_guid)) == 0) break; } @@ -148,18 +146,18 @@ vmbus_channel_process_offer(hv_vmbus_cha logstr[0] = '\0'; if (channel != NULL) { snprintf(logstr, sizeof(logstr), ", primary chan%u", - channel->offer_msg.child_rel_id); + channel->ch_id); } device_printf(sc->vmbus_dev, "chan%u subchanid%u offer%s\n", - new_channel->offer_msg.child_rel_id, - new_channel->offer_msg.offer.sub_channel_index, logstr); + new_channel->ch_id, + new_channel->ch_subidx, logstr); } if (channel != NULL) { /* * Check if this is a sub channel. */ - if (new_channel->offer_msg.offer.sub_channel_index != 0) { + if (new_channel->ch_subidx != 0) { /* * It is a sub channel offer, process it. */ @@ -200,7 +198,7 @@ vmbus_channel_process_offer(hv_vmbus_cha } printf("VMBUS: duplicated primary channel%u\n", - new_channel->offer_msg.child_rel_id); + new_channel->ch_id); hv_vmbus_free_vmbus_channel(new_channel); return; } @@ -212,9 +210,7 @@ vmbus_channel_process_offer(hv_vmbus_cha * (We need to set the device field before calling * hv_vmbus_child_device_add()) */ - new_channel->device = hv_vmbus_child_device_create( - new_channel->offer_msg.offer.interface_type, - new_channel->offer_msg.offer.interface_instance, new_channel); + new_channel->device = hv_vmbus_child_device_create(new_channel); /* * Add the new device to the bus. This will kick off device-driver @@ -241,7 +237,7 @@ vmbus_channel_cpu_set(struct hv_vmbus_ch if (bootverbose) { printf("vmbus_chan%u: assigned to cpu%u [vcpu%u]\n", - chan->offer_msg.child_rel_id, + chan->ch_id, chan->target_cpu, chan->target_vcpu); } } @@ -292,6 +288,12 @@ vmbus_channel_on_offer_internal(struct v /* Allocate the channel object and save this offer */ new_channel = hv_vmbus_allocate_channel(sc); + new_channel->ch_id = offer->child_rel_id; + new_channel->ch_subidx = offer->offer.sub_channel_index; + if (offer->monitor_allocated) + new_channel->ch_flags |= VMBUS_CHAN_FLAG_HASMNF; + new_channel->ch_guid_type = offer->offer.interface_type; + new_channel->ch_guid_inst = offer->offer.interface_instance; /* * By default we setup state to enable batched @@ -319,8 +321,6 @@ vmbus_channel_on_offer_internal(struct v new_channel->ch_sigevt->hc_connid = offer->connection_id; } - memcpy(&new_channel->offer_msg, offer, - sizeof(hv_vmbus_channel_offer_channel)); new_channel->monitor_group = (uint8_t) offer->monitor_id / 32; new_channel->monitor_bit = (uint8_t) offer->monitor_id % 32; @@ -379,13 +379,13 @@ vmbus_chan_detach_task(void *xchan, int if (mh == NULL) { device_printf(sc->vmbus_dev, "can not get msg hypercall for chfree(chan%u)\n", - chan->offer_msg.child_rel_id); + chan->ch_id); goto remove; } req = vmbus_msghc_dataptr(mh); req->chm_hdr.chm_type = VMBUS_CHANMSG_TYPE_CHFREE; - req->chm_chanid = chan->offer_msg.child_rel_id; + req->chm_chanid = chan->ch_id; error = vmbus_msghc_exec_noresult(mh); vmbus_msghc_put(sc, mh); @@ -393,12 +393,12 @@ vmbus_chan_detach_task(void *xchan, int if (error) { device_printf(sc->vmbus_dev, "chfree(chan%u) failed: %d", - chan->offer_msg.child_rel_id, error); + chan->ch_id, error); /* NOTE: Move on! */ } else { if (bootverbose) { device_printf(sc->vmbus_dev, "chan%u freed\n", - chan->offer_msg.child_rel_id); + chan->ch_id); } } remove: Modified: stable/11/sys/dev/hyperv/vmbus/hv_vmbus_priv.h ============================================================================== --- stable/11/sys/dev/hyperv/vmbus/hv_vmbus_priv.h Fri Oct 14 08:26:17 2016 (r307305) +++ stable/11/sys/dev/hyperv/vmbus/hv_vmbus_priv.h Fri Oct 14 08:34:44 2016 (r307306) @@ -213,9 +213,7 @@ void hv_vmbus_release_unattached_chann struct vmbus_softc *); struct hv_device* hv_vmbus_child_device_create( - hv_guid device_type, - hv_guid device_instance, - hv_vmbus_channel *channel); + struct hv_vmbus_channel *channel); void hv_vmbus_child_device_register(struct vmbus_softc *, struct hv_device *child_dev); Modified: stable/11/sys/dev/hyperv/vmbus/vmbus.c ============================================================================== --- stable/11/sys/dev/hyperv/vmbus/vmbus.c Fri Oct 14 08:26:17 2016 (r307305) +++ stable/11/sys/dev/hyperv/vmbus/vmbus.c Fri Oct 14 08:34:44 2016 (r307306) @@ -1017,8 +1017,7 @@ vmbus_child_pnpinfo_str(device_t dev, de } struct hv_device * -hv_vmbus_child_device_create(hv_guid type, hv_guid instance, - hv_vmbus_channel *channel) +hv_vmbus_child_device_create(struct hv_vmbus_channel *channel) { hv_device *child_dev; @@ -1028,8 +1027,8 @@ hv_vmbus_child_device_create(hv_guid typ child_dev = malloc(sizeof(hv_device), M_DEVBUF, M_WAITOK | M_ZERO); child_dev->channel = channel; - memcpy(&child_dev->class_id, &type, sizeof(hv_guid)); - memcpy(&child_dev->device_id, &instance, sizeof(hv_guid)); + child_dev->class_id = channel->ch_guid_type; + child_dev->device_id = channel->ch_guid_inst; return (child_dev); } From owner-svn-src-all@freebsd.org Fri Oct 14 08:37:59 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A0D56C105CD; Fri, 14 Oct 2016 08:37:59 +0000 (UTC) (envelope-from andrew@fubar.geek.nz) Received: from kif.fubar.geek.nz (kif.fubar.geek.nz [178.62.119.249]) by mx1.freebsd.org (Postfix) with ESMTP id 6F147CEC; Fri, 14 Oct 2016 08:37:58 +0000 (UTC) (envelope-from andrew@fubar.geek.nz) Received: from zapp (5ec3950e.skybroadband.com [94.195.149.14]) by kif.fubar.geek.nz (Postfix) with ESMTPSA id 9E750D78E6; Fri, 14 Oct 2016 08:37:28 +0000 (UTC) Date: Fri, 14 Oct 2016 09:37:26 +0100 From: Andrew Turner To: Oleksandr Tymoshenko Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r307252 - head/sys/arm/broadcom/bcm2835 Message-ID: <20161014093726.197f8e05@zapp> In-Reply-To: <201610140300.u9E30r1O061196@repo.freebsd.org> References: <201610140300.u9E30r1O061196@repo.freebsd.org> X-Mailer: Claws Mail 3.14.0 (GTK+ 2.24.29; amd64-portbld-freebsd12.0) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Oct 2016 08:37:59 -0000 On Fri, 14 Oct 2016 03:00:53 +0000 (UTC) Oleksandr Tymoshenko wrote: > Author: gonzo > Date: Fri Oct 14 03:00:53 2016 > New Revision: 307252 > URL: https://svnweb.freebsd.org/changeset/base/307252 > > Log: > Make bcm2835_machdep.c optional > > bcm2835_machdep.c contains only bits enabled by "options PLATFORM", > this option available only on ARM, not ARM64 > > Modified: > head/sys/arm/broadcom/bcm2835/files.bcm283x > > Modified: head/sys/arm/broadcom/bcm2835/files.bcm283x > ============================================================================== > --- head/sys/arm/broadcom/bcm2835/files.bcm283x Fri Oct 14 02:58:31 2016 (r307251) > +++ head/sys/arm/broadcom/bcm2835/files.bcm283x Fri Oct 14 03:00:53 2016 (r307252) > @@ -9,7 +9,7 @@ arm/broadcom/bcm2835/bcm2835_fbd.c opti > arm/broadcom/bcm2835/bcm2835_ft5406.c optional evdev bcm2835_ft5406 > arm/broadcom/bcm2835/bcm2835_gpio.c optional gpio > arm/broadcom/bcm2835/bcm2835_intr.c standard > -arm/broadcom/bcm2835/bcm2835_machdep.c standard > +arm/broadcom/bcm2835/bcm2835_machdep.c optional platform > arm/broadcom/bcm2835/bcm2835_mbox.c standard > arm/broadcom/bcm2835/bcm2835_rng.c optional random > arm/broadcom/bcm2835/bcm2835_sdhci.c optional sdhci > Any of these files you need should be added to files.arm64 being optional on the appropriate soc_ value. Andrew From owner-svn-src-all@freebsd.org Fri Oct 14 08:45:55 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id EE214C109F1; Fri, 14 Oct 2016 08:45:55 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 8DF6424F; Fri, 14 Oct 2016 08:45:55 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9E8jsEf097506; Fri, 14 Oct 2016 08:45:54 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9E8jsVl097498; Fri, 14 Oct 2016 08:45:54 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610140845.u9E8jsVl097498@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Fri, 14 Oct 2016 08:45:54 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307307 - in stable/11/sys: dev/hyperv/include dev/hyperv/netvsc dev/hyperv/storvsc dev/hyperv/utilities dev/hyperv/vmbus modules/hyperv/utilities X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Oct 2016 08:45:56 -0000 Author: sephe Date: Fri Oct 14 08:45:53 2016 New Revision: 307307 URL: https://svnweb.freebsd.org/changeset/base/307307 Log: MFC 302698-302704,302706 302698 hyperv/vmbus: Add vmbus method for GUID base device probing. Reduce the exposure of hv_device. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7024 302699 hyperv/vmbus: All ivars are read-only; nuke unnecessary write_ivar Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7025 302700 hyperv/vmbus: Add channel ivar accessor. This makes life easier during the transition period to nuke the hv_device. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7026 302701 hyperv/stor: Avoid the hv_device and nuke the broken get_stor_device This paves way to nuke the hv_device, which is actually an unncessary indirection. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7027 302702 hyperv/util: Avoid the hv_device This paves way to nuke the hv_device, which is actually an unncessary indirection. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7028 302703 hyperv/vmbus: Deprecate the usage of hv_device. This paves way to nuke the hv_device, which is actually an unncessary indirection. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7032 302704 hyperv/hn: Avoid the hv_device This paves way to nuke the hv_device, which is actually an unncessary indirection. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7033 302706 hyperv: Get rid of hv_device, which is unnecessary indirection. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7034 Modified: stable/11/sys/dev/hyperv/include/hyperv.h stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.c stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.h stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.c stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.h stable/11/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c stable/11/sys/dev/hyperv/utilities/hv_heartbeat.c stable/11/sys/dev/hyperv/utilities/hv_kvp.c stable/11/sys/dev/hyperv/utilities/hv_shutdown.c stable/11/sys/dev/hyperv/utilities/hv_timesync.c stable/11/sys/dev/hyperv/utilities/hv_util.c stable/11/sys/dev/hyperv/utilities/hv_util.h stable/11/sys/dev/hyperv/vmbus/hv_channel.c stable/11/sys/dev/hyperv/vmbus/hv_channel_mgmt.c stable/11/sys/dev/hyperv/vmbus/hv_vmbus_priv.h stable/11/sys/dev/hyperv/vmbus/vmbus.c stable/11/sys/dev/hyperv/vmbus/vmbus_if.m stable/11/sys/modules/hyperv/utilities/Makefile Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/hyperv/include/hyperv.h ============================================================================== --- stable/11/sys/dev/hyperv/include/hyperv.h Fri Oct 14 08:34:44 2016 (r307306) +++ stable/11/sys/dev/hyperv/include/hyperv.h Fri Oct 14 08:45:53 2016 (r307307) @@ -399,20 +399,6 @@ typedef struct { #define HW_MACADDR_LEN 6 -enum { - HV_VMBUS_IVAR_TYPE, - HV_VMBUS_IVAR_INSTANCE, - HV_VMBUS_IVAR_NODE, - HV_VMBUS_IVAR_DEVCTX -}; - -#define HV_VMBUS_ACCESSOR(var, ivar, type) \ - __BUS_ACCESSOR(vmbus, var, HV_VMBUS, ivar, type) - -HV_VMBUS_ACCESSOR(type, TYPE, const char *) -HV_VMBUS_ACCESSOR(devctx, DEVCTX, struct hv_device *) - - /* * Common defines for Hyper-V ICs */ @@ -534,7 +520,7 @@ typedef union { } __packed hv_vmbus_connection_id; typedef struct hv_vmbus_channel { - struct hv_device* device; + device_t ch_dev; struct vmbus_softc *vmbus_sc; hv_vmbus_channel_state state; uint32_t ch_flags; /* VMBUS_CHAN_FLAG_ */ @@ -647,15 +633,6 @@ hv_set_channel_read_state(hv_vmbus_chann channel->batched_reading = state; } -typedef struct hv_device { - hv_guid class_id; - hv_guid device_id; - device_t device; - hv_vmbus_channel* channel; -} hv_device; - - - int hv_vmbus_channel_recv_packet( hv_vmbus_channel* channel, void* buffer, @@ -737,4 +714,10 @@ hv_get_phys_addr(void *virt) return (ret); } +static __inline struct hv_vmbus_channel * +vmbus_get_channel(device_t dev) +{ + return device_get_ivars(dev); +} + #endif /* __HYPERV_H__ */ Modified: stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.c ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.c Fri Oct 14 08:34:44 2016 (r307306) +++ stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.c Fri Oct 14 08:45:53 2016 (r307307) @@ -58,31 +58,30 @@ MALLOC_DEFINE(M_NETVSC, "netvsc", "Hyper * Forward declarations */ static void hv_nv_on_channel_callback(void *xchan); -static int hv_nv_init_send_buffer_with_net_vsp(struct hv_device *device); -static int hv_nv_init_rx_buffer_with_net_vsp(struct hv_device *device); +static int hv_nv_init_send_buffer_with_net_vsp(struct hn_softc *sc); +static int hv_nv_init_rx_buffer_with_net_vsp(struct hn_softc *); static int hv_nv_destroy_send_buffer(netvsc_dev *net_dev); static int hv_nv_destroy_rx_buffer(netvsc_dev *net_dev); -static int hv_nv_connect_to_vsp(struct hv_device *device); +static int hv_nv_connect_to_vsp(struct hn_softc *sc); static void hv_nv_on_send_completion(netvsc_dev *net_dev, - struct hv_device *device, struct hv_vmbus_channel *, hv_vm_packet_descriptor *pkt); + struct hv_vmbus_channel *, hv_vm_packet_descriptor *pkt); static void hv_nv_on_receive_completion(struct hv_vmbus_channel *chan, uint64_t tid, uint32_t status); static void hv_nv_on_receive(netvsc_dev *net_dev, - struct hv_device *device, struct hv_vmbus_channel *chan, + struct hn_softc *sc, struct hv_vmbus_channel *chan, hv_vm_packet_descriptor *pkt); /* * */ static inline netvsc_dev * -hv_nv_alloc_net_device(struct hv_device *device) +hv_nv_alloc_net_device(struct hn_softc *sc) { netvsc_dev *net_dev; - hn_softc_t *sc = device_get_softc(device->device); net_dev = malloc(sizeof(netvsc_dev), M_NETVSC, M_WAITOK | M_ZERO); - net_dev->dev = device; + net_dev->sc = sc; net_dev->destroy = FALSE; sc->net_dev = net_dev; @@ -90,43 +89,21 @@ hv_nv_alloc_net_device(struct hv_device } /* - * + * XXX unnecessary; nuke it. */ static inline netvsc_dev * -hv_nv_get_outbound_net_device(struct hv_device *device) +hv_nv_get_outbound_net_device(struct hn_softc *sc) { - hn_softc_t *sc = device_get_softc(device->device); - netvsc_dev *net_dev = sc->net_dev;; - - if ((net_dev != NULL) && net_dev->destroy) { - return (NULL); - } - - return (net_dev); + return sc->net_dev; } /* - * + * XXX unnecessary; nuke it. */ static inline netvsc_dev * -hv_nv_get_inbound_net_device(struct hv_device *device) +hv_nv_get_inbound_net_device(struct hn_softc *sc) { - hn_softc_t *sc = device_get_softc(device->device); - netvsc_dev *net_dev = sc->net_dev;; - - if (net_dev == NULL) { - return (net_dev); - } - /* - * When the device is being destroyed; we only - * permit incoming packets if and only if there - * are outstanding sends. - */ - if (net_dev->destroy) { - return (NULL); - } - - return (net_dev); + return sc->net_dev; } int @@ -164,13 +141,13 @@ hv_nv_get_next_send_section(netvsc_dev * * Hyper-V extensible switch and the synthetic data path. */ static int -hv_nv_init_rx_buffer_with_net_vsp(struct hv_device *device) +hv_nv_init_rx_buffer_with_net_vsp(struct hn_softc *sc) { netvsc_dev *net_dev; nvsp_msg *init_pkt; int ret = 0; - net_dev = hv_nv_get_outbound_net_device(device); + net_dev = hv_nv_get_outbound_net_device(sc); if (!net_dev) { return (ENODEV); } @@ -185,7 +162,7 @@ hv_nv_init_rx_buffer_with_net_vsp(struct * GPADL: Guest physical address descriptor list. */ ret = hv_vmbus_channel_establish_gpadl( - device->channel, net_dev->rx_buf, + sc->hn_prichan, net_dev->rx_buf, net_dev->rx_buf_size, &net_dev->rx_buf_gpadl_handle); if (ret != 0) { goto cleanup; @@ -206,7 +183,7 @@ hv_nv_init_rx_buffer_with_net_vsp(struct /* Send the gpadl notification request */ - ret = hv_vmbus_channel_send_packet(device->channel, init_pkt, + ret = hv_vmbus_channel_send_packet(sc->hn_prichan, init_pkt, sizeof(nvsp_msg), (uint64_t)(uintptr_t)init_pkt, HV_VMBUS_PACKET_TYPE_DATA_IN_BAND, HV_VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED); @@ -256,13 +233,13 @@ exit: * Net VSC initialize send buffer with net VSP */ static int -hv_nv_init_send_buffer_with_net_vsp(struct hv_device *device) +hv_nv_init_send_buffer_with_net_vsp(struct hn_softc *sc) { netvsc_dev *net_dev; nvsp_msg *init_pkt; int ret = 0; - net_dev = hv_nv_get_outbound_net_device(device); + net_dev = hv_nv_get_outbound_net_device(sc); if (!net_dev) { return (ENODEV); } @@ -279,7 +256,7 @@ hv_nv_init_send_buffer_with_net_vsp(stru * Note: This call uses the vmbus connection rather than the * channel to establish the gpadl handle. */ - ret = hv_vmbus_channel_establish_gpadl(device->channel, + ret = hv_vmbus_channel_establish_gpadl(sc->hn_prichan, net_dev->send_buf, net_dev->send_buf_size, &net_dev->send_buf_gpadl_handle); if (ret != 0) { @@ -300,7 +277,7 @@ hv_nv_init_send_buffer_with_net_vsp(stru /* Send the gpadl notification request */ - ret = hv_vmbus_channel_send_packet(device->channel, init_pkt, + ret = hv_vmbus_channel_send_packet(sc->hn_prichan, init_pkt, sizeof(nvsp_msg), (uint64_t)init_pkt, HV_VMBUS_PACKET_TYPE_DATA_IN_BAND, HV_VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED); @@ -360,7 +337,7 @@ hv_nv_destroy_rx_buffer(netvsc_dev *net_ revoke_pkt->msgs.vers_1_msgs.revoke_rx_buf.id = NETVSC_RECEIVE_BUFFER_ID; - ret = hv_vmbus_channel_send_packet(net_dev->dev->channel, + ret = hv_vmbus_channel_send_packet(net_dev->sc->hn_prichan, revoke_pkt, sizeof(nvsp_msg), (uint64_t)(uintptr_t)revoke_pkt, HV_VMBUS_PACKET_TYPE_DATA_IN_BAND, 0); @@ -376,7 +353,7 @@ hv_nv_destroy_rx_buffer(netvsc_dev *net_ /* Tear down the gpadl on the vsp end */ if (net_dev->rx_buf_gpadl_handle) { - ret = hv_vmbus_channel_teardown_gpdal(net_dev->dev->channel, + ret = hv_vmbus_channel_teardown_gpdal(net_dev->sc->hn_prichan, net_dev->rx_buf_gpadl_handle); /* * If we failed here, we might as well return and have a leak @@ -428,7 +405,7 @@ hv_nv_destroy_send_buffer(netvsc_dev *ne revoke_pkt->msgs.vers_1_msgs.revoke_send_buf.id = NETVSC_SEND_BUFFER_ID; - ret = hv_vmbus_channel_send_packet(net_dev->dev->channel, + ret = hv_vmbus_channel_send_packet(net_dev->sc->hn_prichan, revoke_pkt, sizeof(nvsp_msg), (uint64_t)(uintptr_t)revoke_pkt, HV_VMBUS_PACKET_TYPE_DATA_IN_BAND, 0); @@ -443,7 +420,7 @@ hv_nv_destroy_send_buffer(netvsc_dev *ne /* Tear down the gpadl on the vsp end */ if (net_dev->send_buf_gpadl_handle) { - ret = hv_vmbus_channel_teardown_gpdal(net_dev->dev->channel, + ret = hv_vmbus_channel_teardown_gpdal(net_dev->sc->hn_prichan, net_dev->send_buf_gpadl_handle); /* @@ -478,7 +455,7 @@ hv_nv_destroy_send_buffer(netvsc_dev *ne * to the negotiated version, so we cannot rely on that. */ static int -hv_nv_negotiate_nvsp_protocol(struct hv_device *device, netvsc_dev *net_dev, +hv_nv_negotiate_nvsp_protocol(struct hn_softc *sc, netvsc_dev *net_dev, uint32_t nvsp_ver) { nvsp_msg *init_pkt; @@ -495,7 +472,7 @@ hv_nv_negotiate_nvsp_protocol(struct hv_ init_pkt->msgs.init_msgs.init.protocol_version_2 = nvsp_ver; /* Send the init request */ - ret = hv_vmbus_channel_send_packet(device->channel, init_pkt, + ret = hv_vmbus_channel_send_packet(sc->hn_prichan, init_pkt, sizeof(nvsp_msg), (uint64_t)(uintptr_t)init_pkt, HV_VMBUS_PACKET_TYPE_DATA_IN_BAND, HV_VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED); @@ -516,13 +493,13 @@ hv_nv_negotiate_nvsp_protocol(struct hv_ * Not valid for NDIS version 1. */ static int -hv_nv_send_ndis_config(struct hv_device *device, uint32_t mtu) +hv_nv_send_ndis_config(struct hn_softc *sc, uint32_t mtu) { netvsc_dev *net_dev; nvsp_msg *init_pkt; int ret; - net_dev = hv_nv_get_outbound_net_device(device); + net_dev = hv_nv_get_outbound_net_device(sc); if (!net_dev) return (-ENODEV); @@ -539,7 +516,7 @@ hv_nv_send_ndis_config(struct hv_device = 1; /* Send the configuration packet */ - ret = hv_vmbus_channel_send_packet(device->channel, init_pkt, + ret = hv_vmbus_channel_send_packet(sc->hn_prichan, init_pkt, sizeof(nvsp_msg), (uint64_t)(uintptr_t)init_pkt, HV_VMBUS_PACKET_TYPE_DATA_IN_BAND, 0); if (ret != 0) @@ -552,7 +529,7 @@ hv_nv_send_ndis_config(struct hv_device * Net VSC connect to VSP */ static int -hv_nv_connect_to_vsp(struct hv_device *device) +hv_nv_connect_to_vsp(struct hn_softc *sc) { netvsc_dev *net_dev; nvsp_msg *init_pkt; @@ -564,20 +541,16 @@ hv_nv_connect_to_vsp(struct hv_device *d int i; int protocol_number = nitems(protocol_list); int ret = 0; - device_t dev = device->device; - hn_softc_t *sc = device_get_softc(dev); + device_t dev = sc->hn_dev; struct ifnet *ifp = sc->hn_ifp; - net_dev = hv_nv_get_outbound_net_device(device); - if (!net_dev) { - return (ENODEV); - } + net_dev = hv_nv_get_outbound_net_device(sc); /* * Negotiate the NVSP version. Try the latest NVSP first. */ for (i = protocol_number - 1; i >= 0; i--) { - if (hv_nv_negotiate_nvsp_protocol(device, net_dev, + if (hv_nv_negotiate_nvsp_protocol(sc, net_dev, protocol_list[i]) == 0) { net_dev->nvsp_version = protocol_list[i]; if (bootverbose) @@ -599,7 +572,7 @@ hv_nv_connect_to_vsp(struct hv_device *d * This needs to be right after the NVSP init message per Haiyang */ if (net_dev->nvsp_version >= NVSP_PROTOCOL_VERSION_2) - ret = hv_nv_send_ndis_config(device, ifp->if_mtu); + ret = hv_nv_send_ndis_config(sc, ifp->if_mtu); /* * Send the NDIS version @@ -622,7 +595,7 @@ hv_nv_connect_to_vsp(struct hv_device *d /* Send the init request */ - ret = hv_vmbus_channel_send_packet(device->channel, init_pkt, + ret = hv_vmbus_channel_send_packet(sc->hn_prichan, init_pkt, sizeof(nvsp_msg), (uint64_t)(uintptr_t)init_pkt, HV_VMBUS_PACKET_TYPE_DATA_IN_BAND, 0); if (ret != 0) { @@ -643,9 +616,9 @@ hv_nv_connect_to_vsp(struct hv_device *d net_dev->rx_buf_size = NETVSC_RECEIVE_BUFFER_SIZE; net_dev->send_buf_size = NETVSC_SEND_BUFFER_SIZE; - ret = hv_nv_init_rx_buffer_with_net_vsp(device); + ret = hv_nv_init_rx_buffer_with_net_vsp(sc); if (ret == 0) - ret = hv_nv_init_send_buffer_with_net_vsp(device); + ret = hv_nv_init_send_buffer_with_net_vsp(sc); cleanup: return (ret); @@ -677,13 +650,13 @@ hv_nv_subchan_attach(struct hv_vmbus_cha * Callback when the device belonging to this driver is added */ netvsc_dev * -hv_nv_on_device_add(struct hv_device *device, void *additional_info) +hv_nv_on_device_add(struct hn_softc *sc, void *additional_info) { - struct hv_vmbus_channel *chan = device->channel; + struct hv_vmbus_channel *chan = sc->hn_prichan; netvsc_dev *net_dev; int ret = 0; - net_dev = hv_nv_alloc_net_device(device); + net_dev = hv_nv_alloc_net_device(sc); if (net_dev == NULL) return NULL; @@ -707,7 +680,7 @@ hv_nv_on_device_add(struct hv_device *de /* * Connect with the NetVsp */ - ret = hv_nv_connect_to_vsp(device); + ret = hv_nv_connect_to_vsp(sc); if (ret != 0) goto close; @@ -733,9 +706,8 @@ cleanup: * Net VSC on device remove */ int -hv_nv_on_device_remove(struct hv_device *device, boolean_t destroy_channel) +hv_nv_on_device_remove(struct hn_softc *sc, boolean_t destroy_channel) { - hn_softc_t *sc = device_get_softc(device->device); netvsc_dev *net_dev = sc->net_dev;; /* Stop outbound traffic ie sends and receives completions */ @@ -748,12 +720,12 @@ hv_nv_on_device_remove(struct hv_device /* Now, we can close the channel safely */ if (!destroy_channel) { - device->channel->state = + sc->hn_prichan->state = HV_CHANNEL_CLOSING_NONDESTRUCTIVE_STATE; } - free(device->channel->hv_chan_rdbuf, M_NETVSC); - hv_vmbus_channel_close(device->channel); + free(sc->hn_prichan->hv_chan_rdbuf, M_NETVSC); + hv_vmbus_channel_close(sc->hn_prichan); sema_destroy(&net_dev->channel_init_sema); free(net_dev, M_NETVSC); @@ -765,8 +737,7 @@ hv_nv_on_device_remove(struct hv_device * Net VSC on send completion */ static void -hv_nv_on_send_completion(netvsc_dev *net_dev, - struct hv_device *device, struct hv_vmbus_channel *chan, +hv_nv_on_send_completion(netvsc_dev *net_dev, struct hv_vmbus_channel *chan, hv_vm_packet_descriptor *pkt) { nvsp_msg *nvsp_msg_pkt; @@ -871,14 +842,14 @@ hv_nv_on_send(struct hv_vmbus_channel *c * with virtual addresses. */ static void -hv_nv_on_receive(netvsc_dev *net_dev, struct hv_device *device, +hv_nv_on_receive(netvsc_dev *net_dev, struct hn_softc *sc, struct hv_vmbus_channel *chan, hv_vm_packet_descriptor *pkt) { hv_vm_transfer_page_packet_header *vm_xfer_page_pkt; nvsp_msg *nvsp_msg_pkt; netvsc_packet vsc_pkt; netvsc_packet *net_vsc_pkt = &vsc_pkt; - device_t dev = device->device; + device_t dev = sc->hn_dev; int count = 0; int i = 0; int status = nvsp_status_success; @@ -912,7 +883,6 @@ hv_nv_on_receive(netvsc_dev *net_dev, st } count = vm_xfer_page_pkt->range_count; - net_vsc_pkt->device = device; /* Each range represents 1 RNDIS pkt that contains 1 Ethernet frame */ for (i = 0; i < count; i++) { @@ -922,7 +892,7 @@ hv_nv_on_receive(netvsc_dev *net_dev, st net_vsc_pkt->tot_data_buf_len = vm_xfer_page_pkt->ranges[i].byte_count; - hv_rf_on_receive(net_dev, device, chan, net_vsc_pkt); + hv_rf_on_receive(net_dev, chan, net_vsc_pkt); if (net_vsc_pkt->status != nvsp_status_success) { status = nvsp_status_failure; } @@ -978,14 +948,14 @@ retry_send_cmplt: * Net VSC receiving vRSS send table from VSP */ static void -hv_nv_send_table(struct hv_device *device, hv_vm_packet_descriptor *pkt) +hv_nv_send_table(struct hn_softc *sc, hv_vm_packet_descriptor *pkt) { netvsc_dev *net_dev; nvsp_msg *nvsp_msg_pkt; int i; uint32_t count, *table; - net_dev = hv_nv_get_inbound_net_device(device); + net_dev = hv_nv_get_inbound_net_device(sc); if (!net_dev) return; @@ -1021,9 +991,9 @@ static void hv_nv_on_channel_callback(void *xchan) { struct hv_vmbus_channel *chan = xchan; - struct hv_device *device = chan->device; + device_t dev = chan->ch_dev; + struct hn_softc *sc = device_get_softc(dev); netvsc_dev *net_dev; - device_t dev = device->device; uint32_t bytes_rxed; uint64_t request_id; hv_vm_packet_descriptor *desc; @@ -1031,7 +1001,7 @@ hv_nv_on_channel_callback(void *xchan) int bufferlen = NETVSC_PACKET_SIZE; int ret = 0; - net_dev = hv_nv_get_inbound_net_device(device); + net_dev = hv_nv_get_inbound_net_device(sc); if (net_dev == NULL) return; @@ -1045,14 +1015,14 @@ hv_nv_on_channel_callback(void *xchan) desc = (hv_vm_packet_descriptor *)buffer; switch (desc->type) { case HV_VMBUS_PACKET_TYPE_COMPLETION: - hv_nv_on_send_completion(net_dev, device, - chan, desc); + hv_nv_on_send_completion(net_dev, chan, + desc); break; case HV_VMBUS_PACKET_TYPE_DATA_USING_TRANSFER_PAGES: - hv_nv_on_receive(net_dev, device, chan, desc); + hv_nv_on_receive(net_dev, sc, chan, desc); break; case HV_VMBUS_PACKET_TYPE_DATA_IN_BAND: - hv_nv_send_table(device, desc); + hv_nv_send_table(sc, desc); break; default: device_printf(dev, Modified: stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.h ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.h Fri Oct 14 08:34:44 2016 (r307306) +++ stable/11/sys/dev/hyperv/netvsc/hv_net_vsc.h Fri Oct 14 08:45:53 2016 (r307307) @@ -1040,7 +1040,7 @@ typedef struct nvsp_msg_ { * Per netvsc channel-specific */ typedef struct netvsc_dev_ { - struct hv_device *dev; + struct hn_softc *sc; /* Send buffer allocated by us but manages by NetVSP */ void *send_buf; @@ -1107,7 +1107,6 @@ typedef void (*pfn_on_send_rx_completion #endif typedef struct netvsc_packet_ { - struct hv_device *device; hv_bool_uint8_t is_data_pkt; /* One byte */ uint16_t vlan_tci; uint32_t status; @@ -1239,8 +1238,8 @@ typedef struct hn_softc { int hn_initdone; /* See hv_netvsc_drv_freebsd.c for rules on how to use */ int temp_unusable; - struct hv_device *hn_dev_obj; netvsc_dev *net_dev; + struct hv_vmbus_channel *hn_prichan; int hn_rx_ring_cnt; int hn_rx_ring_inuse; @@ -1262,10 +1261,10 @@ typedef struct hn_softc { */ extern int hv_promisc_mode; -void netvsc_linkstatus_callback(struct hv_device *device_obj, uint32_t status); -netvsc_dev *hv_nv_on_device_add(struct hv_device *device, +void netvsc_linkstatus_callback(struct hn_softc *sc, uint32_t status); +netvsc_dev *hv_nv_on_device_add(struct hn_softc *sc, void *additional_info); -int hv_nv_on_device_remove(struct hv_device *device, +int hv_nv_on_device_remove(struct hn_softc *sc, boolean_t destroy_channel); int hv_nv_on_send(struct hv_vmbus_channel *chan, netvsc_packet *pkt); int hv_nv_get_next_send_section(netvsc_dev *net_dev); Modified: stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Fri Oct 14 08:34:44 2016 (r307306) +++ stable/11/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Fri Oct 14 08:45:53 2016 (r307307) @@ -411,18 +411,12 @@ static const hv_guid g_net_vsc_device_ty static int netvsc_probe(device_t dev) { - const char *p; - - p = vmbus_get_type(dev); - if (!memcmp(p, &g_net_vsc_device_type.data, sizeof(hv_guid))) { + if (VMBUS_PROBE_GUID(device_get_parent(dev), dev, + &g_net_vsc_device_type) == 0) { device_set_desc(dev, "Hyper-V Network Interface"); - if (bootverbose) - printf("Netvsc probe... DONE \n"); - - return (BUS_PROBE_DEFAULT); + return BUS_PROBE_DEFAULT; } - - return (ENXIO); + return ENXIO; } /* @@ -434,8 +428,6 @@ netvsc_probe(device_t dev) static int netvsc_attach(device_t dev) { - struct hv_device *device_ctx = vmbus_get_devctx(dev); - struct hv_vmbus_channel *pri_chan; netvsc_device_info device_info; hn_softc_t *sc; int unit = device_get_unit(dev); @@ -449,6 +441,7 @@ netvsc_attach(device_t dev) sc->hn_unit = unit; sc->hn_dev = dev; + sc->hn_prichan = vmbus_get_channel(dev); if (hn_tx_taskq == NULL) { sc->hn_tx_taskq = taskqueue_create("hn_tx", M_WAITOK, @@ -472,8 +465,6 @@ netvsc_attach(device_t dev) } NV_LOCK_INIT(sc, "NetVSCLock"); - sc->hn_dev_obj = device_ctx; - ifp = sc->hn_ifp = if_alloc(IFT_ETHER); ifp->if_softc = sc; if_initname(ifp, device_get_name(dev), device_get_unit(dev)); @@ -516,12 +507,7 @@ netvsc_attach(device_t dev) /* * Associate the first TX/RX ring w/ the primary channel. */ - pri_chan = device_ctx->channel; - KASSERT(HV_VMBUS_CHAN_ISPRIMARY(pri_chan), ("not primary channel")); - KASSERT(pri_chan->ch_subidx == 0, - ("primary channel subidx %u", - pri_chan->ch_subidx)); - hn_channel_attach(sc, pri_chan); + hn_channel_attach(sc, sc->hn_prichan); ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; ifp->if_ioctl = hn_ioctl; @@ -558,7 +544,7 @@ netvsc_attach(device_t dev) IFCAP_LRO; ifp->if_hwassist = sc->hn_tx_ring[0].hn_csum_assist | CSUM_TSO; - error = hv_rf_on_device_add(device_ctx, &device_info, ring_cnt); + error = hv_rf_on_device_add(sc, &device_info, ring_cnt); if (error) goto failed; KASSERT(sc->net_dev->num_channel > 0 && @@ -632,7 +618,6 @@ static int netvsc_detach(device_t dev) { struct hn_softc *sc = device_get_softc(dev); - struct hv_device *hv_device = vmbus_get_devctx(dev); if (bootverbose) printf("netvsc_detach\n"); @@ -648,7 +633,7 @@ netvsc_detach(device_t dev) * the netdevice. */ - hv_rf_on_device_remove(hv_device, HV_RF_NV_DESTROY_CHANNEL); + hv_rf_on_device_remove(sc, HV_RF_NV_DESTROY_CHANNEL); hn_stop_tx_tasks(sc); @@ -1207,10 +1192,8 @@ hn_start_locked(struct hn_tx_ring *txr, * Link up/down notification */ void -netvsc_linkstatus_callback(struct hv_device *device_obj, uint32_t status) +netvsc_linkstatus_callback(struct hn_softc *sc, uint32_t status) { - hn_softc_t *sc = device_get_softc(device_obj->device); - if (status == 1) { sc->hn_carrier = 1; } else { @@ -1531,7 +1514,6 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, struct ifaddr *ifa = (struct ifaddr *)data; #endif netvsc_device_info device_info; - struct hv_device *hn_dev; int mask, error = 0; int retry_cnt = 500; @@ -1549,8 +1531,6 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, error = ether_ioctl(ifp, cmd, data); break; case SIOCSIFMTU: - hn_dev = vmbus_get_devctx(sc->hn_dev); - /* Check MTU value change */ if (ifp->if_mtu == ifr->ifr_mtu) break; @@ -1597,7 +1577,7 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, * MTU to take effect. This includes tearing down, but not * deleting the channel, then bringing it back up. */ - error = hv_rf_on_device_remove(hn_dev, HV_RF_NV_RETAIN_CHANNEL); + error = hv_rf_on_device_remove(sc, HV_RF_NV_RETAIN_CHANNEL); if (error) { NV_LOCK(sc); sc->temp_unusable = FALSE; @@ -1606,9 +1586,9 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, } /* Wait for subchannels to be destroyed */ - vmbus_drain_subchan(hn_dev->channel); + vmbus_drain_subchan(sc->hn_prichan); - error = hv_rf_on_device_add(hn_dev, &device_info, + error = hv_rf_on_device_add(sc, &device_info, sc->hn_rx_ring_inuse); if (error) { NV_LOCK(sc); @@ -1773,7 +1753,6 @@ hn_stop(hn_softc_t *sc) { struct ifnet *ifp; int ret, i; - struct hv_device *device_ctx = vmbus_get_devctx(sc->hn_dev); ifp = sc->hn_ifp; @@ -1788,7 +1767,7 @@ hn_stop(hn_softc_t *sc) if_link_state_change(ifp, LINK_STATE_DOWN); sc->hn_initdone = 0; - ret = hv_rf_on_close(device_ctx); + ret = hv_rf_on_close(sc); } /* @@ -1856,7 +1835,6 @@ static void hn_ifinit_locked(hn_softc_t *sc) { struct ifnet *ifp; - struct hv_device *device_ctx = vmbus_get_devctx(sc->hn_dev); int ret, i; ifp = sc->hn_ifp; @@ -1867,7 +1845,7 @@ hn_ifinit_locked(hn_softc_t *sc) hv_promisc_mode = 1; - ret = hv_rf_on_open(device_ctx); + ret = hv_rf_on_open(sc); if (ret != 0) { return; } else { @@ -2990,13 +2968,12 @@ hn_subchan_attach(struct hn_softc *sc, s static void hn_subchan_setup(struct hn_softc *sc) { - struct hv_device *device_ctx = vmbus_get_devctx(sc->hn_dev); struct hv_vmbus_channel **subchan; int subchan_cnt = sc->net_dev->num_channel - 1; int i; /* Wait for sub-channels setup to complete. */ - subchan = vmbus_get_subchan(device_ctx->channel, subchan_cnt); + subchan = vmbus_get_subchan(sc->hn_prichan, subchan_cnt); /* Attach the sub-channels. */ for (i = 0; i < subchan_cnt; ++i) { Modified: stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.c ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.c Fri Oct 14 08:34:44 2016 (r307306) +++ stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.c Fri Oct 14 08:45:53 2016 (r307307) @@ -88,7 +88,7 @@ static int hv_rf_close_device(rndis_dev static void hv_rf_on_send_request_completion(struct hv_vmbus_channel *, void *context); static void hv_rf_on_send_request_halt_completion(struct hv_vmbus_channel *, void *context); int -hv_rf_send_offload_request(struct hv_device *device, +hv_rf_send_offload_request(struct hn_softc *sc, rndis_offload_params *offloads); /* * Set the Per-Packet-Info with the specified type @@ -298,7 +298,7 @@ hv_rf_send_request(rndis_device *device, packet->send_buf_section_size = 0; sendit: - ret = hv_nv_on_send(device->net_dev->dev->channel, packet); + ret = hv_nv_on_send(device->net_dev->sc->hn_prichan, packet); return (ret); } @@ -350,7 +350,7 @@ hv_rf_receive_response(rndis_device *dev } int -hv_rf_send_offload_request(struct hv_device *device, +hv_rf_send_offload_request(struct hn_softc *sc, rndis_offload_params *offloads) { rndis_request *request; @@ -358,8 +358,7 @@ hv_rf_send_offload_request(struct hv_dev rndis_offload_params *offload_req; rndis_set_complete *set_complete; rndis_device *rndis_dev; - hn_softc_t *sc = device_get_softc(device->device); - device_t dev = device->device; + device_t dev = sc->hn_dev; netvsc_dev *net_dev = sc->net_dev; uint32_t vsp_version = net_dev->nvsp_version; uint32_t extlen = sizeof(rndis_offload_params); @@ -436,14 +435,14 @@ hv_rf_receive_indicate_status(rndis_devi switch(indicate->status) { case RNDIS_STATUS_MEDIA_CONNECT: - netvsc_linkstatus_callback(device->net_dev->dev, 1); + netvsc_linkstatus_callback(device->net_dev->sc, 1); break; case RNDIS_STATUS_MEDIA_DISCONNECT: - netvsc_linkstatus_callback(device->net_dev->dev, 0); + netvsc_linkstatus_callback(device->net_dev->sc, 0); break; default: /* TODO: */ - device_printf(device->net_dev->dev->device, + device_printf(device->net_dev->sc->hn_dev, "unknown status %d received\n", indicate->status); break; } @@ -536,7 +535,7 @@ hv_rf_receive_data(rndis_device *device, { rndis_packet *rndis_pkt; uint32_t data_offset; - device_t dev = device->net_dev->dev->device; + device_t dev = device->net_dev->sc->hn_dev; struct hv_rf_recvinfo info; rndis_pkt = &message->msg.packet; @@ -579,7 +578,7 @@ hv_rf_receive_data(rndis_device *device, * RNDIS filter on receive */ int -hv_rf_on_receive(netvsc_dev *net_dev, struct hv_device *device, +hv_rf_on_receive(netvsc_dev *net_dev, struct hv_vmbus_channel *chan, netvsc_packet *pkt) { rndis_device *rndis_dev; @@ -1061,7 +1060,7 @@ hv_rf_close_device(rndis_device *device) * RNDIS filter on device add */ int -hv_rf_on_device_add(struct hv_device *device, void *additl_info, +hv_rf_on_device_add(struct hn_softc *sc, void *additl_info, int nchan) { int ret; @@ -1072,7 +1071,7 @@ hv_rf_on_device_add(struct hv_device *de struct rndis_recv_scale_cap rsscaps; uint32_t rsscaps_size = sizeof(struct rndis_recv_scale_cap); netvsc_device_info *dev_info = (netvsc_device_info *)additl_info; - device_t dev = device->device; + device_t dev = sc->hn_dev; rndis_dev = hv_get_rndis_device(); if (rndis_dev == NULL) { @@ -1085,7 +1084,7 @@ hv_rf_on_device_add(struct hv_device *de * (hv_rf_on_receive()) before this call is completed. * Note: Earlier code used a function pointer here. */ - net_dev = hv_nv_on_device_add(device, additl_info); + net_dev = hv_nv_on_device_add(sc, additl_info); if (!net_dev) { hv_put_rndis_device(rndis_dev); @@ -1123,7 +1122,7 @@ hv_rf_on_device_add(struct hv_device *de offloads.udp_ipv6_csum = RNDIS_OFFLOAD_PARAMETERS_TX_RX_ENABLED; offloads.lso_v2_ipv4 = RNDIS_OFFLOAD_PARAMETERS_LSOV2_ENABLED; - ret = hv_rf_send_offload_request(device, &offloads); + ret = hv_rf_send_offload_request(sc, &offloads); if (ret != 0) { /* TODO: shut down rndis device and the channel */ device_printf(dev, @@ -1170,7 +1169,7 @@ hv_rf_on_device_add(struct hv_device *de init_pkt->msgs.vers_5_msgs.subchannel_request.num_subchannels = net_dev->num_channel - 1; - ret = hv_vmbus_channel_send_packet(device->channel, init_pkt, + ret = hv_vmbus_channel_send_packet(sc->hn_prichan, init_pkt, sizeof(nvsp_msg), (uint64_t)(uintptr_t)init_pkt, HV_VMBUS_PACKET_TYPE_DATA_IN_BAND, HV_VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED); @@ -1204,9 +1203,8 @@ out: * RNDIS filter on device remove */ int -hv_rf_on_device_remove(struct hv_device *device, boolean_t destroy_channel) +hv_rf_on_device_remove(struct hn_softc *sc, boolean_t destroy_channel) { - hn_softc_t *sc = device_get_softc(device->device); netvsc_dev *net_dev = sc->net_dev; rndis_device *rndis_dev = (rndis_device *)net_dev->extension; int ret; @@ -1218,7 +1216,7 @@ hv_rf_on_device_remove(struct hv_device net_dev->extension = NULL; /* Pass control to inner driver to remove the device */ - ret |= hv_nv_on_device_remove(device, destroy_channel); + ret |= hv_nv_on_device_remove(sc, destroy_channel); return (ret); } @@ -1227,9 +1225,8 @@ hv_rf_on_device_remove(struct hv_device * RNDIS filter on open */ int -hv_rf_on_open(struct hv_device *device) +hv_rf_on_open(struct hn_softc *sc) { - hn_softc_t *sc = device_get_softc(device->device); netvsc_dev *net_dev = sc->net_dev; return (hv_rf_open_device((rndis_device *)net_dev->extension)); @@ -1239,9 +1236,8 @@ hv_rf_on_open(struct hv_device *device) * RNDIS filter on close */ int -hv_rf_on_close(struct hv_device *device) +hv_rf_on_close(struct hn_softc *sc) { - hn_softc_t *sc = device_get_softc(device->device); netvsc_dev *net_dev = sc->net_dev; return (hv_rf_close_device((rndis_device *)net_dev->extension)); Modified: stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.h ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.h Fri Oct 14 08:34:44 2016 (r307306) +++ stable/11/sys/dev/hyperv/netvsc/hv_rndis_filter.h Fri Oct 14 08:45:53 2016 (r307307) @@ -111,15 +111,16 @@ typedef struct rndis_device_ { * Externs */ struct hv_vmbus_channel; +struct hn_softc; -int hv_rf_on_receive(netvsc_dev *net_dev, struct hv_device *device, +int hv_rf_on_receive(netvsc_dev *net_dev, struct hv_vmbus_channel *chan, netvsc_packet *pkt); void hv_rf_receive_rollup(netvsc_dev *net_dev); void hv_rf_channel_rollup(struct hv_vmbus_channel *chan); -int hv_rf_on_device_add(struct hv_device *device, void *additl_info, int nchan); -int hv_rf_on_device_remove(struct hv_device *device, boolean_t destroy_channel); -int hv_rf_on_open(struct hv_device *device); -int hv_rf_on_close(struct hv_device *device); +int hv_rf_on_device_add(struct hn_softc *sc, void *additl_info, int nchan); +int hv_rf_on_device_remove(struct hn_softc *sc, boolean_t destroy_channel); +int hv_rf_on_open(struct hn_softc *sc); +int hv_rf_on_close(struct hn_softc *sc); #endif /* __HV_RNDIS_FILTER_H__ */ Modified: stable/11/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c ============================================================================== --- stable/11/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c Fri Oct 14 08:34:44 2016 (r307306) +++ stable/11/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c Fri Oct 14 08:45:53 2016 (r307307) @@ -125,7 +125,7 @@ struct hv_storvsc_request { }; struct storvsc_softc { - struct hv_device *hs_dev; + struct hv_vmbus_channel *hs_chan; LIST_HEAD(, hv_storvsc_request) hs_free_list; struct mtx hs_lock; struct storvsc_driver_props *hs_drv_props; @@ -139,6 +139,7 @@ struct storvsc_softc { struct sema hs_drain_sema; struct hv_storvsc_request hs_init_req; struct hv_storvsc_request hs_reset_req; + device_t hs_dev; }; @@ -264,11 +265,11 @@ static int create_storvsc_request(union static void storvsc_free_request(struct storvsc_softc *sc, struct hv_storvsc_request *reqp); static enum hv_storage_type storvsc_get_storage_type(device_t dev); static void hv_storvsc_rescan_target(struct storvsc_softc *sc); -static void hv_storvsc_on_channel_callback(void *context); +static void hv_storvsc_on_channel_callback(void *xchan); static void hv_storvsc_on_iocompletion( struct storvsc_softc *sc, struct vstor_packet *vstor_packet, struct hv_storvsc_request *request); -static int hv_storvsc_connect_vsp(struct hv_device *device); +static int hv_storvsc_connect_vsp(struct storvsc_softc *); static void storvsc_io_done(struct hv_storvsc_request *reqp); static void storvsc_copy_sgl_to_bounce_buf(struct sglist *bounce_sgl, bus_dma_segment_t *orig_sgl, @@ -297,72 +298,16 @@ DRIVER_MODULE(storvsc, vmbus, storvsc_dr MODULE_VERSION(storvsc, 1); MODULE_DEPEND(storvsc, vmbus, 1, 1, 1); - -/** - * The host is capable of sending messages to us that are - * completely unsolicited. So, we need to address the race - * condition where we may be in the process of unloading the - * driver when the host may send us an unsolicited message. - * We address this issue by implementing a sequentially - * consistent protocol: - * - * 1. Channel callback is invoked while holding the channel lock - * and an unloading driver will reset the channel callback under - * the protection of this channel lock. - * - * 2. To ensure bounded wait time for unloading a driver, we don't - * permit outgoing traffic once the device is marked as being - * destroyed. - * - * 3. Once the device is marked as being destroyed, we only - * permit incoming traffic to properly account for - * packets already sent out. - */ -static inline struct storvsc_softc * -get_stor_device(struct hv_device *device, - boolean_t outbound) -{ - struct storvsc_softc *sc; - - sc = device_get_softc(device->device); - - if (outbound) { *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-all@freebsd.org Fri Oct 14 08:55:51 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 80A7AC10E55; Fri, 14 Oct 2016 08:55:51 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 5AC3AB80; Fri, 14 Oct 2016 08:55:51 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9E8toXC001653; Fri, 14 Oct 2016 08:55:50 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9E8tori001647; Fri, 14 Oct 2016 08:55:50 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610140855.u9E8tori001647@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Fri, 14 Oct 2016 08:55:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307308 - in stable/11/sys/dev/hyperv: include vmbus X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Oct 2016 08:55:51 -0000 Author: sephe Date: Fri Oct 14 08:55:49 2016 New Revision: 307308 URL: https://svnweb.freebsd.org/changeset/base/307308 Log: MFC 302707-302709 302707 hyperv/vmbus: Nuke unused field from hv_vmbus_channel. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7036 302708 hyperv/bufring: Remove unused fields Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7037 302709 hyperv/vmbus: Pack bool field into flags field Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7038 Modified: stable/11/sys/dev/hyperv/include/hyperv.h stable/11/sys/dev/hyperv/vmbus/hv_channel.c stable/11/sys/dev/hyperv/vmbus/hv_channel_mgmt.c stable/11/sys/dev/hyperv/vmbus/hv_ring_buffer.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/hyperv/include/hyperv.h ============================================================================== --- stable/11/sys/dev/hyperv/include/hyperv.h Fri Oct 14 08:45:53 2016 (r307307) +++ stable/11/sys/dev/hyperv/include/hyperv.h Fri Oct 14 08:55:49 2016 (r307308) @@ -471,7 +471,7 @@ typedef struct { uint8_t reserved[4084]; /* - * WARNING: Ring data starts here + ring_data_start_offset + * WARNING: Ring data starts here * !!! DO NOT place any fields below this !!! */ uint8_t buffer[0]; /* doubles as interrupt mask */ @@ -491,10 +491,8 @@ typedef struct { typedef struct { hv_vmbus_ring_buffer* ring_buffer; - uint32_t ring_size; /* Include the shared header */ struct mtx ring_lock; uint32_t ring_data_size; /* ring_size */ - uint32_t ring_data_start_offset; } hv_vmbus_ring_buffer_info; typedef void (*hv_vmbus_pfn_channel_callback)(void *context); @@ -553,19 +551,6 @@ typedef struct hv_vmbus_channel { hv_vmbus_pfn_channel_callback on_channel_callback; void* channel_callback_context; - /* - * If batched_reading is set to "true", mask the interrupt - * and read until the channel is empty. - * If batched_reading is set to "false", the channel is not - * going to perform batched reading. - * - * Batched reading is enabled by default; specific - * drivers that don't want this behavior can turn it off. - */ - boolean_t batched_reading; - - boolean_t is_dedicated_interrupt; - struct hypercall_sigevt_in *ch_sigevt; struct hyperv_dma ch_sigevt_dma; @@ -626,11 +611,23 @@ typedef struct hv_vmbus_channel { #define HV_VMBUS_CHAN_ISPRIMARY(chan) ((chan)->primary_channel == NULL) #define VMBUS_CHAN_FLAG_HASMNF 0x0001 +/* + * If this flag is set, this channel's interrupt will be masked in ISR, + * and the RX bufring will be drained before this channel's interrupt is + * unmasked. + * + * This flag is turned on by default. Drivers can turn it off according + * to their own requirement. + */ +#define VMBUS_CHAN_FLAG_BATCHREAD 0x0002 static inline void -hv_set_channel_read_state(hv_vmbus_channel* channel, boolean_t state) +hv_set_channel_read_state(hv_vmbus_channel* channel, boolean_t on) { - channel->batched_reading = state; + if (!on) + channel->ch_flags &= ~VMBUS_CHAN_FLAG_BATCHREAD; + else + channel->ch_flags |= VMBUS_CHAN_FLAG_BATCHREAD; } int hv_vmbus_channel_recv_packet( Modified: stable/11/sys/dev/hyperv/vmbus/hv_channel.c ============================================================================== --- stable/11/sys/dev/hyperv/vmbus/hv_channel.c Fri Oct 14 08:45:53 2016 (r307307) +++ stable/11/sys/dev/hyperv/vmbus/hv_channel.c Fri Oct 14 08:55:49 2016 (r307308) @@ -856,11 +856,13 @@ VmbusProcessChannelEvent(void* context, void* arg; uint32_t bytes_to_read; hv_vmbus_channel* channel = (hv_vmbus_channel*)context; - boolean_t is_batched_reading; + bool is_batched_reading = false; + + if (channel->ch_flags & VMBUS_CHAN_FLAG_BATCHREAD) + is_batched_reading = true; if (channel->on_channel_callback != NULL) { arg = channel->channel_callback_context; - is_batched_reading = channel->batched_reading; /* * Optimize host to guest signaling by ensuring: * 1. While reading the channel, we disable interrupts from @@ -917,7 +919,7 @@ vmbus_event_flags_proc(struct vmbus_soft if (channel == NULL || channel->rxq == NULL) continue; - if (channel->batched_reading) + if (channel->ch_flags & VMBUS_CHAN_FLAG_BATCHREAD) hv_ring_buffer_read_begin(&channel->inbound); taskqueue_enqueue(channel->rxq, &channel->channel_task); } Modified: stable/11/sys/dev/hyperv/vmbus/hv_channel_mgmt.c ============================================================================== --- stable/11/sys/dev/hyperv/vmbus/hv_channel_mgmt.c Fri Oct 14 08:45:53 2016 (r307307) +++ stable/11/sys/dev/hyperv/vmbus/hv_channel_mgmt.c Fri Oct 14 08:55:49 2016 (r307308) @@ -282,21 +282,19 @@ vmbus_channel_on_offer_internal(struct v { hv_vmbus_channel* new_channel; - /* Allocate the channel object and save this offer */ + /* + * Allocate the channel object and save this offer + */ new_channel = hv_vmbus_allocate_channel(sc); new_channel->ch_id = offer->child_rel_id; new_channel->ch_subidx = offer->offer.sub_channel_index; - if (offer->monitor_allocated) - new_channel->ch_flags |= VMBUS_CHAN_FLAG_HASMNF; new_channel->ch_guid_type = offer->offer.interface_type; new_channel->ch_guid_inst = offer->offer.interface_instance; - /* - * By default we setup state to enable batched - * reading. A specific service can choose to - * disable this prior to opening the channel. - */ - new_channel->batched_reading = TRUE; + /* Batch reading is on by default */ + new_channel->ch_flags |= VMBUS_CHAN_FLAG_BATCHREAD; + if (offer->monitor_allocated) + new_channel->ch_flags |= VMBUS_CHAN_FLAG_HASMNF; new_channel->ch_sigevt = hyperv_dmamem_alloc( bus_get_dma_tag(sc->vmbus_dev), @@ -310,12 +308,8 @@ vmbus_channel_on_offer_internal(struct v return; } new_channel->ch_sigevt->hc_connid = VMBUS_CONNID_EVENT; - - if (sc->vmbus_version != VMBUS_VERSION_WS2008) { - new_channel->is_dedicated_interrupt = - (offer->is_dedicated_interrupt != 0); + if (sc->vmbus_version != VMBUS_VERSION_WS2008) new_channel->ch_sigevt->hc_connid = offer->connection_id; - } new_channel->monitor_group = (uint8_t) offer->monitor_id / 32; new_channel->monitor_bit = (uint8_t) offer->monitor_id % 32; Modified: stable/11/sys/dev/hyperv/vmbus/hv_ring_buffer.c ============================================================================== --- stable/11/sys/dev/hyperv/vmbus/hv_ring_buffer.c Fri Oct 14 08:45:53 2016 (r307307) +++ stable/11/sys/dev/hyperv/vmbus/hv_ring_buffer.c Fri Oct 14 08:55:49 2016 (r307308) @@ -286,7 +286,6 @@ hv_vmbus_ring_buffer_init( ring_info->ring_buffer->read_index = ring_info->ring_buffer->write_index = 0; - ring_info->ring_size = buffer_len; ring_info->ring_data_size = buffer_len - sizeof(hv_vmbus_ring_buffer); mtx_init(&ring_info->ring_lock, "vmbus ring buffer", NULL, MTX_SPIN); From owner-svn-src-all@freebsd.org Fri Oct 14 09:00:30 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 5AB0CC111FD; Fri, 14 Oct 2016 09:00:30 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 33A62D6E; Fri, 14 Oct 2016 09:00:30 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9E90TSb001912; Fri, 14 Oct 2016 09:00:29 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9E90TXo001911; Fri, 14 Oct 2016 09:00:29 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610140900.u9E90TXo001911@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Fri, 14 Oct 2016 09:00:29 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307309 - stable/11/sys/dev/hyperv/vmbus X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Oct 2016 09:00:30 -0000 Author: sephe Date: Fri Oct 14 09:00:29 2016 New Revision: 307309 URL: https://svnweb.freebsd.org/changeset/base/307309 Log: MFC 302710,302713 302710 hyperv/vmbus: Remove unnecessary callback check. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7046 302713 hyperv/vmbus: Install different task function for batch/non-batch channels This avoids bunch of unnecessary checks on hot path and simplifies the channel processing. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7085 Modified: stable/11/sys/dev/hyperv/vmbus/hv_channel.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/hyperv/vmbus/hv_channel.c ============================================================================== --- stable/11/sys/dev/hyperv/vmbus/hv_channel.c Fri Oct 14 08:55:49 2016 (r307308) +++ stable/11/sys/dev/hyperv/vmbus/hv_channel.c Fri Oct 14 09:00:29 2016 (r307309) @@ -51,9 +51,10 @@ __FBSDID("$FreeBSD$"); #include static void vmbus_channel_set_event(hv_vmbus_channel* channel); -static void VmbusProcessChannelEvent(void* channel, int pending); static void vmbus_chan_update_evtflagcnt(struct vmbus_softc *, const struct hv_vmbus_channel *); +static void vmbus_chan_task(void *, int); +static void vmbus_chan_task_nobatch(void *, int); /** * @brief Trigger an event notification on the specified channel @@ -213,7 +214,13 @@ hv_vmbus_channel_open( new_channel->rxq = VMBUS_PCPU_GET(new_channel->vmbus_sc, event_tq, new_channel->target_cpu); - TASK_INIT(&new_channel->channel_task, 0, VmbusProcessChannelEvent, new_channel); + if (new_channel->ch_flags & VMBUS_CHAN_FLAG_BATCHREAD) { + TASK_INIT(&new_channel->channel_task, 0, + vmbus_chan_task, new_channel); + } else { + TASK_INIT(&new_channel->channel_task, 0, + vmbus_chan_task_nobatch, new_channel); + } /* Allocate the ring buffer */ out = contigmalloc((send_ring_buffer_size + recv_ring_buffer_size), @@ -846,46 +853,48 @@ hv_vmbus_channel_recv_packet_raw( return (0); } - -/** - * Process a channel event notification - */ static void -VmbusProcessChannelEvent(void* context, int pending) +vmbus_chan_task(void *xchan, int pending __unused) { - void* arg; - uint32_t bytes_to_read; - hv_vmbus_channel* channel = (hv_vmbus_channel*)context; - bool is_batched_reading = false; + struct hv_vmbus_channel *chan = xchan; + void (*callback)(void *); + void *arg; + + arg = chan->channel_callback_context; + callback = chan->on_channel_callback; + + /* + * Optimize host to guest signaling by ensuring: + * 1. While reading the channel, we disable interrupts from + * host. + * 2. Ensure that we process all posted messages from the host + * before returning from this callback. + * 3. Once we return, enable signaling from the host. Once this + * state is set we check to see if additional packets are + * available to read. In this case we repeat the process. + * + * NOTE: Interrupt has been disabled in the ISR. + */ + for (;;) { + uint32_t left; - if (channel->ch_flags & VMBUS_CHAN_FLAG_BATCHREAD) - is_batched_reading = true; + callback(arg); - if (channel->on_channel_callback != NULL) { - arg = channel->channel_callback_context; - /* - * Optimize host to guest signaling by ensuring: - * 1. While reading the channel, we disable interrupts from - * host. - * 2. Ensure that we process all posted messages from the host - * before returning from this callback. - * 3. Once we return, enable signaling from the host. Once this - * state is set we check to see if additional packets are - * available to read. In this case we repeat the process. - */ - do { - if (is_batched_reading) - hv_ring_buffer_read_begin(&channel->inbound); + left = hv_ring_buffer_read_end(&chan->inbound); + if (left == 0) { + /* No more data in RX bufring; done */ + break; + } + hv_ring_buffer_read_begin(&chan->inbound); + } +} - channel->on_channel_callback(arg); +static void +vmbus_chan_task_nobatch(void *xchan, int pending __unused) +{ + struct hv_vmbus_channel *chan = xchan; - if (is_batched_reading) - bytes_to_read = - hv_ring_buffer_read_end(&channel->inbound); - else - bytes_to_read = 0; - } while (is_batched_reading && (bytes_to_read != 0)); - } + chan->on_channel_callback(chan->channel_callback_context); } static __inline void From owner-svn-src-all@freebsd.org Fri Oct 14 09:10:43 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 60152C11580; Fri, 14 Oct 2016 09:10:43 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 3B3B27CA; Fri, 14 Oct 2016 09:10:43 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9E9Aglj006371; Fri, 14 Oct 2016 09:10:42 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9E9AfZg006362; Fri, 14 Oct 2016 09:10:41 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201610140910.u9E9AfZg006362@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Fri, 14 Oct 2016 09:10:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307310 - in stable/11/sys/dev/hyperv: include vmbus X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Oct 2016 09:10:43 -0000 Author: sephe Date: Fri Oct 14 09:10:41 2016 New Revision: 307310 URL: https://svnweb.freebsd.org/changeset/base/307310 Log: MFC 302723,302726,302731 302723 hyperv: All Hypercall parameters have same alignment requirement. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7086 302726 hyperv: Signal event input parameter is shared w/ MNF Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7087 302731 hyperv/vmbus: Reorganize MNF event sending. Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7088 Modified: stable/11/sys/dev/hyperv/include/hyperv.h stable/11/sys/dev/hyperv/vmbus/hv_channel.c stable/11/sys/dev/hyperv/vmbus/hv_channel_mgmt.c stable/11/sys/dev/hyperv/vmbus/hyperv.c stable/11/sys/dev/hyperv/vmbus/hyperv_reg.h stable/11/sys/dev/hyperv/vmbus/hyperv_var.h stable/11/sys/dev/hyperv/vmbus/vmbus.c stable/11/sys/dev/hyperv/vmbus/vmbus_reg.h stable/11/sys/dev/hyperv/vmbus/vmbus_var.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/hyperv/include/hyperv.h ============================================================================== --- stable/11/sys/dev/hyperv/include/hyperv.h Fri Oct 14 09:00:29 2016 (r307309) +++ stable/11/sys/dev/hyperv/include/hyperv.h Fri Oct 14 09:10:41 2016 (r307310) @@ -523,12 +523,13 @@ typedef struct hv_vmbus_channel { hv_vmbus_channel_state state; uint32_t ch_flags; /* VMBUS_CHAN_FLAG_ */ uint32_t ch_id; /* channel id */ + /* * These are based on the offer_msg.monitor_id. * Save it here for easy access. */ - uint8_t monitor_group; - uint8_t monitor_bit; + int ch_montrig_idx; /* MNF trig index */ + uint32_t ch_montrig_mask;/* MNF trig mask */ uint32_t ring_buffer_gpadl_handle; /* @@ -551,8 +552,8 @@ typedef struct hv_vmbus_channel { hv_vmbus_pfn_channel_callback on_channel_callback; void* channel_callback_context; - struct hypercall_sigevt_in *ch_sigevt; - struct hyperv_dma ch_sigevt_dma; + struct hyperv_mon_param *ch_monprm; + struct hyperv_dma ch_monprm_dma; /* * From Win8, this field specifies the target virtual process Modified: stable/11/sys/dev/hyperv/vmbus/hv_channel.c ============================================================================== --- stable/11/sys/dev/hyperv/vmbus/hv_channel.c Fri Oct 14 09:00:29 2016 (r307309) +++ stable/11/sys/dev/hyperv/vmbus/hv_channel.c Fri Oct 14 09:10:41 2016 (r307310) @@ -50,7 +50,7 @@ __FBSDID("$FreeBSD$"); #include #include -static void vmbus_channel_set_event(hv_vmbus_channel* channel); +static void vmbus_chan_send_event(hv_vmbus_channel* channel); static void vmbus_chan_update_evtflagcnt(struct vmbus_softc *, const struct hv_vmbus_channel *); static void vmbus_chan_task(void *, int); @@ -60,7 +60,7 @@ static void vmbus_chan_task_nobatch(void * @brief Trigger an event notification on the specified channel */ static void -vmbus_channel_set_event(hv_vmbus_channel *channel) +vmbus_chan_send_event(hv_vmbus_channel *channel) { struct vmbus_softc *sc = channel->vmbus_sc; uint32_t chanid = channel->ch_id; @@ -69,16 +69,12 @@ vmbus_channel_set_event(hv_vmbus_channel 1UL << (chanid & VMBUS_EVTFLAG_MASK)); if (channel->ch_flags & VMBUS_CHAN_FLAG_HASMNF) { - hv_vmbus_monitor_page *monitor_page; - - monitor_page = sc->vmbus_mnf2; - synch_set_bit(channel->monitor_bit, - (uint32_t *)&monitor_page-> - trigger_group[channel->monitor_group].u.pending); + atomic_set_int( + &sc->vmbus_mnf2->mnf_trigs[channel->ch_montrig_idx].mt_pending, + channel->ch_montrig_mask); } else { - hypercall_signal_event(channel->ch_sigevt_dma.hv_paddr); + hypercall_signal_event(channel->ch_monprm_dma.hv_paddr); } - } static int @@ -622,9 +618,8 @@ hv_vmbus_channel_send_packet( &need_sig); /* TODO: We should determine if this is optional */ - if (ret == 0 && need_sig) { - vmbus_channel_set_event(channel); - } + if (ret == 0 && need_sig) + vmbus_chan_send_event(channel); return (ret); } @@ -690,9 +685,8 @@ hv_vmbus_channel_send_packet_pagebuffer( &need_sig); /* TODO: We should determine if this is optional */ - if (ret == 0 && need_sig) { - vmbus_channel_set_event(channel); - } + if (ret == 0 && need_sig) + vmbus_chan_send_event(channel); return (ret); } @@ -766,9 +760,8 @@ hv_vmbus_channel_send_packet_multipagebu &need_sig); /* TODO: We should determine if this is optional */ - if (ret == 0 && need_sig) { - vmbus_channel_set_event(channel); - } + if (ret == 0 && need_sig) + vmbus_chan_send_event(channel); return (ret); } Modified: stable/11/sys/dev/hyperv/vmbus/hv_channel_mgmt.c ============================================================================== --- stable/11/sys/dev/hyperv/vmbus/hv_channel_mgmt.c Fri Oct 14 09:00:29 2016 (r307309) +++ stable/11/sys/dev/hyperv/vmbus/hv_channel_mgmt.c Fri Oct 14 09:10:41 2016 (r307310) @@ -296,23 +296,29 @@ vmbus_channel_on_offer_internal(struct v if (offer->monitor_allocated) new_channel->ch_flags |= VMBUS_CHAN_FLAG_HASMNF; - new_channel->ch_sigevt = hyperv_dmamem_alloc( + new_channel->ch_monprm = hyperv_dmamem_alloc( bus_get_dma_tag(sc->vmbus_dev), - HYPERCALL_SIGEVTIN_ALIGN, 0, sizeof(struct hypercall_sigevt_in), - &new_channel->ch_sigevt_dma, BUS_DMA_WAITOK | BUS_DMA_ZERO); - if (new_channel->ch_sigevt == NULL) { - device_printf(sc->vmbus_dev, "sigevt alloc failed\n"); + HYPERCALL_PARAM_ALIGN, 0, sizeof(struct hyperv_mon_param), + &new_channel->ch_monprm_dma, BUS_DMA_WAITOK | BUS_DMA_ZERO); + if (new_channel->ch_monprm == NULL) { + device_printf(sc->vmbus_dev, "monprm alloc failed\n"); /* XXX */ mtx_destroy(&new_channel->sc_lock); free(new_channel, M_DEVBUF); return; } - new_channel->ch_sigevt->hc_connid = VMBUS_CONNID_EVENT; + new_channel->ch_monprm->mp_connid = VMBUS_CONNID_EVENT; if (sc->vmbus_version != VMBUS_VERSION_WS2008) - new_channel->ch_sigevt->hc_connid = offer->connection_id; + new_channel->ch_monprm->mp_connid = offer->connection_id; - new_channel->monitor_group = (uint8_t) offer->monitor_id / 32; - new_channel->monitor_bit = (uint8_t) offer->monitor_id % 32; + if (new_channel->ch_flags & VMBUS_CHAN_FLAG_HASMNF) { + new_channel->ch_montrig_idx = + offer->monitor_id / VMBUS_MONTRIG_LEN; + if (new_channel->ch_montrig_idx >= VMBUS_MONTRIGS_MAX) + panic("invalid monitor id %u", offer->monitor_id); + new_channel->ch_montrig_mask = + 1 << (offer->monitor_id % VMBUS_MONTRIG_LEN); + } /* Select default cpu for this channel. */ vmbus_channel_select_defcpu(new_channel); Modified: stable/11/sys/dev/hyperv/vmbus/hyperv.c ============================================================================== --- stable/11/sys/dev/hyperv/vmbus/hyperv.c Fri Oct 14 09:00:29 2016 (r307309) +++ stable/11/sys/dev/hyperv/vmbus/hyperv.c Fri Oct 14 09:10:41 2016 (r307310) @@ -109,10 +109,10 @@ hypercall_post_message(bus_addr_t msg_pa } uint64_t -hypercall_signal_event(bus_addr_t sigevt_paddr) +hypercall_signal_event(bus_addr_t monprm_paddr) { return hypercall_md(hypercall_context.hc_addr, - HYPERCALL_SIGNAL_EVENT, sigevt_paddr, 0); + HYPERCALL_SIGNAL_EVENT, monprm_paddr, 0); } int Modified: stable/11/sys/dev/hyperv/vmbus/hyperv_reg.h ============================================================================== --- stable/11/sys/dev/hyperv/vmbus/hyperv_reg.h Fri Oct 14 09:00:29 2016 (r307309) +++ stable/11/sys/dev/hyperv/vmbus/hyperv_reg.h Fri Oct 14 09:10:41 2016 (r307310) @@ -133,6 +133,15 @@ #define CPUID_LEAF_HV_HWFEATURES 0x40000006 /* + * Hyper-V Monitor Notification Facility + */ +struct hyperv_mon_param { + uint32_t mp_connid; + uint16_t mp_evtflag_ofs; + uint16_t mp_rsvd; +} __packed; + +/* * Hyper-V message types */ #define HYPERV_MSGTYPE_NONE 0 @@ -153,13 +162,22 @@ /* * Hypercall input parameters */ +#define HYPERCALL_PARAM_ALIGN 8 +#if 0 +/* + * XXX + * <> requires + * input parameters size to be multiple of 8, however, many post + * message input parameters do _not_ meet this requirement. + */ +#define HYPERCALL_PARAM_SIZE_ALIGN 8 +#endif /* * HYPERCALL_POST_MESSAGE */ #define HYPERCALL_POSTMSGIN_DSIZE_MAX 240 #define HYPERCALL_POSTMSGIN_SIZE 256 -#define HYPERCALL_POSTMSGIN_ALIGN 8 struct hypercall_postmsg_in { uint32_t hc_connid; @@ -172,13 +190,8 @@ CTASSERT(sizeof(struct hypercall_postmsg /* * HYPERCALL_SIGNAL_EVENT + * + * struct hyperv_mon_param. */ -#define HYPERCALL_SIGEVTIN_ALIGN 8 - -struct hypercall_sigevt_in { - uint32_t hc_connid; - uint16_t hc_evtflag_ofs; - uint16_t hc_rsvd; -} __packed; #endif /* !_HYPERV_REG_H_ */ Modified: stable/11/sys/dev/hyperv/vmbus/hyperv_var.h ============================================================================== --- stable/11/sys/dev/hyperv/vmbus/hyperv_var.h Fri Oct 14 09:00:29 2016 (r307309) +++ stable/11/sys/dev/hyperv/vmbus/hyperv_var.h Fri Oct 14 09:10:41 2016 (r307310) @@ -39,6 +39,6 @@ extern u_int hyperv_features; extern u_int hyperv_recommends; uint64_t hypercall_post_message(bus_addr_t msg_paddr); -uint64_t hypercall_signal_event(bus_addr_t sigevt_paddr); +uint64_t hypercall_signal_event(bus_addr_t monprm_paddr); #endif /* !_HYPERV_VAR_H_ */ Modified: stable/11/sys/dev/hyperv/vmbus/vmbus.c ============================================================================== --- stable/11/sys/dev/hyperv/vmbus/vmbus.c Fri Oct 14 09:00:29 2016 (r307309) +++ stable/11/sys/dev/hyperv/vmbus/vmbus.c Fri Oct 14 09:10:41 2016 (r307310) @@ -130,7 +130,7 @@ vmbus_msghc_alloc(bus_dma_tag_t parent_d mh = malloc(sizeof(*mh), M_DEVBUF, M_WAITOK | M_ZERO); mh->mh_inprm = hyperv_dmamem_alloc(parent_dtag, - HYPERCALL_POSTMSGIN_ALIGN, 0, HYPERCALL_POSTMSGIN_SIZE, + HYPERCALL_PARAM_ALIGN, 0, HYPERCALL_POSTMSGIN_SIZE, &mh->mh_inprm_dma, BUS_DMA_WAITOK); if (mh->mh_inprm == NULL) { free(mh, M_DEVBUF); @@ -835,7 +835,8 @@ vmbus_dma_alloc(struct vmbus_softc *sc) return ENOMEM; sc->vmbus_mnf2 = hyperv_dmamem_alloc(parent_dtag, PAGE_SIZE, 0, - PAGE_SIZE, &sc->vmbus_mnf2_dma, BUS_DMA_WAITOK | BUS_DMA_ZERO); + sizeof(struct vmbus_mnf), &sc->vmbus_mnf2_dma, + BUS_DMA_WAITOK | BUS_DMA_ZERO); if (sc->vmbus_mnf2 == NULL) return ENOMEM; Modified: stable/11/sys/dev/hyperv/vmbus/vmbus_reg.h ============================================================================== --- stable/11/sys/dev/hyperv/vmbus/vmbus_reg.h Fri Oct 14 09:00:29 2016 (r307309) +++ stable/11/sys/dev/hyperv/vmbus/vmbus_reg.h Fri Oct 14 09:10:41 2016 (r307310) @@ -72,6 +72,34 @@ struct vmbus_evtflags { CTASSERT(sizeof(struct vmbus_evtflags) == VMBUS_EVTFLAGS_SIZE); /* + * Hyper-V Monitor Notification Facility + */ + +struct vmbus_mon_trig { + uint32_t mt_pending; + uint32_t mt_armed; +} __packed; + +#define VMBUS_MONTRIGS_MAX 4 +#define VMBUS_MONTRIG_LEN 32 + +struct vmbus_mnf { + uint32_t mnf_state; + uint32_t mnf_rsvd1; + + struct vmbus_mon_trig mnf_trigs[VMBUS_MONTRIGS_MAX]; + uint8_t mnf_rsvd2[536]; + + uint16_t mnf_lat[VMBUS_MONTRIGS_MAX][VMBUS_MONTRIG_LEN]; + uint8_t mnf_rsvd3[256]; + + struct hyperv_mon_param + mnf_param[VMBUS_MONTRIGS_MAX][VMBUS_MONTRIG_LEN]; + uint8_t mnf_rsvd4[1984]; +} __packed; +CTASSERT(sizeof(struct vmbus_mnf) == PAGE_SIZE); + +/* * Channel */ Modified: stable/11/sys/dev/hyperv/vmbus/vmbus_var.h ============================================================================== --- stable/11/sys/dev/hyperv/vmbus/vmbus_var.h Fri Oct 14 09:00:29 2016 (r307309) +++ stable/11/sys/dev/hyperv/vmbus/vmbus_var.h Fri Oct 14 09:10:41 2016 (r307310) @@ -71,7 +71,7 @@ struct vmbus_softc { void (*vmbus_event_proc)(struct vmbus_softc *, int); u_long *vmbus_tx_evtflags; /* event flags to host */ - void *vmbus_mnf2; /* monitored by host */ + struct vmbus_mnf *vmbus_mnf2; /* monitored by host */ u_long *vmbus_rx_evtflags; /* compat evtflgs from host */ From owner-svn-src-all@freebsd.org Fri Oct 14 09:29:01 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 2743BC11C3E; Fri, 14 Oct 2016 09:29:01 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id E9370373; Fri, 14 Oct 2016 09:29:00 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9E9T0dx012936; Fri, 14 Oct 2016 09:29:00 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9E9T0Ew012935; Fri, 14 Oct 2016 09:29:00 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201610140929.u9E9T0Ew012935@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Fri, 14 Oct 2016 09:29:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307311 - stable/11/lib/libc/gen X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Oct 2016 09:29:01 -0000 Author: kib Date: Fri Oct 14 09:28:59 2016 New Revision: 307311 URL: https://svnweb.freebsd.org/changeset/base/307311 Log: MFC r307036: Fill msg_len for the initial element of msgvec. Modified: stable/11/lib/libc/gen/recvmmsg.c Directory Properties: stable/11/ (props changed) Modified: stable/11/lib/libc/gen/recvmmsg.c ============================================================================== --- stable/11/lib/libc/gen/recvmmsg.c Fri Oct 14 09:10:41 2016 (r307310) +++ stable/11/lib/libc/gen/recvmmsg.c Fri Oct 14 09:28:59 2016 (r307311) @@ -69,6 +69,8 @@ recvmmsg(int s, struct mmsghdr *__restri if (ret == -1) return (ret); + msgvec[0].msg_len = ret; + /* * Do non-blocking receive for second and later messages if * WAITFORONE is set. From owner-svn-src-all@freebsd.org Fri Oct 14 09:34:49 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id F128AC11E14; Fri, 14 Oct 2016 09:34:49 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id B1F67A1A; Fri, 14 Oct 2016 09:34:49 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9E9Ym2c016877; Fri, 14 Oct 2016 09:34:48 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9E9Ymlc016876; Fri, 14 Oct 2016 09:34:48 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201610140934.u9E9Ymlc016876@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Fri, 14 Oct 2016 09:34:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307312 - stable/11/lib/libc/gen X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Oct 2016 09:34:50 -0000 Author: kib Date: Fri Oct 14 09:34:48 2016 New Revision: 307312 URL: https://svnweb.freebsd.org/changeset/base/307312 Log: MFC r307037: Correct indent. Modified: stable/11/lib/libc/gen/recvmmsg.c Directory Properties: stable/11/ (props changed) Modified: stable/11/lib/libc/gen/recvmmsg.c ============================================================================== --- stable/11/lib/libc/gen/recvmmsg.c Fri Oct 14 09:28:59 2016 (r307311) +++ stable/11/lib/libc/gen/recvmmsg.c Fri Oct 14 09:34:48 2016 (r307312) @@ -83,10 +83,9 @@ recvmmsg(int s, struct mmsghdr *__restri ret = __sys_recvmsg(s, &msgvec[i].msg_hdr, flags); if (ret == -1) { /* We have received messages. Let caller know - * about the data received, socket - * error is returned on next - * invocation. - */ + * about the data received, socket error is + * returned on next invocation. + */ return (rcvd); } From owner-svn-src-all@freebsd.org Fri Oct 14 11:41:08 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 35E38C11679; Fri, 14 Oct 2016 11:41:08 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id EB1CFFB3; Fri, 14 Oct 2016 11:41:07 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9EBf7j9062522; Fri, 14 Oct 2016 11:41:07 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9EBf6U3062517; Fri, 14 Oct 2016 11:41:06 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201610141141.u9EBf6U3062517@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Fri, 14 Oct 2016 11:41:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-vendor@freebsd.org Subject: svn commit: r307313 - in vendor-sys/illumos/dist/uts/common/fs/zfs: . sys X-SVN-Group: vendor-sys MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Oct 2016 11:41:08 -0000 Author: mav Date: Fri Oct 14 11:41:06 2016 New Revision: 307313 URL: https://svnweb.freebsd.org/changeset/base/307313 Log: 5120 zfs should allow large block/gzip/raidz boot pool (loader project) Reviewed by: George Wilson Reviewed by: Yuri Pankov Reviewed by: Andrew Stormont Reviewed by: Matthew Ahrens Approved by: Robert Mustacchi Author: Toomas Soome openzfs/openzfs@c8811bd3e2427dddbac6c05a59cfe117d8fea370 Modified: vendor-sys/illumos/dist/uts/common/fs/zfs/spa.c vendor-sys/illumos/dist/uts/common/fs/zfs/sys/zio.h vendor-sys/illumos/dist/uts/common/fs/zfs/vdev.c vendor-sys/illumos/dist/uts/common/fs/zfs/zfs_ioctl.c Modified: vendor-sys/illumos/dist/uts/common/fs/zfs/spa.c ============================================================================== --- vendor-sys/illumos/dist/uts/common/fs/zfs/spa.c Fri Oct 14 09:34:48 2016 (r307312) +++ vendor-sys/illumos/dist/uts/common/fs/zfs/spa.c Fri Oct 14 11:41:06 2016 (r307313) @@ -26,6 +26,7 @@ * Copyright (c) 2014 Spectra Logic Corporation, All rights reserved. * Copyright 2013 Saso Kiselkov. All rights reserved. * Copyright (c) 2014 Integros [integros.com] + * Copyright 2016 Toomas Soome */ /* @@ -519,12 +520,6 @@ spa_prop_validate(spa_t *spa, nvlist_t * &propval)) == 0 && !BOOTFS_COMPRESS_VALID(propval)) { error = SET_ERROR(ENOTSUP); - } else if ((error = - dsl_prop_get_int_ds(dmu_objset_ds(os), - zfs_prop_to_name(ZFS_PROP_RECORDSIZE), - &propval)) == 0 && - propval > SPA_OLD_MAXBLOCKSIZE) { - error = SET_ERROR(ENOTSUP); } else { objnum = dmu_objset_id(os); } Modified: vendor-sys/illumos/dist/uts/common/fs/zfs/sys/zio.h ============================================================================== --- vendor-sys/illumos/dist/uts/common/fs/zfs/sys/zio.h Fri Oct 14 09:34:48 2016 (r307312) +++ vendor-sys/illumos/dist/uts/common/fs/zfs/sys/zio.h Fri Oct 14 11:41:06 2016 (r307313) @@ -25,6 +25,7 @@ * Copyright (c) 2012, 2016 by Delphix. All rights reserved. * Copyright (c) 2013 by Saso Kiselkov. All rights reserved. * Copyright (c) 2013, Joyent, Inc. All rights reserved. + * Copyright 2016 Toomas Soome */ #ifndef _ZIO_H @@ -141,6 +142,15 @@ enum zio_compress { #define BOOTFS_COMPRESS_VALID(compress) \ ((compress) == ZIO_COMPRESS_LZJB || \ (compress) == ZIO_COMPRESS_LZ4 || \ + (compress) == ZIO_COMPRESS_GZIP_1 || \ + (compress) == ZIO_COMPRESS_GZIP_2 || \ + (compress) == ZIO_COMPRESS_GZIP_3 || \ + (compress) == ZIO_COMPRESS_GZIP_4 || \ + (compress) == ZIO_COMPRESS_GZIP_5 || \ + (compress) == ZIO_COMPRESS_GZIP_6 || \ + (compress) == ZIO_COMPRESS_GZIP_7 || \ + (compress) == ZIO_COMPRESS_GZIP_8 || \ + (compress) == ZIO_COMPRESS_GZIP_9 || \ (compress) == ZIO_COMPRESS_ON || \ (compress) == ZIO_COMPRESS_OFF) Modified: vendor-sys/illumos/dist/uts/common/fs/zfs/vdev.c ============================================================================== --- vendor-sys/illumos/dist/uts/common/fs/zfs/vdev.c Fri Oct 14 09:34:48 2016 (r307312) +++ vendor-sys/illumos/dist/uts/common/fs/zfs/vdev.c Fri Oct 14 11:41:06 2016 (r307313) @@ -24,6 +24,7 @@ * Copyright (c) 2011, 2015 by Delphix. All rights reserved. * Copyright 2015 Nexenta Systems, Inc. All rights reserved. * Copyright (c) 2014 Integros [integros.com] + * Copyright 2016 Toomas Soome */ #include @@ -3319,9 +3320,8 @@ vdev_set_state(vdev_t *vd, boolean_t iso /* * Check the vdev configuration to ensure that it's capable of supporting - * a root pool. Currently, we do not support RAID-Z or partial configuration. - * In addition, only a single top-level vdev is allowed and none of the leaves - * can be wholedisks. + * a root pool. We do not support partial configuration. + * In addition, only a single top-level vdev is allowed. */ boolean_t vdev_is_bootable(vdev_t *vd) @@ -3332,8 +3332,7 @@ vdev_is_bootable(vdev_t *vd) if (strcmp(vdev_type, VDEV_TYPE_ROOT) == 0 && vd->vdev_children > 1) { return (B_FALSE); - } else if (strcmp(vdev_type, VDEV_TYPE_RAIDZ) == 0 || - strcmp(vdev_type, VDEV_TYPE_MISSING) == 0) { + } else if (strcmp(vdev_type, VDEV_TYPE_MISSING) == 0) { return (B_FALSE); } } Modified: vendor-sys/illumos/dist/uts/common/fs/zfs/zfs_ioctl.c ============================================================================== --- vendor-sys/illumos/dist/uts/common/fs/zfs/zfs_ioctl.c Fri Oct 14 09:34:48 2016 (r307312) +++ vendor-sys/illumos/dist/uts/common/fs/zfs/zfs_ioctl.c Fri Oct 14 11:41:06 2016 (r307313) @@ -30,6 +30,7 @@ * Copyright (c) 2013 by Saso Kiselkov. All rights reserved. * Copyright (c) 2013 Steven Hartland. All rights reserved. * Copyright (c) 2014 Integros [integros.com] + * Copyright 2016 Toomas Soome */ /* @@ -3837,16 +3838,6 @@ zfs_check_settable(const char *dsname, n spa_t *spa; /* - * If this is a bootable dataset then - * the we don't allow large (>128K) blocks, - * because GRUB doesn't support them. - */ - if (zfs_is_bootfs(dsname) && - intval > SPA_OLD_MAXBLOCKSIZE) { - return (SET_ERROR(ERANGE)); - } - - /* * We don't allow setting the property above 1MB, * unless the tunable has been changed. */ From owner-svn-src-all@freebsd.org Fri Oct 14 11:46:18 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A7563C118AB; Fri, 14 Oct 2016 11:46:18 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 824F861C; Fri, 14 Oct 2016 11:46:18 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9EBkHic066054; Fri, 14 Oct 2016 11:46:17 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9EBkHMF066053; Fri, 14 Oct 2016 11:46:17 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201610141146.u9EBkHMF066053@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Fri, 14 Oct 2016 11:46:17 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-vendor@freebsd.org Subject: svn commit: r307314 - vendor-sys/illumos/dist/uts/common/fs/zfs X-SVN-Group: vendor-sys MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Oct 2016 11:46:18 -0000 Author: mav Date: Fri Oct 14 11:46:17 2016 New Revision: 307314 URL: https://svnweb.freebsd.org/changeset/base/307314 Log: 6988 spa_sync() spends half its time in dmu_objset_do_userquota_updates Using a benchmark which creates 2 million files in one TXG, I observe that the thread running spa_sync() is on CPU almost the entire time we are syncing, and therefore can be a performance bottleneck. About 50% of the time in spa_sync() is in dmu_objset_do_userquota_updates(). The problem is that dmu_objset_do_userquota_updates() calls zap_increment_int(DMU_USERUSED_OBJECT) once for every file that was modified (or created). In this benchmark, all the files are owned by the same user/group, so all 2 million calls to zap_increment_int() are modifying the same entry in the zap. The same issue exists for the DMU_GROUPUSED_OBJECT. We should keep an in-memory map from user to space delta while we are syncing, and when we finish, iterate over the in-memory map and modify the ZAP once per entry. This reduces the number of calls to zap_increment_int() from "number of objects modified" to "number of owners/groups of modified files". This reduced the time spent in spa_sync() in the file create benchmark by ~33%, from 11 seconds to 7 seconds. Closes #107 Reviewed by: George Wilson Reviewed by: Steve Gonczi Reviewed by: Ned Bass Reviewed by: Jinshan Xiong Author: Matthew Ahrens openzfs/openzfs@5fc46359c569369d87728ca09f8705cdff6cc8e2 Modified: vendor-sys/illumos/dist/uts/common/fs/zfs/dmu_objset.c Modified: vendor-sys/illumos/dist/uts/common/fs/zfs/dmu_objset.c ============================================================================== --- vendor-sys/illumos/dist/uts/common/fs/zfs/dmu_objset.c Fri Oct 14 11:41:06 2016 (r307313) +++ vendor-sys/illumos/dist/uts/common/fs/zfs/dmu_objset.c Fri Oct 14 11:46:17 2016 (r307314) @@ -1207,18 +1207,83 @@ dmu_objset_userused_enabled(objset_t *os DMU_USERUSED_DNODE(os) != NULL); } +typedef struct userquota_node { + uint64_t uqn_id; + int64_t uqn_delta; + avl_node_t uqn_node; +} userquota_node_t; + +typedef struct userquota_cache { + avl_tree_t uqc_user_deltas; + avl_tree_t uqc_group_deltas; +} userquota_cache_t; + +static int +userquota_compare(const void *l, const void *r) +{ + const userquota_node_t *luqn = l; + const userquota_node_t *ruqn = r; + + if (luqn->uqn_id < ruqn->uqn_id) + return (-1); + if (luqn->uqn_id > ruqn->uqn_id) + return (1); + return (0); +} + static void -do_userquota_update(objset_t *os, uint64_t used, uint64_t flags, - uint64_t user, uint64_t group, boolean_t subtract, dmu_tx_t *tx) +do_userquota_cacheflush(objset_t *os, userquota_cache_t *cache, dmu_tx_t *tx) +{ + void *cookie; + userquota_node_t *uqn; + + ASSERT(dmu_tx_is_syncing(tx)); + + cookie = NULL; + while ((uqn = avl_destroy_nodes(&cache->uqc_user_deltas, + &cookie)) != NULL) { + VERIFY0(zap_increment_int(os, DMU_USERUSED_OBJECT, + uqn->uqn_id, uqn->uqn_delta, tx)); + kmem_free(uqn, sizeof (*uqn)); + } + avl_destroy(&cache->uqc_user_deltas); + + cookie = NULL; + while ((uqn = avl_destroy_nodes(&cache->uqc_group_deltas, + &cookie)) != NULL) { + VERIFY0(zap_increment_int(os, DMU_GROUPUSED_OBJECT, + uqn->uqn_id, uqn->uqn_delta, tx)); + kmem_free(uqn, sizeof (*uqn)); + } + avl_destroy(&cache->uqc_group_deltas); +} + +static void +userquota_update_cache(avl_tree_t *avl, uint64_t id, int64_t delta) +{ + userquota_node_t search = { .uqn_id = id }; + avl_index_t idx; + + userquota_node_t *uqn = avl_find(avl, &search, &idx); + if (uqn == NULL) { + uqn = kmem_zalloc(sizeof (*uqn), KM_SLEEP); + uqn->uqn_id = id; + avl_insert(avl, uqn, idx); + } + uqn->uqn_delta += delta; +} + +static void +do_userquota_update(userquota_cache_t *cache, uint64_t used, uint64_t flags, + uint64_t user, uint64_t group, boolean_t subtract) { if ((flags & DNODE_FLAG_USERUSED_ACCOUNTED)) { int64_t delta = DNODE_SIZE + used; if (subtract) delta = -delta; - VERIFY3U(0, ==, zap_increment_int(os, DMU_USERUSED_OBJECT, - user, delta, tx)); - VERIFY3U(0, ==, zap_increment_int(os, DMU_GROUPUSED_OBJECT, - group, delta, tx)); + + userquota_update_cache(&cache->uqc_user_deltas, user, delta); + userquota_update_cache(&cache->uqc_group_deltas, group, delta); } } @@ -1227,9 +1292,15 @@ dmu_objset_do_userquota_updates(objset_t { dnode_t *dn; list_t *list = &os->os_synced_dnodes; + userquota_cache_t cache = { 0 }; ASSERT(list_head(list) == NULL || dmu_objset_userused_enabled(os)); + avl_create(&cache.uqc_user_deltas, userquota_compare, + sizeof (userquota_node_t), offsetof(userquota_node_t, uqn_node)); + avl_create(&cache.uqc_group_deltas, userquota_compare, + sizeof (userquota_node_t), offsetof(userquota_node_t, uqn_node)); + while (dn = list_head(list)) { int flags; ASSERT(!DMU_OBJECT_IS_SPECIAL(dn->dn_object)); @@ -1239,32 +1310,26 @@ dmu_objset_do_userquota_updates(objset_t /* Allocate the user/groupused objects if necessary. */ if (DMU_USERUSED_DNODE(os)->dn_type == DMU_OT_NONE) { - VERIFY(0 == zap_create_claim(os, + VERIFY0(zap_create_claim(os, DMU_USERUSED_OBJECT, DMU_OT_USERGROUP_USED, DMU_OT_NONE, 0, tx)); - VERIFY(0 == zap_create_claim(os, + VERIFY0(zap_create_claim(os, DMU_GROUPUSED_OBJECT, DMU_OT_USERGROUP_USED, DMU_OT_NONE, 0, tx)); } - /* - * We intentionally modify the zap object even if the - * net delta is zero. Otherwise - * the block of the zap obj could be shared between - * datasets but need to be different between them after - * a bprewrite. - */ - flags = dn->dn_id_flags; ASSERT(flags); if (flags & DN_ID_OLD_EXIST) { - do_userquota_update(os, dn->dn_oldused, dn->dn_oldflags, - dn->dn_olduid, dn->dn_oldgid, B_TRUE, tx); + do_userquota_update(&cache, + dn->dn_oldused, dn->dn_oldflags, + dn->dn_olduid, dn->dn_oldgid, B_TRUE); } if (flags & DN_ID_NEW_EXIST) { - do_userquota_update(os, DN_USED_BYTES(dn->dn_phys), + do_userquota_update(&cache, + DN_USED_BYTES(dn->dn_phys), dn->dn_phys->dn_flags, dn->dn_newuid, - dn->dn_newgid, B_FALSE, tx); + dn->dn_newgid, B_FALSE); } mutex_enter(&dn->dn_mtx); @@ -1285,6 +1350,7 @@ dmu_objset_do_userquota_updates(objset_t list_remove(list, dn); dnode_rele(dn, list); } + do_userquota_cacheflush(os, &cache, tx); } /* From owner-svn-src-all@freebsd.org Fri Oct 14 11:49:38 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 426DAC11957; Fri, 14 Oct 2016 11:49:38 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id EC79D81B; Fri, 14 Oct 2016 11:49:37 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9EBnbDk066216; Fri, 14 Oct 2016 11:49:37 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9EBnaHr066212; Fri, 14 Oct 2016 11:49:36 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201610141149.u9EBnaHr066212@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Fri, 14 Oct 2016 11:49:36 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-vendor@freebsd.org Subject: svn commit: r307315 - in vendor-sys/illumos/dist/uts/common/fs/zfs: . sys X-SVN-Group: vendor-sys MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Oct 2016 11:49:38 -0000 Author: mav Date: Fri Oct 14 11:49:36 2016 New Revision: 307315 URL: https://svnweb.freebsd.org/changeset/base/307315 Log: 7301 zpool export -f should be able to interrupt file freeing Reviewed by: Matthew Ahrens Reviewed by: Sanjay Nadkarni Reviewed by: Saso Kiselkov Reviewed by: John Kennedy Author: Alek Pinchuk Closes #175 Modified: vendor-sys/illumos/dist/uts/common/fs/zfs/dmu.c vendor-sys/illumos/dist/uts/common/fs/zfs/sys/zfs_znode.h vendor-sys/illumos/dist/uts/common/fs/zfs/zfs_dir.c vendor-sys/illumos/dist/uts/common/fs/zfs/zfs_vfsops.c Modified: vendor-sys/illumos/dist/uts/common/fs/zfs/dmu.c ============================================================================== --- vendor-sys/illumos/dist/uts/common/fs/zfs/dmu.c Fri Oct 14 11:46:17 2016 (r307314) +++ vendor-sys/illumos/dist/uts/common/fs/zfs/dmu.c Fri Oct 14 11:49:36 2016 (r307315) @@ -24,7 +24,7 @@ */ /* Copyright (c) 2013 by Saso Kiselkov. All rights reserved. */ /* Copyright (c) 2013, Joyent, Inc. All rights reserved. */ -/* Copyright (c) 2014, Nexenta Systems, Inc. All rights reserved. */ +/* Copyright 2016 Nexenta Systems, Inc. All rights reserved. */ #include #include @@ -695,6 +695,22 @@ get_next_chunk(dnode_t *dn, uint64_t *st return (0); } +/* + * If this objset is of type OST_ZFS return true if vfs's unmounted flag is set, + * otherwise return false. + * Used below in dmu_free_long_range_impl() to enable abort when unmounting + */ +/*ARGSUSED*/ +static boolean_t +dmu_objset_zfs_unmounting(objset_t *os) +{ +#ifdef _KERNEL + if (dmu_objset_type(os) == DMU_OST_ZFS) + return (zfs_get_vfs_flag_unmounted(os)); +#endif + return (B_FALSE); +} + static int dmu_free_long_range_impl(objset_t *os, dnode_t *dn, uint64_t offset, uint64_t length) @@ -711,6 +727,9 @@ dmu_free_long_range_impl(objset_t *os, d while (length != 0) { uint64_t chunk_end, chunk_begin; + if (dmu_objset_zfs_unmounting(dn->dn_objset)) + return (SET_ERROR(EINTR)); + chunk_end = chunk_begin = offset + length; /* move chunk_begin backwards to the beginning of this chunk */ Modified: vendor-sys/illumos/dist/uts/common/fs/zfs/sys/zfs_znode.h ============================================================================== --- vendor-sys/illumos/dist/uts/common/fs/zfs/sys/zfs_znode.h Fri Oct 14 11:46:17 2016 (r307314) +++ vendor-sys/illumos/dist/uts/common/fs/zfs/sys/zfs_znode.h Fri Oct 14 11:49:36 2016 (r307315) @@ -22,6 +22,7 @@ * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2012, 2015 by Delphix. All rights reserved. * Copyright (c) 2014 Integros [integros.com] + * Copyright 2016 Nexenta Systems, Inc. All rights reserved. */ #ifndef _SYS_FS_ZFS_ZNODE_H @@ -302,6 +303,7 @@ extern int zfs_sync(vfs_t *vfsp, short f extern dev_t zfs_cmpldev(uint64_t); extern int zfs_get_zplprop(objset_t *os, zfs_prop_t prop, uint64_t *value); extern int zfs_get_stats(objset_t *os, nvlist_t *nv); +extern boolean_t zfs_get_vfs_flag_unmounted(objset_t *os); extern void zfs_znode_dmu_fini(znode_t *); extern void zfs_log_create(zilog_t *zilog, dmu_tx_t *tx, uint64_t txtype, Modified: vendor-sys/illumos/dist/uts/common/fs/zfs/zfs_dir.c ============================================================================== --- vendor-sys/illumos/dist/uts/common/fs/zfs/zfs_dir.c Fri Oct 14 11:46:17 2016 (r307314) +++ vendor-sys/illumos/dist/uts/common/fs/zfs/zfs_dir.c Fri Oct 14 11:49:36 2016 (r307315) @@ -618,8 +618,8 @@ zfs_rmnode(znode_t *zp) error = dmu_free_long_range(os, zp->z_id, 0, DMU_OBJECT_END); if (error) { /* - * Not enough space. Leave the file in the unlinked - * set. + * Not enough space or we were interrupted by unmount. + * Leave the file in the unlinked set. */ zfs_znode_dmu_fini(zp); zfs_znode_free(zp); Modified: vendor-sys/illumos/dist/uts/common/fs/zfs/zfs_vfsops.c ============================================================================== --- vendor-sys/illumos/dist/uts/common/fs/zfs/zfs_vfsops.c Fri Oct 14 11:46:17 2016 (r307314) +++ vendor-sys/illumos/dist/uts/common/fs/zfs/zfs_vfsops.c Fri Oct 14 11:49:36 2016 (r307315) @@ -22,6 +22,7 @@ * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2012, 2015 by Delphix. All rights reserved. * Copyright (c) 2014 Integros [integros.com] + * Copyright 2016 Nexenta Systems, Inc. All rights reserved. */ /* Portions Copyright 2010 Robert Milkowski */ @@ -1728,7 +1729,7 @@ zfs_root(vfs_t *vfsp, vnode_t **vpp) /* * Teardown the zfsvfs::z_os. * - * Note, if 'unmounting' if FALSE, we return with the 'z_teardown_lock' + * Note, if 'unmounting' is FALSE, we return with the 'z_teardown_lock' * and 'z_teardown_inactive_lock' held. */ static int @@ -1793,8 +1794,8 @@ zfsvfs_teardown(zfsvfs_t *zfsvfs, boolea */ if (unmounting) { zfsvfs->z_unmounted = B_TRUE; - rrm_exit(&zfsvfs->z_teardown_lock, FTAG); rw_exit(&zfsvfs->z_teardown_inactive_lock); + rrm_exit(&zfsvfs->z_teardown_lock, FTAG); } /* @@ -2272,6 +2273,29 @@ zfs_get_zplprop(objset_t *os, zfs_prop_t return (error); } +/* + * Return true if the coresponding vfs's unmounted flag is set. + * Otherwise return false. + * If this function returns true we know VFS unmount has been initiated. + */ +boolean_t +zfs_get_vfs_flag_unmounted(objset_t *os) +{ + zfsvfs_t *zfvp; + boolean_t unmounted = B_FALSE; + + ASSERT(dmu_objset_type(os) == DMU_OST_ZFS); + + mutex_enter(&os->os_user_ptr_lock); + zfvp = dmu_objset_get_user(os); + if (zfvp != NULL && zfvp->z_vfs != NULL && + (zfvp->z_vfs->vfs_flag & VFS_UNMOUNTED)) + unmounted = B_TRUE; + mutex_exit(&os->os_user_ptr_lock); + + return (unmounted); +} + static vfsdef_t vfw = { VFSDEF_VERSION, MNTTYPE_ZFS, From owner-svn-src-all@freebsd.org Fri Oct 14 11:57:10 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 15233C11B67; Fri, 14 Oct 2016 11:57:10 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id DB1C1D3C; Fri, 14 Oct 2016 11:57:09 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9EBv9lN070070; Fri, 14 Oct 2016 11:57:09 GMT (envelope-from bapt@FreeBSD.org) Received: (from bapt@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9EBv9xf070069; Fri, 14 Oct 2016 11:57:09 GMT (envelope-from bapt@FreeBSD.org) Message-Id: <201610141157.u9EBv9xf070069@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bapt set sender to bapt@FreeBSD.org using -f From: Baptiste Daroussin Date: Fri, 14 Oct 2016 11:57:09 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307316 - head/sys/boot/userboot/userboot X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Oct 2016 11:57:10 -0000 Author: bapt Date: Fri Oct 14 11:57:08 2016 New Revision: 307316 URL: https://svnweb.freebsd.org/changeset/base/307316 Log: Fix build WITHOUT_FORTH MFC after: 1 week Sponsored by: Gandi.net Modified: head/sys/boot/userboot/userboot/Makefile Modified: head/sys/boot/userboot/userboot/Makefile ============================================================================== --- head/sys/boot/userboot/userboot/Makefile Fri Oct 14 11:49:36 2016 (r307315) +++ head/sys/boot/userboot/userboot/Makefile Fri Oct 14 11:57:08 2016 (r307316) @@ -51,9 +51,10 @@ BOOT_FORTH= yes CFLAGS+= -DBOOT_FORTH -I${.CURDIR}/../../ficl -I${.CURDIR}/../../ficl/i386 CFLAGS+= -DBF_DICTSIZE=15000 LIBFICL= ${.OBJDIR}/../ficl/libficl.a -LIBSTAND= ${.OBJDIR}/../libstand/libstand.a .endif +LIBSTAND= ${.OBJDIR}/../libstand/libstand.a + .if ${MK_ZFS} != "no" CFLAGS+= -DUSERBOOT_ZFS_SUPPORT LIBZFSBOOT= ${.OBJDIR}/../zfs/libzfsboot.a From owner-svn-src-all@freebsd.org Fri Oct 14 12:01:34 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id EF749C10311; Fri, 14 Oct 2016 12:01:34 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id AF1746B3; Fri, 14 Oct 2016 12:01:34 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9EC1XRM073186; Fri, 14 Oct 2016 12:01:33 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9EC1X2O073182; Fri, 14 Oct 2016 12:01:33 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201610141201.u9EC1X2O073182@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Fri, 14 Oct 2016 12:01:33 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307317 - in head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs: . sys X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Oct 2016 12:01:35 -0000 Author: mav Date: Fri Oct 14 12:01:33 2016 New Revision: 307317 URL: https://svnweb.freebsd.org/changeset/base/307317 Log: MFV r307313: 5120 zfs should allow large block/gzip/raidz boot pool (loader project) Reviewed by: George Wilson Reviewed by: Yuri Pankov Reviewed by: Andrew Stormont Reviewed by: Matthew Ahrens Approved by: Robert Mustacchi Author: Toomas Soome openzfs/openzfs@c8811bd3e2427dddbac6c05a59cfe117d8fea370 FreeBSD still does not support booting from gzip-compressed datasets, so keep one chunk of this commit out. Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zio.h head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev.c head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c Directory Properties: head/sys/cddl/contrib/opensolaris/ (props changed) Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c ============================================================================== --- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c Fri Oct 14 11:57:08 2016 (r307316) +++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c Fri Oct 14 12:01:33 2016 (r307317) @@ -27,6 +27,7 @@ * Copyright (c) 2014 Spectra Logic Corporation, All rights reserved. * Copyright 2013 Saso Kiselkov. All rights reserved. * Copyright (c) 2014 Integros [integros.com] + * Copyright 2016 Toomas Soome */ /* @@ -539,12 +540,6 @@ spa_prop_validate(spa_t *spa, nvlist_t * &propval)) == 0 && !BOOTFS_COMPRESS_VALID(propval)) { error = SET_ERROR(ENOTSUP); - } else if ((error = - dsl_prop_get_int_ds(dmu_objset_ds(os), - zfs_prop_to_name(ZFS_PROP_RECORDSIZE), - &propval)) == 0 && - propval > SPA_OLD_MAXBLOCKSIZE) { - error = SET_ERROR(ENOTSUP); } else { objnum = dmu_objset_id(os); } Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zio.h ============================================================================== --- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zio.h Fri Oct 14 11:57:08 2016 (r307316) +++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zio.h Fri Oct 14 12:01:33 2016 (r307317) @@ -24,6 +24,7 @@ * Copyright 2011 Nexenta Systems, Inc. All rights reserved. * Copyright (c) 2012, 2016 by Delphix. All rights reserved. * Copyright (c) 2013 by Saso Kiselkov. All rights reserved. + * Copyright 2016 Toomas Soome */ #ifndef _ZIO_H Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev.c ============================================================================== --- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev.c Fri Oct 14 11:57:08 2016 (r307316) +++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev.c Fri Oct 14 12:01:33 2016 (r307317) @@ -25,6 +25,7 @@ * Copyright 2015 Nexenta Systems, Inc. All rights reserved. * Copyright 2013 Martin Matuska . All rights reserved. * Copyright (c) 2014 Integros [integros.com] + * Copyright 2016 Toomas Soome */ #include @@ -3474,16 +3475,10 @@ vdev_set_state(vdev_t *vd, boolean_t iso /* * Check the vdev configuration to ensure that it's capable of supporting - * a root pool. + * a root pool. We do not support partial configuration. + * In addition, only a single top-level vdev is allowed. * - * On Solaris, we do not support RAID-Z or partial configuration. In - * addition, only a single top-level vdev is allowed and none of the - * leaves can be wholedisks. - * - * For FreeBSD, we can boot from any configuration. There is a - * limitation that the boot filesystem must be either uncompressed or - * compresses with lzjb compression but I'm not sure how to enforce - * that here. + * FreeBSD does not have above limitations. */ boolean_t vdev_is_bootable(vdev_t *vd) @@ -3495,8 +3490,7 @@ vdev_is_bootable(vdev_t *vd) if (strcmp(vdev_type, VDEV_TYPE_ROOT) == 0 && vd->vdev_children > 1) { return (B_FALSE); - } else if (strcmp(vdev_type, VDEV_TYPE_RAIDZ) == 0 || - strcmp(vdev_type, VDEV_TYPE_MISSING) == 0) { + } else if (strcmp(vdev_type, VDEV_TYPE_MISSING) == 0) { return (B_FALSE); } } Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c ============================================================================== --- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c Fri Oct 14 11:57:08 2016 (r307316) +++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c Fri Oct 14 12:01:33 2016 (r307317) @@ -31,6 +31,7 @@ * Copyright (c) 2013 by Saso Kiselkov. All rights reserved. * Copyright (c) 2013 Steven Hartland. All rights reserved. * Copyright (c) 2014 Integros [integros.com] + * Copyright 2016 Toomas Soome */ /* @@ -3945,16 +3946,6 @@ zfs_check_settable(const char *dsname, n spa_t *spa; /* - * If this is a bootable dataset then - * the we don't allow large (>128K) blocks, - * because GRUB doesn't support them. - */ - if (zfs_is_bootfs(dsname) && - intval > SPA_OLD_MAXBLOCKSIZE) { - return (SET_ERROR(ERANGE)); - } - - /* * We don't allow setting the property above 1MB, * unless the tunable has been changed. */ From owner-svn-src-all@freebsd.org Fri Oct 14 12:03:05 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 74CE4C105B9; Fri, 14 Oct 2016 12:03:05 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4C13EB16; Fri, 14 Oct 2016 12:03:05 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9EC34CB074057; Fri, 14 Oct 2016 12:03:04 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9EC34mk074056; Fri, 14 Oct 2016 12:03:04 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201610141203.u9EC34mk074056@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Fri, 14 Oct 2016 12:03:04 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307318 - head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Oct 2016 12:03:05 -0000 Author: mav Date: Fri Oct 14 12:03:04 2016 New Revision: 307318 URL: https://svnweb.freebsd.org/changeset/base/307318 Log: MFV r307314: 6988 spa_sync() spends half its time in dmu_objset_do_userquota_updates Using a benchmark which creates 2 million files in one TXG, I observe that the thread running spa_sync() is on CPU almost the entire time we are syncing, and therefore can be a performance bottleneck. About 50% of the time in spa_sync() is in dmu_objset_do_userquota_updates(). The problem is that dmu_objset_do_userquota_updates() calls zap_increment_int(DMU_USERUSED_OBJECT) once for every file that was modified (or created). In this benchmark, all the files are owned by the same user/group, so all 2 million calls to zap_increment_int() are modifying the same entry in the zap. The same issue exists for the DMU_GROUPUSED_OBJECT. We should keep an in-memory map from user to space delta while we are syncing, and when we finish, iterate over the in-memory map and modify the ZAP once per entry. This reduces the number of calls to zap_increment_int() from "number of objects modified" to "number of owners/groups of modified files". This reduced the time spent in spa_sync() in the file create benchmark by ~33%, from 11 seconds to 7 seconds. Closes #107 Reviewed by: George Wilson Reviewed by: Steve Gonczi Reviewed by: Ned Bass Reviewed by: Jinshan Xiong Author: Matthew Ahrens openzfs/openzfs@5fc46359c569369d87728ca09f8705cdff6cc8e2 Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_objset.c Directory Properties: head/sys/cddl/contrib/opensolaris/ (props changed) Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_objset.c ============================================================================== --- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_objset.c Fri Oct 14 12:01:33 2016 (r307317) +++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_objset.c Fri Oct 14 12:03:04 2016 (r307318) @@ -1207,18 +1207,83 @@ dmu_objset_userused_enabled(objset_t *os DMU_USERUSED_DNODE(os) != NULL); } +typedef struct userquota_node { + uint64_t uqn_id; + int64_t uqn_delta; + avl_node_t uqn_node; +} userquota_node_t; + +typedef struct userquota_cache { + avl_tree_t uqc_user_deltas; + avl_tree_t uqc_group_deltas; +} userquota_cache_t; + +static int +userquota_compare(const void *l, const void *r) +{ + const userquota_node_t *luqn = l; + const userquota_node_t *ruqn = r; + + if (luqn->uqn_id < ruqn->uqn_id) + return (-1); + if (luqn->uqn_id > ruqn->uqn_id) + return (1); + return (0); +} + static void -do_userquota_update(objset_t *os, uint64_t used, uint64_t flags, - uint64_t user, uint64_t group, boolean_t subtract, dmu_tx_t *tx) +do_userquota_cacheflush(objset_t *os, userquota_cache_t *cache, dmu_tx_t *tx) +{ + void *cookie; + userquota_node_t *uqn; + + ASSERT(dmu_tx_is_syncing(tx)); + + cookie = NULL; + while ((uqn = avl_destroy_nodes(&cache->uqc_user_deltas, + &cookie)) != NULL) { + VERIFY0(zap_increment_int(os, DMU_USERUSED_OBJECT, + uqn->uqn_id, uqn->uqn_delta, tx)); + kmem_free(uqn, sizeof (*uqn)); + } + avl_destroy(&cache->uqc_user_deltas); + + cookie = NULL; + while ((uqn = avl_destroy_nodes(&cache->uqc_group_deltas, + &cookie)) != NULL) { + VERIFY0(zap_increment_int(os, DMU_GROUPUSED_OBJECT, + uqn->uqn_id, uqn->uqn_delta, tx)); + kmem_free(uqn, sizeof (*uqn)); + } + avl_destroy(&cache->uqc_group_deltas); +} + +static void +userquota_update_cache(avl_tree_t *avl, uint64_t id, int64_t delta) +{ + userquota_node_t search = { .uqn_id = id }; + avl_index_t idx; + + userquota_node_t *uqn = avl_find(avl, &search, &idx); + if (uqn == NULL) { + uqn = kmem_zalloc(sizeof (*uqn), KM_SLEEP); + uqn->uqn_id = id; + avl_insert(avl, uqn, idx); + } + uqn->uqn_delta += delta; +} + +static void +do_userquota_update(userquota_cache_t *cache, uint64_t used, uint64_t flags, + uint64_t user, uint64_t group, boolean_t subtract) { if ((flags & DNODE_FLAG_USERUSED_ACCOUNTED)) { int64_t delta = DNODE_SIZE + used; if (subtract) delta = -delta; - VERIFY3U(0, ==, zap_increment_int(os, DMU_USERUSED_OBJECT, - user, delta, tx)); - VERIFY3U(0, ==, zap_increment_int(os, DMU_GROUPUSED_OBJECT, - group, delta, tx)); + + userquota_update_cache(&cache->uqc_user_deltas, user, delta); + userquota_update_cache(&cache->uqc_group_deltas, group, delta); } } @@ -1227,9 +1292,15 @@ dmu_objset_do_userquota_updates(objset_t { dnode_t *dn; list_t *list = &os->os_synced_dnodes; + userquota_cache_t cache = { 0 }; ASSERT(list_head(list) == NULL || dmu_objset_userused_enabled(os)); + avl_create(&cache.uqc_user_deltas, userquota_compare, + sizeof (userquota_node_t), offsetof(userquota_node_t, uqn_node)); + avl_create(&cache.uqc_group_deltas, userquota_compare, + sizeof (userquota_node_t), offsetof(userquota_node_t, uqn_node)); + while (dn = list_head(list)) { int flags; ASSERT(!DMU_OBJECT_IS_SPECIAL(dn->dn_object)); @@ -1239,32 +1310,26 @@ dmu_objset_do_userquota_updates(objset_t /* Allocate the user/groupused objects if necessary. */ if (DMU_USERUSED_DNODE(os)->dn_type == DMU_OT_NONE) { - VERIFY(0 == zap_create_claim(os, + VERIFY0(zap_create_claim(os, DMU_USERUSED_OBJECT, DMU_OT_USERGROUP_USED, DMU_OT_NONE, 0, tx)); - VERIFY(0 == zap_create_claim(os, + VERIFY0(zap_create_claim(os, DMU_GROUPUSED_OBJECT, DMU_OT_USERGROUP_USED, DMU_OT_NONE, 0, tx)); } - /* - * We intentionally modify the zap object even if the - * net delta is zero. Otherwise - * the block of the zap obj could be shared between - * datasets but need to be different between them after - * a bprewrite. - */ - flags = dn->dn_id_flags; ASSERT(flags); if (flags & DN_ID_OLD_EXIST) { - do_userquota_update(os, dn->dn_oldused, dn->dn_oldflags, - dn->dn_olduid, dn->dn_oldgid, B_TRUE, tx); + do_userquota_update(&cache, + dn->dn_oldused, dn->dn_oldflags, + dn->dn_olduid, dn->dn_oldgid, B_TRUE); } if (flags & DN_ID_NEW_EXIST) { - do_userquota_update(os, DN_USED_BYTES(dn->dn_phys), + do_userquota_update(&cache, + DN_USED_BYTES(dn->dn_phys), dn->dn_phys->dn_flags, dn->dn_newuid, - dn->dn_newgid, B_FALSE, tx); + dn->dn_newgid, B_FALSE); } mutex_enter(&dn->dn_mtx); @@ -1285,6 +1350,7 @@ dmu_objset_do_userquota_updates(objset_t list_remove(list, dn); dnode_rele(dn, list); } + do_userquota_cacheflush(os, &cache, tx); } /* From owner-svn-src-all@freebsd.org Fri Oct 14 12:12:52 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 6DE74C109D6; Fri, 14 Oct 2016 12:12:52 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from citapm.icyb.net.ua (citapm.icyb.net.ua [212.40.38.140]) by mx1.freebsd.org (Postfix) with ESMTP id E8FB42FB; Fri, 14 Oct 2016 12:12:50 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from porto.starpoint.kiev.ua (porto-e.starpoint.kiev.ua [212.40.38.100]) by citapm.icyb.net.ua (8.8.8p3/ICyb-2.3exp) with ESMTP id PAA08899; Fri, 14 Oct 2016 15:12:42 +0300 (EEST) (envelope-from avg@FreeBSD.org) Received: from localhost ([127.0.0.1]) by porto.starpoint.kiev.ua with esmtp (Exim 4.34 (FreeBSD)) id 1bv1Lu-000KnV-H4; Fri, 14 Oct 2016 15:12:42 +0300 Subject: Re: svn commit: r307317 - in head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs: . sys To: Alexander Motin , src-committers@FreeBSD.org, svn-src-all@FreeBSD.org, svn-src-head@FreeBSD.org References: <201610141201.u9EC1X2O073182@repo.freebsd.org> From: Andriy Gapon Message-ID: <0e5b9464-e039-1c00-9805-6110f154f9f0@FreeBSD.org> Date: Fri, 14 Oct 2016 15:11:21 +0300 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <201610141201.u9EC1X2O073182@repo.freebsd.org> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Oct 2016 12:12:52 -0000 On 14/10/2016 15:01, Alexander Motin wrote: > Author: mav > Date: Fri Oct 14 12:01:33 2016 > New Revision: 307317 > URL: https://svnweb.freebsd.org/changeset/base/307317 > > Log: > MFV r307313: > 5120 zfs should allow large block/gzip/raidz boot pool (loader project) > > Reviewed by: George Wilson > Reviewed by: Yuri Pankov > Reviewed by: Andrew Stormont > Reviewed by: Matthew Ahrens > Approved by: Robert Mustacchi > Author: Toomas Soome > > openzfs/openzfs@c8811bd3e2427dddbac6c05a59cfe117d8fea370 > > FreeBSD still does not support booting from gzip-compressed datasets, > so keep one chunk of this commit out. Does FreeBSD boot code support large blocks? Just to be sure. And maybe this is worth some additional notice because users sometimes forget to upgrade gptzfsboot / zfsboot. -- Andriy Gapon From owner-svn-src-all@freebsd.org Fri Oct 14 12:23:04 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id AB250C10CA2; Fri, 14 Oct 2016 12:23:04 +0000 (UTC) (envelope-from mavbsd@gmail.com) Received: from mail-lf0-x235.google.com (mail-lf0-x235.google.com [IPv6:2a00:1450:4010:c07::235]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 45542C1C; Fri, 14 Oct 2016 12:23:04 +0000 (UTC) (envelope-from mavbsd@gmail.com) Received: by mail-lf0-x235.google.com with SMTP id b75so192828434lfg.3; Fri, 14 Oct 2016 05:23:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:subject:to:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding; bh=TKnWtdbZzIfjoRjzv6QzAGXvBud4W+Tt1Y3BZM6dqyU=; b=lSf9l26zLA10uJJFb97RHIzCqWmKHHXevi7Tzj98u8gickF8uMQgTuIeEbo33PjVty 2S2tGakgQwq3vCBtAxzFY4rDb/jPNZ3tPvpDiunipOQ1Xm2csDvjCb6xA+0TjKGTWqZQ 1E4r4bjio4F4tXsCmPAHmGHm553ceX6nAprLwxScLZrJH/Wh07IzQp8mNzJ/EaxXjWbF 8rZq9pEKtrnigt5HRwkpm0eAjN6hLhJSxgdlK4WSNbMOLVLK3Ynz4xrLrVg6zGai/3NU U50tEthQZeCejMeva+EhvdLyiibfhnP6vyQPhwn9sjrIIO34EQ46xYLOWBZcbGU/oFSQ MYXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:subject:to:references:from:message-id :date:user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=TKnWtdbZzIfjoRjzv6QzAGXvBud4W+Tt1Y3BZM6dqyU=; b=CmHhIFJTi3Hfzh8/QlOgEMJ8E/5oYX2+IT773cK17RqUcHhkCvaEereKZaECJl1sky YnIjdsLOVm2OYPCs74KGUOLb/kSQx3YpFCMmUF1cd2DaanxvNHjDaD4noxvVCQhSTgOa A3rX/qVcUrBTqyPw1YfC3AW3RdsVkNYaMsfo7XDo2hAHr/PdPZ3wtrFyg0H1vnRKpTNZ FCVBwmUIjSLhIFYGylWhIUbYByAbPCDvnv+cYPevzfyt37lbKemF9ek18yr6pMCc8W0j uzc7luTjW4bE3lcj8n0W8EVIYbZSMtWVkquzceVVEOg6cTvKknXnWrY35wi9ud1Rbzk4 l8cA== X-Gm-Message-State: AA6/9RkuMa6gWRCig4L/cSm20Q5yPRR/XYNEpwG4dn1aZDFkq9cFoxWqKzjAdsp0vvD7AA== X-Received: by 10.25.234.141 with SMTP id y13mr3581557lfi.25.1476447781096; Fri, 14 Oct 2016 05:23:01 -0700 (PDT) Received: from mavbook.mavhome.dp.ua ([134.249.139.101]) by smtp.gmail.com with ESMTPSA id g7sm5112680ljg.44.2016.10.14.05.22.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 14 Oct 2016 05:23:00 -0700 (PDT) Sender: Alexander Motin Subject: Re: svn commit: r307317 - in head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs: . sys To: Andriy Gapon , src-committers@FreeBSD.org, svn-src-all@FreeBSD.org, svn-src-head@FreeBSD.org References: <201610141201.u9EC1X2O073182@repo.freebsd.org> <0e5b9464-e039-1c00-9805-6110f154f9f0@FreeBSD.org> From: Alexander Motin Message-ID: <65265e09-a704-86c0-8e8a-ed423c941d40@FreeBSD.org> Date: Fri, 14 Oct 2016 15:22:59 +0300 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 In-Reply-To: <0e5b9464-e039-1c00-9805-6110f154f9f0@FreeBSD.org> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Oct 2016 12:23:04 -0000 On 14.10.2016 15:11, Andriy Gapon wrote: > On 14/10/2016 15:01, Alexander Motin wrote: >> Author: mav >> Date: Fri Oct 14 12:01:33 2016 >> New Revision: 307317 >> URL: https://svnweb.freebsd.org/changeset/base/307317 >> >> Log: >> MFV r307313: >> 5120 zfs should allow large block/gzip/raidz boot pool (loader project) >> >> Reviewed by: George Wilson >> Reviewed by: Yuri Pankov >> Reviewed by: Andrew Stormont >> Reviewed by: Matthew Ahrens >> Approved by: Robert Mustacchi >> Author: Toomas Soome >> >> openzfs/openzfs@c8811bd3e2427dddbac6c05a59cfe117d8fea370 >> >> FreeBSD still does not support booting from gzip-compressed datasets, >> so keep one chunk of this commit out. > > Does FreeBSD boot code support large blocks? Just to be sure. According to r304321 commit message -- it does now. > And maybe this is worth some additional notice because users sometimes forget to > upgrade gptzfsboot / zfsboot. Where would you like to see it to be noticeable? -- Alexander Motin From owner-svn-src-all@freebsd.org Fri Oct 14 12:59:52 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 536A1C115AE; Fri, 14 Oct 2016 12:59:52 +0000 (UTC) (envelope-from julian@freebsd.org) Received: from vps1.elischer.org (vps1.elischer.org [204.109.63.16]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "vps1.elischer.org", Issuer "CA Cert Signing Authority" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id EF729EEE; Fri, 14 Oct 2016 12:59:51 +0000 (UTC) (envelope-from julian@freebsd.org) Received: from julian-mbp3.pixel8networks.com (50-196-156-133-static.hfc.comcastbusiness.net [50.196.156.133]) (authenticated bits=0) by vps1.elischer.org (8.15.2/8.15.2) with ESMTPSA id u9ECxnVd096664 (version=TLSv1.2 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO); Fri, 14 Oct 2016 05:59:50 -0700 (PDT) (envelope-from julian@freebsd.org) Subject: Re: svn commit: r307317 - in head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs: . sys To: Alexander Motin , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org References: <201610141201.u9EC1X2O073182@repo.freebsd.org> From: Julian Elischer Message-ID: Date: Fri, 14 Oct 2016 05:59:44 -0700 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <201610141201.u9EC1X2O073182@repo.freebsd.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Oct 2016 12:59:52 -0000 On 14/10/2016 5:01 AM, Alexander Motin wrote: > Author: mav > Date: Fri Oct 14 12:01:33 2016 > New Revision: 307317 > URL: https://svnweb.freebsd.org/changeset/base/307317 > > Log: > MFV r307313: > 5120 zfs should allow large block/gzip/raidz boot pool (loader project) > > Reviewed by: George Wilson > Reviewed by: Yuri Pankov > Reviewed by: Andrew Stormont > Reviewed by: Matthew Ahrens > Approved by: Robert Mustacchi > Author: Toomas Soome > > openzfs/openzfs@c8811bd3e2427dddbac6c05a59cfe117d8fea370 > > FreeBSD still does not support booting from gzip-compressed datasets, > so keep one chunk of this commit out. might it not have been a bit better to have just put #if 0 around the bits so that we could still see them? also may help with future merges > > Modified: > head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c > head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zio.h > head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev.c > head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c > Directory Properties: > head/sys/cddl/contrib/opensolaris/ (props changed) > > Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c > ============================================================================== > --- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c Fri Oct 14 11:57:08 2016 (r307316) > +++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c Fri Oct 14 12:01:33 2016 (r307317) > @@ -27,6 +27,7 @@ > * Copyright (c) 2014 Spectra Logic Corporation, All rights reserved. > * Copyright 2013 Saso Kiselkov. All rights reserved. > * Copyright (c) 2014 Integros [integros.com] > + * Copyright 2016 Toomas Soome > */ > > /* > @@ -539,12 +540,6 @@ spa_prop_validate(spa_t *spa, nvlist_t * > &propval)) == 0 && > !BOOTFS_COMPRESS_VALID(propval)) { > error = SET_ERROR(ENOTSUP); > - } else if ((error = > - dsl_prop_get_int_ds(dmu_objset_ds(os), > - zfs_prop_to_name(ZFS_PROP_RECORDSIZE), > - &propval)) == 0 && > - propval > SPA_OLD_MAXBLOCKSIZE) { > - error = SET_ERROR(ENOTSUP); > } else { > objnum = dmu_objset_id(os); > } > > Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zio.h > ============================================================================== > --- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zio.h Fri Oct 14 11:57:08 2016 (r307316) > +++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zio.h Fri Oct 14 12:01:33 2016 (r307317) > @@ -24,6 +24,7 @@ > * Copyright 2011 Nexenta Systems, Inc. All rights reserved. > * Copyright (c) 2012, 2016 by Delphix. All rights reserved. > * Copyright (c) 2013 by Saso Kiselkov. All rights reserved. > + * Copyright 2016 Toomas Soome > */ > > #ifndef _ZIO_H > > Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev.c > ============================================================================== > --- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev.c Fri Oct 14 11:57:08 2016 (r307316) > +++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev.c Fri Oct 14 12:01:33 2016 (r307317) > @@ -25,6 +25,7 @@ > * Copyright 2015 Nexenta Systems, Inc. All rights reserved. > * Copyright 2013 Martin Matuska . All rights reserved. > * Copyright (c) 2014 Integros [integros.com] > + * Copyright 2016 Toomas Soome > */ > > #include > @@ -3474,16 +3475,10 @@ vdev_set_state(vdev_t *vd, boolean_t iso > > /* > * Check the vdev configuration to ensure that it's capable of supporting > - * a root pool. > + * a root pool. We do not support partial configuration. > + * In addition, only a single top-level vdev is allowed. > * > - * On Solaris, we do not support RAID-Z or partial configuration. In > - * addition, only a single top-level vdev is allowed and none of the > - * leaves can be wholedisks. > - * > - * For FreeBSD, we can boot from any configuration. There is a > - * limitation that the boot filesystem must be either uncompressed or > - * compresses with lzjb compression but I'm not sure how to enforce > - * that here. > + * FreeBSD does not have above limitations. > */ > boolean_t > vdev_is_bootable(vdev_t *vd) > @@ -3495,8 +3490,7 @@ vdev_is_bootable(vdev_t *vd) > if (strcmp(vdev_type, VDEV_TYPE_ROOT) == 0 && > vd->vdev_children > 1) { > return (B_FALSE); > - } else if (strcmp(vdev_type, VDEV_TYPE_RAIDZ) == 0 || > - strcmp(vdev_type, VDEV_TYPE_MISSING) == 0) { > + } else if (strcmp(vdev_type, VDEV_TYPE_MISSING) == 0) { > return (B_FALSE); > } > } > > Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c > ============================================================================== > --- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c Fri Oct 14 11:57:08 2016 (r307316) > +++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c Fri Oct 14 12:01:33 2016 (r307317) > @@ -31,6 +31,7 @@ > * Copyright (c) 2013 by Saso Kiselkov. All rights reserved. > * Copyright (c) 2013 Steven Hartland. All rights reserved. > * Copyright (c) 2014 Integros [integros.com] > + * Copyright 2016 Toomas Soome > */ > > /* > @@ -3945,16 +3946,6 @@ zfs_check_settable(const char *dsname, n > spa_t *spa; > > /* > - * If this is a bootable dataset then > - * the we don't allow large (>128K) blocks, > - * because GRUB doesn't support them. > - */ > - if (zfs_is_bootfs(dsname) && > - intval > SPA_OLD_MAXBLOCKSIZE) { > - return (SET_ERROR(ERANGE)); > - } > - > - /* > * We don't allow setting the property above 1MB, > * unless the tunable has been changed. > */ > > From owner-svn-src-all@freebsd.org Fri Oct 14 13:20:03 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id DF2A4C10429; Fri, 14 Oct 2016 13:20:03 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from citapm.icyb.net.ua (citapm.icyb.net.ua [212.40.38.140]) by mx1.freebsd.org (Postfix) with ESMTP id 4504F64E; Fri, 14 Oct 2016 13:20:02 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from porto.starpoint.kiev.ua (porto-e.starpoint.kiev.ua [212.40.38.100]) by citapm.icyb.net.ua (8.8.8p3/ICyb-2.3exp) with ESMTP id QAA09074; Fri, 14 Oct 2016 16:20:00 +0300 (EEST) (envelope-from avg@FreeBSD.org) Received: from localhost ([127.0.0.1]) by porto.starpoint.kiev.ua with esmtp (Exim 4.34 (FreeBSD)) id 1bv2P2-000KrM-MC; Fri, 14 Oct 2016 16:20:00 +0300 Subject: Re: svn commit: r307317 - in head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs: . sys To: Alexander Motin , src-committers@FreeBSD.org, svn-src-all@FreeBSD.org, svn-src-head@FreeBSD.org References: <201610141201.u9EC1X2O073182@repo.freebsd.org> <0e5b9464-e039-1c00-9805-6110f154f9f0@FreeBSD.org> <65265e09-a704-86c0-8e8a-ed423c941d40@FreeBSD.org> From: Andriy Gapon Message-ID: <030747b3-a83c-8b16-d9b1-3d5d3b7ae142@FreeBSD.org> Date: Fri, 14 Oct 2016 16:18:39 +0300 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <65265e09-a704-86c0-8e8a-ed423c941d40@FreeBSD.org> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Oct 2016 13:20:04 -0000 On 14/10/2016 15:22, Alexander Motin wrote: > On 14.10.2016 15:11, Andriy Gapon wrote: >> On 14/10/2016 15:01, Alexander Motin wrote: >>> Author: mav >>> Date: Fri Oct 14 12:01:33 2016 >>> New Revision: 307317 >>> URL: https://svnweb.freebsd.org/changeset/base/307317 >>> >>> Log: >>> MFV r307313: >>> 5120 zfs should allow large block/gzip/raidz boot pool (loader project) >>> >>> Reviewed by: George Wilson >>> Reviewed by: Yuri Pankov >>> Reviewed by: Andrew Stormont >>> Reviewed by: Matthew Ahrens >>> Approved by: Robert Mustacchi >>> Author: Toomas Soome >>> >>> openzfs/openzfs@c8811bd3e2427dddbac6c05a59cfe117d8fea370 >>> >>> FreeBSD still does not support booting from gzip-compressed datasets, >>> so keep one chunk of this commit out. >> >> Does FreeBSD boot code support large blocks? Just to be sure. > > According to r304321 commit message -- it does now. Okay. >> And maybe this is worth some additional notice because users sometimes forget to >> upgrade gptzfsboot / zfsboot. > > Where would you like to see it to be noticeable? That's a good question for which I do not have a good answer. Ideally 'zfs set recordsize=' would warn when setting a large block size on a boot filesystem and 'zpool set bootfs=' would warn when switching the boot filesystem to a filesystem that already has a large block size. But not sure if that's doable without kludges. -- Andriy Gapon From owner-svn-src-all@freebsd.org Fri Oct 14 14:57:44 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 8341EC11E50; Fri, 14 Oct 2016 14:57:44 +0000 (UTC) (envelope-from jtl@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 5FE8E630; Fri, 14 Oct 2016 14:57:44 +0000 (UTC) (envelope-from jtl@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9EEvhsp039213; Fri, 14 Oct 2016 14:57:43 GMT (envelope-from jtl@FreeBSD.org) Received: (from jtl@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9EEvhT8039210; Fri, 14 Oct 2016 14:57:43 GMT (envelope-from jtl@FreeBSD.org) Message-Id: <201610141457.u9EEvhT8039210@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jtl set sender to jtl@FreeBSD.org using -f From: "Jonathan T. Looney" Date: Fri, 14 Oct 2016 14:57:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307319 - in head/sys/netinet: . tcp_stacks X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Oct 2016 14:57:44 -0000 Author: jtl Date: Fri Oct 14 14:57:43 2016 New Revision: 307319 URL: https://svnweb.freebsd.org/changeset/base/307319 Log: The code currently resets the keepalive timer each time a packet is received on a TCP session that has entered the ESTABLISHED state. This results in a lot of calls to reset the keepalive timer. This patch changes the behavior so we set the keepalive timer for the keepalive idle time (TP_KEEPIDLE). When the keepalive timer fires, it will first check to see if the session has been idle for TP_KEEPIDLE ticks. If not, it will reschedule the keepalive timer for the time the session will have been idle for TP_KEEPIDLE ticks. For a session with regular communication, the keepalive timer should fire approximately once every TP_KEEPIDLE ticks. For sessions with irregular communication, the keepalive timer might fire more often. But, the disruption from a periodic keepalive timer should be less than the regular cost of resetting the keepalive timer on every packet. (FWIW, this change saved approximately 1.73% of the busy CPU cycles on a particular test system with a heavy TCP output load. Of course, the actual impact is very specific to the particular hardware and workload.) Reviewed by: gallatin, rrs MFC after: 2 weeks Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D8243 Modified: head/sys/netinet/tcp_input.c head/sys/netinet/tcp_stacks/fastpath.c head/sys/netinet/tcp_timer.c Modified: head/sys/netinet/tcp_input.c ============================================================================== --- head/sys/netinet/tcp_input.c Fri Oct 14 12:03:04 2016 (r307318) +++ head/sys/netinet/tcp_input.c Fri Oct 14 14:57:43 2016 (r307319) @@ -1565,8 +1565,6 @@ tcp_do_segment(struct mbuf *m, struct tc * validation to ignore broken/spoofed segs. */ tp->t_rcvtime = ticks; - if (TCPS_HAVEESTABLISHED(tp->t_state)) - tcp_timer_activate(tp, TT_KEEP, TP_KEEPIDLE(tp)); /* * Scale up the window into a 32-bit value. Modified: head/sys/netinet/tcp_stacks/fastpath.c ============================================================================== --- head/sys/netinet/tcp_stacks/fastpath.c Fri Oct 14 12:03:04 2016 (r307318) +++ head/sys/netinet/tcp_stacks/fastpath.c Fri Oct 14 14:57:43 2016 (r307319) @@ -1819,8 +1819,6 @@ tcp_do_segment_fastslow(struct mbuf *m, * validation to ignore broken/spoofed segs. */ tp->t_rcvtime = ticks; - if (TCPS_HAVEESTABLISHED(tp->t_state)) - tcp_timer_activate(tp, TT_KEEP, TP_KEEPIDLE(tp)); /* * Unscale the window into a 32-bit value. @@ -2266,8 +2264,6 @@ tcp_do_segment_fastack(struct mbuf *m, s * validation to ignore broken/spoofed segs. */ tp->t_rcvtime = ticks; - if (TCPS_HAVEESTABLISHED(tp->t_state)) - tcp_timer_activate(tp, TT_KEEP, TP_KEEPIDLE(tp)); /* * Unscale the window into a 32-bit value. Modified: head/sys/netinet/tcp_timer.c ============================================================================== --- head/sys/netinet/tcp_timer.c Fri Oct 14 12:03:04 2016 (r307318) +++ head/sys/netinet/tcp_timer.c Fri Oct 14 14:57:43 2016 (r307319) @@ -468,6 +468,26 @@ tcp_timer_keep(void *xtp) } KASSERT((tp->t_timers->tt_flags & TT_STOPPED) == 0, ("%s: tp %p tcpcb can't be stopped here", __func__, tp)); + + /* + * Because we don't regularly reset the keepalive callout in + * the ESTABLISHED state, it may be that we don't actually need + * to send a keepalive yet. If that occurs, schedule another + * call for the next time the keepalive timer might expire. + */ + if (TCPS_HAVEESTABLISHED(tp->t_state)) { + u_int idletime; + + idletime = ticks - tp->t_rcvtime; + if (idletime < TP_KEEPIDLE(tp)) { + callout_reset(&tp->t_timers->tt_keep, + TP_KEEPIDLE(tp) - idletime, tcp_timer_keep, tp); + INP_WUNLOCK(inp); + CURVNET_RESTORE(); + return; + } + } + /* * Keep-alive timer went off; send something * or drop connection if idle for too long. From owner-svn-src-all@freebsd.org Fri Oct 14 15:16:45 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id EC9ACC113AE; Fri, 14 Oct 2016 15:16:45 +0000 (UTC) (envelope-from luigi@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id C609BB9; Fri, 14 Oct 2016 15:16:45 +0000 (UTC) (envelope-from luigi@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9EFGio0046618; Fri, 14 Oct 2016 15:16:44 GMT (envelope-from luigi@FreeBSD.org) Received: (from luigi@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9EFGiV8046617; Fri, 14 Oct 2016 15:16:44 GMT (envelope-from luigi@FreeBSD.org) Message-Id: <201610141516.u9EFGiV8046617@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: luigi set sender to luigi@FreeBSD.org using -f From: Luigi Rizzo Date: Fri, 14 Oct 2016 15:16:44 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307320 - head/release/picobsd/build X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Oct 2016 15:16:46 -0000 Author: luigi Date: Fri Oct 14 15:16:44 2016 New Revision: 307320 URL: https://svnweb.freebsd.org/changeset/base/307320 Log: adjust picobsd script to work with HEAD Modified: head/release/picobsd/build/picobsd Modified: head/release/picobsd/build/picobsd ============================================================================== --- head/release/picobsd/build/picobsd Fri Oct 14 14:57:43 2016 (r307319) +++ head/release/picobsd/build/picobsd Fri Oct 14 15:16:44 2016 (r307320) @@ -8,6 +8,10 @@ # picobsd [options] image_type [site_name] # # CWARNFLAGS can be used to pass -Wall or similar options +#export CWARNFLAGS=-D______________sxasxa__________________________ +#export WARNS=2 +# EFIABI... unused attributes ? +export NO_WERROR=1 # # Where image_type is a directory with the picobsd config info, # and ${image_type}/floppy.tree.${site_name} contains @@ -165,7 +169,7 @@ create_includes_and_libraries2() { # opt local no log "create_includes_and_libraries2() for ${SRC} $1" - no="-DNO_CLEAN -DNO_PROFILE -DNO_GAMES -DNO_LIBC_R" # WITHOUT_CDDL=1" + no="-DNO_CLEAN -DMK_PROFILE=no -DNO_GAMES -DNO_LIBC_R" # WITHOUT_CDDL=1" no="$no -DWITHOUT_CASPER" no="$no -DMALLOC_PRODUCTION" @@ -674,7 +678,7 @@ populate_mfs_tree() { ) || fail $? crunch log "Setting up host key for sshd:" - for K in rsa1 rsa dsa ; do + for K in rsa dsa ; do if [ $K = rsa1 ] ; then i=ssh_host_key else @@ -844,6 +848,7 @@ fill_floppy_image() { mkdir -p ${dst} ( cd ${BUILDDIR} + # old style mfs lookup, find markers in kernel set 0 0 # reset variables # $1 takes the offset of the MFS filesystem set `strings -at d kernel | grep "MFS Filesystem goes here"` @@ -852,6 +857,16 @@ fill_floppy_image() { set `strings -at d kernel | grep "MFS Filesystem had better"` mfs_end=$1 mfs_size="$((${mfs_end} - ${mfs_start}))" + if [ ${mfs_start} = 0 -o ${mfs_end} = 0 ] ; then + # similar to sys/tools/embed_mfs.sh + local x="`objdump -h kernel | grep oldmfs`" + mfs_size=`echo ${x} | awk '{printf("%d", "0x" $3)}' 2> /dev/null` + mfs_start=`echo ${x} | awk '{printf("%d", "0x" $6)}' 2> /dev/null` + if [ ${mfs_start} = 0 -o ${mfs_size} = 0 ] ; then + log "-- old style mfs location not found, have" + logverbose "$x" + fi + fi set -- `ls -l ${c_fs}`; imgsize="$5" if [ ${mfs_start} -gt 0 -a ${mfs_size} -ge ${imgsize} ] ; then mfs_ofs=$((${mfs_start} + 8192)) @@ -953,9 +968,15 @@ set_build_parameters() { OSVERSION=$3 log "OSVERSION is ${OSVERSION}" - export MAKEOBJDIRPREFIX=${l_objtree} - export TARGET_ARCH=${o_arch} TARGET=${o_arch} - # XXX 20131001 see if CLANG fixes the build + export MAKEOBJDIRPREFIX=${l_objtree} + export TARGET_ARCH=${o_arch} TARGET=${o_arch} + # XXX 20131001 see if CLANG fixes the build + if true; then + echo "--- build with clang" + export WITHOUT_CLANG=yes + export WITHOUT_CLANG_BOOTSTRAP=yes + # export WITH_CLANG_BOOTSTRAP=yes + else export WITHOUT_CLANG_IS_CC=yes export WITHOUT_CLANG_BOOTSTRAP=yes export WITH_GCC=yes @@ -964,14 +985,15 @@ set_build_parameters() { export WITHOUT_CLANG=yes export WITHOUT_ICONV=yes export WITHOUT_TESTS=yes + fi - # XXX why change machine_arch ? - #-- export MACHINE_ARCH=`uname -m` MACHINE=`uname -m` - # export CWARNFLAGS="-Wextra -Wno-sign-compare -Wno-missing-field-initializers" - # XXX BINMAKE does not really exist anymore - eval "export BINMAKE=\"`cd ${SRC}; make -f Makefile -V BINMAKE`\"" - [ "$BINMAKE" = "" ] && \ - eval "export BINMAKE=\"`cd ${SRC}; make -f Makefile -V SUB_MAKE`\"" + # XXX why change machine_arch ? + #-- export MACHINE_ARCH=`uname -m` MACHINE=`uname -m` + # export CWARNFLAGS="-Wextra -Wno-sign-compare -Wno-missing-field-initializers" + # XXX BINMAKE does not really exist anymore + eval "export BINMAKE=\"`cd ${SRC}; make -f Makefile -V BINMAKE`\"" + [ "$BINMAKE" = "" ] && \ + eval "export BINMAKE=\"`cd ${SRC}; make -f Makefile -V SUB_MAKE`\"" if [ "${o_init_src}" != "" ] ; then create_includes_and_libraries2 From owner-svn-src-all@freebsd.org Fri Oct 14 15:53:49 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E83A9C102B7; Fri, 14 Oct 2016 15:53:49 +0000 (UTC) (envelope-from andrew@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id C289AB9; Fri, 14 Oct 2016 15:53:49 +0000 (UTC) (envelope-from andrew@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9EFrmqn062161; Fri, 14 Oct 2016 15:53:48 GMT (envelope-from andrew@FreeBSD.org) Received: (from andrew@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9EFrmT7062155; Fri, 14 Oct 2016 15:53:48 GMT (envelope-from andrew@FreeBSD.org) Message-Id: <201610141553.u9EFrmT7062155@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: andrew set sender to andrew@FreeBSD.org using -f From: Andrew Turner Date: Fri, 14 Oct 2016 15:53:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307321 - in head/sys/arm64: arm64 include X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Oct 2016 15:53:50 -0000 Author: andrew Date: Fri Oct 14 15:53:48 2016 New Revision: 307321 URL: https://svnweb.freebsd.org/changeset/base/307321 Log: Rework how we store the VFP registers in the pcb. This will be used when creating a floating-point context within the kernel without having to move the stored values in memory. Sponsored by: The FreeBSD Foundation Modified: head/sys/arm64/arm64/machdep.c head/sys/arm64/arm64/vfp.c head/sys/arm64/arm64/vm_machdep.c head/sys/arm64/include/pcb.h head/sys/arm64/include/vfp.h Modified: head/sys/arm64/arm64/machdep.c ============================================================================== --- head/sys/arm64/arm64/machdep.c Fri Oct 14 15:16:44 2016 (r307320) +++ head/sys/arm64/arm64/machdep.c Fri Oct 14 15:53:48 2016 (r307321) @@ -192,9 +192,12 @@ fill_fpregs(struct thread *td, struct fp */ vfp_save_state(td, pcb); - memcpy(regs->fp_q, pcb->pcb_vfp, sizeof(regs->fp_q)); - regs->fp_cr = pcb->pcb_fpcr; - regs->fp_sr = pcb->pcb_fpsr; + KASSERT(pcb->pcb_fpusaved == &pcb->pcb_fpustate, + ("Called fill_fpregs while the kernel is using the VFP")); + memcpy(regs->fp_q, pcb->pcb_fpustate.vfp_regs, + sizeof(regs->fp_q)); + regs->fp_cr = pcb->pcb_fpustate.vfp_fpcr; + regs->fp_sr = pcb->pcb_fpustate.vfp_fpsr; } else #endif memset(regs->fp_q, 0, sizeof(regs->fp_q)); @@ -208,9 +211,11 @@ set_fpregs(struct thread *td, struct fpr struct pcb *pcb; pcb = td->td_pcb; - memcpy(pcb->pcb_vfp, regs->fp_q, sizeof(regs->fp_q)); - pcb->pcb_fpcr = regs->fp_cr; - pcb->pcb_fpsr = regs->fp_sr; + KASSERT(pcb->pcb_fpusaved == &pcb->pcb_fpustate, + ("Called set_fpregs while the kernel is using the VFP")); + memcpy(pcb->pcb_fpustate.vfp_regs, regs->fp_q, sizeof(regs->fp_q)); + pcb->pcb_fpustate.vfp_fpcr = regs->fp_cr; + pcb->pcb_fpustate.vfp_fpsr = regs->fp_sr; #endif return (0); } @@ -334,10 +339,12 @@ get_fpcontext(struct thread *td, mcontex */ vfp_save_state(td, curpcb); - memcpy(mcp->mc_fpregs.fp_q, curpcb->pcb_vfp, + KASSERT(curpcb->pcb_fpusaved == &curpcb->pcb_fpustate, + ("Called get_fpcontext while the kernel is using the VFP")); + memcpy(mcp->mc_fpregs.fp_q, curpcb->pcb_fpustate.vfp_regs, sizeof(mcp->mc_fpregs)); - mcp->mc_fpregs.fp_cr = curpcb->pcb_fpcr; - mcp->mc_fpregs.fp_sr = curpcb->pcb_fpsr; + mcp->mc_fpregs.fp_cr = curpcb->pcb_fpustate.vfp_fpcr; + mcp->mc_fpregs.fp_sr = curpcb->pcb_fpustate.vfp_fpsr; mcp->mc_fpregs.fp_flags = curpcb->pcb_fpflags; mcp->mc_flags |= _MC_FP_VALID; } @@ -363,10 +370,12 @@ set_fpcontext(struct thread *td, mcontex */ vfp_discard(td); - memcpy(curpcb->pcb_vfp, mcp->mc_fpregs.fp_q, + KASSERT(curpcb->pcb_fpusaved == &curpcb->pcb_fpustate, + ("Called set_fpcontext while the kernel is using the VFP")); + memcpy(curpcb->pcb_fpustate.vfp_regs, mcp->mc_fpregs.fp_q, sizeof(mcp->mc_fpregs)); - curpcb->pcb_fpcr = mcp->mc_fpregs.fp_cr; - curpcb->pcb_fpsr = mcp->mc_fpregs.fp_sr; + curpcb->pcb_fpustate.vfp_fpcr = mcp->mc_fpregs.fp_cr; + curpcb->pcb_fpustate.vfp_fpsr = mcp->mc_fpregs.fp_sr; curpcb->pcb_fpflags = mcp->mc_fpregs.fp_flags; } @@ -607,6 +616,7 @@ init_proc0(vm_offset_t kstack) thread0.td_kstack = kstack; thread0.td_pcb = (struct pcb *)(thread0.td_kstack) - 1; thread0.td_pcb->pcb_fpflags = 0; + thread0.td_pcb->pcb_fpusaved = &thread0.td_pcb->pcb_fpustate; thread0.td_pcb->pcb_vfpcpu = UINT_MAX; thread0.td_frame = &proc0_tf; pcpup->pc_curpcb = thread0.td_pcb; Modified: head/sys/arm64/arm64/vfp.c ============================================================================== --- head/sys/arm64/arm64/vfp.c Fri Oct 14 15:16:44 2016 (r307320) +++ head/sys/arm64/arm64/vfp.c Fri Oct 14 15:53:48 2016 (r307321) @@ -34,6 +34,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -42,7 +43,10 @@ __FBSDID("$FreeBSD$"); #include /* Sanity check we can store all the VFP registers */ -CTASSERT(sizeof(((struct pcb *)0)->pcb_vfp) == 16 * 32); +CTASSERT(sizeof(((struct pcb *)0)->pcb_fpustate.vfp_regs) == 16 * 32); + +static MALLOC_DEFINE(M_FPUKERN_CTX, "fpukern_ctx", + "Kernel contexts for VFP state"); static void vfp_enable(void) @@ -81,11 +85,73 @@ vfp_discard(struct thread *td) vfp_disable(); } -void -vfp_save_state(struct thread *td, struct pcb *pcb) +static void +vfp_store(struct vfpstate *state) +{ + __int128_t *vfp_state; + uint64_t fpcr, fpsr; + + vfp_state = state->vfp_regs; + __asm __volatile( + "mrs %0, fpcr \n" + "mrs %1, fpsr \n" + "stp q0, q1, [%2, #16 * 0]\n" + "stp q2, q3, [%2, #16 * 2]\n" + "stp q4, q5, [%2, #16 * 4]\n" + "stp q6, q7, [%2, #16 * 6]\n" + "stp q8, q9, [%2, #16 * 8]\n" + "stp q10, q11, [%2, #16 * 10]\n" + "stp q12, q13, [%2, #16 * 12]\n" + "stp q14, q15, [%2, #16 * 14]\n" + "stp q16, q17, [%2, #16 * 16]\n" + "stp q18, q19, [%2, #16 * 18]\n" + "stp q20, q21, [%2, #16 * 20]\n" + "stp q22, q23, [%2, #16 * 22]\n" + "stp q24, q25, [%2, #16 * 24]\n" + "stp q26, q27, [%2, #16 * 26]\n" + "stp q28, q29, [%2, #16 * 28]\n" + "stp q30, q31, [%2, #16 * 30]\n" + : "=&r"(fpcr), "=&r"(fpsr) : "r"(vfp_state)); + + state->vfp_fpcr = fpcr; + state->vfp_fpsr = fpsr; +} + +static void +vfp_restore(struct vfpstate *state) { __int128_t *vfp_state; uint64_t fpcr, fpsr; + + vfp_state = state->vfp_regs; + fpcr = state->vfp_fpcr; + fpsr = state->vfp_fpsr; + + __asm __volatile( + "ldp q0, q1, [%2, #16 * 0]\n" + "ldp q2, q3, [%2, #16 * 2]\n" + "ldp q4, q5, [%2, #16 * 4]\n" + "ldp q6, q7, [%2, #16 * 6]\n" + "ldp q8, q9, [%2, #16 * 8]\n" + "ldp q10, q11, [%2, #16 * 10]\n" + "ldp q12, q13, [%2, #16 * 12]\n" + "ldp q14, q15, [%2, #16 * 14]\n" + "ldp q16, q17, [%2, #16 * 16]\n" + "ldp q18, q19, [%2, #16 * 18]\n" + "ldp q20, q21, [%2, #16 * 20]\n" + "ldp q22, q23, [%2, #16 * 22]\n" + "ldp q24, q25, [%2, #16 * 24]\n" + "ldp q26, q27, [%2, #16 * 26]\n" + "ldp q28, q29, [%2, #16 * 28]\n" + "ldp q30, q31, [%2, #16 * 30]\n" + "msr fpcr, %0 \n" + "msr fpsr, %1 \n" + : : "r"(fpcr), "r"(fpsr), "r"(vfp_state)); +} + +void +vfp_save_state(struct thread *td, struct pcb *pcb) +{ uint32_t cpacr; KASSERT(pcb != NULL, ("NULL vfp pcb")); @@ -104,31 +170,7 @@ vfp_save_state(struct thread *td, struct KASSERT(PCPU_GET(fpcurthread) == td, ("Storing an invalid VFP state")); - vfp_state = pcb->pcb_vfp; - __asm __volatile( - "mrs %0, fpcr \n" - "mrs %1, fpsr \n" - "stp q0, q1, [%2, #16 * 0]\n" - "stp q2, q3, [%2, #16 * 2]\n" - "stp q4, q5, [%2, #16 * 4]\n" - "stp q6, q7, [%2, #16 * 6]\n" - "stp q8, q9, [%2, #16 * 8]\n" - "stp q10, q11, [%2, #16 * 10]\n" - "stp q12, q13, [%2, #16 * 12]\n" - "stp q14, q15, [%2, #16 * 14]\n" - "stp q16, q17, [%2, #16 * 16]\n" - "stp q18, q19, [%2, #16 * 18]\n" - "stp q20, q21, [%2, #16 * 20]\n" - "stp q22, q23, [%2, #16 * 22]\n" - "stp q24, q25, [%2, #16 * 24]\n" - "stp q26, q27, [%2, #16 * 26]\n" - "stp q28, q29, [%2, #16 * 28]\n" - "stp q30, q31, [%2, #16 * 30]\n" - : "=&r"(fpcr), "=&r"(fpsr) : "r"(vfp_state)); - - pcb->pcb_fpcr = fpcr; - pcb->pcb_fpsr = fpsr; - + vfp_store(pcb->pcb_fpusaved); dsb(ish); vfp_disable(); } @@ -138,8 +180,6 @@ vfp_save_state(struct thread *td, struct void vfp_restore_state(void) { - __int128_t *vfp_state; - uint64_t fpcr, fpsr; struct pcb *curpcb; u_int cpu; @@ -158,31 +198,7 @@ vfp_restore_state(void) */ if (PCPU_GET(fpcurthread) != curthread || cpu != curpcb->pcb_vfpcpu) { - vfp_state = curthread->td_pcb->pcb_vfp; - fpcr = curthread->td_pcb->pcb_fpcr; - fpsr = curthread->td_pcb->pcb_fpsr; - - __asm __volatile( - "ldp q0, q1, [%2, #16 * 0]\n" - "ldp q2, q3, [%2, #16 * 2]\n" - "ldp q4, q5, [%2, #16 * 4]\n" - "ldp q6, q7, [%2, #16 * 6]\n" - "ldp q8, q9, [%2, #16 * 8]\n" - "ldp q10, q11, [%2, #16 * 10]\n" - "ldp q12, q13, [%2, #16 * 12]\n" - "ldp q14, q15, [%2, #16 * 14]\n" - "ldp q16, q17, [%2, #16 * 16]\n" - "ldp q18, q19, [%2, #16 * 18]\n" - "ldp q20, q21, [%2, #16 * 20]\n" - "ldp q22, q23, [%2, #16 * 22]\n" - "ldp q24, q25, [%2, #16 * 24]\n" - "ldp q26, q27, [%2, #16 * 26]\n" - "ldp q28, q29, [%2, #16 * 28]\n" - "ldp q30, q31, [%2, #16 * 30]\n" - "msr fpcr, %0 \n" - "msr fpsr, %1 \n" - : : "r"(fpcr), "r"(fpsr), "r"(vfp_state)); - + vfp_restore(curthread->td_pcb->pcb_fpusaved); PCPU_SET(fpcurthread, curthread); curpcb->pcb_vfpcpu = cpu; } Modified: head/sys/arm64/arm64/vm_machdep.c ============================================================================== --- head/sys/arm64/arm64/vm_machdep.c Fri Oct 14 15:16:44 2016 (r307320) +++ head/sys/arm64/arm64/vm_machdep.c Fri Oct 14 15:53:48 2016 (r307321) @@ -101,6 +101,7 @@ cpu_fork(struct thread *td1, struct proc td2->td_pcb->pcb_x[9] = (uintptr_t)td2; td2->td_pcb->pcb_x[PCB_LR] = (uintptr_t)fork_trampoline; td2->td_pcb->pcb_sp = (uintptr_t)td2->td_frame; + td2->td_pcb->pcb_fpusaved = &td2->td_pcb->pcb_fpustate; td2->td_pcb->pcb_vfpcpu = UINT_MAX; /* Setup to release spin count in fork_exit(). */ @@ -169,6 +170,7 @@ cpu_copy_thread(struct thread *td, struc td->td_pcb->pcb_x[9] = (uintptr_t)td; td->td_pcb->pcb_x[PCB_LR] = (uintptr_t)fork_trampoline; td->td_pcb->pcb_sp = (uintptr_t)td->td_frame; + td->td_pcb->pcb_fpusaved = &td->td_pcb->pcb_fpustate; td->td_pcb->pcb_vfpcpu = UINT_MAX; /* Setup to release spin count in fork_exit(). */ @@ -246,6 +248,7 @@ cpu_fork_kthread_handler(struct thread * td->td_pcb->pcb_x[9] = (uintptr_t)arg; td->td_pcb->pcb_x[PCB_LR] = (uintptr_t)fork_trampoline; td->td_pcb->pcb_sp = (uintptr_t)td->td_frame; + td->td_pcb->pcb_fpusaved = &td->td_pcb->pcb_fpustate; td->td_pcb->pcb_vfpcpu = UINT_MAX; } Modified: head/sys/arm64/include/pcb.h ============================================================================== --- head/sys/arm64/include/pcb.h Fri Oct 14 15:16:44 2016 (r307320) +++ head/sys/arm64/include/pcb.h Fri Oct 14 15:53:48 2016 (r307321) @@ -31,6 +31,8 @@ #ifndef LOCORE +#include + struct trapframe; #define PCB_LR 30 @@ -49,13 +51,17 @@ struct pcb { #define PCB_SINGLE_STEP_SHIFT 0 #define PCB_SINGLE_STEP (1 << PCB_SINGLE_STEP_SHIFT) - /* Place last to simplify the asm to access the rest if the struct */ - __uint128_t pcb_vfp[32]; - uint32_t pcb_fpcr; - uint32_t pcb_fpsr; + struct vfpstate *pcb_fpusaved; int pcb_fpflags; #define PCB_FP_STARTED 0x01 u_int pcb_vfpcpu; /* Last cpu this thread ran VFP code */ + + /* + * The userspace VFP state. The pcb_fpusaved pointer will point to + * this unless the kernel has allocated a VFP context. + * Place last to simplify the asm to access the rest if the struct. + */ + struct vfpstate pcb_fpustate; }; #ifdef _KERNEL Modified: head/sys/arm64/include/vfp.h ============================================================================== --- head/sys/arm64/include/vfp.h Fri Oct 14 15:16:44 2016 (r307320) +++ head/sys/arm64/include/vfp.h Fri Oct 14 15:53:48 2016 (r307321) @@ -35,6 +35,12 @@ #ifdef _KERNEL #ifndef LOCORE +struct vfpstate { + __uint128_t vfp_regs[32]; + uint32_t vfp_fpcr; + uint32_t vfp_fpsr; +}; + void vfp_init(void); void vfp_discard(struct thread *); void vfp_restore_state(void); From owner-svn-src-all@freebsd.org Fri Oct 14 16:05:46 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 1865FC1083E; Fri, 14 Oct 2016 16:05:46 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id DC431BA0; Fri, 14 Oct 2016 16:05:45 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9EG5it7065966; Fri, 14 Oct 2016 16:05:44 GMT (envelope-from imp@FreeBSD.org) Received: (from imp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9EG5iBX065964; Fri, 14 Oct 2016 16:05:44 GMT (envelope-from imp@FreeBSD.org) Message-Id: <201610141605.u9EG5iBX065964@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: imp set sender to imp@FreeBSD.org using -f From: Warner Losh Date: Fri, 14 Oct 2016 16:05:44 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307322 - head/sys/boot/common X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Oct 2016 16:05:46 -0000 Author: imp Date: Fri Oct 14 16:05:44 2016 New Revision: 307322 URL: https://svnweb.freebsd.org/changeset/base/307322 Log: The file /boot/boot.conf existed for the 3.0 release (r38764). It was replaced by /boot/loader.rc for 3.1 (r42682). In May 2000, this was documented as deprecated (r61942) (between FreeBSD 4.0 and 4.1). Remove it since it's not been the preferred method in 17 years and has been deprecated for 16. Differential Revision: https://reviews.freebsd.org/D8142 Modified: head/sys/boot/common/interp.c head/sys/boot/common/loader.8 Modified: head/sys/boot/common/interp.c ============================================================================== --- head/sys/boot/common/interp.c Fri Oct 14 15:53:48 2016 (r307321) +++ head/sys/boot/common/interp.c Fri Oct 14 16:05:44 2016 (r307322) @@ -104,8 +104,7 @@ interact(const char *rc) if (rc == NULL) { /* Read our default configuration. */ - if (include("/boot/loader.rc") != CMD_OK) - include("/boot/boot.conf"); + include("/boot/loader.rc"); } else if (*rc != '\0') include(rc); Modified: head/sys/boot/common/loader.8 ============================================================================== --- head/sys/boot/common/loader.8 Fri Oct 14 15:53:48 2016 (r307321) +++ head/sys/boot/common/loader.8 Fri Oct 14 16:05:44 2016 (r307322) @@ -90,9 +90,7 @@ which is default. After that, .Pa /boot/loader.rc -is processed if available, and, failing that, -.Pa /boot/boot.conf -is read for historical reasons. +is processed if available. These files are processed through the .Ic include command, which reads all of them into memory before processing them, @@ -957,10 +955,6 @@ itself. Additional .Tn FICL initialization. -.It Pa /boot/boot.conf -.Nm -bootstrapping script. -Deprecated. .It Pa /boot/defaults/loader.conf .It Pa /boot/loader.conf .It Pa /boot/loader.conf.local From owner-svn-src-all@freebsd.org Fri Oct 14 16:23:06 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 44C99C11011; Fri, 14 Oct 2016 16:23:06 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 16F45A59; Fri, 14 Oct 2016 16:23:06 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9EGN56Q073167; Fri, 14 Oct 2016 16:23:05 GMT (envelope-from imp@FreeBSD.org) Received: (from imp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9EGN552073166; Fri, 14 Oct 2016 16:23:05 GMT (envelope-from imp@FreeBSD.org) Message-Id: <201610141623.u9EGN552073166@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: imp set sender to imp@FreeBSD.org using -f From: Warner Losh Date: Fri, 14 Oct 2016 16:23:05 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307323 - head/sys/boot/common X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Oct 2016 16:23:06 -0000 Author: imp Date: Fri Oct 14 16:23:05 2016 New Revision: 307323 URL: https://svnweb.freebsd.org/changeset/base/307323 Log: Remove fetching of pInterp. Currently, there's no actual effect other than to store the location of a forth word that is subsequently never used. It was last used before the 2.03 ficl upgrade in r51786. It was only used from r43614 (so Feb-Sept 1999) on head and in the 3.x branch (merged r43715 3.1 -> EOL). Remove it since nobody cared enough to report the bug in the last 18 years rather than fix it. It's need seems to have passed in the 2.03 ficl update. Differential Revision: https://reviews.freebsd.org/D8150 Modified: head/sys/boot/common/interp_forth.c Modified: head/sys/boot/common/interp_forth.c ============================================================================== --- head/sys/boot/common/interp_forth.c Fri Oct 14 16:05:44 2016 (r307322) +++ head/sys/boot/common/interp_forth.c Fri Oct 14 16:23:05 2016 (r307323) @@ -63,7 +63,6 @@ extern char bootprog_rev[]; FICL_SYSTEM *bf_sys; FICL_VM *bf_vm; -FICL_WORD *pInterp; /* * Shim for taking commands from BF and passing them out to 'standard' @@ -281,8 +280,6 @@ bf_init(const char *rc) ficlSetEnv(bf_sys, "loader_version", (bootprog_rev[0] - '0') * 10 + (bootprog_rev[2] - '0')); - pInterp = ficlLookup(bf_sys, "interpret"); - /* try to load and run init file if present */ if (rc == NULL) rc = "/boot/boot.4th"; @@ -293,9 +290,6 @@ bf_init(const char *rc) close(fd); } } - - /* Do this again, so that interpret can be redefined. */ - pInterp = ficlLookup(bf_sys, "interpret"); } /* From owner-svn-src-all@freebsd.org Fri Oct 14 16:23:15 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 419F5C1107E; Fri, 14 Oct 2016 16:23:15 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 089D4BE9; Fri, 14 Oct 2016 16:23:14 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9EGNEg3073235; Fri, 14 Oct 2016 16:23:14 GMT (envelope-from imp@FreeBSD.org) Received: (from imp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9EGNCNO073220; Fri, 14 Oct 2016 16:23:12 GMT (envelope-from imp@FreeBSD.org) Message-Id: <201610141623.u9EGNCNO073220@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: imp set sender to imp@FreeBSD.org using -f From: Warner Losh Date: Fri, 14 Oct 2016 16:23:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307324 - in head/sys/boot: common efi/loader efi/loader/arch/amd64 efi/loader/arch/arm efi/loader/arch/arm64 efi/loader/arch/i386 ficl ficl/i386 i386/libi386 mips/beri/loader pc98/libpc98 X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Oct 2016 16:23:15 -0000 Author: imp Date: Fri Oct 14 16:23:12 2016 New Revision: 307324 URL: https://svnweb.freebsd.org/changeset/base/307324 Log: Create a new linker set, Xficl_compile_set which contains a list of functions to call at the appropriate time to register new forth words. In the past we've done this with ifdef soup, but now if the file is included in the build, we'll get the new forth words. Use this new functionality to move the pci bios stuff out of loader.c by moving it to biospci.c. Move the pnp functionality to common/pnp.c. Move the inb/outb forth words to the i386 sysdep.c file where their implementation is defined. Adjust the efi linker scripts and build machinery to cope. his should be an invisible change to forth scripts and user experience. Differential Revision: https://reviews.freebsd.org/D8145 Modified: head/sys/boot/common/bootstrap.h head/sys/boot/common/pnp.c head/sys/boot/efi/loader/Makefile head/sys/boot/efi/loader/arch/amd64/ldscript.amd64 head/sys/boot/efi/loader/arch/arm/ldscript.arm head/sys/boot/efi/loader/arch/arm64/ldscript.arm64 head/sys/boot/efi/loader/arch/i386/ldscript.i386 head/sys/boot/ficl/ficl.h head/sys/boot/ficl/i386/sysdep.c head/sys/boot/ficl/loader.c head/sys/boot/i386/libi386/Makefile head/sys/boot/i386/libi386/biospci.c head/sys/boot/i386/libi386/libi386.h head/sys/boot/mips/beri/loader/loader.ldscript head/sys/boot/pc98/libpc98/Makefile Modified: head/sys/boot/common/bootstrap.h ============================================================================== --- head/sys/boot/common/bootstrap.h Fri Oct 14 16:23:05 2016 (r307323) +++ head/sys/boot/common/bootstrap.h Fri Oct 14 16:23:12 2016 (r307324) @@ -142,8 +142,6 @@ struct pnpinfo STAILQ_HEAD(pnpinfo_stql, pnpinfo); -extern struct pnpinfo_stql pnp_devices; - extern struct pnphandler *pnphandlers[]; /* provided by MD code */ void pnp_addident(struct pnpinfo *pi, char *ident); Modified: head/sys/boot/common/pnp.c ============================================================================== --- head/sys/boot/common/pnp.c Fri Oct 14 16:23:05 2016 (r307323) +++ head/sys/boot/common/pnp.c Fri Oct 14 16:23:12 2016 (r307324) @@ -17,8 +17,9 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include "ficl.h" -struct pnpinfo_stql pnp_devices; +static struct pnpinfo_stql pnp_devices; static int pnp_devices_initted = 0; static void pnp_discard(void); @@ -185,3 +186,47 @@ pnp_eisaformat(u_int8_t *data) return(idbuf); } +void +ficlPnpdevices(FICL_VM *pVM) +{ + static int pnp_devices_initted = 0; +#if FICL_ROBUST > 1 + vmCheckStack(pVM, 0, 1); +#endif + + if(!pnp_devices_initted) { + STAILQ_INIT(&pnp_devices); + pnp_devices_initted = 1; + } + + stackPushPtr(pVM->pStack, &pnp_devices); + + return; +} + +void +ficlPnphandlers(FICL_VM *pVM) +{ +#if FICL_ROBUST > 1 + vmCheckStack(pVM, 0, 1); +#endif + + stackPushPtr(pVM->pStack, pnphandlers); + + return; +} + +/* + * Glue function to add the appropriate forth words to access pnp BIOS + * functionality. + */ +static void ficlCompilePnp(FICL_SYSTEM *pSys) +{ + FICL_DICT *dp = pSys->dp; + assert (dp); + + dictAppendWord(dp, "pnpdevices",ficlPnpdevices, FW_DEFAULT); + dictAppendWord(dp, "pnphandlers",ficlPnphandlers, FW_DEFAULT); +} + +FICL_COMPILE_SET(ficlCompilePnp); Modified: head/sys/boot/efi/loader/Makefile ============================================================================== --- head/sys/boot/efi/loader/Makefile Fri Oct 14 16:23:05 2016 (r307323) +++ head/sys/boot/efi/loader/Makefile Fri Oct 14 16:23:12 2016 (r307324) @@ -145,6 +145,7 @@ loader.efi: ${PROG} ${OBJCOPY} -j .peheader -j .text -j .sdata -j .data \ -j .dynamic -j .dynsym -j .rel.dyn \ -j .rela.dyn -j .reloc -j .eh_frame -j set_Xcommand_set \ + -j set_Xficl_compile_set \ --output-target=${EFI_TARGET} ${.ALLSRC} ${.TARGET} LIBEFI= ${.OBJDIR}/../libefi/libefi.a Modified: head/sys/boot/efi/loader/arch/amd64/ldscript.amd64 ============================================================================== --- head/sys/boot/efi/loader/arch/amd64/ldscript.amd64 Fri Oct 14 16:23:05 2016 (r307323) +++ head/sys/boot/efi/loader/arch/amd64/ldscript.amd64 Fri Oct 14 16:23:12 2016 (r307324) @@ -40,6 +40,11 @@ SECTIONS *(set_Xcommand_set) __stop_set_Xcommand_set = .; } + set_Xficl_compile_set : { + __start_set_Xficl_compile_set = .; + *(set_Xficl_compile_set) + __stop_set_Xficl_compile_set = .; + } . = ALIGN(4096); __gp = .; .sdata : { Modified: head/sys/boot/efi/loader/arch/arm/ldscript.arm ============================================================================== --- head/sys/boot/efi/loader/arch/arm/ldscript.arm Fri Oct 14 16:23:05 2016 (r307323) +++ head/sys/boot/efi/loader/arch/arm/ldscript.arm Fri Oct 14 16:23:12 2016 (r307324) @@ -47,6 +47,11 @@ SECTIONS *(set_Xcommand_set) __stop_set_Xcommand_set = .; } + set_Xficl_compile_set : { + __start_set_Xficl_compile_set = .; + *(set_Xficl_compile_set) + __stop_set_Xficl_compile_set = .; + } __gp = .; .plt : { *(.plt) } .dynamic : { *(.dynamic) } Modified: head/sys/boot/efi/loader/arch/arm64/ldscript.arm64 ============================================================================== --- head/sys/boot/efi/loader/arch/arm64/ldscript.arm64 Fri Oct 14 16:23:05 2016 (r307323) +++ head/sys/boot/efi/loader/arch/arm64/ldscript.arm64 Fri Oct 14 16:23:12 2016 (r307324) @@ -43,6 +43,11 @@ SECTIONS *(set_Xcommand_set) __stop_set_Xcommand_set = .; } + set_Xficl_compile_set : { + __start_set_Xficl_compile_set = .; + *(set_Xficl_compile_set) + __stop_set_Xficl_compile_set = .; + } . = ALIGN(16); __gp = .; .sdata : { Modified: head/sys/boot/efi/loader/arch/i386/ldscript.i386 ============================================================================== --- head/sys/boot/efi/loader/arch/i386/ldscript.i386 Fri Oct 14 16:23:05 2016 (r307323) +++ head/sys/boot/efi/loader/arch/i386/ldscript.i386 Fri Oct 14 16:23:12 2016 (r307324) @@ -35,6 +35,11 @@ SECTIONS *(set_Xcommand_set) __stop_set_Xcommand_set = .; } + set_Xficl_compile_set : { + __start_set_Xficl_compile_set = .; + *(set_Xficl_compile_set) + __stop_set_Xficl_compile_set = .; + } . = ALIGN(4096); __gp = .; .sdata : { Modified: head/sys/boot/ficl/ficl.h ============================================================================== --- head/sys/boot/ficl/ficl.h Fri Oct 14 16:23:05 2016 (r307323) +++ head/sys/boot/ficl/ficl.h Fri Oct 14 16:23:12 2016 (r307324) @@ -1150,6 +1150,13 @@ typedef struct ficlFILE } ficlFILE; #endif +#include + +typedef void ficlCompileFcn(FICL_SYSTEM *); +#define FICL_COMPILE_SET(func) \ + DATA_SET(Xficl_compile_set, func) +SET_DECLARE(Xficl_compile_set, ficlCompileFcn); + #ifdef __cplusplus } #endif Modified: head/sys/boot/ficl/i386/sysdep.c ============================================================================== --- head/sys/boot/ficl/i386/sysdep.c Fri Oct 14 16:23:05 2016 (r307323) +++ head/sys/boot/ficl/i386/sysdep.c Fri Oct 14 16:23:12 2016 (r307324) @@ -81,7 +81,6 @@ void ficlFree (void *p) } #ifndef TESTMAIN -#ifdef __i386__ /* * outb ( port# c -- ) * Store a byte to I/O port number port# @@ -111,7 +110,22 @@ ficlInb(FICL_VM *pVM) c=inb(port); stackPushINT(pVM->pStack,c); } -#endif + +/* + * Glue function to add the appropriate forth words to access x86 special cpu + * functionality. + */ +static void ficlCompileCpufunc(FICL_SYSTEM *pSys) +{ + FICL_DICT *dp = pSys->dp; + assert (dp); + + dictAppendWord(dp, "outb", ficlOutb, FW_DEFAULT); + dictAppendWord(dp, "inb", ficlInb, FW_DEFAULT); +} + +FICL_COMPILE_SET(ficlCompileCpufunc); + #endif /* Modified: head/sys/boot/ficl/loader.c ============================================================================== --- head/sys/boot/ficl/loader.c Fri Oct 14 16:23:05 2016 (r307323) +++ head/sys/boot/ficl/loader.c Fri Oct 14 16:23:12 2016 (r307324) @@ -287,43 +287,6 @@ ficlFindfile(FICL_VM *pVM) return; } -#ifndef TESTMAIN -#ifdef HAVE_PNP - -void -ficlPnpdevices(FICL_VM *pVM) -{ - static int pnp_devices_initted = 0; -#if FICL_ROBUST > 1 - vmCheckStack(pVM, 0, 1); -#endif - - if(!pnp_devices_initted) { - STAILQ_INIT(&pnp_devices); - pnp_devices_initted = 1; - } - - stackPushPtr(pVM->pStack, &pnp_devices); - - return; -} - -void -ficlPnphandlers(FICL_VM *pVM) -{ -#if FICL_ROBUST > 1 - vmCheckStack(pVM, 0, 1); -#endif - - stackPushPtr(pVM->pStack, pnphandlers); - - return; -} - -#endif - -#endif /* ndef TESTMAIN */ - void ficlCcall(FICL_VM *pVM) { @@ -800,141 +763,6 @@ static void fkey(FICL_VM *pVM) } -#ifdef __i386__ -/* - * pcibios-device-count (devid -- count) - * - * Returns the PCI BIOS' count of how many devices matching devid are in the system. - * devid is the 32-bit vendor + device. - */ -static void -ficlPciBiosCountDevices(FICL_VM *pVM) -{ - uint32_t devid; - int i; - - devid = stackPopINT(pVM->pStack); - - i = biospci_count_device_type(devid); - - stackPushINT(pVM->pStack, i); -} - -/* - * pcibios-write-config (locator offset width value -- ) - * - * Writes the specified config register. - * Locator is bus << 8 | device << 3 | fuction - * offset is the pci config register - * width is 0 for byte, 1 for word, 2 for dword - * value is the value to write - */ -static void -ficlPciBiosWriteConfig(FICL_VM *pVM) -{ - uint32_t value, width, offset, locator; - - value = stackPopINT(pVM->pStack); - width = stackPopINT(pVM->pStack); - offset = stackPopINT(pVM->pStack); - locator = stackPopINT(pVM->pStack); - - biospci_write_config(locator, offset, width, value); -} - -/* - * pcibios-read-config (locator offset width -- value) - * - * Reads the specified config register. - * Locator is bus << 8 | device << 3 | fuction - * offset is the pci config register - * width is 0 for byte, 1 for word, 2 for dword - * value is the value to read from the register - */ -static void -ficlPciBiosReadConfig(FICL_VM *pVM) -{ - uint32_t value, width, offset, locator; - - width = stackPopINT(pVM->pStack); - offset = stackPopINT(pVM->pStack); - locator = stackPopINT(pVM->pStack); - - biospci_read_config(locator, offset, width, &value); - - stackPushINT(pVM->pStack, value); -} - -/* - * pcibios-find-devclass (class index -- locator) - * - * Finds the index'th instance of class in the pci tree. - * must be an exact match. - * class is the class to search for. - * index 0..N (set to 0, increment until error) - * - * Locator is bus << 8 | device << 3 | fuction (or -1 on error) - */ -static void -ficlPciBiosFindDevclass(FICL_VM *pVM) -{ - uint32_t index, class, locator; - - index = stackPopINT(pVM->pStack); - class = stackPopINT(pVM->pStack); - - if (biospci_find_devclass(class, index, &locator)) - locator = 0xffffffff; - - stackPushINT(pVM->pStack, locator); -} - -/* - * pcibios-find-device(devid index -- locator) - * - * Finds the index'th instance of devid in the pci tree. - * must be an exact match. - * class is the class to search for. - * index 0..N (set to 0, increment until error) - * - * Locator is bus << 8 | device << 3 | fuction (or -1 on error) - */ -static void -ficlPciBiosFindDevice(FICL_VM *pVM) -{ - uint32_t index, devid, locator; - - index = stackPopINT(pVM->pStack); - devid = stackPopINT(pVM->pStack); - - if (biospci_find_device(devid, index, &locator)) - locator = 0xffffffff; - - stackPushINT(pVM->pStack, locator); -} - -/* - * pcibios-find-device(bus device function -- locator) - * - * converts bus, device, function to locator. - * - * Locator is bus << 8 | device << 3 | fuction - */ -static void -ficlPciBiosLocator(FICL_VM *pVM) -{ - uint32_t bus, device, function, locator; - - function = stackPopINT(pVM->pStack); - device = stackPopINT(pVM->pStack); - bus = stackPopINT(pVM->pStack); - - locator = biospci_locator(bus, device, function); - - stackPushINT(pVM->pStack, locator); -} -#endif - /* ** Retrieves free space remaining on the dictionary */ @@ -963,6 +791,7 @@ static void ficlDictIncrease(FICL_VM *pV **************************************************************************/ void ficlCompilePlatform(FICL_SYSTEM *pSys) { + ficlCompileFcn **fnpp; FICL_DICT *dp = pSys->dp; assert (dp); @@ -994,24 +823,10 @@ void ficlCompilePlatform(FICL_SYSTEM *pS dictAppendWord(dp, "ccall", ficlCcall, FW_DEFAULT); dictAppendWord(dp, "uuid-from-string", ficlUuidFromString, FW_DEFAULT); dictAppendWord(dp, "uuid-to-string", ficlUuidToString, FW_DEFAULT); -#ifndef TESTMAIN -#ifdef __i386__ - dictAppendWord(dp, "outb", ficlOutb, FW_DEFAULT); - dictAppendWord(dp, "inb", ficlInb, FW_DEFAULT); -#endif -#ifdef HAVE_PNP - dictAppendWord(dp, "pnpdevices",ficlPnpdevices, FW_DEFAULT); - dictAppendWord(dp, "pnphandlers",ficlPnphandlers, FW_DEFAULT); -#endif -#endif -#ifdef __i386__ - dictAppendWord(dp, "pcibios-device-count", ficlPciBiosCountDevices, FW_DEFAULT); - dictAppendWord(dp, "pcibios-read-config", ficlPciBiosReadConfig, FW_DEFAULT); - dictAppendWord(dp, "pcibios-write-config", ficlPciBiosWriteConfig, FW_DEFAULT); - dictAppendWord(dp, "pcibios-find-devclass", ficlPciBiosFindDevclass, FW_DEFAULT); - dictAppendWord(dp, "pcibios-find-device", ficlPciBiosFindDevice, FW_DEFAULT); - dictAppendWord(dp, "pcibios-locator", ficlPciBiosLocator, FW_DEFAULT); -#endif + + SET_FOREACH(fnpp, Xficl_compile_set) { + (*fnpp)(pSys); + } #if defined(PC98) ficlSetEnv(pSys, "arch-pc98", FICL_TRUE); Modified: head/sys/boot/i386/libi386/Makefile ============================================================================== --- head/sys/boot/i386/libi386/Makefile Fri Oct 14 16:23:05 2016 (r307323) +++ head/sys/boot/i386/libi386/Makefile Fri Oct 14 16:23:12 2016 (r307324) @@ -54,7 +54,8 @@ CFLAGS+= -DTERM_EMU # XXX: make alloca() useable CFLAGS+= -Dalloca=__builtin_alloca -CFLAGS+= -I${.CURDIR}/../../common -I${.CURDIR}/../common \ +CFLAGS+= -I${.CURDIR}/../../ficl -I${.CURDIR}/../../ficl/i386 \ + -I${.CURDIR}/../../common -I${.CURDIR}/../common \ -I${.CURDIR}/../btx/lib \ -I${.CURDIR}/../../../contrib/dev/acpica/include \ -I${.CURDIR}/../../.. -I. Modified: head/sys/boot/i386/libi386/biospci.c ============================================================================== --- head/sys/boot/i386/libi386/biospci.c Fri Oct 14 16:23:05 2016 (r307323) +++ head/sys/boot/i386/libi386/biospci.c Fri Oct 14 16:23:12 2016 (r307324) @@ -1,5 +1,6 @@ /*- * Copyright (c) 1998 Michael Smith + * Copyright (c) 2016 Netflix, Inc * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -37,6 +38,7 @@ __FBSDID("$FreeBSD$"); #include #include #include "libi386.h" +#include "ficl.h" /* * Stupid PCI BIOS interface doesn't let you simply enumerate everything @@ -338,7 +340,7 @@ biospci_find_devclass(uint32_t class, in return (0); } -int +static int biospci_find_device(uint32_t devid, int index, uint32_t *locator) { v86.ctl = V86_FLAGS; @@ -407,7 +409,7 @@ biospci_locator(int8_t bus, uint8_t devi * Counts the number of instances of devid we have in the system, as least as * far as the PCI BIOS is able to tell. */ -int +static int biospci_count_device_type(uint32_t devid) { int i; @@ -426,3 +428,155 @@ biospci_count_device_type(uint32_t devid } return i; } + +/* + * pcibios-device-count (devid -- count) + * + * Returns the PCI BIOS' count of how many devices matching devid are in the system. + * devid is the 32-bit vendor + device. + */ +static void +ficlPciBiosCountDevices(FICL_VM *pVM) +{ + uint32_t devid; + int i; + + devid = stackPopINT(pVM->pStack); + + i = biospci_count_device_type(devid); + + stackPushINT(pVM->pStack, i); +} + +/* + * pcibios-write-config (locator offset width value -- ) + * + * Writes the specified config register. + * Locator is bus << 8 | device << 3 | fuction + * offset is the pci config register + * width is 0 for byte, 1 for word, 2 for dword + * value is the value to write + */ +static void +ficlPciBiosWriteConfig(FICL_VM *pVM) +{ + uint32_t value, width, offset, locator; + + value = stackPopINT(pVM->pStack); + width = stackPopINT(pVM->pStack); + offset = stackPopINT(pVM->pStack); + locator = stackPopINT(pVM->pStack); + + biospci_write_config(locator, offset, width, value); +} + +/* + * pcibios-read-config (locator offset width -- value) + * + * Reads the specified config register. + * Locator is bus << 8 | device << 3 | fuction + * offset is the pci config register + * width is 0 for byte, 1 for word, 2 for dword + * value is the value to read from the register + */ +static void +ficlPciBiosReadConfig(FICL_VM *pVM) +{ + uint32_t value, width, offset, locator; + + width = stackPopINT(pVM->pStack); + offset = stackPopINT(pVM->pStack); + locator = stackPopINT(pVM->pStack); + + biospci_read_config(locator, offset, width, &value); + + stackPushINT(pVM->pStack, value); +} + +/* + * pcibios-find-devclass (class index -- locator) + * + * Finds the index'th instance of class in the pci tree. + * must be an exact match. + * class is the class to search for. + * index 0..N (set to 0, increment until error) + * + * Locator is bus << 8 | device << 3 | fuction (or -1 on error) + */ +static void +ficlPciBiosFindDevclass(FICL_VM *pVM) +{ + uint32_t index, class, locator; + + index = stackPopINT(pVM->pStack); + class = stackPopINT(pVM->pStack); + + if (biospci_find_devclass(class, index, &locator)) + locator = 0xffffffff; + + stackPushINT(pVM->pStack, locator); +} + +/* + * pcibios-find-device(devid index -- locator) + * + * Finds the index'th instance of devid in the pci tree. + * must be an exact match. + * class is the class to search for. + * index 0..N (set to 0, increment until error) + * + * Locator is bus << 8 | device << 3 | fuction (or -1 on error) + */ +static void +ficlPciBiosFindDevice(FICL_VM *pVM) +{ + uint32_t index, devid, locator; + + index = stackPopINT(pVM->pStack); + devid = stackPopINT(pVM->pStack); + + if (biospci_find_device(devid, index, &locator)) + locator = 0xffffffff; + + stackPushINT(pVM->pStack, locator); +} + +/* + * pcibios-find-device(bus device function -- locator) + * + * converts bus, device, function to locator. + * + * Locator is bus << 8 | device << 3 | fuction + */ +static void +ficlPciBiosLocator(FICL_VM *pVM) +{ + uint32_t bus, device, function, locator; + + function = stackPopINT(pVM->pStack); + device = stackPopINT(pVM->pStack); + bus = stackPopINT(pVM->pStack); + + locator = biospci_locator(bus, device, function); + + stackPushINT(pVM->pStack, locator); +} + +/* + * Glue function to add the appropriate forth words to access pci bios + * functionality. + */ +static void ficlCompilePciBios(FICL_SYSTEM *pSys) +{ + FICL_DICT *dp = pSys->dp; + assert (dp); + + dictAppendWord(dp, "pcibios-device-count", ficlPciBiosCountDevices, FW_DEFAULT); + dictAppendWord(dp, "pcibios-read-config", ficlPciBiosReadConfig, FW_DEFAULT); + dictAppendWord(dp, "pcibios-write-config", ficlPciBiosWriteConfig, FW_DEFAULT); + dictAppendWord(dp, "pcibios-find-devclass", ficlPciBiosFindDevclass, FW_DEFAULT); + dictAppendWord(dp, "pcibios-find-device", ficlPciBiosFindDevice, FW_DEFAULT); + dictAppendWord(dp, "pcibios-locator", ficlPciBiosLocator, FW_DEFAULT); +} + +FICL_COMPILE_SET(ficlCompilePciBios); Modified: head/sys/boot/i386/libi386/libi386.h ============================================================================== --- head/sys/boot/i386/libi386/libi386.h Fri Oct 14 16:23:05 2016 (r307323) +++ head/sys/boot/i386/libi386/libi386.h Fri Oct 14 16:23:12 2016 (r307324) @@ -104,12 +104,10 @@ extern uint32_t high_heap_size; /* exte extern vm_offset_t high_heap_base; /* for use as the heap */ void biospci_detect(void); -int biospci_count_device_type(uint32_t devid); -int biospci_find_devclass(uint32_t class, int index, uint32_t *locator); -int biospci_find_device(uint32_t devid, int index, uint32_t *locator); -int biospci_write_config(uint32_t locator, int offset, int width, uint32_t val); -int biospci_read_config(uint32_t locator, int offset, int width, uint32_t *val); +int biospci_find_devclass(uint32_t class, int index, uint32_t *locator); +int biospci_read_config(uint32_t locator, int offset, int width, uint32_t *val); uint32_t biospci_locator(int8_t bus, uint8_t device, uint8_t function); +int biospci_write_config(uint32_t locator, int offset, int width, uint32_t val); void biosacpi_detect(void); Modified: head/sys/boot/mips/beri/loader/loader.ldscript ============================================================================== --- head/sys/boot/mips/beri/loader/loader.ldscript Fri Oct 14 16:23:05 2016 (r307323) +++ head/sys/boot/mips/beri/loader/loader.ldscript Fri Oct 14 16:23:12 2016 (r307324) @@ -65,6 +65,10 @@ SECTIONS __start_set_Xcommand_set = .; KEEP(*(set_Xcommand_set)) __stop_set_Xcommand_set = .; + + __start_set_Xficl_compile_set = .; + KEEP(*(set_Xficl_compile_set)) + __stop_set_Xficl_compile_set = .; } .data ALIGN(0x10): { *(.data*)} .bss ALIGN(0x10): { *(.bss*) } Modified: head/sys/boot/pc98/libpc98/Makefile ============================================================================== --- head/sys/boot/pc98/libpc98/Makefile Fri Oct 14 16:23:05 2016 (r307323) +++ head/sys/boot/pc98/libpc98/Makefile Fri Oct 14 16:23:12 2016 (r307324) @@ -37,7 +37,8 @@ CFLAGS+= -DTERM_EMU # XXX: make alloca() useable CFLAGS+= -Dalloca=__builtin_alloca -CFLAGS+= -I${.CURDIR}/../../common \ +CFLAGS+= -I${.CURDIR}/../../ficl -I${.CURDIR}/../../ficl/i386 \ + -I${.CURDIR}/../../common \ -I${.CURDIR}/../btx/lib \ -I${.CURDIR}/../../i386/libi386 \ -I${.CURDIR}/../../.. -I. From owner-svn-src-all@freebsd.org Fri Oct 14 17:04:08 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D6F39C11ED2; Fri, 14 Oct 2016 17:04:08 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id A748B755; Fri, 14 Oct 2016 17:04:08 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9EH47oh088474; Fri, 14 Oct 2016 17:04:07 GMT (envelope-from emaste@FreeBSD.org) Received: (from emaste@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9EH475B088473; Fri, 14 Oct 2016 17:04:07 GMT (envelope-from emaste@FreeBSD.org) Message-Id: <201610141704.u9EH475B088473@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: emaste set sender to emaste@FreeBSD.org using -f From: Ed Maste Date: Fri, 14 Oct 2016 17:04:07 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307325 - head/lib X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Oct 2016 17:04:08 -0000 Author: emaste Date: Fri Oct 14 17:04:07 2016 New Revision: 307325 URL: https://svnweb.freebsd.org/changeset/base/307325 Log: Simplify logic for libproc and librtld_db in lib/Makefile Modified: head/lib/Makefile Modified: head/lib/Makefile ============================================================================== --- head/lib/Makefile Fri Oct 14 16:23:12 2016 (r307324) +++ head/lib/Makefile Fri Oct 14 17:04:07 2016 (r307325) @@ -166,26 +166,13 @@ SUBDIR.${MK_NIS}+= libypclnt .if ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "amd64" _libvgl= libvgl -_libproc= libproc -_librtld_db= librtld_db .endif .if ${MACHINE_CPUARCH} == "amd64" SUBDIR.${MK_BHYVE}+= libvmmapi .endif -.if ${MACHINE_CPUARCH} == "mips" -_libproc= libproc -_librtld_db= librtld_db -.endif - -.if ${MACHINE_CPUARCH} == "powerpc" -_libproc= libproc -_librtld_db= librtld_db -.endif - -.if ${MACHINE_CPUARCH} == "aarch64" || ${MACHINE_CPUARCH} == "arm" || \ - ${MACHINE_CPUARCH} == "riscv" +.if ${MACHINE_CPUARCH} != "sparc64" _libproc= libproc _librtld_db= librtld_db .endif From owner-svn-src-all@freebsd.org Fri Oct 14 17:10:54 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id ED879C12070; Fri, 14 Oct 2016 17:10:54 +0000 (UTC) (envelope-from ambrisko@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id A87DB993; Fri, 14 Oct 2016 17:10:54 +0000 (UTC) (envelope-from ambrisko@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9EHArFX089413; Fri, 14 Oct 2016 17:10:53 GMT (envelope-from ambrisko@FreeBSD.org) Received: (from ambrisko@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9EHArlL089412; Fri, 14 Oct 2016 17:10:53 GMT (envelope-from ambrisko@FreeBSD.org) Message-Id: <201610141710.u9EHArlL089412@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ambrisko set sender to ambrisko@FreeBSD.org using -f From: Doug Ambrisko Date: Fri, 14 Oct 2016 17:10:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307326 - head/sys/boot/efi/loader X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Oct 2016 17:10:55 -0000 Author: ambrisko Date: Fri Oct 14 17:10:53 2016 New Revision: 307326 URL: https://svnweb.freebsd.org/changeset/base/307326 Log: In UEFI mode expose the SMBIOS anchor base address via kenv so the kernel etc. can find out where the SMBIOS entry point is located. In pure UEFI mode the BIOS is not mapped into the standard address space so the SMBIOS table might not appear between 0xf0000 and 0xfffff. The UEFI environment can report this the location of the anchor. If it is reported then expose it as hint.smbios.0.mem. This can then be used by other tools. However, we should make smbios(4) useful and have it take this value and provide accesor function so ipmi(4) etc. don't have to parse and figure things about the SMBIOS table. I have some simple patches to smbios(4) to expose this address as sysctl and for ipmi(4) to get the base address. However, the real fix is to have ipmi(4) ask smbios(4) for what it wants and have smbios(4) parse it out and return it. This would make smbios(4) useful and reduce duplicated code. If this address doesn't point to the anchor then finding SMBIOS info. will fail as if this didn't exist. So there should be no harm. With this change and the following hack, dmidecode works on a bunch of UEFI machines that I tested: if kenv hint.smbios.0.mem > /dev/null then mkdir -p /sys/firmware/efi mount -t tmpfs -o size=8k tmpfs /sys/firmware/efi echo "SMBIOS=`kenv hint.smbios.0.mem`" > /sys/firmware/efi/systab fi Linux exposes this information via the /sys/firmware/efi/systab file which dmidecode looks at. We should update dmidecode to do this the FreeBSD way when we determine what that is! Reviewed by: jhb Modified: head/sys/boot/efi/loader/main.c Modified: head/sys/boot/efi/loader/main.c ============================================================================== --- head/sys/boot/efi/loader/main.c Fri Oct 14 17:04:07 2016 (r307325) +++ head/sys/boot/efi/loader/main.c Fri Oct 14 17:10:53 2016 (r307326) @@ -235,6 +235,7 @@ main(int argc, CHAR16 *argv[]) uint64_t pool_guid; UINTN k; int has_kbd; + char buf[40]; archsw.arch_autoload = efi_autoload; archsw.arch_getdev = efi_getdev; @@ -447,6 +448,9 @@ main(int argc, CHAR16 *argv[]) for (k = 0; k < ST->NumberOfTableEntries; k++) { guid = &ST->ConfigurationTable[k].VendorGuid; if (!memcmp(guid, &smbios, sizeof(EFI_GUID))) { + snprintf(buf, sizeof(buf), "%p", + ST->ConfigurationTable[k].VendorTable); + setenv("hint.smbios.0.mem", buf, 1); smbios_detect(ST->ConfigurationTable[k].VendorTable); break; } @@ -603,7 +607,8 @@ command_configuration(int argc, char *ar else if (!memcmp(guid, &acpi20, sizeof(EFI_GUID))) printf("ACPI 2.0 Table"); else if (!memcmp(guid, &smbios, sizeof(EFI_GUID))) - printf("SMBIOS Table"); + printf("SMBIOS Table %p", + ST->ConfigurationTable[i].VendorTable); else if (!memcmp(guid, &dxe, sizeof(EFI_GUID))) printf("DXE Table"); else if (!memcmp(guid, &hoblist, sizeof(EFI_GUID))) From owner-svn-src-all@freebsd.org Fri Oct 14 17:16:03 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B7002C12120 for ; Fri, 14 Oct 2016 17:16:03 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: from mail-io0-x236.google.com (mail-io0-x236.google.com [IPv6:2607:f8b0:4001:c06::236]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 7FF68D45 for ; Fri, 14 Oct 2016 17:16:03 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: by mail-io0-x236.google.com with SMTP id r30so127908012ioi.1 for ; Fri, 14 Oct 2016 10:16:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20150623.gappssmtp.com; s=20150623; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=qlpBKLImWdQ+oox1XayuRsswXPtrHZ7z2bRuUr6zV8I=; b=UfS0q14kUFcc6IIFTHCtCsTdDsJuPwVs+P/L3Qu9vyKvIXkUFAOOmRSI3ZTLFIPsnv zthkJEWFk2/MIJP9sEQ9n0JJUkRQsmhlfcpzzb+AvDmJ4zxDrljGFWiicNdFoFQxNT3d rRBLb6OU0l9hzsuWcsNeLrXDnf5X4WGhbdMMoWX50TP+eMdYDCBV2+WZXXwZkja5K+TX OjYhJVRjBiWWjG7sT9YvJD7hV15+BlcItwxaS49mgzeMpPN4pxqylosEymhGSQkTZSOZ JCFd6Tvin1uBtgzuI0QrJsUX+TnZgUQx/+b/Ngv29SW7IEx+vdCmc1SfgWTt2x5fRj+p bRbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=qlpBKLImWdQ+oox1XayuRsswXPtrHZ7z2bRuUr6zV8I=; b=Lg6o3leKyVFxXqZal2hqfYM/dCQ0akKLcpgNETEDD8zz7U8/e0TD77Wrt9yWQrDlDB NgBti+2NPJWAdz04LNwYiUYPj2Tsf0/q19FPIMYnjsq20BIjo1Vtswjs+LWUDBVMP0ma PaYmmQbA3C1RYSuKVuJQtfkCiNx6In6Ljix/hQTMkRFnz6shgoLaZgHpeGlAoSvYL/Wk scLNstcydYRdgNGlxuwec6IcSOq+Xq7A5bzQqI+G0NYYcOtNVA3vmAEMeN2UJryio6M9 QH8MjXQbyoEIlmR2pAukMpCqqsXKVr00Ozp1oDw8N+1L3M6ubRuEpEQ4N1np2Ezbicsv zjBw== X-Gm-Message-State: AA6/9Rm4aTcTqYtyK3ZMrknPX0P9iZj17L00rED/+oyiYa/qtXRmiDSfCm5iuSQIlbTQ7rmE5rZmCBmlaf81lA== X-Received: by 10.107.139.79 with SMTP id n76mr14303401iod.166.1476465362851; Fri, 14 Oct 2016 10:16:02 -0700 (PDT) MIME-Version: 1.0 Sender: wlosh@bsdimp.com Received: by 10.79.77.85 with HTTP; Fri, 14 Oct 2016 10:16:02 -0700 (PDT) X-Originating-IP: [69.53.245.200] In-Reply-To: <201610141710.u9EHArlL089412@repo.freebsd.org> References: <201610141710.u9EHArlL089412@repo.freebsd.org> From: Warner Losh Date: Fri, 14 Oct 2016 11:16:02 -0600 X-Google-Sender-Auth: FpWsXjim2P93vs0DxZi91dZts24 Message-ID: Subject: Re: svn commit: r307326 - head/sys/boot/efi/loader To: Doug Ambrisko Cc: src-committers , "svn-src-all@freebsd.org" , "svn-src-head@freebsd.org" Content-Type: text/plain; charset=UTF-8 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Oct 2016 17:16:03 -0000 Love the functionality, but don't like using the 'hint' namespace for this. Can we change it now before too many things depend on it? We had similar issues in ACPI and moved it to the 'acpi' space. Can we move this to the 'smbios' space please? The reason is that 'hint' is special and sometimes filtered out, so it is a poor choice to export data from the boot loader to the kernel. Warner On Fri, Oct 14, 2016 at 11:10 AM, Doug Ambrisko wrote: > Author: ambrisko > Date: Fri Oct 14 17:10:53 2016 > New Revision: 307326 > URL: https://svnweb.freebsd.org/changeset/base/307326 > > Log: > In UEFI mode expose the SMBIOS anchor base address via kenv so the kernel > etc. can find out where the SMBIOS entry point is located. In pure > UEFI mode the BIOS is not mapped into the standard address space so the > SMBIOS table might not appear between 0xf0000 and 0xfffff. The > UEFI environment can report this the location of the anchor. If it is > reported then expose it as hint.smbios.0.mem. This can then be used > by other tools. However, we should make smbios(4) useful and have it > take this value and provide accesor function so ipmi(4) etc. don't > have to parse and figure things about the SMBIOS table. I have some > simple patches to smbios(4) to expose this address as sysctl and > for ipmi(4) to get the base address. However, the real fix is to > have ipmi(4) ask smbios(4) for what it wants and have smbios(4) > parse it out and return it. This would make smbios(4) useful and reduce > duplicated code. If this address doesn't point to the anchor then > finding SMBIOS info. will fail as if this didn't exist. So there should > be no harm. > > With this change and the following hack, dmidecode works on a bunch of > UEFI machines that I tested: > > if kenv hint.smbios.0.mem > /dev/null > then > mkdir -p /sys/firmware/efi > mount -t tmpfs -o size=8k tmpfs /sys/firmware/efi > echo "SMBIOS=`kenv hint.smbios.0.mem`" > /sys/firmware/efi/systab > fi > > Linux exposes this information via the /sys/firmware/efi/systab file which > dmidecode looks at. We should update dmidecode to do this the FreeBSD > way when we determine what that is! > > Reviewed by: jhb > > Modified: > head/sys/boot/efi/loader/main.c > > Modified: head/sys/boot/efi/loader/main.c > ============================================================================== > --- head/sys/boot/efi/loader/main.c Fri Oct 14 17:04:07 2016 (r307325) > +++ head/sys/boot/efi/loader/main.c Fri Oct 14 17:10:53 2016 (r307326) > @@ -235,6 +235,7 @@ main(int argc, CHAR16 *argv[]) > uint64_t pool_guid; > UINTN k; > int has_kbd; > + char buf[40]; > > archsw.arch_autoload = efi_autoload; > archsw.arch_getdev = efi_getdev; > @@ -447,6 +448,9 @@ main(int argc, CHAR16 *argv[]) > for (k = 0; k < ST->NumberOfTableEntries; k++) { > guid = &ST->ConfigurationTable[k].VendorGuid; > if (!memcmp(guid, &smbios, sizeof(EFI_GUID))) { > + snprintf(buf, sizeof(buf), "%p", > + ST->ConfigurationTable[k].VendorTable); > + setenv("hint.smbios.0.mem", buf, 1); > smbios_detect(ST->ConfigurationTable[k].VendorTable); > break; > } > @@ -603,7 +607,8 @@ command_configuration(int argc, char *ar > else if (!memcmp(guid, &acpi20, sizeof(EFI_GUID))) > printf("ACPI 2.0 Table"); > else if (!memcmp(guid, &smbios, sizeof(EFI_GUID))) > - printf("SMBIOS Table"); > + printf("SMBIOS Table %p", > + ST->ConfigurationTable[i].VendorTable); > else if (!memcmp(guid, &dxe, sizeof(EFI_GUID))) > printf("DXE Table"); > else if (!memcmp(guid, &hoblist, sizeof(EFI_GUID))) > From owner-svn-src-all@freebsd.org Fri Oct 14 17:23:28 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C2A09C12286; Fri, 14 Oct 2016 17:23:28 +0000 (UTC) (envelope-from gonzo@id.bluezbox.com) Received: from id.bluezbox.com (id.bluezbox.com [45.55.20.155]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 8FFDC1B0; Fri, 14 Oct 2016 17:23:28 +0000 (UTC) (envelope-from gonzo@id.bluezbox.com) Received: from [76.102.118.237] (helo=[10.0.1.5]) by id.bluezbox.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.86_2 (FreeBSD)) (envelope-from ) id 1bv6CZ-0005VE-UD; Fri, 14 Oct 2016 10:23:25 -0700 From: Oleksandr Tymoshenko Message-Id: Mime-Version: 1.0 (Mac OS X Mail 10.0 \(3226\)) Subject: Re: svn commit: r307257 - in head/sys: arm/broadcom/bcm2835 arm64/broadcom arm64/broadcom/bcm2837 arm64/conf conf Date: Fri, 14 Oct 2016 10:23:24 -0700 In-Reply-To: <20161014093123.606cb8f3@zapp> Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org To: Andrew Turner References: <201610140337.u9E3baB7077179@repo.freebsd.org> <20161014093123.606cb8f3@zapp> X-Mailer: Apple Mail (2.3226) Sender: gonzo@id.bluezbox.com X-Spam-Level: -- X-Spam-Report: Spam detection software, running on the system "id.bluezbox.com", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see The administrator of that system for details. Content preview: > On Oct 14, 2016, at 1:31 AM, Andrew Turner wrote: > > On Fri, 14 Oct 2016 03:37:36 +0000 (UTC) > Oleksandr Tymoshenko > wrote: > >> Author: gonzo >> Date: Fri Oct 14 03:37:35 2016 >> New Revision: 307257 >> URL: https://svnweb.freebsd.org/changeset/base/307257 >> >> Log: >> Add initial Raspberry Pi 3 support >> >> RPI3 kernel config builds kernel compatible with latest upstream >> device tree and firmware: >> https://github.com/raspberrypi/firmware/tree/master/boot As of today >> it's 597c662a613df1144a6bc43e5f4505d83bd748ca >> Default console is PL01x, so pi3-disable-bt dt overlay should be >> configured in config.txt and stock U-Boot should be patched to use >> proper serial port. >> Yet unsupported: SMP, VCHIQ, RNG driver. RNG requires some work due >> to upstream device tree incompatibility. >> >> Multiple people contributed to this work over time: db@, loos@, >> manu@ >> >> Added: >> head/sys/arm64/broadcom/ >> head/sys/arm64/broadcom/bcm2837/ >> head/sys/arm64/broadcom/bcm2837/files.bcm2837 (contents, props >> changed) head/sys/arm64/conf/RPI3 (contents, props changed) >> Modified: >> head/sys/arm/broadcom/bcm2835/bcm2835_vcbus.h >> head/sys/conf/options.arm64 >> >> Modified: head/sys/arm/broadcom/bcm2835/bcm2835_vcbus.h >> ============================================================================== >> --- head/sys/arm/broadcom/bcm2835/bcm2835_vcbus.h Fri Oct 14 >> 03:32:20 2016 (r307256) +++ >> head/sys/arm/broadcom/bcm2835/bcm2835_vcbus.h Fri Oct 14 >> 03:37:35 2016 (r307257) @@ -37, 7 +37, 7 @@ #define >> BCM2835_VCBUS_IO_BASE 0x7E000000 #define >> BCM2835_VCBUS_SDRAM_UNCACHED 0xC0000000 >> -#ifdef SOC_BCM2836 >> +#if defined(SOC_BCM2836) || defined(SOC_BCM2837) > > You could reverse the logic here to: > #ifdef SOC_BCM2835 > <2835 macros> > #else > > #endif > >> #define BCM2835_ARM_IO_BASE 0x3f000000 >> #define BCM2835_VCBUS_SDRAM_BASE >> BCM2835_VCBUS_SDRAM_UNCACHED #else >> >> Added: [...] Content analysis details: (-2.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP 0.0 HEADER_FROM_DIFFERENT_DOMAINS From and EnvelopeFrom 2nd level mail domains are different -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 0.0 HTML_MESSAGE BODY: HTML included in message Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.23 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Oct 2016 17:23:28 -0000 > On Oct 14, 2016, at 1:31 AM, Andrew Turner = wrote: >=20 > On Fri, 14 Oct 2016 03:37:36 +0000 (UTC) > Oleksandr Tymoshenko > = wrote: >=20 >> Author: gonzo >> Date: Fri Oct 14 03:37:35 2016 >> New Revision: 307257 >> URL: https://svnweb.freebsd.org/changeset/base/307257 >>=20 >> Log: >> Add initial Raspberry Pi 3 support >>=20 >> RPI3 kernel config builds kernel compatible with latest upstream >> device tree and firmware: >> https://github.com/raspberrypi/firmware/tree/master/boot As of today >> it's 597c662a613df1144a6bc43e5f4505d83bd748ca=20 >> Default console is PL01x, so pi3-disable-bt dt overlay should be >> configured in config.txt and stock U-Boot should be patched to use >> proper serial port.=20 >> Yet unsupported: SMP, VCHIQ, RNG driver. RNG requires some work due >> to upstream device tree incompatibility. >>=20 >> Multiple people contributed to this work over time: db@, loos@, >> manu@ >>=20 >> Added: >> head/sys/arm64/broadcom/ >> head/sys/arm64/broadcom/bcm2837/ >> head/sys/arm64/broadcom/bcm2837/files.bcm2837 (contents, props >> changed) head/sys/arm64/conf/RPI3 (contents, props changed) >> Modified: >> head/sys/arm/broadcom/bcm2835/bcm2835_vcbus.h >> head/sys/conf/options.arm64 >>=20 >> Modified: head/sys/arm/broadcom/bcm2835/bcm2835_vcbus.h >> = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D >> --- head/sys/arm/broadcom/bcm2835/bcm2835_vcbus.h Fri Oct 14 >> 03:32:20 2016 (r307256) +++ >> head/sys/arm/broadcom/bcm2835/bcm2835_vcbus.h Fri Oct 14 >> 03:37:35 2016 (r307257) @@ -37,7 +37,7 @@ #define >> BCM2835_VCBUS_IO_BASE 0x7E000000 #define >> BCM2835_VCBUS_SDRAM_UNCACHED 0xC0000000=20 >> -#ifdef SOC_BCM2836 >> +#if defined(SOC_BCM2836) || defined(SOC_BCM2837) >=20 > You could reverse the logic here to: > #ifdef SOC_BCM2835 > <2835 macros> > #else > > #endif >=20 >> #define BCM2835_ARM_IO_BASE 0x3f000000 >> #define BCM2835_VCBUS_SDRAM_BASE >> BCM2835_VCBUS_SDRAM_UNCACHED #else >>=20 >> Added: head/sys/arm64/broadcom/bcm2837/files.bcm2837 >> = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D >> --- /dev/null 00:00:00 1970 (empty, because file is >> newly added) +++ head/sys/arm64/broadcom/bcm2837/files.bcm2837 >> Fri Oct 14 03:37:35 2016 (r307257) @@ -0,0 +1,4 @@ >> +# $FreeBSD$ >> + >> +arm/broadcom/bcm2835/bcm2836.c standard > This should be in files.arm64 and enabled when the SOC_ option is set. >=20 >> +kern/kern_clocksource.c standard > This is already in files.arm64. Thanks, I will fix these.=20 >>=20 >> Added: head/sys/arm64/conf/RPI3 >=20 > Why a new kernel config and not GENERIC? I thought about it. But no SMP support yet. When we have SMP support we = can get rid of RPI3 config.=20 > ... >> Modified: head/sys/conf/options.arm64 >> = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D >> --- head/sys/conf/options.arm64 Fri Oct 14 03:32:20 >> 2016 (r307256) +++ head/sys/conf/options.arm64 Fri Oct >> 14 03:37:35 2016 (r307257) @@ -9,5 +9,6 @@ >> VFP opt_global.h=20 >> # SoC Support >> SOC_ALLWINNER_A64 opt_soc.h >> +SOC_BCM2837 opt_global.h > This should be SOC_BRCM_BCM2837 (or maybe SOC_BRCM_BCM283X) and live = in > opt_soc.h This one to match ARM SOC_XXX pattern. All SOC_ for arm reside in = opt_global, since BCM SoC files are used in ARM and ARM64 files they will need to = include two files to get options from the same category. Probably we should = convert all SOC_XXX opts to opt_soc.h for consistency, but I didn=E2=80=99t want to do this = in this change. =20= From owner-svn-src-all@freebsd.org Fri Oct 14 17:25:30 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id BC596C122FD; Fri, 14 Oct 2016 17:25:30 +0000 (UTC) (envelope-from sbruno@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 9695C3C6; Fri, 14 Oct 2016 17:25:30 +0000 (UTC) (envelope-from sbruno@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9EHPTRP096073; Fri, 14 Oct 2016 17:25:29 GMT (envelope-from sbruno@FreeBSD.org) Received: (from sbruno@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9EHPT5p096069; Fri, 14 Oct 2016 17:25:29 GMT (envelope-from sbruno@FreeBSD.org) Message-Id: <201610141725.u9EHPT5p096069@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sbruno set sender to sbruno@FreeBSD.org using -f From: Sean Bruno Date: Fri, 14 Oct 2016 17:25:29 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307327 - in head: sys/boot/efi/loader/arch/i386 targets/pseudo/userland/misc X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Oct 2016 17:25:30 -0000 Author: sbruno Date: Fri Oct 14 17:25:29 2016 New Revision: 307327 URL: https://svnweb.freebsd.org/changeset/base/307327 Log: Update i386 build of loader.efi (but leave it disabled) so that we at least build it now. Reviewed by: emaste Differential Revision: https://reviews.freebsd.org/D7801 Modified: head/sys/boot/efi/loader/arch/i386/efimd.c head/sys/boot/efi/loader/arch/i386/elf32_freebsd.c head/sys/boot/efi/loader/arch/i386/exec.c head/targets/pseudo/userland/misc/Makefile.depend Modified: head/sys/boot/efi/loader/arch/i386/efimd.c ============================================================================== --- head/sys/boot/efi/loader/arch/i386/efimd.c Fri Oct 14 17:10:53 2016 (r307326) +++ head/sys/boot/efi/loader/arch/i386/efimd.c Fri Oct 14 17:25:29 2016 (r307327) @@ -48,7 +48,10 @@ static EFI_GUID hcdp_guid = HCDP_TABLE_G static UINTN mapkey; -uint64_t +int ldr_bootinfo(struct bootinfo *, uint64_t *); +int ldr_enter(const char *); + +static uint64_t ldr_alloc(vm_offset_t va) { Modified: head/sys/boot/efi/loader/arch/i386/elf32_freebsd.c ============================================================================== --- head/sys/boot/efi/loader/arch/i386/elf32_freebsd.c Fri Oct 14 17:10:53 2016 (r307326) +++ head/sys/boot/efi/loader/arch/i386/elf32_freebsd.c Fri Oct 14 17:25:29 2016 (r307327) @@ -35,12 +35,16 @@ __FBSDID("$FreeBSD$"); #include #include +#include +#include + #include "bootstrap.h" #include "../libi386/libi386.h" #include "../btx/lib/btxv86.h" extern void __exec(caddr_t addr, ...); - +extern int bi_load(char *args, vm_offset_t *modulep, vm_offset_t *kernendp); +extern int ldr_enter(const char *kernel); static int elf32_exec(struct preloaded_file *amp); static int elf32_obj_exec(struct preloaded_file *amp); @@ -72,14 +76,14 @@ elf32_exec(struct preloaded_file *fp) ehdr = (Elf_Ehdr *)&(md->md_data); efi_time_fini(); - err = bi_load(fp->f_args, &boothowto, &bootdev, &bootinfop, &modulep, &kernend); + err = bi_load(fp->f_args, &modulep, &kernend); if (err != 0) { efi_time_init(); return(err); } entry = ehdr->e_entry & 0xffffff; - printf("Start @ 0x%lx ...\n", entry); + printf("Start @ 0x%x ...\n", entry); ldr_enter(fp->f_name); Modified: head/sys/boot/efi/loader/arch/i386/exec.c ============================================================================== --- head/sys/boot/efi/loader/arch/i386/exec.c Fri Oct 14 17:10:53 2016 (r307326) +++ head/sys/boot/efi/loader/arch/i386/exec.c Fri Oct 14 17:25:29 2016 (r307327) @@ -36,6 +36,12 @@ __FBSDID("$FreeBSD$"); uint32_t __base; struct __v86 __v86; +/* XXX - Needed a definition here to implicitly define exit(); do not remove. */ +static void +exit(int x) +{ +} + void __v86int() { Modified: head/targets/pseudo/userland/misc/Makefile.depend ============================================================================== --- head/targets/pseudo/userland/misc/Makefile.depend Fri Oct 14 17:10:53 2016 (r307326) +++ head/targets/pseudo/userland/misc/Makefile.depend Fri Oct 14 17:25:29 2016 (r307327) @@ -77,7 +77,7 @@ DIRDEPS.amd64+= \ DIRDEPS.arm= ${_sys_boot_fdt} ${_sys_boot_efi} DIRDEPS.arm64= ${_sys_boot_fdt} ${_sys_boot_efi} -DIRDEPS.i386= ${DIRDEPS.x86sys} sys/boot/efi/libefi +DIRDEPS.i386= ${DIRDEPS.x86sys} ${_sys_boot_efi} DIRDEPS.powerpc= ${_sys_boot_fdt} sys/boot/libstand32 sys/boot/ofw sys/boot/uboot DIRDEPS.pc98= sys/boot/libstand32 DIRDEPS.sparc64= sys/boot/ofw ${_sys_boot_zfs} From owner-svn-src-all@freebsd.org Fri Oct 14 17:26:12 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 34CA2C1238F; Fri, 14 Oct 2016 17:26:12 +0000 (UTC) (envelope-from rpokala@mac.com) Received: from mr11p00im-asmtp002.me.com (mr11p00im-asmtp002.me.com [17.110.69.253]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 1859F7E2; Fri, 14 Oct 2016 17:26:12 +0000 (UTC) (envelope-from rpokala@mac.com) Received: from process-dkim-sign-daemon.mr11p00im-asmtp002.me.com by mr11p00im-asmtp002.me.com (Oracle Communications Messaging Server 7.0.5.38.0 64bit (built Feb 26 2016)) id <0OF100300S5S3V00@mr11p00im-asmtp002.me.com>; Fri, 14 Oct 2016 17:26:06 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mac.com; s=4d515a; t=1476465966; bh=CLnjgBpsjqQdU2QVw8G04mzbN4t4okiMwl1lQCMbup4=; h=Date:Subject:From:To:Message-id:MIME-version:Content-type; b=sMMjixqVnp3/srRYLs53GdTeqCyg26aff0tvZ/HpjbN3Ntt9uELqZanfTUyZKAdP2 dNptJbBhUw50V3wDhCEnR9rE41RrLGLc/3Nl5GAI2SNtVl1BQ3PO9Zw9edUDag122a M7Ice8psKM3//tCpAoJc+n6qO8wnVl0n6sqwn+Flo6SFdoDkAib6PJ7T7InEmcMe0N n5RSMBnffP1Ofr5oAnkpiUq4TpmTyGSLrJm1dGeZ3ce7rvRk2JvrjheTNjNlJhJv0s e4To3UDCf6c+3VxoB4kD3EI4UUMYSyYXAWDBpDka3KHm14R1zyoh6GHuYeDtd6VqCH s31QLmt4KWpNQ== Received: from [192.168.1.4] (c-67-188-225-23.hsd1.ca.comcast.net [67.188.225.23]) by mr11p00im-asmtp002.me.com (Oracle Communications Messaging Server 7.0.5.38.0 64bit (built Feb 26 2016)) with ESMTPSA id <0OF100DNASFGC910@mr11p00im-asmtp002.me.com>; Fri, 14 Oct 2016 17:26:06 +0000 (GMT) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2016-10-14_08:,, signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 clxscore=1034 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1603290000 definitions=main-1610140311 User-Agent: Microsoft-MacOutlook/f.1b.0.161010 Date: Fri, 14 Oct 2016 10:26:04 -0700 Subject: Re: svn commit: r307326 - head/sys/boot/efi/loader From: Ravi Pokala Sender: "Pokala, Ravi" To: Warner Losh , Doug Ambrisko Cc: src-committers , "svn-src-all@freebsd.org" , "svn-src-head@freebsd.org" Message-id: <1D37BB03-A7B1-443B-B628-E712202D3934@panasas.com> Thread-topic: svn commit: r307326 - head/sys/boot/efi/loader References: <201610141710.u9EHArlL089412@repo.freebsd.org> In-reply-to: MIME-version: 1.0 Content-type: text/plain; charset=UTF-8 Content-transfer-encoding: 7bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Oct 2016 17:26:12 -0000 -----Original Message----- > From: on behalf of Warner Losh > Date: 2016-10-14, Friday at 10:16 > To: Doug Ambrisko > Cc: src-committers , "svn-src-all@freebsd.org" , "svn-src-head@freebsd.org" > Subject: Re: svn commit: r307326 - head/sys/boot/efi/loader > > Love the functionality, Ditto! Thank you Doug! :-) > but don't like using the 'hint' namespace for > this. Can we change it now before too many things depend on it? We had > similar issues in ACPI and moved it to the 'acpi' space. Can we move > this to the 'smbios' space please? > > The reason is that 'hint' is special and sometimes filtered out, so it > is a poor choice to export data from the boot loader to the kernel. Loader already exports a bunch of stuff as "smbios.*" kenv variables. So perhaps "smbios.addr" or somesuch? Thanks, Ravi (rpokala@) > Warner > > On Fri, Oct 14, 2016 at 11:10 AM, Doug Ambrisko wrote: >> Author: ambrisko >> Date: Fri Oct 14 17:10:53 2016 >> New Revision: 307326 >> URL: https://svnweb.freebsd.org/changeset/base/307326 >> >> Log: >> In UEFI mode expose the SMBIOS anchor base address via kenv so the kernel >> etc. can find out where the SMBIOS entry point is located. In pure >> UEFI mode the BIOS is not mapped into the standard address space so the >> SMBIOS table might not appear between 0xf0000 and 0xfffff. The >> UEFI environment can report this the location of the anchor. If it is >> reported then expose it as hint.smbios.0.mem. This can then be used >> by other tools. However, we should make smbios(4) useful and have it >> take this value and provide accesor function so ipmi(4) etc. don't >> have to parse and figure things about the SMBIOS table. I have some >> simple patches to smbios(4) to expose this address as sysctl and >> for ipmi(4) to get the base address. However, the real fix is to >> have ipmi(4) ask smbios(4) for what it wants and have smbios(4) >> parse it out and return it. This would make smbios(4) useful and reduce >> duplicated code. If this address doesn't point to the anchor then >> finding SMBIOS info. will fail as if this didn't exist. So there should >> be no harm. >> >> With this change and the following hack, dmidecode works on a bunch of >> UEFI machines that I tested: >> >> if kenv hint.smbios.0.mem > /dev/null >> then >> mkdir -p /sys/firmware/efi >> mount -t tmpfs -o size=8k tmpfs /sys/firmware/efi >> echo "SMBIOS=`kenv hint.smbios.0.mem`" > /sys/firmware/efi/systab >> fi >> >> Linux exposes this information via the /sys/firmware/efi/systab file which >> dmidecode looks at. We should update dmidecode to do this the FreeBSD >> way when we determine what that is! >> >> Reviewed by: jhb >> >> Modified: >> head/sys/boot/efi/loader/main.c >> >> Modified: head/sys/boot/efi/loader/main.c >> ============================================================================== >> --- head/sys/boot/efi/loader/main.c Fri Oct 14 17:04:07 2016 (r307325) >> +++ head/sys/boot/efi/loader/main.c Fri Oct 14 17:10:53 2016 (r307326) >> @@ -235,6 +235,7 @@ main(int argc, CHAR16 *argv[]) >> uint64_t pool_guid; >> UINTN k; >> int has_kbd; >> + char buf[40]; >> >> archsw.arch_autoload = efi_autoload; >> archsw.arch_getdev = efi_getdev; >> @@ -447,6 +448,9 @@ main(int argc, CHAR16 *argv[]) >> for (k = 0; k < ST->NumberOfTableEntries; k++) { >> guid = &ST->ConfigurationTable[k].VendorGuid; >> if (!memcmp(guid, &smbios, sizeof(EFI_GUID))) { >> + snprintf(buf, sizeof(buf), "%p", >> + ST->ConfigurationTable[k].VendorTable); >> + setenv("hint.smbios.0.mem", buf, 1); >> smbios_detect(ST->ConfigurationTable[k].VendorTable); >> break; >> } >> @@ -603,7 +607,8 @@ command_configuration(int argc, char *ar >> else if (!memcmp(guid, &acpi20, sizeof(EFI_GUID))) >> printf("ACPI 2.0 Table"); >> else if (!memcmp(guid, &smbios, sizeof(EFI_GUID))) >> - printf("SMBIOS Table"); >> + printf("SMBIOS Table %p", >> + ST->ConfigurationTable[i].VendorTable); >> else if (!memcmp(guid, &dxe, sizeof(EFI_GUID))) >> printf("DXE Table"); >> else if (!memcmp(guid, &hoblist, sizeof(EFI_GUID))) >> From owner-svn-src-all@freebsd.org Fri Oct 14 17:26:43 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id CEB7CC123DF; Fri, 14 Oct 2016 17:26:43 +0000 (UTC) (envelope-from gonzo@id.bluezbox.com) Received: from id.bluezbox.com (id.bluezbox.com [45.55.20.155]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id A43C3952; Fri, 14 Oct 2016 17:26:43 +0000 (UTC) (envelope-from gonzo@id.bluezbox.com) Received: from [76.102.118.237] (helo=[10.0.1.5]) by id.bluezbox.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.86_2 (FreeBSD)) (envelope-from ) id 1bv6Fk-0005Vp-PK; Fri, 14 Oct 2016 10:26:41 -0700 Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 10.0 \(3226\)) Subject: Re: svn commit: r307252 - head/sys/arm/broadcom/bcm2835 From: Oleksandr Tymoshenko In-Reply-To: <20161014093726.197f8e05@zapp> Date: Fri, 14 Oct 2016 10:26:41 -0700 Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Content-Transfer-Encoding: quoted-printable Message-Id: References: <201610140300.u9E30r1O061196@repo.freebsd.org> <20161014093726.197f8e05@zapp> To: Andrew Turner X-Mailer: Apple Mail (2.3226) Sender: gonzo@id.bluezbox.com X-Spam-Level: -- X-Spam-Report: Spam detection software, running on the system "id.bluezbox.com", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see The administrator of that system for details. Content preview: > On Oct 14, 2016, at 1:37 AM, Andrew Turner wrote: > > On Fri, 14 Oct 2016 03:00:53 +0000 (UTC) > Oleksandr Tymoshenko wrote: > >> Author: gonzo >> Date: Fri Oct 14 03:00:53 2016 >> New Revision: 307252 >> URL: https://svnweb.freebsd.org/changeset/base/307252 >> >> Log: >> Make bcm2835_machdep.c optional >> >> bcm2835_machdep.c contains only bits enabled by "options PLATFORM", >> this option available only on ARM, not ARM64 >> >> Modified: >> head/sys/arm/broadcom/bcm2835/files.bcm283x >> >> Modified: head/sys/arm/broadcom/bcm2835/files.bcm283x >> ============================================================================== >> --- head/sys/arm/broadcom/bcm2835/files.bcm283x Fri Oct 14 02:58:31 2016 (r307251) >> +++ head/sys/arm/broadcom/bcm2835/files.bcm283x Fri Oct 14 03:00:53 2016 (r307252) >> @@ -9,7 +9,7 @@ arm/broadcom/bcm2835/bcm2835_fbd.c opti >> arm/broadcom/bcm2835/bcm2835_ft5406.c optional evdev bcm2835_ft5406 >> arm/broadcom/bcm2835/bcm2835_gpio.c optional gpio >> arm/broadcom/bcm2835/bcm2835_intr.c standard >> -arm/broadcom/bcm2835/bcm2835_machdep.c standard >> +arm/broadcom/bcm2835/bcm2835_machdep.c optional platform >> arm/broadcom/bcm2835/bcm2835_mbox.c standard >> arm/broadcom/bcm2835/bcm2835_rng.c optional random >> arm/broadcom/bcm2835/bcm2835_sdhci.c optional sdhci >> > > Any of these files you need should be added to files.arm64 being > optional on the appropriate soc_ value. [...] Content analysis details: (-2.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP 0.0 HEADER_FROM_DIFFERENT_DOMAINS From and EnvelopeFrom 2nd level mail domains are different -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Oct 2016 17:26:43 -0000 > On Oct 14, 2016, at 1:37 AM, Andrew Turner = wrote: >=20 > On Fri, 14 Oct 2016 03:00:53 +0000 (UTC) > Oleksandr Tymoshenko wrote: >=20 >> Author: gonzo >> Date: Fri Oct 14 03:00:53 2016 >> New Revision: 307252 >> URL: https://svnweb.freebsd.org/changeset/base/307252 >>=20 >> Log: >> Make bcm2835_machdep.c optional >>=20 >> bcm2835_machdep.c contains only bits enabled by "options PLATFORM", >> this option available only on ARM, not ARM64 >>=20 >> Modified: >> head/sys/arm/broadcom/bcm2835/files.bcm283x >>=20 >> Modified: head/sys/arm/broadcom/bcm2835/files.bcm283x >> = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D >> --- head/sys/arm/broadcom/bcm2835/files.bcm283x Fri Oct 14 = 02:58:31 2016 (r307251) >> +++ head/sys/arm/broadcom/bcm2835/files.bcm283x Fri Oct 14 = 03:00:53 2016 (r307252) >> @@ -9,7 +9,7 @@ arm/broadcom/bcm2835/bcm2835_fbd.c opti >> arm/broadcom/bcm2835/bcm2835_ft5406.c optional evdev = bcm2835_ft5406 >> arm/broadcom/bcm2835/bcm2835_gpio.c optional gpio >> arm/broadcom/bcm2835/bcm2835_intr.c standard >> -arm/broadcom/bcm2835/bcm2835_machdep.c standard >> +arm/broadcom/bcm2835/bcm2835_machdep.c optional = platform >> arm/broadcom/bcm2835/bcm2835_mbox.c standard >> arm/broadcom/bcm2835/bcm2835_rng.c optional random >> arm/broadcom/bcm2835/bcm2835_sdhci.c optional sdhci >>=20 >=20 > Any of these files you need should be added to files.arm64 being > optional on the appropriate soc_ value. I don=E2=80=99t quite follow. These files are shared between ARM and = ARM64 port, does that mean they should be in both files.arm64 and files.arm? Or in files.arm64 and files.bcm283x? From owner-svn-src-all@freebsd.org Fri Oct 14 17:27:11 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id CBB4EC12430; Fri, 14 Oct 2016 17:27:11 +0000 (UTC) (envelope-from ambrisko@ambrisko.com) Received: from mail.ambrisko.com (mail.ambrisko.com [70.91.206.90]) by mx1.freebsd.org (Postfix) with ESMTP id AA6EBAC7; Fri, 14 Oct 2016 17:27:11 +0000 (UTC) (envelope-from ambrisko@ambrisko.com) X-Ambrisko-Me: Yes Received: from server2.ambrisko.com (HELO internal.ambrisko.com) ([192.168.1.2]) by ironport.ambrisko.com with ESMTP; 14 Oct 2016 10:40:04 -0700 Received: from ambrisko.com (localhost [127.0.0.1]) by internal.ambrisko.com (8.15.2/8.14.4) with ESMTP id u9EHR5eT066494; Fri, 14 Oct 2016 10:27:05 -0700 (PDT) (envelope-from ambrisko@ambrisko.com) Received: (from ambrisko@localhost) by ambrisko.com (8.15.2/8.14.4/Submit) id u9EHR5sL066493; Fri, 14 Oct 2016 10:27:05 -0700 (PDT) (envelope-from ambrisko) Date: Fri, 14 Oct 2016 10:27:05 -0700 From: Doug Ambrisko To: Warner Losh Cc: Doug Ambrisko , src-committers , "svn-src-all@freebsd.org" , "svn-src-head@freebsd.org" Subject: Re: svn commit: r307326 - head/sys/boot/efi/loader Message-ID: <20161014172705.GA65545@ambrisko.com> References: <201610141710.u9EHArlL089412@repo.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.6.1 (2016-04-27) X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Oct 2016 17:27:11 -0000 On Fri, Oct 14, 2016 at 11:16:02AM -0600, Warner Losh wrote: | Love the functionality, but don't like using the 'hint' namespace for | this. Can we change it now before too many things depend on it? We had | similar issues in ACPI and moved it to the 'acpi' space. Can we move | this to the 'smbios' space please? | | The reason is that 'hint' is special and sometimes filtered out, so it | is a poor choice to export data from the boot loader to the kernel. The reason I picked hint was it could be put /boot/device.hints to make it work as well and that it was a hint. Other standards in the future might use other methods. Looking back over the email I had with John he had suggested hint.smbios.0.anchor to make this look different. This code had been hanging around for so long I forgot about that and we were using hint.smbios.0.mem in our shipping code base. However, I hope that nothing would use this except for smbios(4) and for people to make smbios(4) useful for this info. Thanks, Doug A. | On Fri, Oct 14, 2016 at 11:10 AM, Doug Ambrisko wrote: | > Author: ambrisko | > Date: Fri Oct 14 17:10:53 2016 | > New Revision: 307326 | > URL: https://svnweb.freebsd.org/changeset/base/307326 | > | > Log: | > In UEFI mode expose the SMBIOS anchor base address via kenv so the kernel | > etc. can find out where the SMBIOS entry point is located. In pure | > UEFI mode the BIOS is not mapped into the standard address space so the | > SMBIOS table might not appear between 0xf0000 and 0xfffff. The | > UEFI environment can report this the location of the anchor. If it is | > reported then expose it as hint.smbios.0.mem. This can then be used | > by other tools. However, we should make smbios(4) useful and have it | > take this value and provide accesor function so ipmi(4) etc. don't | > have to parse and figure things about the SMBIOS table. I have some | > simple patches to smbios(4) to expose this address as sysctl and | > for ipmi(4) to get the base address. However, the real fix is to | > have ipmi(4) ask smbios(4) for what it wants and have smbios(4) | > parse it out and return it. This would make smbios(4) useful and reduce | > duplicated code. If this address doesn't point to the anchor then | > finding SMBIOS info. will fail as if this didn't exist. So there should | > be no harm. | > | > With this change and the following hack, dmidecode works on a bunch of | > UEFI machines that I tested: | > | > if kenv hint.smbios.0.mem > /dev/null | > then | > mkdir -p /sys/firmware/efi | > mount -t tmpfs -o size=8k tmpfs /sys/firmware/efi | > echo "SMBIOS=`kenv hint.smbios.0.mem`" > /sys/firmware/efi/systab | > fi | > | > Linux exposes this information via the /sys/firmware/efi/systab file which | > dmidecode looks at. We should update dmidecode to do this the FreeBSD | > way when we determine what that is! | > | > Reviewed by: jhb | > | > Modified: | > head/sys/boot/efi/loader/main.c | > | > Modified: head/sys/boot/efi/loader/main.c | > ============================================================================== | > --- head/sys/boot/efi/loader/main.c Fri Oct 14 17:04:07 2016 (r307325) | > +++ head/sys/boot/efi/loader/main.c Fri Oct 14 17:10:53 2016 (r307326) | > @@ -235,6 +235,7 @@ main(int argc, CHAR16 *argv[]) | > uint64_t pool_guid; | > UINTN k; | > int has_kbd; | > + char buf[40]; | > | > archsw.arch_autoload = efi_autoload; | > archsw.arch_getdev = efi_getdev; | > @@ -447,6 +448,9 @@ main(int argc, CHAR16 *argv[]) | > for (k = 0; k < ST->NumberOfTableEntries; k++) { | > guid = &ST->ConfigurationTable[k].VendorGuid; | > if (!memcmp(guid, &smbios, sizeof(EFI_GUID))) { | > + snprintf(buf, sizeof(buf), "%p", | > + ST->ConfigurationTable[k].VendorTable); | > + setenv("hint.smbios.0.mem", buf, 1); | > smbios_detect(ST->ConfigurationTable[k].VendorTable); | > break; | > } | > @@ -603,7 +607,8 @@ command_configuration(int argc, char *ar | > else if (!memcmp(guid, &acpi20, sizeof(EFI_GUID))) | > printf("ACPI 2.0 Table"); | > else if (!memcmp(guid, &smbios, sizeof(EFI_GUID))) | > - printf("SMBIOS Table"); | > + printf("SMBIOS Table %p", | > + ST->ConfigurationTable[i].VendorTable); | > else if (!memcmp(guid, &dxe, sizeof(EFI_GUID))) | > printf("DXE Table"); | > else if (!memcmp(guid, &hoblist, sizeof(EFI_GUID))) | > From owner-svn-src-all@freebsd.org Fri Oct 14 17:33:33 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id DD927C1263C; Fri, 14 Oct 2016 17:33:33 +0000 (UTC) (envelope-from rpokala@mac.com) Received: from mr11p00im-asmtp004.me.com (mr11p00im-asmtp004.me.com [17.110.69.135]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id C0268EDF; Fri, 14 Oct 2016 17:33:33 +0000 (UTC) (envelope-from rpokala@mac.com) Received: from process-dkim-sign-daemon.mr11p00im-asmtp004.me.com by mr11p00im-asmtp004.me.com (Oracle Communications Messaging Server 7.0.5.38.0 64bit (built Feb 26 2016)) id <0OF100G00SACXS00@mr11p00im-asmtp004.me.com>; Fri, 14 Oct 2016 17:33:17 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mac.com; s=4d515a; t=1476466397; bh=zvPoYPQq03zjqodIMcPo2HdMU/Juo2b/Cju/W+4Sqdk=; h=Date:Subject:From:To:Message-id:MIME-version:Content-type; b=qYoARebOuSTQ3uZdaNPXAAO2vd4EzsG2AqZDPZ/ANbrUA1pesaRid5rs1xGjfdUZI vZ/4VDjD/koyLWc3Avgh+N0cjjwuxrkEobcvF2rMegLBUf1I8YdQEDInABVkyov+BH 3nQkXZJYx44y5O4Ecg2i+Ot/o4NkMeHt1huUt3Ta9xWS1oDE4xxnxv9nLi1fMiz+fg gTDxCMbeqBrE40WDsMNyY0q7dSI1smYCERZ4Yu90QgCDWLXKPbhXruL4vQ5q7c6ghF Kh202gJUduQJbMRw4dtq4zc9kqFUoYzm3Gu8j7fmVR8Zw97aAyM8hju0hETuBdIvTl jQFgNTThcLq+A== Received: from [192.168.1.4] (c-67-188-225-23.hsd1.ca.comcast.net [67.188.225.23]) by mr11p00im-asmtp004.me.com (Oracle Communications Messaging Server 7.0.5.38.0 64bit (built Feb 26 2016)) with ESMTPSA id <0OF1004J0SRGC920@mr11p00im-asmtp004.me.com>; Fri, 14 Oct 2016 17:33:17 +0000 (GMT) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2016-10-14_08:,, signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 clxscore=1034 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1603290000 definitions=main-1610140313 User-Agent: Microsoft-MacOutlook/f.1b.0.161010 Date: Fri, 14 Oct 2016 10:33:15 -0700 Subject: Re: svn commit: r307326 - head/sys/boot/efi/loader From: Ravi Pokala Sender: "Pokala, Ravi" To: Doug Ambrisko , Warner Losh Cc: Doug Ambrisko , src-committers , "svn-src-all@freebsd.org" , "svn-src-head@freebsd.org" Message-id: <3FF8A9D8-0C8A-4033-A7FC-8B64E9AB025F@panasas.com> Thread-topic: svn commit: r307326 - head/sys/boot/efi/loader References: <201610141710.u9EHArlL089412@repo.freebsd.org> <20161014172705.GA65545@ambrisko.com> In-reply-to: <20161014172705.GA65545@ambrisko.com> MIME-version: 1.0 Content-type: text/plain; charset=UTF-8 Content-transfer-encoding: 7bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Oct 2016 17:33:34 -0000 -----Original Message----- > From: on behalf of Doug Ambrisko > Date: 2016-10-14, Friday at 10:27 > To: Warner Losh > Cc: Doug Ambrisko , src-committers , "svn-src-all@freebsd.org" , "svn-src-head@freebsd.org" > Subject: Re: svn commit: r307326 - head/sys/boot/efi/loader > > On Fri, Oct 14, 2016 at 11:16:02AM -0600, Warner Losh wrote: > | Love the functionality, but don't like using the 'hint' namespace for > | this. Can we change it now before too many things depend on it? We had > | similar issues in ACPI and moved it to the 'acpi' space. Can we move > | this to the 'smbios' space please? > | > | The reason is that 'hint' is special and sometimes filtered out, so it > | is a poor choice to export data from the boot loader to the kernel. > > The reason I picked hint was it could be put /boot/device.hints > to make it work as well and that it was a hint. Other standards in the > future might use other methods. Looking back over the email I had > with John he had suggested hint.smbios.0.anchor to make this look > different. This code had been hanging around for so long I forgot > about that and we were using hint.smbios.0.mem in our shipping code base. > > However, I hope that nothing would use this except for smbios(4) and > for people to make smbios(4) useful for this info. Doug's looking at me when he says that. :-) We talked about this last night at BAFUG; right now, even if smbios(4) is able to find the SMBIOS info -- it currently only looks at the aforementioned 0xf0000 - 0xfffff range, so it can't find it on UEFI -- smbios(4) doesn't actually provide any interface for that information. Doug and I have talked about making smbios(4) useful, by parsing the data and providing KPIs and APIs, for years now; I think I'll *finally* have the time and motivation to do so "soon". -Ravi (rpokala@) > Thanks, > > Doug A. From owner-svn-src-all@freebsd.org Fri Oct 14 17:40:49 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 71538C127E2; Fri, 14 Oct 2016 17:40:49 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4320912A9; Fri, 14 Oct 2016 17:40:49 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9EHemo6002882; Fri, 14 Oct 2016 17:40:48 GMT (envelope-from gonzo@FreeBSD.org) Received: (from gonzo@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9EHemIk002881; Fri, 14 Oct 2016 17:40:48 GMT (envelope-from gonzo@FreeBSD.org) Message-Id: <201610141740.u9EHemIk002881@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: gonzo set sender to gonzo@FreeBSD.org using -f From: Oleksandr Tymoshenko Date: Fri, 14 Oct 2016 17:40:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307328 - head/sys/arm64/broadcom/bcm2837 X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Oct 2016 17:40:49 -0000 Author: gonzo Date: Fri Oct 14 17:40:48 2016 New Revision: 307328 URL: https://svnweb.freebsd.org/changeset/base/307328 Log: Remove redundant kern_clocksource.c. It is already in conf/files.arm64 Reported by: andrew Modified: head/sys/arm64/broadcom/bcm2837/files.bcm2837 Modified: head/sys/arm64/broadcom/bcm2837/files.bcm2837 ============================================================================== --- head/sys/arm64/broadcom/bcm2837/files.bcm2837 Fri Oct 14 17:25:29 2016 (r307327) +++ head/sys/arm64/broadcom/bcm2837/files.bcm2837 Fri Oct 14 17:40:48 2016 (r307328) @@ -1,4 +1,3 @@ # $FreeBSD$ arm/broadcom/bcm2835/bcm2836.c standard -kern/kern_clocksource.c standard From owner-svn-src-all@freebsd.org Fri Oct 14 17:43:41 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 7EC3FC12955; Fri, 14 Oct 2016 17:43:41 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4ADE117A6; Fri, 14 Oct 2016 17:43:41 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9EHhe7x003748; Fri, 14 Oct 2016 17:43:40 GMT (envelope-from emaste@FreeBSD.org) Received: (from emaste@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9EHhetk003745; Fri, 14 Oct 2016 17:43:40 GMT (envelope-from emaste@FreeBSD.org) Message-Id: <201610141743.u9EHhetk003745@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: emaste set sender to emaste@FreeBSD.org using -f From: Ed Maste Date: Fri, 14 Oct 2016 17:43:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-releng@freebsd.org Subject: svn commit: r307329 - releng/10.3/contrib/libarchive/libarchive/test X-SVN-Group: releng MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Oct 2016 17:43:41 -0000 Author: emaste Date: Fri Oct 14 17:43:39 2016 New Revision: 307329 URL: https://svnweb.freebsd.org/changeset/base/307329 Log: Remove duplicate file content from patch misapplication in r306941 The three files affected were tests and aren't normally built so this had no user-facing effect in the normal case. Approved by: so Modified: releng/10.3/contrib/libarchive/libarchive/test/test_write_disk_secure744.c releng/10.3/contrib/libarchive/libarchive/test/test_write_disk_secure745.c releng/10.3/contrib/libarchive/libarchive/test/test_write_disk_secure746.c Modified: releng/10.3/contrib/libarchive/libarchive/test/test_write_disk_secure744.c ============================================================================== --- releng/10.3/contrib/libarchive/libarchive/test/test_write_disk_secure744.c Fri Oct 14 17:40:48 2016 (r307328) +++ releng/10.3/contrib/libarchive/libarchive/test/test_write_disk_secure744.c Fri Oct 14 17:43:39 2016 (r307329) @@ -93,98 +93,3 @@ DEFINE_TEST(test_write_disk_secure744) free(buff); #endif } -/*- - * Copyright (c) 2003-2007,2016 Tim Kientzle - * 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(S) ``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(S) BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#include "test.h" -__FBSDID("$FreeBSD$"); - -#define UMASK 022 - -/* - * Github Issue #744 describes a bug in the sandboxing code that - * causes very long pathnames to not get checked for symlinks. - */ - -DEFINE_TEST(test_write_disk_secure744) -{ -#if defined(_WIN32) && !defined(__CYGWIN__) - skipping("archive_write_disk security checks not supported on Windows"); -#else - struct archive *a; - struct archive_entry *ae; - size_t buff_size = 8192; - char *buff = malloc(buff_size); - char *p = buff; - int n = 0; - int t; - - assert(buff != NULL); - - /* Start with a known umask. */ - assertUmask(UMASK); - - /* Create an archive_write_disk object. */ - assert((a = archive_write_disk_new()) != NULL); - archive_write_disk_set_options(a, ARCHIVE_EXTRACT_SECURE_SYMLINKS); - - while (p + 500 < buff + buff_size) { - memset(p, 'x', 100); - p += 100; - p[0] = '\0'; - - buff[0] = ((n / 1000) % 10) + '0'; - buff[1] = ((n / 100) % 10)+ '0'; - buff[2] = ((n / 10) % 10)+ '0'; - buff[3] = ((n / 1) % 10)+ '0'; - buff[4] = '_'; - ++n; - - /* Create a symlink pointing to the testworkdir */ - assert((ae = archive_entry_new()) != NULL); - archive_entry_copy_pathname(ae, buff); - archive_entry_set_mode(ae, S_IFREG | 0777); - archive_entry_copy_symlink(ae, testworkdir); - assertEqualIntA(a, ARCHIVE_OK, archive_write_header(a, ae)); - archive_entry_free(ae); - - *p++ = '/'; - sprintf(p, "target%d", n); - - /* Try to create a file through the symlink, should fail. */ - assert((ae = archive_entry_new()) != NULL); - archive_entry_copy_pathname(ae, buff); - archive_entry_set_mode(ae, S_IFDIR | 0777); - - t = archive_write_header(a, ae); - archive_entry_free(ae); - failure("Attempt to create target%d via %d-character symlink should have failed", n, (int)strlen(buff)); - if(!assertEqualInt(ARCHIVE_FAILED, t)) { - break; - } - } - archive_free(a); - free(buff); -#endif -} Modified: releng/10.3/contrib/libarchive/libarchive/test/test_write_disk_secure745.c ============================================================================== --- releng/10.3/contrib/libarchive/libarchive/test/test_write_disk_secure745.c Fri Oct 14 17:40:48 2016 (r307328) +++ releng/10.3/contrib/libarchive/libarchive/test/test_write_disk_secure745.c Fri Oct 14 17:43:39 2016 (r307329) @@ -77,82 +77,3 @@ DEFINE_TEST(test_write_disk_secure745) archive_write_free(a); #endif } -/*- - * Copyright (c) 2003-2007,2016 Tim Kientzle - * 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(S) ``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(S) BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#include "test.h" -__FBSDID("$FreeBSD$"); - -#define UMASK 022 - -/* - * Github Issue #745 describes a bug in the sandboxing code that - * allows one to use a symlink to edit the permissions on a file or - * directory outside of the sandbox. - */ - -DEFINE_TEST(test_write_disk_secure745) -{ -#if defined(_WIN32) && !defined(__CYGWIN__) - skipping("archive_write_disk security checks not supported on Windows"); -#else - struct archive *a; - struct archive_entry *ae; - - /* Start with a known umask. */ - assertUmask(UMASK); - - /* Create an archive_write_disk object. */ - assert((a = archive_write_disk_new()) != NULL); - archive_write_disk_set_options(a, ARCHIVE_EXTRACT_SECURE_SYMLINKS); - - /* The target dir: The one we're going to try to change permission on */ - assertMakeDir("target", 0700); - - /* The sandbox dir we're going to run inside of. */ - assertMakeDir("sandbox", 0700); - assertChdir("sandbox"); - - /* Create a symlink pointing to the target directory */ - assert((ae = archive_entry_new()) != NULL); - archive_entry_copy_pathname(ae, "sym"); - archive_entry_set_mode(ae, AE_IFLNK | 0777); - archive_entry_copy_symlink(ae, "../target"); - assert(0 == archive_write_header(a, ae)); - archive_entry_free(ae); - - /* Try to alter the target dir through the symlink; this should fail. */ - assert((ae = archive_entry_new()) != NULL); - archive_entry_copy_pathname(ae, "sym"); - archive_entry_set_mode(ae, S_IFDIR | 0777); - assert(0 == archive_write_header(a, ae)); - archive_entry_free(ae); - - /* Permission of target dir should not have changed. */ - assertFileMode("../target", 0700); - - assert(0 == archive_write_close(a)); - archive_write_free(a); -#endif -} Modified: releng/10.3/contrib/libarchive/libarchive/test/test_write_disk_secure746.c ============================================================================== --- releng/10.3/contrib/libarchive/libarchive/test/test_write_disk_secure746.c Fri Oct 14 17:40:48 2016 (r307328) +++ releng/10.3/contrib/libarchive/libarchive/test/test_write_disk_secure746.c Fri Oct 14 17:43:39 2016 (r307329) @@ -127,132 +127,3 @@ DEFINE_TEST(test_write_disk_secure746b) archive_write_free(a); #endif } -/*- - * Copyright (c) 2003-2007,2016 Tim Kientzle - * 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(S) ``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(S) BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#include "test.h" -__FBSDID("$FreeBSD$"); - -#define UMASK 022 - -/* - * Github Issue #746 describes a problem in which hardlink targets are - * not adequately checked and can be used to modify entries outside of - * the sandbox. - */ - -/* - * Verify that ARCHIVE_EXTRACT_SECURE_NODOTDOT disallows '..' in hardlink - * targets. - */ -DEFINE_TEST(test_write_disk_secure746a) -{ -#if defined(_WIN32) && !defined(__CYGWIN__) - skipping("archive_write_disk security checks not supported on Windows"); -#else - struct archive *a; - struct archive_entry *ae; - - /* Start with a known umask. */ - assertUmask(UMASK); - - /* The target directory we're going to try to affect. */ - assertMakeDir("target", 0700); - assertMakeFile("target/foo", 0700, "unmodified"); - - /* The sandbox dir we're going to work within. */ - assertMakeDir("sandbox", 0700); - assertChdir("sandbox"); - - /* Create an archive_write_disk object. */ - assert((a = archive_write_disk_new()) != NULL); - archive_write_disk_set_options(a, ARCHIVE_EXTRACT_SECURE_NODOTDOT); - - /* Attempt to hardlink to the target directory. */ - assert((ae = archive_entry_new()) != NULL); - archive_entry_copy_pathname(ae, "bar"); - archive_entry_set_mode(ae, AE_IFREG | 0777); - archive_entry_set_size(ae, 8); - archive_entry_copy_hardlink(ae, "../target/foo"); - assertEqualInt(ARCHIVE_FAILED, archive_write_header(a, ae)); - assertEqualInt(ARCHIVE_FATAL, archive_write_data(a, "modified", 8)); - archive_entry_free(ae); - - /* Verify that target file contents are unchanged. */ - assertTextFileContents("unmodified", "../target/foo"); -#endif -} - -/* - * Verify that ARCHIVE_EXTRACT_SECURE_NOSYMLINK disallows symlinks in hardlink - * targets. - */ -DEFINE_TEST(test_write_disk_secure746b) -{ -#if defined(_WIN32) && !defined(__CYGWIN__) - skipping("archive_write_disk security checks not supported on Windows"); -#else - struct archive *a; - struct archive_entry *ae; - - /* Start with a known umask. */ - assertUmask(UMASK); - - /* The target directory we're going to try to affect. */ - assertMakeDir("target", 0700); - assertMakeFile("target/foo", 0700, "unmodified"); - - /* The sandbox dir we're going to work within. */ - assertMakeDir("sandbox", 0700); - assertChdir("sandbox"); - - /* Create an archive_write_disk object. */ - assert((a = archive_write_disk_new()) != NULL); - archive_write_disk_set_options(a, ARCHIVE_EXTRACT_SECURE_SYMLINKS); - - /* Create a symlink to the target directory. */ - assert((ae = archive_entry_new()) != NULL); - archive_entry_copy_pathname(ae, "symlink"); - archive_entry_set_mode(ae, AE_IFLNK | 0777); - archive_entry_copy_symlink(ae, "../target"); - assertEqualIntA(a, ARCHIVE_OK, archive_write_header(a, ae)); - archive_entry_free(ae); - - /* Attempt to hardlink to the target directory via the symlink. */ - assert((ae = archive_entry_new()) != NULL); - archive_entry_copy_pathname(ae, "bar"); - archive_entry_set_mode(ae, AE_IFREG | 0777); - archive_entry_set_size(ae, 8); - archive_entry_copy_hardlink(ae, "symlink/foo"); - assertEqualIntA(a, ARCHIVE_FAILED, archive_write_header(a, ae)); - assertEqualIntA(a, ARCHIVE_FATAL, archive_write_data(a, "modified", 8)); - archive_entry_free(ae); - - /* Verify that target file contents are unchanged. */ - assertTextFileContents("unmodified", "../target/foo"); - - assertEqualIntA(a, ARCHIVE_FATAL, archive_write_close(a)); - archive_write_free(a); -#endif -} From owner-svn-src-all@freebsd.org Fri Oct 14 17:55:43 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 6DC51C12BE4; Fri, 14 Oct 2016 17:55:43 +0000 (UTC) (envelope-from ambrisko@ambrisko.com) Received: from mail.ambrisko.com (mail.ambrisko.com [70.91.206.90]) by mx1.freebsd.org (Postfix) with ESMTP id 4041A1D21; Fri, 14 Oct 2016 17:55:43 +0000 (UTC) (envelope-from ambrisko@ambrisko.com) X-Ambrisko-Me: Yes Received: from server2.ambrisko.com (HELO internal.ambrisko.com) ([192.168.1.2]) by ironport.ambrisko.com with ESMTP; 14 Oct 2016 11:08:42 -0700 Received: from ambrisko.com (localhost [127.0.0.1]) by internal.ambrisko.com (8.15.2/8.14.4) with ESMTP id u9EHtgG4069054; Fri, 14 Oct 2016 10:55:42 -0700 (PDT) (envelope-from ambrisko@ambrisko.com) Received: (from ambrisko@localhost) by ambrisko.com (8.15.2/8.14.4/Submit) id u9EHtgtb069053; Fri, 14 Oct 2016 10:55:42 -0700 (PDT) (envelope-from ambrisko) Date: Fri, 14 Oct 2016 10:55:42 -0700 From: Doug Ambrisko To: Ravi Pokala Cc: Warner Losh , Doug Ambrisko , src-committers , "svn-src-all@freebsd.org" , "svn-src-head@freebsd.org" Subject: Re: svn commit: r307326 - head/sys/boot/efi/loader Message-ID: <20161014175542.GB65545@ambrisko.com> References: <201610141710.u9EHArlL089412@repo.freebsd.org> <20161014172705.GA65545@ambrisko.com> <3FF8A9D8-0C8A-4033-A7FC-8B64E9AB025F@panasas.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <3FF8A9D8-0C8A-4033-A7FC-8B64E9AB025F@panasas.com> User-Agent: Mutt/1.6.1 (2016-04-27) X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Oct 2016 17:55:43 -0000 On Fri, Oct 14, 2016 at 10:33:15AM -0700, Ravi Pokala wrote: | -----Original Message----- | > From: on behalf of Doug Ambrisko | > Date: 2016-10-14, Friday at 10:27 | > To: Warner Losh | > Cc: Doug Ambrisko , src-committers , "svn-src-all@freebsd.org" , "svn-src-head@freebsd.org" | > Subject: Re: svn commit: r307326 - head/sys/boot/efi/loader | > | > On Fri, Oct 14, 2016 at 11:16:02AM -0600, Warner Losh wrote: | > | Love the functionality, but don't like using the 'hint' namespace for | > | this. Can we change it now before too many things depend on it? We had | > | similar issues in ACPI and moved it to the 'acpi' space. Can we move | > | this to the 'smbios' space please? | > | | > | The reason is that 'hint' is special and sometimes filtered out, so it | > | is a poor choice to export data from the boot loader to the kernel. | > | > The reason I picked hint was it could be put /boot/device.hints | > to make it work as well and that it was a hint. Other standards in the | > future might use other methods. Looking back over the email I had | > with John he had suggested hint.smbios.0.anchor to make this look | > different. This code had been hanging around for so long I forgot | > about that and we were using hint.smbios.0.mem in our shipping code base. | > | > However, I hope that nothing would use this except for smbios(4) and | > for people to make smbios(4) useful for this info. | | Doug's looking at me when he says that. :-) | | We talked about this last night at BAFUG; right now, even if smbios(4) | is able to find the SMBIOS info -- it currently only looks at the | aforementioned 0xf0000 - 0xfffff range, so it can't find it on UEFI -- | smbios(4) doesn't actually provide any interface for that information. | Doug and I have talked about making smbios(4) useful, by parsing the | data and providing KPIs and APIs, for years now; I think I'll *finally* | have the time and motivation to do so "soon". I've actually talked to a few people. However, your the first to step up. This needs to be designed and will take some time and review. I would hope that except for smbios(4), nothing else would use this kenv but there is nothing to prevent that :-( I could name it super_secret_dont_use. BTW, to get you started this patch prevents smbios(4) from blowing chunks when it gets a anchor in high memory and works on legacy machines. --- /sys/x86/bios/smbios.c 2013-10-01 14:28:25.000000000 -0700 +++ ./smbios.c 2016-04-11 11:58:03.234969000 -0700 @@ -38,6 +38,7 @@ __FBSDID("$FreeBSD: release/9.2.0/sys/x8 #include #include #include +#include #include #include @@ -59,7 +60,7 @@ struct smbios_softc { }; #define RES2EPS(res) ((struct smbios_eps *)rman_get_virtual(res)) -#define ADDR2EPS(addr) ((struct smbios_eps *)BIOS_PADDRTOVADDR(addr)) +#define ADDR2EPS(addr) ((struct smbios_eps *)PHYS_TO_DMAP(addr)) static devclass_t smbios_devclass; @@ -71,19 +72,26 @@ static int smbios_modevent (module_t, in static int smbios_cksum (struct smbios_eps *); +static unsigned long addr; +static SYSCTL_NODE(_hw, OID_AUTO, smbios, CTLFLAG_RD, 0, + "SMBIOS driver parameters"); +SYSCTL_LONG(_hw_smbios, OID_AUTO, mem, CTLFLAG_RW, + &addr, 0, ""); + static void smbios_identify (driver_t *driver, device_t parent) { device_t child; - u_int32_t addr; int length; int rid; if (!device_is_alive(parent)) return; - addr = bios_sigsearch(SMBIOS_START, SMBIOS_SIG, SMBIOS_LEN, - SMBIOS_STEP, SMBIOS_OFF); + if (resource_long_value("smbios", 0, "mem", &addr) != 0 || + addr == 0) + addr = bios_sigsearch(SMBIOS_START, SMBIOS_SIG, SMBIOS_LEN, + SMBIOS_STEP, SMBIOS_OFF); if (addr != 0) { rid = 0; length = ADDR2EPS(addr)->length; Note I don't plan to commit this since it doesn't really do much and we need a lot more. Thanks, Doug A. From owner-svn-src-all@freebsd.org Fri Oct 14 18:25:56 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 223F4C1216E for ; Fri, 14 Oct 2016 18:25:56 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: from mail-io0-x22c.google.com (mail-io0-x22c.google.com [IPv6:2607:f8b0:4001:c06::22c]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id DB130D80 for ; Fri, 14 Oct 2016 18:25:55 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: by mail-io0-x22c.google.com with SMTP id j37so129951360ioo.3 for ; Fri, 14 Oct 2016 11:25:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20150623.gappssmtp.com; s=20150623; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=GZTgEuTVhz29Xz4tjYWUnaBXd62F5LPZdmqJUFRB7oM=; b=DORQZd1zek3nKszWWMWVfuD2sQrT9vgCcSySLsRtto4OJZbuO+50HiV/FLMb0Ec72C mAZfAdleP4lVuZA29kOA/VSDrp4Y91iY8pRZj0l2TiczinuP3kLraxQiftapHhYubMf9 CdG920SaIsa0v6rjkvjpA2J2AVaIurgCIz8X0GrgbvI67yrATCA3FUcJfDCjfeF9ik/L dJBUYY/DB0iPRQX0x/W2sWOV1m8J0z8jCepLR8/2YiMZXWJz3qD9lXeCouSFxeX9UtT+ xfaM3HLKQJyyODkEA12I4QE6eqiBd/s3GKAwebDYmyIVCC/2GjYSiZxSKY72chDX1Uhu MdKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=GZTgEuTVhz29Xz4tjYWUnaBXd62F5LPZdmqJUFRB7oM=; b=O1GuN9zpmIqwaqK13KHxfa8B1HiJ7CgLTV9eR6cgjVouryzhePHsZal+PcxltD3pWD r1eMry5zCKE1Ca6GFG1SJFjPpC/vXQmgAyQDVMhZzEZYuN8x9FP1gATbXb9d8gxI9+on GDLGgE0cpNoCQFy8o0BZwxkF753d0XpRfBP5ihZ8CBNNMZQamiliBAi7S6Fy+JKjI5A9 nv7Fty+cq+KR0jj1fNYoXacIs84mLnWZr4ABw+Ck2DowGxo/BhFtLWM7McjkQhWFkkQC fjnABcBjB9YSoGpmcefR3DB7yoATkuwMBLSTkPYmzjU9Mmp5841C6Ot/G/TfAjY6IcC8 Q9hw== X-Gm-Message-State: AA6/9Rnh3mimku5/ppE1nCb+cZNW6QZco3yccXGn2mRxQOinjrQVN4GxxRECVpl7jlyn5o+PJcngXR3ywzk/uQ== X-Received: by 10.107.139.79 with SMTP id n76mr14626164iod.166.1476469555278; Fri, 14 Oct 2016 11:25:55 -0700 (PDT) MIME-Version: 1.0 Sender: wlosh@bsdimp.com Received: by 10.79.77.85 with HTTP; Fri, 14 Oct 2016 11:25:54 -0700 (PDT) X-Originating-IP: [2607:fb90:6c81:f6a1:0:22:e381:4d01] Received: by 10.79.77.85 with HTTP; Fri, 14 Oct 2016 11:25:54 -0700 (PDT) In-Reply-To: <20161014175542.GB65545@ambrisko.com> References: <201610141710.u9EHArlL089412@repo.freebsd.org> <20161014172705.GA65545@ambrisko.com> <3FF8A9D8-0C8A-4033-A7FC-8B64E9AB025F@panasas.com> <20161014175542.GB65545@ambrisko.com> From: Warner Losh Date: Fri, 14 Oct 2016 12:25:54 -0600 X-Google-Sender-Auth: V9n-d-WeNwgst20it5x-x-KCAy4 Message-ID: Subject: Re: svn commit: r307326 - head/sys/boot/efi/loader To: Doug Ambrisko Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers , Doug Ambrisko , Ravi Pokala Content-Type: text/plain; charset=UTF-8 X-Content-Filtered-By: Mailman/MimeDel 2.1.23 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Oct 2016 18:25:56 -0000 On Oct 14, 2016 11:55 AM, "Doug Ambrisko" wrote: > > On Fri, Oct 14, 2016 at 10:33:15AM -0700, Ravi Pokala wrote: > | -----Original Message----- > | > From: on behalf of Doug Ambrisko < ambrisko@ambrisko.com> > | > Date: 2016-10-14, Friday at 10:27 > | > To: Warner Losh > | > Cc: Doug Ambrisko , src-committers < src-committers@freebsd.org>, "svn-src-all@freebsd.org" < svn-src-all@freebsd.org>, "svn-src-head@freebsd.org" < svn-src-head@freebsd.org> > | > Subject: Re: svn commit: r307326 - head/sys/boot/efi/loader > | > > | > On Fri, Oct 14, 2016 at 11:16:02AM -0600, Warner Losh wrote: > | > | Love the functionality, but don't like using the 'hint' namespace for > | > | this. Can we change it now before too many things depend on it? We had > | > | similar issues in ACPI and moved it to the 'acpi' space. Can we move > | > | this to the 'smbios' space please? > | > | > | > | The reason is that 'hint' is special and sometimes filtered out, so it > | > | is a poor choice to export data from the boot loader to the kernel. > | > > | > The reason I picked hint was it could be put /boot/device.hints > | > to make it work as well and that it was a hint. Other standards in the > | > future might use other methods. Looking back over the email I had > | > with John he had suggested hint.smbios.0.anchor to make this look > | > different. This code had been hanging around for so long I forgot > | > about that and we were using hint.smbios.0.mem in our shipping code base. > | > > | > However, I hope that nothing would use this except for smbios(4) and > | > for people to make smbios(4) useful for this info. > | > | Doug's looking at me when he says that. :-) > | > | We talked about this last night at BAFUG; right now, even if smbios(4) > | is able to find the SMBIOS info -- it currently only looks at the > | aforementioned 0xf0000 - 0xfffff range, so it can't find it on UEFI -- > | smbios(4) doesn't actually provide any interface for that information. > | Doug and I have talked about making smbios(4) useful, by parsing the > | data and providing KPIs and APIs, for years now; I think I'll *finally* > | have the time and motivation to do so "soon". > > I've actually talked to a few people. However, your the first to > step up. This needs to be designed and will take some time and > review. I would hope that except for smbios(4), nothing else would > use this kenv but there is nothing to prevent that :-( I could name > it super_secret_dont_use. > > BTW, to get you started this patch prevents smbios(4) from blowing chunks > when it gets a anchor in high memory and works on legacy machines. > > --- /sys/x86/bios/smbios.c 2013-10-01 14:28:25.000000000 -0700 > +++ ./smbios.c 2016-04-11 11:58:03.234969000 -0700 > @@ -38,6 +38,7 @@ __FBSDID("$FreeBSD: release/9.2.0/sys/x8 > #include > #include > #include > +#include > > #include > #include > @@ -59,7 +60,7 @@ struct smbios_softc { > }; > > #define RES2EPS(res) ((struct smbios_eps *)rman_get_virtual(res)) > -#define ADDR2EPS(addr) ((struct smbios_eps *)BIOS_PADDRTOVADDR(addr)) > +#define ADDR2EPS(addr) ((struct smbios_eps *)PHYS_TO_DMAP(addr)) > > static devclass_t smbios_devclass; > > @@ -71,19 +72,26 @@ static int smbios_modevent (module_t, in > > static int smbios_cksum (struct smbios_eps *); > > +static unsigned long addr; > +static SYSCTL_NODE(_hw, OID_AUTO, smbios, CTLFLAG_RD, 0, > + "SMBIOS driver parameters"); > +SYSCTL_LONG(_hw_smbios, OID_AUTO, mem, CTLFLAG_RW, > + &addr, 0, ""); > + > static void > smbios_identify (driver_t *driver, device_t parent) > { > device_t child; > - u_int32_t addr; > int length; > int rid; > > if (!device_is_alive(parent)) > return; > > - addr = bios_sigsearch(SMBIOS_START, SMBIOS_SIG, SMBIOS_LEN, > - SMBIOS_STEP, SMBIOS_OFF); > + if (resource_long_value("smbios", 0, "mem", &addr) != 0 || > + addr == 0) > + addr = bios_sigsearch(SMBIOS_START, SMBIOS_SIG, SMBIOS_LEN, > + SMBIOS_STEP, SMBIOS_OFF); > if (addr != 0) { > rid = 0; > length = ADDR2EPS(addr)->length; > > Note I don't plan to commit this since it doesn't really do much and we > need a lot more. I was planning on exporting all smbios stuff via sysctl. You can still put non hints.* in device.hints too. I can rework things a bit to be more complete is you like... Warner From owner-svn-src-all@freebsd.org Fri Oct 14 18:42:31 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id DA90BC12578; Fri, 14 Oct 2016 18:42:31 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id A5C2CA14; Fri, 14 Oct 2016 18:42:31 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9EIgUSU026429; Fri, 14 Oct 2016 18:42:30 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9EIgUvW026428; Fri, 14 Oct 2016 18:42:30 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201610141842.u9EIgUvW026428@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Fri, 14 Oct 2016 18:42:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307330 - stable/11/sys/sys X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Oct 2016 18:42:32 -0000 Author: mav Date: Fri Oct 14 18:42:30 2016 New Revision: 307330 URL: https://svnweb.freebsd.org/changeset/base/307330 Log: Bump __FreeBSD_version for todays ZFS merges. Modified: stable/11/sys/sys/param.h Modified: stable/11/sys/sys/param.h ============================================================================== --- stable/11/sys/sys/param.h Fri Oct 14 17:43:39 2016 (r307329) +++ stable/11/sys/sys/param.h Fri Oct 14 18:42:30 2016 (r307330) @@ -58,7 +58,7 @@ * in the range 5 to 9. */ #undef __FreeBSD_version -#define __FreeBSD_version 1100503 /* Master, propagated to newvers */ +#define __FreeBSD_version 1100504 /* Master, propagated to newvers */ /* * __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD, From owner-svn-src-all@freebsd.org Fri Oct 14 18:43:19 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 38D46C125D8; Fri, 14 Oct 2016 18:43:19 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 0A9E9B89; Fri, 14 Oct 2016 18:43:18 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9EIhI3M026504; Fri, 14 Oct 2016 18:43:18 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9EIhIOc026503; Fri, 14 Oct 2016 18:43:18 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201610141843.u9EIhIOc026503@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Fri, 14 Oct 2016 18:43:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307331 - stable/10/sys/sys X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Oct 2016 18:43:19 -0000 Author: mav Date: Fri Oct 14 18:43:17 2016 New Revision: 307331 URL: https://svnweb.freebsd.org/changeset/base/307331 Log: Bump __FreeBSD_version for todays ZFS merges. Modified: stable/10/sys/sys/param.h Modified: stable/10/sys/sys/param.h ============================================================================== --- stable/10/sys/sys/param.h Fri Oct 14 18:42:30 2016 (r307330) +++ stable/10/sys/sys/param.h Fri Oct 14 18:43:17 2016 (r307331) @@ -58,7 +58,7 @@ * in the range 5 to 9. */ #undef __FreeBSD_version -#define __FreeBSD_version 1003508 /* Master, propagated to newvers */ +#define __FreeBSD_version 1003509 /* Master, propagated to newvers */ /* * __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD, From owner-svn-src-all@freebsd.org Fri Oct 14 18:43:47 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 9B17FC12620; Fri, 14 Oct 2016 18:43:47 +0000 (UTC) (envelope-from ambrisko@ambrisko.com) Received: from mail.ambrisko.com (mail.ambrisko.com [70.91.206.90]) by mx1.freebsd.org (Postfix) with ESMTP id 69FBFCE3; Fri, 14 Oct 2016 18:43:47 +0000 (UTC) (envelope-from ambrisko@ambrisko.com) X-Ambrisko-Me: Yes Received: from server2.ambrisko.com (HELO internal.ambrisko.com) ([192.168.1.2]) by ironport.ambrisko.com with ESMTP; 14 Oct 2016 11:56:45 -0700 Received: from ambrisko.com (localhost [127.0.0.1]) by internal.ambrisko.com (8.15.2/8.14.4) with ESMTP id u9EIhkF4073231; Fri, 14 Oct 2016 11:43:46 -0700 (PDT) (envelope-from ambrisko@ambrisko.com) Received: (from ambrisko@localhost) by ambrisko.com (8.15.2/8.14.4/Submit) id u9EIhktm073230; Fri, 14 Oct 2016 11:43:46 -0700 (PDT) (envelope-from ambrisko) Date: Fri, 14 Oct 2016 11:43:46 -0700 From: Doug Ambrisko To: Warner Losh Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers , Doug Ambrisko , Ravi Pokala Subject: Re: svn commit: r307326 - head/sys/boot/efi/loader Message-ID: <20161014184346.GA71804@ambrisko.com> References: <201610141710.u9EHArlL089412@repo.freebsd.org> <20161014172705.GA65545@ambrisko.com> <3FF8A9D8-0C8A-4033-A7FC-8B64E9AB025F@panasas.com> <20161014175542.GB65545@ambrisko.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.6.1 (2016-04-27) X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Oct 2016 18:43:47 -0000 On Fri, Oct 14, 2016 at 12:25:54PM -0600, Warner Losh wrote: | On Oct 14, 2016 11:55 AM, "Doug Ambrisko" <[1]ambrisko@ambrisko.com> | wrote: | > | > On Fri, Oct 14, 2016 at 10:33:15AM -0700, Ravi Pokala wrote: | > | -----Original Message----- | > | > From: <[2]owner-src-committers@freebsd.org> on behalf of Doug | Ambrisko <[3]ambrisko@ambrisko.com> | > | > Date: 2016-10-14, Friday at 10:27 | > | > To: Warner Losh <[4]imp@bsdimp.com> | > | > Cc: Doug Ambrisko <[5]ambrisko@freebsd.org>, src-committers | <[6]src-committers@freebsd.org>, "[7]svn-src-all@freebsd.org" | <[8]svn-src-all@freebsd.org>, "[9]svn-src-head@freebsd.org" | <[10]svn-src-head@freebsd.org> | > | > Subject: Re: svn commit: r307326 - head/sys/boot/efi/loader | > | > | > | > On Fri, Oct 14, 2016 at 11:16:02AM -0600, Warner Losh wrote: | > | > | Love the functionality, but don't like using the 'hint' | namespace for | > | > | this. Can we change it now before too many things depend on it? | We had | > | > | similar issues in ACPI and moved it to the 'acpi' space. Can we | move | > | > | this to the 'smbios' space please? | > | > | | > | > | The reason is that 'hint' is special and sometimes filtered | out, so it | > | > | is a poor choice to export data from the boot loader to the | kernel. | > | > | > | > The reason I picked hint was it could be put /boot/device.hints | > | > to make it work as well and that it was a hint. Other standards | in the | > | > future might use other methods. Looking back over the email I | had | > | > with John he had suggested hint.smbios.0.anchor to make this look | > | > different. This code had been hanging around for so long I | forgot | > | > about that and we were using hint.smbios.0.mem in our shipping | code base. | > | > | > | > However, I hope that nothing would use this except for smbios(4) | and | > | > for people to make smbios(4) useful for this info. | > | | > | Doug's looking at me when he says that. :-) | > | | > | We talked about this last night at BAFUG; right now, even if | smbios(4) | > | is able to find the SMBIOS info -- it currently only looks at the | > | aforementioned 0xf0000 - 0xfffff range, so it can't find it on UEFI | -- | > | smbios(4) doesn't actually provide any interface for that | information. | > | Doug and I have talked about making smbios(4) useful, by parsing | the | > | data and providing KPIs and APIs, for years now; I think I'll | *finally* | > | have the time and motivation to do so "soon". | > | > I've actually talked to a few people. However, your the first to | > step up. This needs to be designed and will take some time and | > review. I would hope that except for smbios(4), nothing else would | > use this kenv but there is nothing to prevent that :-( I could name | > it super_secret_dont_use. | > | > BTW, to get you started this patch prevents smbios(4) from blowing | chunks | > when it gets a anchor in high memory and works on legacy machines. | > | > --- /sys/x86/bios/smbios.c 2013-10-01 14:28:25.000000000 -0700 | > +++ ./smbios.c 2016-04-11 11:58:03.234969000 -0700 | > @@ -38,6 +38,7 @@ __FBSDID("$FreeBSD: release/9.2.0/sys/x8 | > #include | > #include | > #include | > +#include | > | > #include | > #include | > @@ -59,7 +60,7 @@ struct smbios_softc { | > }; | > | > #define RES2EPS(res) ((struct smbios_eps | *)rman_get_virtual(res)) | > -#define ADDR2EPS(addr) ((struct smbios_eps | *)BIOS_PADDRTOVADDR(addr)) | > +#define ADDR2EPS(addr) ((struct smbios_eps | *)PHYS_TO_DMAP(addr)) | > | > static devclass_t smbios_devclass; | > | > @@ -71,19 +72,26 @@ static int smbios_modevent (module_t, in | > | > static int smbios_cksum (struct smbios_eps *); | > | > +static unsigned long addr; | > +static SYSCTL_NODE(_hw, OID_AUTO, smbios, CTLFLAG_RD, 0, | > + "SMBIOS driver parameters"); | > +SYSCTL_LONG(_hw_smbios, OID_AUTO, mem, CTLFLAG_RW, | > + &addr, 0, ""); | > + | > static void | > smbios_identify (driver_t *driver, device_t parent) | > { | > device_t child; | > - u_int32_t addr; | > int length; | > int rid; | > | > if (!device_is_alive(parent)) | > return; | > | > - addr = bios_sigsearch(SMBIOS_START, SMBIOS_SIG, SMBIOS_LEN, | > - SMBIOS_STEP, SMBIOS_OFF); | > + if (resource_long_value("smbios", 0, "mem", &addr) != 0 || | > + addr == 0) | > + addr = bios_sigsearch(SMBIOS_START, SMBIOS_SIG, | SMBIOS_LEN, | > + SMBIOS_STEP, SMBIOS_OFF); | > if (addr != 0) { | > rid = 0; | > length = ADDR2EPS(addr)->length; | > | > Note I don't plan to commit this since it doesn't really do much and | we | > need a lot more. | | I was planning on exporting all smbios stuff via sysctl. | | You can still put non hints.* in device.hints too. I wondered about that. It would look a bit strange. | I can rework things a bit to be more complete is you like... That would be great. A few people have expressed need of this from a kernel level. Adrian mentioned it for NUMA, ipmi(4) needs it, it could be used on Dell machines to fix HW layout issues for NICs. A couple companies could use it for internal needs. Anything to move this forward would help. I don't mind running dmidecode etc. but not needing that would be nice. Thanks, Doug A. From owner-svn-src-all@freebsd.org Fri Oct 14 18:55:46 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 7EA5BC12A22; Fri, 14 Oct 2016 18:55:46 +0000 (UTC) (envelope-from dimitry@andric.com) Received: from tensor.andric.com (tensor.andric.com [87.251.56.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "tensor.andric.com", Issuer "COMODO RSA Domain Validation Secure Server CA" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 3F5238A1; Fri, 14 Oct 2016 18:55:45 +0000 (UTC) (envelope-from dimitry@andric.com) Received: from [IPv6:2001:7b8:3a7::11ea:67ab:fdec:9446] (unknown [IPv6:2001:7b8:3a7:0:11ea:67ab:fdec:9446]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by tensor.andric.com (Postfix) with ESMTPSA id 3229E314C5; Fri, 14 Oct 2016 20:55:36 +0200 (CEST) Subject: Re: svn commit: r307231 - head/lib/libgcc_s Mime-Version: 1.0 (Mac OS X Mail 9.3 \(3124\)) Content-Type: multipart/signed; boundary="Apple-Mail=_39A3A199-5ACE-4C30-A9A6-089782D8B7E8"; protocol="application/pgp-signature"; micalg=pgp-sha1 X-Pgp-Agent: GPGMail 2.6.1 From: Dimitry Andric In-Reply-To: Date: Fri, 14 Oct 2016 20:55:30 +0200 Cc: Bruce Evans , "src-committers@freebsd.org" , "svn-src-all@freebsd.org" , "svn-src-head@freebsd.org" Message-Id: References: <201610131918.u9DJI0bX085695@repo.freebsd.org> <20161014113603.F1039@besplex.bde.org> To: Ed Maste X-Mailer: Apple Mail (2.3124) X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Oct 2016 18:55:46 -0000 --Apple-Mail=_39A3A199-5ACE-4C30-A9A6-089782D8B7E8 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=us-ascii On 14 Oct 2016, at 04:06, Ed Maste wrote: > > Hi Bruce, thank you for the detailed response. > > On 14 October 2016 at 01:53, Bruce Evans wrote: >>> compiler-rt's complex division support routines contain calls to >>> compiler builtins such as `__builtin_scalbnl`. Unfortunately Clang >>> turns these back into a call to `scalbnl`. >> >> gcc-4.2 has the same bug. > > Oh, interesting. Do you know off hand if it's resolved in later GCC? Not for x86, in any case (I think I talked about this with you on IRC before). For example, using the latest gcc 7.0.0 20160911 on this program: float f1(float x, int n) { return __builtin_scalbnf(x, n); } double f2(double x, int n) { return __builtin_scalbn(x, n); } long double f3(long double x, long n) { return __builtin_scalbnl(x, n); } gives this assembly: .p2align 4,,15 .globl f1 .type f1, @function f1: .LFB0: .cfi_startproc jmp scalbnf .cfi_endproc .LFE0: .size f1, .-f1 .p2align 4,,15 .globl f2 .type f2, @function f2: .LFB1: .cfi_startproc jmp scalbn .cfi_endproc .LFE1: .size f2, .-f2 .p2align 4,,15 .globl f3 .type f3, @function f3: .LFB2: .cfi_startproc jmp scalbnl .cfi_endproc .LFE2: .size f3, .-f3 E.g., it looks like the __builtin_scalbn functions were always a red herring. :-) > It seems particularly unfortunate for the compiler to report (by > whatever mechanism) that a builtin exists, and then just turn that > builtin into a library call. Yes, at best this is misleading. -Dimitry --Apple-Mail=_39A3A199-5ACE-4C30-A9A6-089782D8B7E8 Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=signature.asc Content-Type: application/pgp-signature; name=signature.asc Content-Description: Message signed with OpenPGP using GPGMail -----BEGIN PGP SIGNATURE----- Version: GnuPG/MacGPG2 v2.0.30 iEYEARECAAYFAlgBKicACgkQsF6jCi4glqO+cwCaAwubamEu/RR+gK0kEkc0QOvV FfAAoNDhm2dpPWMOsbf3PlgPo6OIb48c =L87B -----END PGP SIGNATURE----- --Apple-Mail=_39A3A199-5ACE-4C30-A9A6-089782D8B7E8-- From owner-svn-src-all@freebsd.org Fri Oct 14 19:54:33 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 082A8C118B3; Fri, 14 Oct 2016 19:54:33 +0000 (UTC) (envelope-from tijl@freebsd.org) Received: from mailrelay105.isp.belgacom.be (mailrelay105.isp.belgacom.be [195.238.20.132]) (using TLSv1.2 with cipher RC4-SHA (128/128 bits)) (Client CN "relay.skynet.be", Issuer "GlobalSign Organization Validation CA - SHA256 - G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id D6E9A7E8; Fri, 14 Oct 2016 19:54:31 +0000 (UTC) (envelope-from tijl@freebsd.org) X-Belgacom-Dynamic: yes X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A2AWBQBJNgFY/1QiyVBcGgEBAQECAQEBA?= =?us-ascii?q?QgBAQEBgzwBAQEBAR1JDnykOZZAKIV6AoIWPRABAgEBAQEBAQFeJ4RiAQEEOhw?= =?us-ascii?q?jEAsYCSUPKh4GE4hWCsMaAQEBAQEBBAEBAQEBAR0FixKCY4FkhV8FmgaGKIlNc?= =?us-ascii?q?o8OSYwwg381H1KEazw0AYg0AQEB?= Received: from 84.34-201-80.adsl-dyn.isp.belgacom.be (HELO kalimero.tijl.coosemans.org) ([80.201.34.84]) by relay.skynet.be with ESMTP; 14 Oct 2016 21:53:16 +0200 Received: from kalimero.tijl.coosemans.org (kalimero.tijl.coosemans.org [127.0.0.1]) by kalimero.tijl.coosemans.org (8.15.2/8.15.2) with ESMTP id u9EJrCSt062739; Fri, 14 Oct 2016 21:53:12 +0200 (CEST) (envelope-from tijl@FreeBSD.org) Date: Fri, 14 Oct 2016 21:53:11 +0200 From: Tijl Coosemans To: Dimitry Andric Cc: Ed Maste , Bruce Evans , "src-committers@freebsd.org" , "svn-src-all@freebsd.org" , "svn-src-head@freebsd.org" Subject: Re: svn commit: r307231 - head/lib/libgcc_s Message-ID: <20161014215311.6b723fab@kalimero.tijl.coosemans.org> In-Reply-To: References: <201610131918.u9DJI0bX085695@repo.freebsd.org> <20161014113603.F1039@besplex.bde.org> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Oct 2016 19:54:33 -0000 On Fri, 14 Oct 2016 20:55:30 +0200 Dimitry Andric wrot= e: > On 14 Oct 2016, at 04:06, Ed Maste wrote: >> On 14 October 2016 at 01:53, Bruce Evans wrote: = =20 >>>> compiler-rt's complex division support routines contain calls to >>>> compiler builtins such as `__builtin_scalbnl`. Unfortunately Clang >>>> turns these back into a call to `scalbnl`. =20 >>>=20 >>> gcc-4.2 has the same bug. =20 >>=20 >> Oh, interesting. Do you know off hand if it's resolved in later GCC? =20 >=20 > Not for x86, in any case (I think I talked about this with you on IRC > before). For example, using the latest gcc 7.0.0 20160911 on this > program: >=20 > float f1(float x, int n) > { > return __builtin_scalbnf(x, n); > } >=20 > double f2(double x, int n) > { > return __builtin_scalbn(x, n); > } >=20 > long double f3(long double x, long n) > { > return __builtin_scalbnl(x, n); > } >=20 > gives this assembly: >=20 > .p2align 4,,15 > .globl f1 > .type f1, @function > f1: > .LFB0: > .cfi_startproc > jmp scalbnf > .cfi_endproc > .LFE0: > .size f1, .-f1 > .p2align 4,,15 > .globl f2 > .type f2, @function > f2: > .LFB1: > .cfi_startproc > jmp scalbn > .cfi_endproc > .LFE1: > .size f2, .-f2 > .p2align 4,,15 > .globl f3 > .type f3, @function > f3: > .LFB2: > .cfi_startproc > jmp scalbnl > .cfi_endproc > .LFE2: > .size f3, .-f3 >=20 > E.g., it looks like the __builtin_scalbn functions were always a red > herring. :-) =46rom https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html: GCC includes built-in versions of many of the functions in the standard C library. These functions come in two forms: one whose names start with the __builtin_ prefix, and the other without. Both forms have the same type (including prototype), the same address (when their address is taken), and the same meaning as the C library functions even if you specify the -fno-builtin option see C Dialect Options). Many of these functions are only optimized in certain cases; if they are not optimized in a particular case, a call to the library function is emitted. From owner-svn-src-all@freebsd.org Fri Oct 14 20:01:09 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 0CAFCC11CC2; Fri, 14 Oct 2016 20:01:09 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id DDE45D55; Fri, 14 Oct 2016 20:01:08 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9EK18wk053821; Fri, 14 Oct 2016 20:01:08 GMT (envelope-from jhb@FreeBSD.org) Received: (from jhb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9EK17ZX053816; Fri, 14 Oct 2016 20:01:07 GMT (envelope-from jhb@FreeBSD.org) Message-Id: <201610142001.u9EK17ZX053816@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhb set sender to jhb@FreeBSD.org using -f From: John Baldwin Date: Fri, 14 Oct 2016 20:01:07 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307332 - in head/sys: amd64/amd64 arm/arm arm64/arm64 i386/i386 powerpc/powerpc X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Oct 2016 20:01:09 -0000 Author: jhb Date: Fri Oct 14 20:01:07 2016 New Revision: 307332 URL: https://svnweb.freebsd.org/changeset/base/307332 Log: Drop support for using mmap() with /dev/kmem. Using the device pager with /dev/kmem is not stable since KVA mappings are transient, but the device pager caches the PA associated with a given offset forever. Interestingly, mips' implementation of memmap() already refused requests for /dev/kmem. Note that kvm_read/kvm_write do not use mmap, but use read and write on /dev/kmem, so this should not affect libkvm users. Reviewed by: kib MFC after: 2 months Modified: head/sys/amd64/amd64/mem.c head/sys/arm/arm/mem.c head/sys/arm64/arm64/mem.c head/sys/i386/i386/mem.c head/sys/powerpc/powerpc/mem.c Modified: head/sys/amd64/amd64/mem.c ============================================================================== --- head/sys/amd64/amd64/mem.c Fri Oct 14 18:43:17 2016 (r307331) +++ head/sys/amd64/amd64/mem.c Fri Oct 14 20:01:07 2016 (r307332) @@ -172,10 +172,9 @@ memmmap(struct cdev *dev, vm_ooffset_t o if (offset >= (1ULL << cpu_maxphyaddr)) return (-1); *paddr = offset; - } else if (dev2unit(dev) == CDEV_MINOR_KMEM) - *paddr = vtophys(offset); - /* else panic! */ - return (0); + return (0); + } + return (-1); } /* Modified: head/sys/arm/arm/mem.c ============================================================================== --- head/sys/arm/arm/mem.c Fri Oct 14 18:43:17 2016 (r307331) +++ head/sys/arm/arm/mem.c Fri Oct 14 20:01:07 2016 (r307332) @@ -161,10 +161,9 @@ int memmmap(struct cdev *dev, vm_ooffset_t offset, vm_paddr_t *paddr, int prot __unused, vm_memattr_t *memattr __unused) { - if (dev2unit(dev) == CDEV_MINOR_MEM) + if (dev2unit(dev) == CDEV_MINOR_MEM) { *paddr = offset; - else if (dev2unit(dev) == CDEV_MINOR_KMEM) - *paddr = vtophys(offset); - /* else panic! */ - return (0); + return (0); + } + return (-1); } Modified: head/sys/arm64/arm64/mem.c ============================================================================== --- head/sys/arm64/arm64/mem.c Fri Oct 14 18:43:17 2016 (r307331) +++ head/sys/arm64/arm64/mem.c Fri Oct 14 20:01:07 2016 (r307332) @@ -123,10 +123,9 @@ int memmmap(struct cdev *dev, vm_ooffset_t offset, vm_paddr_t *paddr, int prot __unused, vm_memattr_t *memattr __unused) { - if (dev2unit(dev) == CDEV_MINOR_MEM) + if (dev2unit(dev) == CDEV_MINOR_MEM) { *paddr = offset; - else if (dev2unit(dev) == CDEV_MINOR_KMEM) - *paddr = vtophys(offset); - /* else panic! */ - return (0); + return (0); + } + return (-1); } Modified: head/sys/i386/i386/mem.c ============================================================================== --- head/sys/i386/i386/mem.c Fri Oct 14 18:43:17 2016 (r307331) +++ head/sys/i386/i386/mem.c Fri Oct 14 20:01:07 2016 (r307332) @@ -161,12 +161,11 @@ int memmmap(struct cdev *dev, vm_ooffset_t offset, vm_paddr_t *paddr, int prot __unused, vm_memattr_t *memattr __unused) { - if (dev2unit(dev) == CDEV_MINOR_MEM) + if (dev2unit(dev) == CDEV_MINOR_MEM) { *paddr = offset; - else if (dev2unit(dev) == CDEV_MINOR_KMEM) - *paddr = vtophys(offset); - /* else panic! */ - return (0); + return (0); + } + return (-1); } /* Modified: head/sys/powerpc/powerpc/mem.c ============================================================================== --- head/sys/powerpc/powerpc/mem.c Fri Oct 14 18:43:17 2016 (r307331) +++ head/sys/powerpc/powerpc/mem.c Fri Oct 14 20:01:07 2016 (r307332) @@ -179,8 +179,6 @@ memmmap(struct cdev *dev, vm_ooffset_t o if (dev2unit(dev) == CDEV_MINOR_MEM) *paddr = offset; - else if (dev2unit(dev) == CDEV_MINOR_KMEM) - *paddr = vtophys(offset); else return (EFAULT); From owner-svn-src-all@freebsd.org Fri Oct 14 21:51:51 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C2829C11610; Fri, 14 Oct 2016 21:51:51 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 76742375; Fri, 14 Oct 2016 21:51:51 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9ELpoJg097724; Fri, 14 Oct 2016 21:51:50 GMT (envelope-from jhb@FreeBSD.org) Received: (from jhb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9ELpomV097723; Fri, 14 Oct 2016 21:51:50 GMT (envelope-from jhb@FreeBSD.org) Message-Id: <201610142151.u9ELpomV097723@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhb set sender to jhb@FreeBSD.org using -f From: John Baldwin Date: Fri, 14 Oct 2016 21:51:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307333 - head/sys/x86/x86 X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Oct 2016 21:51:51 -0000 Author: jhb Date: Fri Oct 14 21:51:50 2016 New Revision: 307333 URL: https://svnweb.freebsd.org/changeset/base/307333 Log: Reprogram I/O APIC interrupt pins when registering an I/O APIC. All I/O APIC pins are masked when an I/O APIC is first probed. The APIC enumerator (MP Table or MADT) then parses its associated tables to configure individual pins to set custom delivery modes or alternate routing (e.g. routing IRQ 0 to intpin 2). Pins for regular interrupt pins are left masked until the first interrupt is assigned. However, pins with unusual settings (e.g. NMI or SMI) are never assigned an interrupt and thus never re-programmed. The I/O APIC code used to reprogram all interrupt pins during registration but this was lost in r151979. In theory, this is mostly a no-op as the ACPI APIC table does not include a way to enumerate NMI or SMI pins for the I/O APIC, so only systems using an MP Table would be affected. Reported by: avg MFC after: 1 month Modified: head/sys/x86/x86/io_apic.c Modified: head/sys/x86/x86/io_apic.c ============================================================================== --- head/sys/x86/x86/io_apic.c Fri Oct 14 20:01:07 2016 (r307332) +++ head/sys/x86/x86/io_apic.c Fri Oct 14 21:51:50 2016 (r307333) @@ -916,11 +916,16 @@ ioapic_register(void *cookie) io->io_id, flags >> 4, flags & 0xf, io->io_intbase, io->io_intbase + io->io_numintr - 1); - /* Register valid pins as interrupt sources. */ + /* + * Reprogram pins to handle special case pins (such as NMI and + * SMI) and register valid pins as interrupt sources. + */ intr_register_pic(&io->io_pic); - for (i = 0, pin = io->io_pins; i < io->io_numintr; i++, pin++) + for (i = 0, pin = io->io_pins; i < io->io_numintr; i++, pin++) { + ioapic_reprogram_intpin(&pin->io_intsrc); if (pin->io_irq < NUM_IO_INTS) intr_register_source(&pin->io_intsrc); + } } /* A simple new-bus driver to consume PCI I/O APIC devices. */ From owner-svn-src-all@freebsd.org Fri Oct 14 22:20:16 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 0FFE4C11D8D; Fri, 14 Oct 2016 22:20:16 +0000 (UTC) (envelope-from andrew@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id D0513FAB; Fri, 14 Oct 2016 22:20:15 +0000 (UTC) (envelope-from andrew@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9EMKErC006602; Fri, 14 Oct 2016 22:20:14 GMT (envelope-from andrew@FreeBSD.org) Received: (from andrew@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9EMKE2l006600; Fri, 14 Oct 2016 22:20:14 GMT (envelope-from andrew@FreeBSD.org) Message-Id: <201610142220.u9EMKE2l006600@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: andrew set sender to andrew@FreeBSD.org using -f From: Andrew Turner Date: Fri, 14 Oct 2016 22:20:14 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307334 - in head/sys/arm64: arm64 include X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Oct 2016 22:20:16 -0000 Author: andrew Date: Fri Oct 14 22:20:14 2016 New Revision: 307334 URL: https://svnweb.freebsd.org/changeset/base/307334 Log: Create macros for the MAIR memory attributes. While here add an uncached memory type, however the VM code still needs to be taught about this. MFC after: 1 week Sponsored by: ABT Systems Ltd Modified: head/sys/arm64/arm64/locore.S head/sys/arm64/include/armreg.h Modified: head/sys/arm64/arm64/locore.S ============================================================================== --- head/sys/arm64/arm64/locore.S Fri Oct 14 21:51:50 2016 (r307333) +++ head/sys/arm64/arm64/locore.S Fri Oct 14 22:20:14 2016 (r307334) @@ -617,8 +617,10 @@ start_mmu: .align 3 mair: - /* Device Normal, no cache Normal, write-back */ - .quad MAIR_ATTR(0x00, 0) | MAIR_ATTR(0x44, 1) | MAIR_ATTR(0xff, 2) + .quad MAIR_ATTR(MAIR_DEVICE_nGnRnE, 0) | \ + MAIR_ATTR(MAIR_NORMAL_NC, 1) | \ + MAIR_ATTR(MAIR_NORMAL_WB, 2) | \ + MAIR_ATTR(MAIR_NORMAL_WT, 3) tcr: .quad (TCR_TxSZ(64 - VIRT_BITS) | TCR_ASID_16 | TCR_TG1_4K | \ TCR_CACHE_ATTRS | TCR_SMP_ATTRS) Modified: head/sys/arm64/include/armreg.h ============================================================================== --- head/sys/arm64/include/armreg.h Fri Oct 14 21:51:50 2016 (r307333) +++ head/sys/arm64/include/armreg.h Fri Oct 14 22:20:14 2016 (r307334) @@ -357,6 +357,10 @@ /* MAIR_EL1 - Memory Attribute Indirection Register */ #define MAIR_ATTR_MASK(idx) (0xff << ((n)* 8)) #define MAIR_ATTR(attr, idx) ((attr) << ((idx) * 8)) +#define MAIR_DEVICE_nGnRnE 0x00 +#define MAIR_NORMAL_NC 0x44 +#define MAIR_NORMAL_WT 0x88 +#define MAIR_NORMAL_WB 0xff /* PAR_EL1 - Physical Address Register */ #define PAR_F_SHIFT 0 From owner-svn-src-all@freebsd.org Fri Oct 14 22:23:05 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 64674C11F4E; Fri, 14 Oct 2016 22:23:05 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 3A6773E8; Fri, 14 Oct 2016 22:23:05 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9EMN4El010031; Fri, 14 Oct 2016 22:23:04 GMT (envelope-from gonzo@FreeBSD.org) Received: (from gonzo@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9EMN3Cb010028; Fri, 14 Oct 2016 22:23:03 GMT (envelope-from gonzo@FreeBSD.org) Message-Id: <201610142223.u9EMN3Cb010028@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: gonzo set sender to gonzo@FreeBSD.org using -f From: Oleksandr Tymoshenko Date: Fri, 14 Oct 2016 22:23:03 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307335 - in head/sys: arm/broadcom/bcm2835 arm64/broadcom arm64/conf conf X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Oct 2016 22:23:05 -0000 Author: gonzo Date: Fri Oct 14 22:23:03 2016 New Revision: 307335 URL: https://svnweb.freebsd.org/changeset/base/307335 Log: Make BRCM2837 port conform FreeBSD/ARM64 guidelines - Rename SOC_BCM2837 to SOC_BRCM_BCM2837, put it to opt_soc.h - do not use files.XXX files, just move required sources to conf/files.arm64 and make them depend on soc_brcm_bcm2837 Suggested by: andrew Deleted: head/sys/arm64/broadcom/ Modified: head/sys/arm/broadcom/bcm2835/bcm2835_vcbus.h head/sys/arm64/conf/RPI3 head/sys/conf/files.arm64 head/sys/conf/options.arm64 Modified: head/sys/arm/broadcom/bcm2835/bcm2835_vcbus.h ============================================================================== --- head/sys/arm/broadcom/bcm2835/bcm2835_vcbus.h Fri Oct 14 22:20:14 2016 (r307334) +++ head/sys/arm/broadcom/bcm2835/bcm2835_vcbus.h Fri Oct 14 22:23:03 2016 (r307335) @@ -33,16 +33,23 @@ #ifndef _BCM2835_VCBUS_H_ #define _BCM2835_VCBUS_H_ +/* + * ARM64 define its SOC options in opt_soc.h + */ +#if defined(__aarch64__) +#include "opt_soc.h" +#endif + #define BCM2835_VCBUS_SDRAM_CACHED 0x40000000 #define BCM2835_VCBUS_IO_BASE 0x7E000000 #define BCM2835_VCBUS_SDRAM_UNCACHED 0xC0000000 -#if defined(SOC_BCM2836) || defined(SOC_BCM2837) -#define BCM2835_ARM_IO_BASE 0x3f000000 -#define BCM2835_VCBUS_SDRAM_BASE BCM2835_VCBUS_SDRAM_UNCACHED -#else +#if defined(SOC_BCM2835) #define BCM2835_ARM_IO_BASE 0x20000000 #define BCM2835_VCBUS_SDRAM_BASE BCM2835_VCBUS_SDRAM_CACHED +#else +#define BCM2835_ARM_IO_BASE 0x3f000000 +#define BCM2835_VCBUS_SDRAM_BASE BCM2835_VCBUS_SDRAM_UNCACHED #endif #define BCM2835_ARM_IO_SIZE 0x01000000 Modified: head/sys/arm64/conf/RPI3 ============================================================================== --- head/sys/arm64/conf/RPI3 Fri Oct 14 22:20:14 2016 (r307334) +++ head/sys/arm64/conf/RPI3 Fri Oct 14 22:23:03 2016 (r307335) @@ -22,9 +22,6 @@ cpu ARM64 ident RPI3 -files "../../arm/broadcom/bcm2835/files.bcm283x" -files "../broadcom/bcm2837/files.bcm2837" - makeoptions DEBUG=-g # Build kernel with gdb(1) debug symbols #makeoptions WITH_CTF=1 # Run ctfconvert(1) for DTrace support @@ -91,7 +88,7 @@ options WITNESS # Enable checks to de options WITNESS_SKIPSPIN # Don't run witness on spinlocks for speed options MALLOC_DEBUG_MAXZONES=8 # Separate malloc(9) zones -options SOC_BCM2837 +options SOC_BRCM_BCM2837 options ROOTDEVNAME=\"ufs:mmcsd0s2\" Modified: head/sys/conf/files.arm64 ============================================================================== --- head/sys/conf/files.arm64 Fri Oct 14 22:20:14 2016 (r307334) +++ head/sys/conf/files.arm64 Fri Oct 14 22:23:03 2016 (r307335) @@ -45,6 +45,24 @@ arm/arm/generic_timer.c standard arm/arm/gic.c standard arm/arm/gic_fdt.c optional fdt arm/arm/pmu.c standard +arm/broadcom/bcm2835/bcm2835_audio.c optional sound vchiq \ + compile-with "${NORMAL_C} -DUSE_VCHIQ_ARM -D__VCCOREVER__=0x04000000 -I$S/contrib/vchiq" +arm/broadcom/bcm2835/bcm2835_bsc.c optional bcm2835_bsc +arm/broadcom/bcm2835/bcm2835_common.c optional fdt soc_brcm_bcm2837 +arm/broadcom/bcm2835/bcm2835_cpufreq.c optional soc_brcm_bcm2837 +arm/broadcom/bcm2835/bcm2835_dma.c optional soc_brcm_bcm2837 +arm/broadcom/bcm2835/bcm2835_fbd.c optional vt soc_brcm_bcm2837 +arm/broadcom/bcm2835/bcm2835_ft5406.c optional evdev bcm2835_ft5406 soc_brcm_bcm2837 +arm/broadcom/bcm2835/bcm2835_gpio.c optional gpio soc_brcm_bcm2837 +arm/broadcom/bcm2835/bcm2835_intr.c optional soc_brcm_bcm2837 +arm/broadcom/bcm2835/bcm2835_mbox.c optional soc_brcm_bcm2837 +arm/broadcom/bcm2835/bcm2835_rng.c optional random soc_brcm_bcm2837 +arm/broadcom/bcm2835/bcm2835_sdhci.c optional sdhci soc_brcm_bcm2837 +arm/broadcom/bcm2835/bcm2835_spi.c optional bcm2835_spi soc_brcm_bcm2837 +arm/broadcom/bcm2835/bcm2835_vcio.c optional soc_brcm_bcm2837 +arm/broadcom/bcm2835/bcm2835_wdog.c optional soc_brcm_bcm2837 +arm/broadcom/bcm2835/bcm2836.c optional soc_brcm_bcm2837 +arm/broadcom/bcm2835/bcm283x_dwc_fdt.c optional dwcotg fdt soc_brcm_bcm2837 arm64/acpica/acpi_machdep.c optional acpi arm64/acpica/OsdEnvironment.c optional acpi arm64/acpica/acpi_wakeup.c optional acpi @@ -96,6 +114,24 @@ arm64/cavium/thunder_pcie_pem.c optiona arm64/cavium/thunder_pcie_pem_fdt.c optional soc_cavm_thunderx pci fdt arm64/cavium/thunder_pcie_common.c optional soc_cavm_thunderx pci arm64/cloudabi64/cloudabi64_sysvec.c optional compat_cloudabi64 +contrib/vchiq/interface/compat/vchi_bsd.c optional vchiq soc_brcm_bcm2837 \ + compile-with "${NORMAL_C} -DUSE_VCHIQ_ARM -D__VCCOREVER__=0x04000000 -I$S/contrib/vchiq" +contrib/vchiq/interface/vchiq_arm/vchiq_2835_arm.c optional vchiq soc_brcm_bcm2837 \ + compile-with "${NORMAL_C} -Wno-unused -DUSE_VCHIQ_ARM -D__VCCOREVER__=0x04000000 -I$S/contrib/vchiq" +contrib/vchiq/interface/vchiq_arm/vchiq_arm.c optional vchiq soc_brcm_bcm2837 \ + compile-with "${NORMAL_C} -Wno-unused -DUSE_VCHIQ_ARM -D__VCCOREVER__=0x04000000 -I$S/contrib/vchiq" +contrib/vchiq/interface/vchiq_arm/vchiq_connected.c optional vchiq soc_brcm_bcm2837 \ + compile-with "${NORMAL_C} -DUSE_VCHIQ_ARM -D__VCCOREVER__=0x04000000 -I$S/contrib/vchiq" +contrib/vchiq/interface/vchiq_arm/vchiq_core.c optional vchiq soc_brcm_bcm2837 \ + compile-with "${NORMAL_C} -DUSE_VCHIQ_ARM -D__VCCOREVER__=0x04000000 -I$S/contrib/vchiq" +contrib/vchiq/interface/vchiq_arm/vchiq_kern_lib.c optional vchiq soc_brcm_bcm2837 \ + compile-with "${NORMAL_C} -DUSE_VCHIQ_ARM -D__VCCOREVER__=0x04000000 -I$S/contrib/vchiq" +contrib/vchiq/interface/vchiq_arm/vchiq_kmod.c optional vchiq soc_brcm_bcm2837 \ + compile-with "${NORMAL_C} -DUSE_VCHIQ_ARM -D__VCCOREVER__=0x04000000 -I$S/contrib/vchiq" +contrib/vchiq/interface/vchiq_arm/vchiq_shim.c optional vchiq soc_brcm_bcm2837 \ + compile-with "${NORMAL_C} -DUSE_VCHIQ_ARM -D__VCCOREVER__=0x04000000 -I$S/contrib/vchiq" +contrib/vchiq/interface/vchiq_arm/vchiq_util.c optional vchiq soc_brcm_bcm2837 \ + compile-with "${NORMAL_C} -DUSE_VCHIQ_ARM -D__VCCOREVER__=0x04000000 -I$S/contrib/vchiq" crypto/blowfish/bf_enc.c optional crypto | ipsec crypto/des/des_enc.c optional crypto | ipsec | netsmb dev/acpica/acpi_if.m optional acpi @@ -103,6 +139,7 @@ dev/ahci/ahci_generic.c optional ahci f dev/cpufreq/cpufreq_dt.c optional cpufreq fdt dev/hwpmc/hwpmc_arm64.c optional hwpmc dev/hwpmc/hwpmc_arm64_md.c optional hwpmc +dev/mbox/mbox_if.m optional soc_brcm_bcm2837 dev/mmc/host/dwmmc.c optional dwmmc fdt dev/mmc/host/dwmmc_hisi.c optional dwmmc fdt soc_hisi_hi6220 dev/ofw/ofw_cpu.c optional fdt Modified: head/sys/conf/options.arm64 ============================================================================== --- head/sys/conf/options.arm64 Fri Oct 14 22:20:14 2016 (r307334) +++ head/sys/conf/options.arm64 Fri Oct 14 22:23:03 2016 (r307335) @@ -9,6 +9,6 @@ VFP opt_global.h # SoC Support SOC_ALLWINNER_A64 opt_soc.h -SOC_BCM2837 opt_global.h +SOC_BRCM_BCM2837 opt_soc.h SOC_CAVM_THUNDERX opt_soc.h SOC_HISI_HI6220 opt_soc.h From owner-svn-src-all@freebsd.org Sat Oct 15 00:01:23 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 5A63DC1046A for ; Sat, 15 Oct 2016 00:01:23 +0000 (UTC) (envelope-from shawn.webb@hardenedbsd.org) Received: from mail-qk0-x231.google.com (mail-qk0-x231.google.com [IPv6:2607:f8b0:400d:c09::231]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 0B386D9E for ; Sat, 15 Oct 2016 00:01:23 +0000 (UTC) (envelope-from shawn.webb@hardenedbsd.org) Received: by mail-qk0-x231.google.com with SMTP id o68so214609857qkf.3 for ; Fri, 14 Oct 2016 17:01:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hardenedbsd-org.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=9bxD518i0BIPGecK1r8L2XzaOOPYnmjSPQ8FL6KZVRg=; b=Ejkq+FetP9tYtd7Kw7OS4ontImcp1J3JfiTwIvoBfa2NKxjibK9cE01HxU8AXDjlrO 6k5bQHIIdoau9CayWmwxhDrP2j2a6ujcdDVRwLJbCnIVgJsbokt8akZ7Xl3J0cALSTGB 8vT34fpmv8TmMNZDJniuoVNE+eyx28ZSjhe7H7NfhGTtBznK0f8cJSlaQRKehIVxKCOD W9wWrmMa2q/9of2CJhvF3yn1jRuzaUu/Q23v8+vWUnyXYDjOh2x6QiNZYtAcrpyhzp4I T6i7k3wqOBl5HTM0IX7T76snqpk3P6nEvPV+uc0ho5S6fUL/eTFgxRtMJd+kO61ZoxkT 1Hew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=9bxD518i0BIPGecK1r8L2XzaOOPYnmjSPQ8FL6KZVRg=; b=hQzoNlZWn6pK6dddsz0PdeP9oae64bPoBh49hDR9py5UN9VR1tHiw9d69qg5VQVSmc dZtxo5oKhCt1tS33nasUXkjElYJy0VlP/jUPsUS6RIM6Cm5lQ7MeF/GrdZw5wJucmXGm al4S2ewpogxZRT9xdZF40tXL2SCtRntwSdGD8Wkxq/Z5CYad52tKqcXCpNRPYke9faR1 JzA5kohHTQ2NRA2lY4p9Ui7voDvJJ63U6B3G3kfSWrohv0xZX7X2Jc7YD7aK4t/66WwO ONxdcsJMhUuiLFb4KOwytUZNU5g9uN9zhvh6mmnW3+Em77/kdTfvQCaEfibnP57/Y3M6 Mwig== X-Gm-Message-State: AA6/9Rkuy1LDJHXlqHX2g8w/X4Ddce8wBYhx6NddAZo8gp17to4u6K5PqOWnCaO3flEnrtcR X-Received: by 10.55.162.150 with SMTP id l144mr15859593qke.72.1476489682130; Fri, 14 Oct 2016 17:01:22 -0700 (PDT) Received: from mutt-hardenedbsd (pool-100-16-218-231.bltmmd.fios.verizon.net. [100.16.218.231]) by smtp.gmail.com with ESMTPSA id y33sm8827397qtc.34.2016.10.14.17.01.20 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 14 Oct 2016 17:01:20 -0700 (PDT) Date: Fri, 14 Oct 2016 20:01:19 -0400 From: Shawn Webb To: "Jonathan T. Looney" Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r307082 - in head: . sys/amd64/conf sys/arm/conf sys/arm64/conf sys/conf sys/i386/conf sys/mips/conf sys/modules/cc sys/modules/khelp sys/netinet sys/netinet/tcp_stacks sys/pc98/conf sy... Message-ID: <20161015000119.GA17390@mutt-hardenedbsd> References: <201610120216.u9C2Gga8041814@repo.freebsd.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="H+4ONPRPur6+Ovig" Content-Disposition: inline In-Reply-To: <201610120216.u9C2Gga8041814@repo.freebsd.org> X-Operating-System: FreeBSD mutt-hardenedbsd 12.0-CURRENT-HBSD FreeBSD 12.0-CURRENT-HBSD X-PGP-Key: http://pgp.mit.edu/pks/lookup?op=vindex&search=0x6A84658F52456EEE User-Agent: Mutt/1.6.1 (2016-04-27) X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 Oct 2016 00:01:23 -0000 --H+4ONPRPur6+Ovig Content-Type: multipart/mixed; boundary="ReaqsoxgOBHFXBhH" Content-Disposition: inline --ReaqsoxgOBHFXBhH Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Oct 12, 2016 at 02:16:42AM +0000, Jonathan T. Looney wrote: > Author: jtl > Date: Wed Oct 12 02:16:42 2016 > New Revision: 307082 > URL: https://svnweb.freebsd.org/changeset/base/307082 >=20 > Log: > In the TCP stack, the hhook(9) framework provides hooks for kernel modu= les > to add actions that run when a TCP frame is sent or received on a TCP > session in the ESTABLISHED state. In the base tree, this functionality = is > only used for the h_ertt module, which is used by the cc_cdg, cc_chd, c= c_hd, > and cc_vegas congestion control modules. > =20 > Presently, we incur overhead to check for hooks each time a TCP frame is > sent or received on an ESTABLISHED TCP session. > =20 > This change adds a new compile-time option (TCP_HHOOK) to determine whe= ther > to include the hhook(9) framework for TCP. To retain backwards > compatibility, I added the TCP_HHOOK option to every configuration file= that > already defined "options INET". (Therefore, this patch introduces no > functional change. In order to see a functional difference, you need to > compile a custom kernel without the TCP_HHOOK option.) This change will > allow users to easily exclude this functionality from their kernel, sho= uld > they wish to do so. > =20 > Note that any users who use a custom kernel configuration and use one o= f the > congestion control modules listed above will need to add the TCP_HHOOK > option to their kernel configuration. > =20 > Reviewed by: rrs, lstewart, hiren (previous version), sjg (makefiles on= ly) > Sponsored by: Netflix > Differential Revision: https://reviews.freebsd.org/D8185 This commit breaks the build when VNET is enabled. Attached is a candidate patch to fix. If the patch doesn't make it to the list, I've pasted it here: http://ix.io/1wbE Thanks, --=20 Shawn Webb Cofounder and Security Engineer HardenedBSD GPG Key ID: 0x6A84658F52456EEE GPG Key Fingerprint: 2ABA B6BD EF6A F486 BE89 3D9E 6A84 658F 5245 6EEE --ReaqsoxgOBHFXBhH Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="2016-10-14-tcp_subr.c.patch.txt" Content-Transfer-Encoding: quoted-printable diff --git a/sys/netinet/tcp_subr.c b/sys/netinet/tcp_subr.c index b8c9ff0..e69c3d4 100644 --- a/sys/netinet/tcp_subr.c +++ b/sys/netinet/tcp_subr.c @@ -742,7 +742,10 @@ tcp_init(void) static void tcp_destroy(void *unused __unused) { - int error, n; + int n; +#ifdef TCP_HHOOK + int error; +#endif =20 /* * All our processes are gone, all our sockets should be cleaned --ReaqsoxgOBHFXBhH-- --H+4ONPRPur6+Ovig Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAEBCAAGBQJYAXHMAAoJEGqEZY9SRW7ur/YQAIr0AlUhxRxuPJwatB+Y9Iyx qbiN3PgBgtCjYXA0JMqZuJP775xnF//pvyXvRgRev1lTTLTK6MLd+j/xTT+kT70l vWCkLI2iNhEz3ZWN2vIIlJbq4fMsyxVTehb07IqdLRehlbvS+Y+cB7Ck6xRFo+DX 0icx4KfWC+zHHtE2ZzyLGb28BLJgk22lBZe5lB4luvsnEIVC37O4A1wAoLw82fMY GYuSnnSVgDPyBYwAvNQa///tVb9iM6EtvCNN6p44NrOtKZRzJIA3BJrwOF94rfB/ wyvW5RXpkRwYiKfwQiyzUvLQf/uRXvYdZfkyjxPq8veaivozTScBXblDQSLjH88P EjuKVu/H94zlTXeNNtXClbL6zLxFankzCFbvhHTtvZ40ajSqF1LfrFo4lZqAWi7/ 7XSiFq4e9w2CdldoMquMIn8/naVELwhWGnm7SD2rSIGk1pWOpOyk0Vm+2VpgvA5j lc/Ef07vQorTwEhmlS0inqEoji1+j2EUVWuTbVe3AgOzYEXBZtbtrcZYdw/O6zwX sr7to/XDtkfAkTgpWsYmb+r91Ngy7EsaLGMtMfYWb7d7ajUhRcmxANiuNN7UiS6O aQkXMhxjXCDQXrFPw2DI/Cg83SSyCqmwrncAXJCXhBf744Hs5f7vCt8gLtXy2rB9 LBTMaLGTGjQ4nDq3e5c+ =laFA -----END PGP SIGNATURE----- --H+4ONPRPur6+Ovig-- From owner-svn-src-all@freebsd.org Sat Oct 15 00:29:16 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 8596FC10C34; Sat, 15 Oct 2016 00:29:16 +0000 (UTC) (envelope-from jtl@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 55F61A05; Sat, 15 Oct 2016 00:29:16 +0000 (UTC) (envelope-from jtl@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9F0TFEB054587; Sat, 15 Oct 2016 00:29:15 GMT (envelope-from jtl@FreeBSD.org) Received: (from jtl@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9F0TFNS054586; Sat, 15 Oct 2016 00:29:15 GMT (envelope-from jtl@FreeBSD.org) Message-Id: <201610150029.u9F0TFNS054586@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jtl set sender to jtl@FreeBSD.org using -f From: "Jonathan T. Looney" Date: Sat, 15 Oct 2016 00:29:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307336 - head/sys/netinet X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 Oct 2016 00:29:16 -0000 Author: jtl Date: Sat Oct 15 00:29:15 2016 New Revision: 307336 URL: https://svnweb.freebsd.org/changeset/base/307336 Log: r307082 added the TCP_HHOOK kernel option and made some existing code only compile when that option is configured. In tcp_destroy(), the error variable is now only used in code enclosed in an '#ifdef TCP_HHOOK' block. This broke the build for VNET images. Enclose the error variable itself in an #ifdef block. Submitted by: Shawn Webb Reported by: Shawn Webb PointyHat to: jtl Modified: head/sys/netinet/tcp_subr.c Modified: head/sys/netinet/tcp_subr.c ============================================================================== --- head/sys/netinet/tcp_subr.c Fri Oct 14 22:23:03 2016 (r307335) +++ head/sys/netinet/tcp_subr.c Sat Oct 15 00:29:15 2016 (r307336) @@ -742,7 +742,10 @@ tcp_init(void) static void tcp_destroy(void *unused __unused) { - int error, n; + int n; +#ifdef TCP_HHOOK + int error; +#endif /* * All our processes are gone, all our sockets should be cleaned From owner-svn-src-all@freebsd.org Sat Oct 15 00:31:22 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 903FEC10D0C; Sat, 15 Oct 2016 00:31:22 +0000 (UTC) (envelope-from jonlooney@gmail.com) Received: from mail-qt0-x22a.google.com (mail-qt0-x22a.google.com [IPv6:2607:f8b0:400d:c0d::22a]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 48D4EC35; Sat, 15 Oct 2016 00:31:22 +0000 (UTC) (envelope-from jonlooney@gmail.com) Received: by mail-qt0-x22a.google.com with SMTP id f6so88802483qtd.2; Fri, 14 Oct 2016 17:31:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=USAHVk0rxHop7CuIHdV2Dl535k9UQXuyy/RKFh+S2jk=; b=XUJbh+ESLCEDArKjApfXDfwrlRteAkz+m3ap8Cgtpsb3Q2rWNs8XMibGMnSpAdTBG6 YOXzsdlCUpFGydOWOV2svbKtdDFhKFjcQy6QMwMmfBPPrRSv/57q8NR8Z9Kfbj84wGai AApQHTELw0WSbBqoQSbbDdvWYk6KGKwCl/T6khqPW8D2fZylgOEdfRWWF8YCqqNzvqvl 9l6U87+rIxi0fTOcOD+u9C8xZ0YTx4JhYhHvNXa07roryRncLlk7lwdjM26FInIjYojE ju2QWv4c2GHKyqXfhP0YWr/J7ztIrl5Uy6aEDOgdxAfKzzmuoVgeHgQh0/7K0zwG5Zr1 gzHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=USAHVk0rxHop7CuIHdV2Dl535k9UQXuyy/RKFh+S2jk=; b=SPYLhzfAltQrpAMil/DndnQxszHnnSZVwNpelqRcadEquMrIForuaRFXTixibUbXlC WMJaGoEa0c/I8ww255HZFEVGaZ4y6UZJV5NUPzF2If5WTM/qFpksD7thMyPrpaz++4nA KVunoSJQ0N2MR24StpoRbZ5O+Xk22WLvN3V1iIviTZzGT1a/9L+8AlKQxsCVHOsJEwN1 DLEW2YHTdcEFDb6b1mIvpuYQAwKC9aD+60gzeOAARkKTc90ulvyLxZj1sqPo2pSgzPom ES7yuDy2DxgHfWZXwEtWjGCnBVwm7xk28/CgEzKyLxGLGORrJESLyvSBySMu0MPcLBOc pMvQ== X-Gm-Message-State: AA6/9RnnkVueGr6H3pzHkx6945BppvXhKRhrecE1P7LT9mjl/Yn53nS38bQbRtmiefHAhChwyK2XrFSY5Ab+DQ== X-Received: by 10.200.33.201 with SMTP id 9mr15305921qtz.141.1476491481465; Fri, 14 Oct 2016 17:31:21 -0700 (PDT) MIME-Version: 1.0 Received: by 10.200.53.208 with HTTP; Fri, 14 Oct 2016 17:31:20 -0700 (PDT) In-Reply-To: <20161015000119.GA17390@mutt-hardenedbsd> References: <201610120216.u9C2Gga8041814@repo.freebsd.org> <20161015000119.GA17390@mutt-hardenedbsd> From: Jonathan Looney Date: Fri, 14 Oct 2016 20:31:20 -0400 Message-ID: Subject: Re: svn commit: r307082 - in head: . sys/amd64/conf sys/arm/conf sys/arm64/conf sys/conf sys/i386/conf sys/mips/conf sys/modules/cc sys/modules/khelp sys/netinet sys/netinet/tcp_stacks sys/pc98/conf sy... To: Shawn Webb Cc: "Jonathan T. Looney" , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Content-Type: text/plain; charset=UTF-8 X-Content-Filtered-By: Mailman/MimeDel 2.1.23 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 Oct 2016 00:31:22 -0000 Thanks! Yes, that was clearly an error on my part, and your patch is an obvious solution. I committed it at r307336. Thanks again! Jonathan On Fri, Oct 14, 2016 at 8:01 PM, Shawn Webb wrote: > On Wed, Oct 12, 2016 at 02:16:42AM +0000, Jonathan T. Looney wrote: > > Author: jtl > > Date: Wed Oct 12 02:16:42 2016 > > New Revision: 307082 > > URL: https://svnweb.freebsd.org/changeset/base/307082 > > > > Log: > > In the TCP stack, the hhook(9) framework provides hooks for kernel > modules > > to add actions that run when a TCP frame is sent or received on a TCP > > session in the ESTABLISHED state. In the base tree, this functionality > is > > only used for the h_ertt module, which is used by the cc_cdg, cc_chd, > cc_hd, > > and cc_vegas congestion control modules. > > > > Presently, we incur overhead to check for hooks each time a TCP frame > is > > sent or received on an ESTABLISHED TCP session. > > > > This change adds a new compile-time option (TCP_HHOOK) to determine > whether > > to include the hhook(9) framework for TCP. To retain backwards > > compatibility, I added the TCP_HHOOK option to every configuration > file that > > already defined "options INET". (Therefore, this patch introduces no > > functional change. In order to see a functional difference, you need to > > compile a custom kernel without the TCP_HHOOK option.) This change will > > allow users to easily exclude this functionality from their kernel, > should > > they wish to do so. > > > > Note that any users who use a custom kernel configuration and use one > of the > > congestion control modules listed above will need to add the TCP_HHOOK > > option to their kernel configuration. > > > > Reviewed by: rrs, lstewart, hiren (previous version), sjg > (makefiles only) > > Sponsored by: Netflix > > Differential Revision: https://reviews.freebsd.org/D8185 > > This commit breaks the build when VNET is enabled. Attached is a > candidate patch to fix. > > If the patch doesn't make it to the list, I've pasted it here: > http://ix.io/1wbE > > Thanks, > > -- > Shawn Webb > Cofounder and Security Engineer > HardenedBSD > > GPG Key ID: 0x6A84658F52456EEE > GPG Key Fingerprint: 2ABA B6BD EF6A F486 BE89 3D9E 6A84 658F 5245 6EEE > From owner-svn-src-all@freebsd.org Sat Oct 15 01:41:29 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D1CF1C11EE6; Sat, 15 Oct 2016 01:41:29 +0000 (UTC) (envelope-from pkelsey@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id AEB0BB9D; Sat, 15 Oct 2016 01:41:29 +0000 (UTC) (envelope-from pkelsey@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9F1fSUf082016; Sat, 15 Oct 2016 01:41:28 GMT (envelope-from pkelsey@FreeBSD.org) Received: (from pkelsey@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9F1fSht082014; Sat, 15 Oct 2016 01:41:28 GMT (envelope-from pkelsey@FreeBSD.org) Message-Id: <201610150141.u9F1fSht082014@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: pkelsey set sender to pkelsey@FreeBSD.org using -f From: Patrick Kelsey Date: Sat, 15 Oct 2016 01:41:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307337 - head/sys/netinet X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 Oct 2016 01:41:29 -0000 Author: pkelsey Date: Sat Oct 15 01:41:28 2016 New Revision: 307337 URL: https://svnweb.freebsd.org/changeset/base/307337 Log: Fix cases where the TFO pending counter would leak references, and eventually, memory. Also renamed some tfo labels and added/reworked comments for clarity. Based on an initial patch from jtl. PR: 213424 Reviewed by: jtl MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D8235 Modified: head/sys/netinet/tcp_input.c head/sys/netinet/tcp_syncache.c Modified: head/sys/netinet/tcp_input.c ============================================================================== --- head/sys/netinet/tcp_input.c Sat Oct 15 00:29:15 2016 (r307336) +++ head/sys/netinet/tcp_input.c Sat Oct 15 01:41:28 2016 (r307337) @@ -1121,7 +1121,7 @@ relocked: goto dropwithreset; } #ifdef TCP_RFC7413 -new_tfo_socket: +tfo_socket_result: #endif if (so == NULL) { /* @@ -1387,7 +1387,7 @@ new_tfo_socket: tcp_dooptions(&to, optp, optlen, TO_SYN); #ifdef TCP_RFC7413 if (syncache_add(&inc, &to, th, inp, &so, m, NULL, NULL)) - goto new_tfo_socket; + goto tfo_socket_result; #else syncache_add(&inc, &to, th, inp, &so, m, NULL, NULL); #endif Modified: head/sys/netinet/tcp_syncache.c ============================================================================== --- head/sys/netinet/tcp_syncache.c Sat Oct 15 00:29:15 2016 (r307336) +++ head/sys/netinet/tcp_syncache.c Sat Oct 15 01:41:28 2016 (r307337) @@ -1151,11 +1151,10 @@ syncache_tfo_expand(struct syncache *sc, * the data, we avoid this DoS scenario. * * The exception to the above is when a SYN with a valid TCP Fast Open (TFO) - * cookie is processed, V_tcp_fastopen_enabled set to true, and the - * TCP_FASTOPEN socket option is set. In this case, a new socket is created - * and returned via lsop, the mbuf is not freed so that tcp_input() can - * queue its data to the socket, and 1 is returned to indicate the - * TFO-socket-creation path was taken. + * cookie is processed and a new socket is created. In this case, any data + * accompanying the SYN will be queued to the socket by tcp_input() and will + * be ACKed either when the application sends response data or the delayed + * ACK timer expires, whichever comes first. */ int syncache_add(struct in_conninfo *inc, struct tcpopt *to, struct tcphdr *th, @@ -1181,6 +1180,7 @@ syncache_add(struct in_conninfo *inc, st struct ucred *cred; #ifdef TCP_RFC7413 uint64_t tfo_response_cookie; + unsigned int *tfo_pending = NULL; int tfo_cookie_valid = 0; int tfo_response_cookie_valid = 0; #endif @@ -1226,8 +1226,13 @@ syncache_add(struct in_conninfo *inc, st &tfo_response_cookie); tfo_cookie_valid = (result > 0); tfo_response_cookie_valid = (result >= 0); - } else - atomic_subtract_int(tp->t_tfo_pending, 1); + } + + /* + * Remember the TFO pending counter as it will have to be + * decremented below if we don't make it to syncache_tfo_expand(). + */ + tfo_pending = tp->t_tfo_pending; } #endif @@ -1468,9 +1473,9 @@ skip_alloc: #ifdef TCP_RFC7413 if (tfo_cookie_valid) { syncache_tfo_expand(sc, lsop, m, tfo_response_cookie); - /* INP_WUNLOCK(inp) will be performed by the called */ + /* INP_WUNLOCK(inp) will be performed by the caller */ rv = 1; - goto tfo_done; + goto tfo_expanded; } #endif @@ -1496,7 +1501,16 @@ done: m_freem(m); } #ifdef TCP_RFC7413 -tfo_done: + /* + * If tfo_pending is not NULL here, then a TFO SYN that did not + * result in a new socket was processed and the associated pending + * counter has not yet been decremented. All such TFO processing paths + * transit this point. + */ + if (tfo_pending != NULL) + tcp_fastopen_decrement_counter(tfo_pending); + +tfo_expanded: #endif if (cred != NULL) crfree(cred); From owner-svn-src-all@freebsd.org Sat Oct 15 05:53:11 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 36F56C12EF9; Sat, 15 Oct 2016 05:53:11 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 05374BBD; Sat, 15 Oct 2016 05:53:10 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9F5rAFH080193; Sat, 15 Oct 2016 05:53:10 GMT (envelope-from imp@FreeBSD.org) Received: (from imp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9F5rAMF080192; Sat, 15 Oct 2016 05:53:10 GMT (envelope-from imp@FreeBSD.org) Message-Id: <201610150553.u9F5rAMF080192@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: imp set sender to imp@FreeBSD.org using -f From: Warner Losh Date: Sat, 15 Oct 2016 05:53:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307338 - head/sys/boot/i386/libi386 X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 Oct 2016 05:53:11 -0000 Author: imp Date: Sat Oct 15 05:53:09 2016 New Revision: 307338 URL: https://svnweb.freebsd.org/changeset/base/307338 Log: Create a pcibios-version environment FORTH word. This allows one to conditionally compile forth code before using the pcibios- words. Modified: head/sys/boot/i386/libi386/biospci.c Modified: head/sys/boot/i386/libi386/biospci.c ============================================================================== --- head/sys/boot/i386/libi386/biospci.c Sat Oct 15 01:41:28 2016 (r307337) +++ head/sys/boot/i386/libi386/biospci.c Sat Oct 15 05:53:09 2016 (r307338) @@ -190,7 +190,6 @@ static struct pci_class {-1, NULL, NULL} }; - static void biospci_enumerate(void); static void biospci_addinfo(int devid, struct pci_class *pc, struct pci_subclass *psc, struct pci_progif *ppi); @@ -199,6 +198,7 @@ struct pnphandler biospcihandler = "PCI BIOS", biospci_enumerate }; +static int biospci_version; #define PCI_BIOS_PRESENT 0xb101 #define FIND_PCI_DEVICE 0xb102 @@ -254,7 +254,7 @@ biospci_detect(void) setenv("pcibios.config2", buf, 1); sprintf(buf, "%d", maxbus); setenv("pcibios.maxbus", buf, 1); - + biospci_version = bcd2bin((version >> 8) & 0xf) * 10 + bcd2bin(version & 0xf); } static void @@ -577,6 +577,8 @@ static void ficlCompilePciBios(FICL_SYST dictAppendWord(dp, "pcibios-find-devclass", ficlPciBiosFindDevclass, FW_DEFAULT); dictAppendWord(dp, "pcibios-find-device", ficlPciBiosFindDevice, FW_DEFAULT); dictAppendWord(dp, "pcibios-locator", ficlPciBiosLocator, FW_DEFAULT); + + ficlSetEnv(pSys, "pcibios-version", biospci_version); } FICL_COMPILE_SET(ficlCompilePciBios); From owner-svn-src-all@freebsd.org Sat Oct 15 06:16:36 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 7FD69C1152F; Sat, 15 Oct 2016 06:16:36 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4F3A2769; Sat, 15 Oct 2016 06:16:36 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9F6GZan087591; Sat, 15 Oct 2016 06:16:35 GMT (envelope-from imp@FreeBSD.org) Received: (from imp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9F6GZCp087590; Sat, 15 Oct 2016 06:16:35 GMT (envelope-from imp@FreeBSD.org) Message-Id: <201610150616.u9F6GZCp087590@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: imp set sender to imp@FreeBSD.org using -f From: Warner Losh Date: Sat, 15 Oct 2016 06:16:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307339 - head/usr.sbin/efivar X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 Oct 2016 06:16:36 -0000 Author: imp Date: Sat Oct 15 06:16:35 2016 New Revision: 307339 URL: https://svnweb.freebsd.org/changeset/base/307339 Log: Implement -t. Use symbolic names in place of the magical 0x7. Submitted by: ambrisko@ Modified: head/usr.sbin/efivar/efivar.c Modified: head/usr.sbin/efivar/efivar.c ============================================================================== --- head/usr.sbin/efivar/efivar.c Sat Oct 15 05:53:09 2016 (r307338) +++ head/usr.sbin/efivar/efivar.c Sat Oct 15 06:16:35 2016 (r307339) @@ -62,7 +62,7 @@ static struct option longopts[] = { static int aflag, Aflag, bflag, dflag, Dflag, Hflag, Nflag, lflag, Lflag, Rflag, wflag, pflag; static char *varname; -static u_long attrib = 0x7; +static u_long attrib = EFI_VARIABLE_NON_VOLATILE |EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS; static void usage(void) @@ -294,11 +294,13 @@ parse_args(int argc, char **argv) case 'R': Rflag++; break; + case 't': + attrib = strtoul(optarg, NULL, 16); + break; case 'w': wflag++; break; case 'f': - case 't': case 0: errx(1, "unknown or unimplemented option\n"); break; From owner-svn-src-all@freebsd.org Sat Oct 15 07:28:48 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 6C529C1240C; Sat, 15 Oct 2016 07:28:48 +0000 (UTC) (envelope-from avos@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 358DD1CC; Sat, 15 Oct 2016 07:28:48 +0000 (UTC) (envelope-from avos@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9F7SlsP014603; Sat, 15 Oct 2016 07:28:47 GMT (envelope-from avos@FreeBSD.org) Received: (from avos@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9F7SkNE014599; Sat, 15 Oct 2016 07:28:46 GMT (envelope-from avos@FreeBSD.org) Message-Id: <201610150728.u9F7SkNE014599@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avos set sender to avos@FreeBSD.org using -f From: Andriy Voskoboinyk Date: Sat, 15 Oct 2016 07:28:46 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307340 - in stable/11: . share/man/man9 X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 Oct 2016 07:28:48 -0000 Author: avos Date: Sat Oct 15 07:28:46 2016 New Revision: 307340 URL: https://svnweb.freebsd.org/changeset/base/307340 Log: MFC r307000, r307001: mbuf(9), mbuf_tags(9): fix function prototypes. - Add m_getclr(9) symlink to ObsoleteFiles.inc (removed in r295481). - Add const qualifiers in m_dup(), m_dup_pkthdr() and m_tag_copy_chain() (r286450). - Fix m_dup_pkthdr() definition (it's not the same as m_move_pkthdr()). Modified: stable/11/ObsoleteFiles.inc stable/11/share/man/man9/Makefile stable/11/share/man/man9/mbuf.9 stable/11/share/man/man9/mbuf_tags.9 Directory Properties: stable/11/ (props changed) Modified: stable/11/ObsoleteFiles.inc ============================================================================== --- stable/11/ObsoleteFiles.inc Sat Oct 15 06:16:35 2016 (r307339) +++ stable/11/ObsoleteFiles.inc Sat Oct 15 07:28:46 2016 (r307340) @@ -38,6 +38,8 @@ # xargs -n1 | sort | uniq -d; # done +# 20161015: remove link to removed m_getclr(9) macro +OLD_FILES+=usr/share/man/man9/m_getclr.9.gz # 20160703: POSIXify locales with variants OLD_FILES+=usr/share/locale/zh_Hant_TW.UTF-8/LC_COLLATE OLD_FILES+=usr/share/locale/zh_Hant_TW.UTF-8/LC_CTYPE Modified: stable/11/share/man/man9/Makefile ============================================================================== --- stable/11/share/man/man9/Makefile Sat Oct 15 06:16:35 2016 (r307339) +++ stable/11/share/man/man9/Makefile Sat Oct 15 07:28:46 2016 (r307340) @@ -1089,7 +1089,6 @@ MLINKS+=\ mbuf.9 m_get2.9 \ mbuf.9 m_getjcl.9 \ mbuf.9 m_getcl.9 \ - mbuf.9 m_getclr.9 \ mbuf.9 MGETHDR.9 \ mbuf.9 m_gethdr.9 \ mbuf.9 m_getm.9 \ Modified: stable/11/share/man/man9/mbuf.9 ============================================================================== --- stable/11/share/man/man9/mbuf.9 Sat Oct 15 06:16:35 2016 (r307339) +++ stable/11/share/man/man9/mbuf.9 Sat Oct 15 07:28:46 2016 (r307340) @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd February 29, 2016 +.Dd October 10, 2016 .Dt MBUF 9 .Os .\" @@ -79,8 +79,6 @@ .Ft struct mbuf * .Fn m_getcl "int how" "short type" "int flags" .Ft struct mbuf * -.Fn m_getclr "int how" "short type" -.Ft struct mbuf * .Fn m_gethdr "int how" "short type" .Ft struct mbuf * .Fn m_free "struct mbuf *mbuf" @@ -107,7 +105,7 @@ .Ft struct mbuf * .Fn m_copypacket "struct mbuf *mbuf" "int how" .Ft struct mbuf * -.Fn m_dup "struct mbuf *mbuf" "int how" +.Fn m_dup "const struct mbuf *mbuf" "int how" .Ft void .Fn m_copydata "const struct mbuf *mbuf" "int offset" "int len" "caddr_t buf" .Ft void @@ -126,8 +124,8 @@ .Fn m_catpkt "struct mbuf *m" "struct mbuf *n" .Ft u_int .Fn m_fixhdr "struct mbuf *mbuf" -.Ft void -.Fn m_dup_pkthdr "struct mbuf *to" "struct mbuf *from" +.Ft int +.Fn m_dup_pkthdr "struct mbuf *to" "const struct mbuf *from" "int how" .Ft void .Fn m_move_pkthdr "struct mbuf *to" "struct mbuf *from" .Ft u_int @@ -602,10 +600,6 @@ This is like but it the size of the cluster allocated will be large enough for .Fa size bytes. -.It Fn m_getclr how type -Allocate an -.Vt mbuf -and zero out the data region. .It Fn m_free mbuf Frees .Vt mbuf . Modified: stable/11/share/man/man9/mbuf_tags.9 ============================================================================== --- stable/11/share/man/man9/mbuf_tags.9 Sat Oct 15 06:16:35 2016 (r307339) +++ stable/11/share/man/man9/mbuf_tags.9 Sat Oct 15 07:28:46 2016 (r307340) @@ -33,7 +33,7 @@ .Ft "struct m_tag *" .Fn m_tag_copy "struct m_tag *t" "int how" .Ft int -.Fn m_tag_copy_chain "struct mbuf *to" "struct mbuf *from" "int how" +.Fn m_tag_copy_chain "struct mbuf *to" "const struct mbuf *from" "int how" .Ft void .Fn m_tag_delete "struct mbuf *m" "struct m_tag *t" .Ft void From owner-svn-src-all@freebsd.org Sat Oct 15 07:30:14 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id CAF2BC124B2; Sat, 15 Oct 2016 07:30:14 +0000 (UTC) (envelope-from mmel@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 9AD5739F; Sat, 15 Oct 2016 07:30:14 +0000 (UTC) (envelope-from mmel@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9F7UD8B014727; Sat, 15 Oct 2016 07:30:13 GMT (envelope-from mmel@FreeBSD.org) Received: (from mmel@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9F7UDhm014726; Sat, 15 Oct 2016 07:30:13 GMT (envelope-from mmel@FreeBSD.org) Message-Id: <201610150730.u9F7UDhm014726@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mmel set sender to mmel@FreeBSD.org using -f From: Michal Meloun Date: Sat, 15 Oct 2016 07:30:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307341 - stable/11/sys/arm/arm X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 Oct 2016 07:30:14 -0000 Author: mmel Date: Sat Oct 15 07:30:13 2016 New Revision: 307341 URL: https://svnweb.freebsd.org/changeset/base/307341 Log: MFC r306754: ARM: Remove unused variable. Not a functional change. Modified: stable/11/sys/arm/arm/locore-v6.S Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/arm/arm/locore-v6.S ============================================================================== --- stable/11/sys/arm/arm/locore-v6.S Sat Oct 15 07:28:46 2016 (r307340) +++ stable/11/sys/arm/arm/locore-v6.S Sat Oct 15 07:30:13 2016 (r307341) @@ -439,9 +439,6 @@ boot_pt1: .text .align 2 -.Lcpufuncs: - .word _C_LABEL(cpufuncs) - #if defined(SMP) ASENTRY_NP(mpentry) From owner-svn-src-all@freebsd.org Sat Oct 15 07:38:28 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 5FEFCC1280A; Sat, 15 Oct 2016 07:38:28 +0000 (UTC) (envelope-from mmel@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 30B6EBB4; Sat, 15 Oct 2016 07:38:28 +0000 (UTC) (envelope-from mmel@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9F7cRGo018409; Sat, 15 Oct 2016 07:38:27 GMT (envelope-from mmel@FreeBSD.org) Received: (from mmel@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9F7cRX4018407; Sat, 15 Oct 2016 07:38:27 GMT (envelope-from mmel@FreeBSD.org) Message-Id: <201610150738.u9F7cRX4018407@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mmel set sender to mmel@FreeBSD.org using -f From: Michal Meloun Date: Sat, 15 Oct 2016 07:38:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307342 - in stable/11/sys/arm: arm include X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 Oct 2016 07:38:28 -0000 Author: mmel Date: Sat Oct 15 07:38:27 2016 New Revision: 307342 URL: https://svnweb.freebsd.org/changeset/base/307342 Log: MFC r306755: ARM: Add identifiers for ARM Cortex v8 and Marvell Sheeva v7 cores. Not a functional change. Modified: stable/11/sys/arm/arm/cpuinfo.c stable/11/sys/arm/include/cpuinfo.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/arm/arm/cpuinfo.c ============================================================================== --- stable/11/sys/arm/arm/cpuinfo.c Sat Oct 15 07:30:13 2016 (r307341) +++ stable/11/sys/arm/arm/cpuinfo.c Sat Oct 15 07:38:27 2016 (r307342) @@ -163,7 +163,11 @@ cpuinfo_get_actlr_modifier(uint32_t *act if (cpuinfo.implementer == CPU_IMPLEMENTER_ARM) { switch (cpuinfo.part_number) { - + case CPU_ARCH_CORTEX_A72: + case CPU_ARCH_CORTEX_A57: + case CPU_ARCH_CORTEX_A53: + /* Nothing to do for AArch32 */ + break; case CPU_ARCH_CORTEX_A17: case CPU_ARCH_CORTEX_A12: /* A12 is merged to A17 */ /* Modified: stable/11/sys/arm/include/cpuinfo.h ============================================================================== --- stable/11/sys/arm/include/cpuinfo.h Sat Oct 15 07:30:13 2016 (r307341) +++ stable/11/sys/arm/include/cpuinfo.h Sat Oct 15 07:38:27 2016 (r307342) @@ -45,10 +45,18 @@ #define CPU_ARCH_CORTEX_A12 0xC0D #define CPU_ARCH_CORTEX_A15 0xC0F #define CPU_ARCH_CORTEX_A17 0xC11 +#define CPU_ARCH_CORTEX_A53 0xD03 +#define CPU_ARCH_CORTEX_A57 0xD07 +#define CPU_ARCH_CORTEX_A72 0xD08 + /* QCOM */ #define CPU_ARCH_KRAIT_300 0x06F +/* MRVL */ +#define CPU_ARCH_SHEEVA_851 0x581 /* PJ4/PJ4B */ +#define CPU_ARCH_SHEEVA_584 0x584 /* PJ4B-MP/PJ4C */ + struct cpuinfo { /* raw id registers */ uint32_t midr; From owner-svn-src-all@freebsd.org Sat Oct 15 08:09:56 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 8FC2AC110F6; Sat, 15 Oct 2016 08:09:56 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 61DD5A36; Sat, 15 Oct 2016 08:09:56 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9F89tdr029703; Sat, 15 Oct 2016 08:09:55 GMT (envelope-from ed@FreeBSD.org) Received: (from ed@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9F89tHm029702; Sat, 15 Oct 2016 08:09:55 GMT (envelope-from ed@FreeBSD.org) Message-Id: <201610150809.u9F89tHm029702@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ed set sender to ed@FreeBSD.org using -f From: Ed Schouten Date: Sat, 15 Oct 2016 08:09:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307343 - head/lib/libc/stdlib X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 Oct 2016 08:09:56 -0000 Author: ed Date: Sat Oct 15 08:09:55 2016 New Revision: 307343 URL: https://svnweb.freebsd.org/changeset/base/307343 Log: Improve phrasing of the STANDARDS section. Reported by: wblock MFC after: 1 month Differential Revision: https://reviews.freebsd.org/D8205 Modified: head/lib/libc/stdlib/tsearch.3 Modified: head/lib/libc/stdlib/tsearch.3 ============================================================================== --- head/lib/libc/stdlib/tsearch.3 Sat Oct 15 07:38:27 2016 (r307342) +++ head/lib/libc/stdlib/tsearch.3 Sat Oct 15 08:09:55 2016 (r307343) @@ -142,10 +142,10 @@ The .Fa posix_tnode type is not part of .St -p1003.1-2008 , -but it is expected to be standardized by future versions of the standard. +but is expected to be standardized by future versions of the standard. It is defined as .Fa void for source-level compatibility. Using .Fa posix_tnode -makes it easier to distinguish between nodes and keys. +makes distinguishing between nodes and keys easier. From owner-svn-src-all@freebsd.org Sat Oct 15 08:27:57 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B747EC11859; Sat, 15 Oct 2016 08:27:57 +0000 (UTC) (envelope-from mmel@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 8EAB77CE; Sat, 15 Oct 2016 08:27:57 +0000 (UTC) (envelope-from mmel@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9F8RuPf037364; Sat, 15 Oct 2016 08:27:56 GMT (envelope-from mmel@FreeBSD.org) Received: (from mmel@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9F8RtEa037349; Sat, 15 Oct 2016 08:27:55 GMT (envelope-from mmel@FreeBSD.org) Message-Id: <201610150827.u9F8RtEa037349@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mmel set sender to mmel@FreeBSD.org using -f From: Michal Meloun Date: Sat, 15 Oct 2016 08:27:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307344 - in stable/11/sys/arm: allwinner altera/socfpga amlogic/aml8726 arm broadcom/bcm2835 freescale/imx include mv/armada38x nvidia/tegra124 rockchip samsung/exynos ti/omap4 xilinx X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 Oct 2016 08:27:57 -0000 Author: mmel Date: Sat Oct 15 08:27:54 2016 New Revision: 307344 URL: https://svnweb.freebsd.org/changeset/base/307344 Log: MFC r306756: ARM: SEV/WFE instructions are implemented starting from ARMv6K, use it directly. Modified: stable/11/sys/arm/allwinner/aw_mp.c stable/11/sys/arm/altera/socfpga/socfpga_mp.c stable/11/sys/arm/amlogic/aml8726/aml8726_mp.c stable/11/sys/arm/arm/cpufunc_asm_armv7.S stable/11/sys/arm/arm/mp_machdep.c stable/11/sys/arm/broadcom/bcm2835/bcm2836_mp.c stable/11/sys/arm/freescale/imx/imx6_mp.c stable/11/sys/arm/include/cpu-v6.h stable/11/sys/arm/include/cpufunc.h stable/11/sys/arm/mv/armada38x/pmsu.c stable/11/sys/arm/nvidia/tegra124/tegra124_mp.c stable/11/sys/arm/rockchip/rk30xx_mp.c stable/11/sys/arm/samsung/exynos/exynos5_mp.c stable/11/sys/arm/ti/omap4/omap4_mp.c stable/11/sys/arm/xilinx/zy7_mp.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/arm/allwinner/aw_mp.c ============================================================================== --- stable/11/sys/arm/allwinner/aw_mp.c Sat Oct 15 08:09:55 2016 (r307343) +++ stable/11/sys/arm/allwinner/aw_mp.c Sat Oct 15 08:27:54 2016 (r307344) @@ -193,7 +193,8 @@ aw_mp_start_ap(platform_t plat) val |= (1 << i); bus_space_write_4(fdtbus_bs_tag, cpucfg, CPUCFG_DBGCTL1, val); - armv7_sev(); + dsb(); + sev(); bus_space_unmap(fdtbus_bs_tag, cpucfg, CPUCFG_SIZE); if (soc_family != ALLWINNERSOC_SUN7I) bus_space_unmap(fdtbus_bs_tag, prcm, PRCM_SIZE); @@ -279,7 +280,8 @@ a83t_mp_start_ap(platform_t plat) panic("Couldn't map the PRCM\n"); aw_mc_mp_start_ap(cpuscfg, cpuxcfg, prcm); - armv7_sev(); + dsb(); + sev(); bus_space_unmap(fdtbus_bs_tag, cpuxcfg, CPUXCFG_SIZE); bus_space_unmap(fdtbus_bs_tag, cpuscfg, CPUCFG_SIZE); bus_space_unmap(fdtbus_bs_tag, prcm, PRCM_SIZE); Modified: stable/11/sys/arm/altera/socfpga/socfpga_mp.c ============================================================================== --- stable/11/sys/arm/altera/socfpga/socfpga_mp.c Sat Oct 15 08:09:55 2016 (r307343) +++ stable/11/sys/arm/altera/socfpga/socfpga_mp.c Sat Oct 15 08:27:54 2016 (r307344) @@ -151,7 +151,8 @@ platform_mp_start_ap(void) /* Put CPU1 out from reset */ bus_space_write_4(fdtbus_bs_tag, rst, MPUMODRST, 0); - armv7_sev(); + dsb(); + sev(); bus_space_unmap(fdtbus_bs_tag, scu, SCU_SIZE); bus_space_unmap(fdtbus_bs_tag, rst, RSTMGR_SIZE); Modified: stable/11/sys/arm/amlogic/aml8726/aml8726_mp.c ============================================================================== --- stable/11/sys/arm/amlogic/aml8726/aml8726_mp.c Sat Oct 15 08:09:55 2016 (r307343) +++ stable/11/sys/arm/amlogic/aml8726/aml8726_mp.c Sat Oct 15 08:27:54 2016 (r307344) @@ -487,7 +487,8 @@ platform_mp_start_ap(void) CPUCONF_BARRIER(AML_CPUCONF_CONTROL_REG); /* Wakeup the now enabled APs */ - armv7_sev(); + dsb(); + sev(); /* * Free the resources which are not needed after startup. Modified: stable/11/sys/arm/arm/cpufunc_asm_armv7.S ============================================================================== --- stable/11/sys/arm/arm/cpufunc_asm_armv7.S Sat Oct 15 08:09:55 2016 (r307343) +++ stable/11/sys/arm/arm/cpufunc_asm_armv7.S Sat Oct 15 08:27:54 2016 (r307344) @@ -297,13 +297,6 @@ ENTRY(armv7_drain_writebuf) RET END(armv7_drain_writebuf) -ENTRY(armv7_sev) - dsb - sev - nop - RET -END(armv7_sev) - ENTRY(armv7_auxctrl) mrc CP15_ACTLR(r2) bic r3, r2, r0 /* Clear bits */ Modified: stable/11/sys/arm/arm/mp_machdep.c ============================================================================== --- stable/11/sys/arm/arm/mp_machdep.c Sat Oct 15 08:09:55 2016 (r307343) +++ stable/11/sys/arm/arm/mp_machdep.c Sat Oct 15 08:27:54 2016 (r307344) @@ -467,9 +467,8 @@ release_aps(void *dummy __unused) #endif atomic_store_rel_int(&aps_ready, 1); /* Wake the other threads up */ -#if __ARM_ARCH >= 7 - armv7_sev(); -#endif + dsb(); + sev(); printf("Release APs\n"); Modified: stable/11/sys/arm/broadcom/bcm2835/bcm2836_mp.c ============================================================================== --- stable/11/sys/arm/broadcom/bcm2835/bcm2836_mp.c Sat Oct 15 08:09:55 2016 (r307343) +++ stable/11/sys/arm/broadcom/bcm2835/bcm2836_mp.c Sat Oct 15 08:27:54 2016 (r307344) @@ -132,7 +132,8 @@ platform_mp_start_ap(void) } while (1); /* dsb and sev */ - armv7_sev(); + dsb(); + sev(); /* recode AP in CPU map */ CPU_SET(i, &all_cpus); Modified: stable/11/sys/arm/freescale/imx/imx6_mp.c ============================================================================== --- stable/11/sys/arm/freescale/imx/imx6_mp.c Sat Oct 15 08:09:55 2016 (r307343) +++ stable/11/sys/arm/freescale/imx/imx6_mp.c Sat Oct 15 08:27:54 2016 (r307344) @@ -150,7 +150,8 @@ platform_mp_start_ap(void) } bus_space_write_4(fdtbus_bs_tag, src, SRC_CONTROL_REG, val); - armv7_sev(); + dsb(); + sev(); bus_space_unmap(fdtbus_bs_tag, scu, SCU_SIZE); bus_space_unmap(fdtbus_bs_tag, src, SRC_SIZE); Modified: stable/11/sys/arm/include/cpu-v6.h ============================================================================== --- stable/11/sys/arm/include/cpu-v6.h Sat Oct 15 08:09:55 2016 (r307343) +++ stable/11/sys/arm/include/cpu-v6.h Sat Oct 15 08:27:54 2016 (r307344) @@ -56,6 +56,8 @@ extern uint32_t ccnt_hi[MAXCPU]; extern int pmu_attched; #endif /* DEV_PMU */ +#define sev() __asm __volatile("sev" : : : "memory") +#define wfe() __asm __volatile("wfe" : : : "memory") /* * Macros to generate CP15 (system control processor) read/write functions. Modified: stable/11/sys/arm/include/cpufunc.h ============================================================================== --- stable/11/sys/arm/include/cpufunc.h Sat Oct 15 08:09:55 2016 (r307343) +++ stable/11/sys/arm/include/cpufunc.h Sat Oct 15 08:27:54 2016 (r307344) @@ -289,7 +289,6 @@ void armv7_cpu_sleep (int); void armv7_setup (void); void armv7_context_switch (void); void armv7_drain_writebuf (void); -void armv7_sev (void); u_int armv7_auxctrl (u_int, u_int); void armadaxp_idcache_wbinv_all (void); Modified: stable/11/sys/arm/mv/armada38x/pmsu.c ============================================================================== --- stable/11/sys/arm/mv/armada38x/pmsu.c Sat Oct 15 08:09:55 2016 (r307343) +++ stable/11/sys/arm/mv/armada38x/pmsu.c Sat Oct 15 08:27:54 2016 (r307344) @@ -146,7 +146,8 @@ pmsu_boot_secondary_cpu(void) pmap_kextract((vm_offset_t)mpentry)); dcache_wbinv_poc_all(); - armv7_sev(); + dsb(); + sev(); bus_space_unmap(fdtbus_bs_tag, vaddr, MV_PMSU_REGS_LEN); Modified: stable/11/sys/arm/nvidia/tegra124/tegra124_mp.c ============================================================================== --- stable/11/sys/arm/nvidia/tegra124/tegra124_mp.c Sat Oct 15 08:09:55 2016 (r307343) +++ stable/11/sys/arm/nvidia/tegra124/tegra124_mp.c Sat Oct 15 08:27:54 2016 (r307344) @@ -121,7 +121,8 @@ tegra124_mp_start_ap(platform_t plat) } } - armv7_sev(); + dsb(); + sev(); bus_space_unmap(fdtbus_bs_tag, pmc, PMC_SIZE); bus_space_unmap(fdtbus_bs_tag, exvec, TEGRA_EXCEPTION_VECTORS_SIZE); } Modified: stable/11/sys/arm/rockchip/rk30xx_mp.c ============================================================================== --- stable/11/sys/arm/rockchip/rk30xx_mp.c Sat Oct 15 08:09:55 2016 (r307343) +++ stable/11/sys/arm/rockchip/rk30xx_mp.c Sat Oct 15 08:27:54 2016 (r307344) @@ -163,7 +163,8 @@ platform_mp_start_ap(void) val &= ~(1 << i); bus_space_write_4(fdtbus_bs_tag, pmu, PMU_PWRDN_CON, val); - armv7_sev(); + dsb(); + sev(); bus_space_unmap(fdtbus_bs_tag, scu, SCU_SIZE); bus_space_unmap(fdtbus_bs_tag, imem, IMEM_SIZE); Modified: stable/11/sys/arm/samsung/exynos/exynos5_mp.c ============================================================================== --- stable/11/sys/arm/samsung/exynos/exynos5_mp.c Sat Oct 15 08:09:55 2016 (r307343) +++ stable/11/sys/arm/samsung/exynos/exynos5_mp.c Sat Oct 15 08:27:54 2016 (r307344) @@ -124,7 +124,8 @@ platform_mp_start_ap(void) dcache_wbinv_poc_all(); - armv7_sev(); + dsb(); + sev(); bus_space_unmap(fdtbus_bs_tag, sysram, 0x100); bus_space_unmap(fdtbus_bs_tag, pmu, 0x20000); } Modified: stable/11/sys/arm/ti/omap4/omap4_mp.c ============================================================================== --- stable/11/sys/arm/ti/omap4/omap4_mp.c Sat Oct 15 08:09:55 2016 (r307343) +++ stable/11/sys/arm/ti/omap4/omap4_mp.c Sat Oct 15 08:27:54 2016 (r307344) @@ -64,6 +64,7 @@ platform_mp_start_ap(void) ti_smc0(0x200, 0xfffffdff, MODIFY_AUX_CORE_0); ti_smc0(pmap_kextract((vm_offset_t)mpentry), 0, WRITE_AUX_CORE_1); - armv7_sev(); + dsb(); + sev(); bus_space_unmap(fdtbus_bs_tag, scu_addr, 0x1000); } Modified: stable/11/sys/arm/xilinx/zy7_mp.c ============================================================================== --- stable/11/sys/arm/xilinx/zy7_mp.c Sat Oct 15 08:09:55 2016 (r307343) +++ stable/11/sys/arm/xilinx/zy7_mp.c Sat Oct 15 08:27:54 2016 (r307344) @@ -94,5 +94,6 @@ platform_mp_start_ap(void) dcache_wbinv_poc_all(); /* Wake up CPU1. */ - armv7_sev(); + dsb(); + sev(); } From owner-svn-src-all@freebsd.org Sat Oct 15 08:31:48 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 44F15C11A17; Sat, 15 Oct 2016 08:31:48 +0000 (UTC) (envelope-from mmel@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 1375AAB7; Sat, 15 Oct 2016 08:31:48 +0000 (UTC) (envelope-from mmel@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9F8Vloh039572; Sat, 15 Oct 2016 08:31:47 GMT (envelope-from mmel@FreeBSD.org) Received: (from mmel@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9F8VlAm039571; Sat, 15 Oct 2016 08:31:47 GMT (envelope-from mmel@FreeBSD.org) Message-Id: <201610150831.u9F8VlAm039571@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mmel set sender to mmel@FreeBSD.org using -f From: Michal Meloun Date: Sat, 15 Oct 2016 08:31:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307345 - stable/11/sys/arm/arm X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 Oct 2016 08:31:48 -0000 Author: mmel Date: Sat Oct 15 08:31:46 2016 New Revision: 307345 URL: https://svnweb.freebsd.org/changeset/base/307345 Log: MFC r306759: ARM: Remove ARMv4 #defines from busdma_machdep-v6.c, it's ARMv6 specific file. Consistently use BUSDMA_DCACHE_ALIGN for cache line alignment. Modified: stable/11/sys/arm/arm/busdma_machdep-v6.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/arm/arm/busdma_machdep-v6.c ============================================================================== --- stable/11/sys/arm/arm/busdma_machdep-v6.c Sat Oct 15 08:27:54 2016 (r307344) +++ stable/11/sys/arm/arm/busdma_machdep-v6.c Sat Oct 15 08:31:46 2016 (r307345) @@ -61,13 +61,8 @@ __FBSDID("$FreeBSD$"); #include #include -#if __ARM_ARCH < 6 -#define BUSDMA_DCACHE_ALIGN arm_dcache_align -#define BUSDMA_DCACHE_MASK arm_dcache_align_mask -#else #define BUSDMA_DCACHE_ALIGN cpuinfo.dcache_line_size #define BUSDMA_DCACHE_MASK cpuinfo.dcache_line_mask -#endif #define MAX_BPAGES 64 #define MAX_DMA_SEGMENTS 4096 @@ -340,7 +335,7 @@ cacheline_bounce(bus_dmamap_t map, bus_a if (map->flags & (DMAMAP_DMAMEM_ALLOC | DMAMAP_COHERENT | DMAMAP_MBUF)) return (0); - return ((addr | size) & arm_dcache_align_mask); + return ((addr | size) & BUSDMA_DCACHE_MASK); } /* From owner-svn-src-all@freebsd.org Sat Oct 15 08:52:43 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C70E0C12CFE; Sat, 15 Oct 2016 08:52:43 +0000 (UTC) (envelope-from mmel@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 7C278BF3; Sat, 15 Oct 2016 08:52:43 +0000 (UTC) (envelope-from mmel@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9F8qgTk048214; Sat, 15 Oct 2016 08:52:42 GMT (envelope-from mmel@FreeBSD.org) Received: (from mmel@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9F8qgeR048213; Sat, 15 Oct 2016 08:52:42 GMT (envelope-from mmel@FreeBSD.org) Message-Id: <201610150852.u9F8qgeR048213@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mmel set sender to mmel@FreeBSD.org using -f From: Michal Meloun Date: Sat, 15 Oct 2016 08:52:42 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307346 - stable/11/sys/dev/ofw X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 Oct 2016 08:52:43 -0000 Author: mmel Date: Sat Oct 15 08:52:42 2016 New Revision: 307346 URL: https://svnweb.freebsd.org/changeset/base/307346 Log: MFC r302560: OFWPCI: Fix style(9). No functional change. Modified: stable/11/sys/dev/ofw/ofwpci.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/ofw/ofwpci.c ============================================================================== --- stable/11/sys/dev/ofw/ofwpci.c Sat Oct 15 08:31:46 2016 (r307345) +++ stable/11/sys/dev/ofw/ofwpci.c Sat Oct 15 08:52:42 2016 (r307346) @@ -195,7 +195,7 @@ ofw_pci_init(device_t dev) sc->sc_io_rman.rm_type = RMAN_ARRAY; sc->sc_io_rman.rm_descr = "PCI I/O Ports"; error = rman_init(&sc->sc_io_rman); - if (error) { + if (error != 0) { device_printf(dev, "rman_init() failed. error = %d\n", error); goto out; } @@ -203,7 +203,7 @@ ofw_pci_init(device_t dev) sc->sc_mem_rman.rm_type = RMAN_ARRAY; sc->sc_mem_rman.rm_descr = "PCI Memory"; error = rman_init(&sc->sc_mem_rman); - if (error) { + if (error != 0) { device_printf(dev, "rman_init() failed. error = %d\n", error); goto out; } @@ -226,7 +226,7 @@ ofw_pci_init(device_t dev) break; } - if (error) { + if (error != 0) { device_printf(dev, "rman_manage_region(%x, %#jx, %#jx) failed. " "error = %d\n", rp->pci_hi & @@ -257,7 +257,7 @@ ofw_pci_attach(device_t dev) sc = device_get_softc(dev); if (!sc->sc_initialized) { error = ofw_pci_init(dev); - if (error) + if (error != 0) return (error); } @@ -437,9 +437,11 @@ ofw_pci_release_resource(device_t bus, d { if (rman_get_flags(res) & RF_ACTIVE) { - int error = bus_deactivate_resource(child, type, rid, res); - if (error) - return error; + int error; + + error = bus_deactivate_resource(child, type, rid, res); + if (error != 0) + return (error); } return (rman_release_resource(res)); @@ -544,9 +546,10 @@ static int ofw_pci_adjust_resource(device_t bus, device_t child, int type, struct resource *res, rman_res_t start, rman_res_t end) { - struct rman *rm = NULL; - struct ofw_pci_softc *sc = device_get_softc(bus); + struct rman *rm; + struct ofw_pci_softc *sc; + sc = device_get_softc(bus); KASSERT(!(rman_get_flags(res) & RF_ACTIVE), ("active resources cannot be adjusted")); if (rman_get_flags(res) & RF_ACTIVE) From owner-svn-src-all@freebsd.org Sat Oct 15 09:09:27 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 46D3FC123D3; Sat, 15 Oct 2016 09:09:27 +0000 (UTC) (envelope-from mmel@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 0899422D; Sat, 15 Oct 2016 09:09:26 +0000 (UTC) (envelope-from mmel@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9F99QMd052458; Sat, 15 Oct 2016 09:09:26 GMT (envelope-from mmel@FreeBSD.org) Received: (from mmel@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9F99Qvi052455; Sat, 15 Oct 2016 09:09:26 GMT (envelope-from mmel@FreeBSD.org) Message-Id: <201610150909.u9F99Qvi052455@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mmel set sender to mmel@FreeBSD.org using -f From: Michal Meloun Date: Sat, 15 Oct 2016 09:09:26 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307347 - stable/11/sys/dev/ofw X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 Oct 2016 09:09:27 -0000 Author: mmel Date: Sat Oct 15 09:09:25 2016 New Revision: 307347 URL: https://svnweb.freebsd.org/changeset/base/307347 Log: MFC r302951,r302952,r304071: r302951: OFWPCI: Improve resource handling. - add new rman for prefetchable memory. Is used only if given 'ranges' property contains prefetchable memory range. r302952: OFWPCI: Add support for NEW_PCIB. r304071: OFWPCI: Don't strip RF_ACTIVE from flags when parent bus method is called. Modified: stable/11/sys/dev/ofw/ofwpci.c stable/11/sys/dev/ofw/ofwpci.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/ofw/ofwpci.c ============================================================================== --- stable/11/sys/dev/ofw/ofwpci.c Sat Oct 15 08:52:42 2016 (r307346) +++ stable/11/sys/dev/ofw/ofwpci.c Sat Oct 15 09:09:25 2016 (r307347) @@ -42,6 +42,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include @@ -94,6 +95,7 @@ static phandle_t ofw_pci_get_node(device * local methods */ static int ofw_pci_fill_ranges(phandle_t, struct ofw_pci_range *); +static struct rman *ofw_pci_get_rman(struct ofw_pci_softc *, int, u_int); /* * Driver methods. @@ -137,13 +139,14 @@ ofw_pci_init(device_t dev) phandle_t node; u_int32_t busrange[2]; struct ofw_pci_range *rp; - int error; + int i, error; struct ofw_pci_cell_info *cell_info; node = ofw_bus_get_node(dev); sc = device_get_softc(dev); sc->sc_initialized = 1; sc->sc_range = NULL; + sc->sc_pci_domain = device_get_unit(dev); cell_info = (struct ofw_pci_cell_info *)malloc(sizeof(*cell_info), M_DEVBUF, M_WAITOK | M_ZERO); @@ -201,17 +204,27 @@ ofw_pci_init(device_t dev) } sc->sc_mem_rman.rm_type = RMAN_ARRAY; - sc->sc_mem_rman.rm_descr = "PCI Memory"; + sc->sc_mem_rman.rm_descr = "PCI Non Prefetchable Memory"; error = rman_init(&sc->sc_mem_rman); if (error != 0) { device_printf(dev, "rman_init() failed. error = %d\n", error); goto out; } - for (rp = sc->sc_range; rp < sc->sc_range + sc->sc_nrange && - rp->pci_hi != 0; rp++) { + sc->sc_pmem_rman.rm_type = RMAN_ARRAY; + sc->sc_pmem_rman.rm_descr = "PCI Prefetchable Memory"; + error = rman_init(&sc->sc_pmem_rman); + if (error != 0) { + device_printf(dev, "rman_init() failed. error = %d\n", error); + goto out; + } + + for (i = 0; i < sc->sc_nrange; i++) { error = 0; + rp = sc->sc_range + i; + if (sc->sc_range_mask & ((uint64_t)1 << i)) + continue; switch (rp->pci_hi & OFW_PCI_PHYS_HI_SPACEMASK) { case OFW_PCI_PHYS_HI_SPACE_CONFIG: break; @@ -221,8 +234,14 @@ ofw_pci_init(device_t dev) break; case OFW_PCI_PHYS_HI_SPACE_MEM32: case OFW_PCI_PHYS_HI_SPACE_MEM64: - error = rman_manage_region(&sc->sc_mem_rman, rp->pci, - rp->pci + rp->size - 1); + if (rp->pci_hi & OFW_PCI_PHYS_HI_PREFETCHABLE) { + sc->sc_have_pmem = 1; + error = rman_manage_region(&sc->sc_pmem_rman, + rp->pci, rp->pci + rp->size - 1); + } else { + error = rman_manage_region(&sc->sc_mem_rman, + rp->pci, rp->pci + rp->size - 1); + } break; } @@ -244,6 +263,7 @@ out: free(sc->sc_range, M_DEVBUF); rman_fini(&sc->sc_io_rman); rman_fini(&sc->sc_mem_rman); + rman_fini(&sc->sc_pmem_rman); return (error); } @@ -318,7 +338,7 @@ ofw_pci_read_ivar(device_t dev, device_t switch (which) { case PCIB_IVAR_DOMAIN: - *result = device_get_unit(dev); + *result = sc->sc_pci_domain; return (0); case PCIB_IVAR_BUS: *result = sc->sc_bus; @@ -385,28 +405,23 @@ ofw_pci_alloc_resource(device_t bus, dev struct rman *rm; int needactivate; + needactivate = flags & RF_ACTIVE; flags &= ~RF_ACTIVE; sc = device_get_softc(bus); - switch (type) { - case SYS_RES_MEMORY: - rm = &sc->sc_mem_rman; - break; - - case SYS_RES_IOPORT: - rm = &sc->sc_io_rman; - break; - - case SYS_RES_IRQ: - return (bus_alloc_resource(bus, type, rid, start, end, count, - flags)); +#if defined(NEW_PCIB) && defined(PCI_RES_BUS) + if (type == PCI_RES_BUS) { + return (pci_domain_alloc_bus(sc->sc_pci_domain, child, rid, + start, end, count, flags | needactivate)); + } +#endif - default: - device_printf(bus, "unknown resource request from %s\n", - device_get_nameunit(child)); - return (NULL); + rm = ofw_pci_get_rman(sc, type, flags); + if (rm == NULL) { + return (bus_generic_alloc_resource(bus, child, type, rid, + start, end, count, flags | needactivate)); } rv = rman_reserve_resource(rm, start, end, count, flags, child); @@ -435,15 +450,30 @@ static int ofw_pci_release_resource(device_t bus, device_t child, int type, int rid, struct resource *res) { + struct ofw_pci_softc *sc; + struct rman *rm; + int error; - if (rman_get_flags(res) & RF_ACTIVE) { - int error; + sc = device_get_softc(bus); + +#if defined(NEW_PCIB) && defined(PCI_RES_BUS) + if (type == PCI_RES_BUS) + return (pci_domain_release_bus(sc->sc_pci_domain, child, rid, + res)); +#endif + rm = ofw_pci_get_rman(sc, type, rman_get_flags(res)); + if (rm == NULL) { + return (bus_generic_release_resource(bus, child, type, rid, + res)); + } + KASSERT(rman_is_region_manager(res, rm), ("rman mismatch")); + + if (rman_get_flags(res) & RF_ACTIVE) { error = bus_deactivate_resource(child, type, rid, res); if (error != 0) return (error); } - return (rman_release_resource(res)); } @@ -454,63 +484,62 @@ ofw_pci_activate_resource(device_t bus, struct ofw_pci_softc *sc; bus_space_handle_t handle; bus_space_tag_t tag; + struct ofw_pci_range *rp; + vm_paddr_t start; + int space; int rv; sc = device_get_softc(bus); - if (type == SYS_RES_IRQ) { - return (bus_activate_resource(bus, type, rid, res)); + if (type != SYS_RES_IOPORT && type != SYS_RES_MEMORY) { + return (bus_generic_activate_resource(bus, child, type, rid, + res)); } - if (type == SYS_RES_MEMORY || type == SYS_RES_IOPORT) { - struct ofw_pci_range *rp; - vm_paddr_t start; - int space; - - start = (vm_paddr_t)rman_get_start(res); - - /* - * Map this through the ranges list - */ - for (rp = sc->sc_range; rp < sc->sc_range + sc->sc_nrange && - rp->pci_hi != 0; rp++) { - if (start < rp->pci || start >= rp->pci + rp->size) - continue; - - switch (rp->pci_hi & OFW_PCI_PHYS_HI_SPACEMASK) { - case OFW_PCI_PHYS_HI_SPACE_IO: - space = SYS_RES_IOPORT; - break; - case OFW_PCI_PHYS_HI_SPACE_MEM32: - case OFW_PCI_PHYS_HI_SPACE_MEM64: - space = SYS_RES_MEMORY; - break; - default: - space = -1; - } - if (type == space) { - start += (rp->host - rp->pci); - break; + start = (vm_paddr_t)rman_get_start(res); + + /* + * Map this through the ranges list + */ + for (rp = sc->sc_range; rp < sc->sc_range + sc->sc_nrange && + rp->pci_hi != 0; rp++) { + if (start < rp->pci || start >= rp->pci + rp->size) + continue; + + switch (rp->pci_hi & OFW_PCI_PHYS_HI_SPACEMASK) { + case OFW_PCI_PHYS_HI_SPACE_IO: + space = SYS_RES_IOPORT; + break; + case OFW_PCI_PHYS_HI_SPACE_MEM32: + case OFW_PCI_PHYS_HI_SPACE_MEM64: + space = SYS_RES_MEMORY; + break; + default: + space = -1; } + + if (type == space) { + start += (rp->host - rp->pci); + break; } + } - if (bootverbose) - printf("ofw_pci mapdev: start %jx, len %jd\n", - (rman_res_t)start, rman_get_size(res)); - - tag = BUS_GET_BUS_TAG(child, child); - if (tag == NULL) - return (ENOMEM); - - rman_set_bustag(res, tag); - rv = bus_space_map(tag, start, - rman_get_size(res), 0, &handle); - if (rv != 0) - return (ENOMEM); + if (bootverbose) + printf("ofw_pci mapdev: start %jx, len %jd\n", + (rman_res_t)start, rman_get_size(res)); + + tag = BUS_GET_BUS_TAG(child, child); + if (tag == NULL) + return (ENOMEM); + + rman_set_bustag(res, tag); + rv = bus_space_map(tag, start, + rman_get_size(res), 0, &handle); + if (rv != 0) + return (ENOMEM); - rman_set_bushandle(res, handle); - rman_set_virtual(res, (void *)handle); /* XXX for powerpc only ? */ - } + rman_set_bushandle(res, handle); + rman_set_virtual(res, (void *)handle); /* XXX for powerpc only ? */ return (rman_activate_resource(res)); } @@ -528,17 +557,19 @@ static int ofw_pci_deactivate_resource(device_t bus, device_t child, int type, int rid, struct resource *res) { + struct ofw_pci_softc *sc; + vm_size_t psize; - /* - * If this is a memory resource, unmap it. - */ - if ((type == SYS_RES_MEMORY) || (type == SYS_RES_IOPORT)) { - u_int32_t psize; + sc = device_get_softc(bus); - psize = rman_get_size(res); - pmap_unmapdev((vm_offset_t)rman_get_virtual(res), psize); + if (type != SYS_RES_IOPORT && type != SYS_RES_MEMORY) { + return (bus_generic_deactivate_resource(bus, child, type, rid, + res)); } + psize = rman_get_size(res); + pmap_unmapdev((vm_offset_t)rman_get_virtual(res), psize); + return (rman_deactivate_resource(res)); } @@ -550,24 +581,20 @@ ofw_pci_adjust_resource(device_t bus, de struct ofw_pci_softc *sc; sc = device_get_softc(bus); - KASSERT(!(rman_get_flags(res) & RF_ACTIVE), - ("active resources cannot be adjusted")); - if (rman_get_flags(res) & RF_ACTIVE) - return (EINVAL); +#if defined(NEW_PCIB) && defined(PCI_RES_BUS) + if (type == PCI_RES_BUS) + return (pci_domain_adjust_bus(sc->sc_pci_domain, child, res, + start, end)); +#endif - switch (type) { - case SYS_RES_MEMORY: - rm = &sc->sc_mem_rman; - break; - case SYS_RES_IOPORT: - rm = &sc->sc_io_rman; - break; - default: - return (ENXIO); + rm = ofw_pci_get_rman(sc, type, rman_get_flags(res)); + if (rm == NULL) { + return (bus_generic_adjust_resource(bus, child, type, res, + start, end)); } - - if (!rman_is_region_manager(res, rm)) - return (EINVAL); + KASSERT(rman_is_region_manager(res, rm), ("rman mismatch")); + KASSERT(!(rman_get_flags(res) & RF_ACTIVE), + ("active resources cannot be adjusted")); return (rman_adjust_resource(res, start, end)); } @@ -629,3 +656,22 @@ ofw_pci_fill_ranges(phandle_t node, stru free(base_ranges, M_DEVBUF); return (nranges); } + +static struct rman * +ofw_pci_get_rman(struct ofw_pci_softc *sc, int type, u_int flags) +{ + + switch (type) { + case SYS_RES_IOPORT: + return (&sc->sc_io_rman); + case SYS_RES_MEMORY: + if (sc->sc_have_pmem && (flags & RF_PREFETCHABLE)) + return (&sc->sc_pmem_rman); + else + return (&sc->sc_mem_rman); + default: + break; + } + + return (NULL); +} Modified: stable/11/sys/dev/ofw/ofwpci.h ============================================================================== --- stable/11/sys/dev/ofw/ofwpci.h Sat Oct 15 08:52:42 2016 (r307346) +++ stable/11/sys/dev/ofw/ofwpci.h Sat Oct 15 09:09:25 2016 (r307347) @@ -60,15 +60,19 @@ struct ofw_pci_softc { int sc_bus; int sc_initialized; int sc_quirks; + int sc_have_pmem; struct ofw_pci_range *sc_range; int sc_nrange; + uint64_t sc_range_mask; struct ofw_pci_cell_info *sc_cell_info; struct rman sc_io_rman; struct rman sc_mem_rman; + struct rman sc_pmem_rman; bus_space_tag_t sc_memt; bus_dma_tag_t sc_dmat; + int sc_pci_domain; struct ofw_bus_iinfo sc_pci_iinfo; }; From owner-svn-src-all@freebsd.org Sat Oct 15 09:10:36 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id AFD19C1243D; Sat, 15 Oct 2016 09:10:36 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 7C2003DA; Sat, 15 Oct 2016 09:10:36 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9F9AZac052561; Sat, 15 Oct 2016 09:10:35 GMT (envelope-from avg@FreeBSD.org) Received: (from avg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9F9AZvk052560; Sat, 15 Oct 2016 09:10:35 GMT (envelope-from avg@FreeBSD.org) Message-Id: <201610150910.u9F9AZvk052560@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avg set sender to avg@FreeBSD.org using -f From: Andriy Gapon Date: Sat, 15 Oct 2016 09:10:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307348 - head/sys/dev/acpi_support X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 Oct 2016 09:10:36 -0000 Author: avg Date: Sat Oct 15 09:10:35 2016 New Revision: 307348 URL: https://svnweb.freebsd.org/changeset/base/307348 Log: aibs / atk0110: add support for querying sensors via GGRP and GITM Comparing to the Linux driver there is still one missing feature. The Linux driver finds and enables "Embedded Controller" item in the 0x11 group if it's not enabled yet. I tested the new method, Torfinn Ingolfsen tested the old method and helped to fix several bugs in the earlier versions of the patch. Tested by: Torfinn Ingolfsen Reviewed by: rpaulo MFC after: 3 weeks Differential Revision: https://reviews.freebsd.org/D8227 Modified: head/sys/dev/acpi_support/atk0110.c Modified: head/sys/dev/acpi_support/atk0110.c ============================================================================== --- head/sys/dev/acpi_support/atk0110.c Sat Oct 15 09:09:25 2016 (r307347) +++ head/sys/dev/acpi_support/atk0110.c Sat Oct 15 09:10:35 2016 (r307348) @@ -28,6 +28,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -51,18 +52,23 @@ ACPI_SERIAL_DECL(aibs, "aibs"); #define AIBS_MORE_SENSORS #define AIBS_VERBOSE -enum aibs_type { - AIBS_VOLT, - AIBS_TEMP, - AIBS_FAN -}; +#define AIBS_GROUP_SENSORS 0x06 + +#define AIBS_SENS_TYPE(x) (((x) >> 16) & 0xff) +#define AIBS_SENS_TYPE_VOLT 2 +#define AIBS_SENS_TYPE_TEMP 3 +#define AIBS_SENS_TYPE_FAN 4 + +#define AIBS_SENS_TYPE_VOLT_NAME "volt" +#define AIBS_SENS_TYPE_VOLT_TEMP "temp" +#define AIBS_SENS_TYPE_VOLT_FAN "fan" struct aibs_sensor { ACPI_INTEGER v; ACPI_INTEGER i; ACPI_INTEGER l; ACPI_INTEGER h; - enum aibs_type t; + int t; }; struct aibs_softc { @@ -72,14 +78,23 @@ struct aibs_softc { struct aibs_sensor *sc_asens_volt; struct aibs_sensor *sc_asens_temp; struct aibs_sensor *sc_asens_fan; + struct aibs_sensor *sc_asens_all; + + struct sysctl_oid *sc_volt_sysctl; + struct sysctl_oid *sc_temp_sysctl; + struct sysctl_oid *sc_fan_sysctl; + + bool sc_ggrp_method; }; static int aibs_probe(device_t); static int aibs_attach(device_t); static int aibs_detach(device_t); static int aibs_sysctl(SYSCTL_HANDLER_ARGS); +static int aibs_sysctl_ggrp(SYSCTL_HANDLER_ARGS); -static void aibs_attach_sif(struct aibs_softc *, enum aibs_type); +static int aibs_attach_ggrp(struct aibs_softc *); +static int aibs_attach_sif(struct aibs_softc *, int); static device_method_t aibs_methods[] = { DEVMETHOD(device_probe, aibs_probe), @@ -109,54 +124,240 @@ aibs_probe(device_t dev) { if (acpi_disabled("aibs") || ACPI_ID_PROBE(device_get_parent(dev), dev, aibs_hids) == NULL) - return ENXIO; + return (ENXIO); device_set_desc(dev, "ASUSTeK AI Booster (ACPI ASOC ATK0110)"); - return 0; + return (0); } static int aibs_attach(device_t dev) { struct aibs_softc *sc = device_get_softc(dev); + int err; sc->sc_dev = dev; sc->sc_ah = acpi_get_handle(dev); - aibs_attach_sif(sc, AIBS_VOLT); - aibs_attach_sif(sc, AIBS_TEMP); - aibs_attach_sif(sc, AIBS_FAN); + sc->sc_ggrp_method = false; + err = aibs_attach_sif(sc, AIBS_SENS_TYPE_VOLT); + if (err == 0) + err = aibs_attach_sif(sc, AIBS_SENS_TYPE_TEMP); + if (err == 0) + err = aibs_attach_sif(sc, AIBS_SENS_TYPE_FAN); + + if (err == 0) + return (0); + + /* Clean up whatever was allocated earlier. */ + if (sc->sc_volt_sysctl != NULL) + sysctl_remove_oid(sc->sc_volt_sysctl, true, true); + if (sc->sc_temp_sysctl != NULL) + sysctl_remove_oid(sc->sc_temp_sysctl, true, true); + if (sc->sc_fan_sysctl != NULL) + sysctl_remove_oid(sc->sc_fan_sysctl, true, true); + aibs_detach(dev); + + sc->sc_ggrp_method = true; + err = aibs_attach_ggrp(sc); + return (err); +} + +static int +aibs_add_sensor(struct aibs_softc *sc, ACPI_OBJECT *o, + struct aibs_sensor* sensor, const char ** descr) +{ + int off; - return 0; + /* + * Packages for the old and new methods are quite + * similar except that the new package has two + * new (unknown / unused) fields after the name field. + */ + if (sc->sc_ggrp_method) + off = 4; + else + off = 2; + + if (o->Type != ACPI_TYPE_PACKAGE) { + device_printf(sc->sc_dev, + "sensor object is not a package: %i type\n", + o->Type); + return (ENXIO); + } + if (o[0].Package.Count != (off + 3) || + o->Package.Elements[0].Type != ACPI_TYPE_INTEGER || + o->Package.Elements[1].Type != ACPI_TYPE_STRING || + o->Package.Elements[off].Type != ACPI_TYPE_INTEGER || + o->Package.Elements[off + 1].Type != ACPI_TYPE_INTEGER || + o->Package.Elements[off + 2].Type != ACPI_TYPE_INTEGER) { + device_printf(sc->sc_dev, "unexpected package content\n"); + return (ENXIO); + } + + sensor->i = o->Package.Elements[0].Integer.Value; + *descr = o->Package.Elements[1].String.Pointer; + sensor->l = o->Package.Elements[off].Integer.Value; + sensor->h = o->Package.Elements[off + 1].Integer.Value; + /* For the new method the second value is a range size. */ + if (sc->sc_ggrp_method) + sensor->h += sensor->l; + sensor->t = AIBS_SENS_TYPE(sensor->i); + + switch (sensor->t) { + case AIBS_SENS_TYPE_VOLT: + case AIBS_SENS_TYPE_TEMP: + case AIBS_SENS_TYPE_FAN: + return (0); + default: + device_printf(sc->sc_dev, "unknown sensor type 0x%x", + sensor->t); + return (ENXIO); + } } static void -aibs_attach_sif(struct aibs_softc *sc, enum aibs_type st) +aibs_sensor_added(struct aibs_softc *sc, struct sysctl_oid *so, + const char *type_name, int idx, struct aibs_sensor *sensor, + const char *descr) +{ + char sysctl_name[8]; + + snprintf(sysctl_name, sizeof(sysctl_name), "%i", idx); +#ifdef AIBS_VERBOSE + device_printf(sc->sc_dev, "%c%i: 0x%08jx %20s %5jd / %5jd\n", + type_name[0], idx, + (uintmax_t)sensor->i, descr, (intmax_t)sensor->l, + (intmax_t)sensor->h); +#endif + SYSCTL_ADD_PROC(device_get_sysctl_ctx(sc->sc_dev), + SYSCTL_CHILDREN(so), idx, sysctl_name, + CTLTYPE_INT | CTLFLAG_RD, sc, (uintptr_t)sensor, + sc->sc_ggrp_method ? aibs_sysctl_ggrp : aibs_sysctl, + sensor->t == AIBS_SENS_TYPE_TEMP ? "IK" : "I", descr); +} + +static int +aibs_attach_ggrp(struct aibs_softc *sc) +{ + ACPI_STATUS s; + ACPI_BUFFER buf; + ACPI_HANDLE h; + ACPI_OBJECT id; + ACPI_OBJECT *bp; + ACPI_OBJECT_LIST arg; + int i; + int t, v, f; + int err; + int *s_idx; + const char *name; + const char *descr; + struct aibs_sensor *sensor; + struct sysctl_oid **so; + + /* First see if GITM is available. */ + s = AcpiGetHandle(sc->sc_ah, "GITM", &h); + if (ACPI_FAILURE(s)) { + if (bootverbose) + device_printf(sc->sc_dev, "GITM not found\n"); + return (ENXIO); + } + + /* + * Now call GGRP with the appropriate argument to list sensors. + * The method lists different groups of entities depending on + * the argument. + */ + id.Integer.Value = AIBS_GROUP_SENSORS; + id.Type = ACPI_TYPE_INTEGER; + arg.Count = 1; + arg.Pointer = &id; + buf.Length = ACPI_ALLOCATE_BUFFER; + buf.Pointer = NULL; + s = AcpiEvaluateObjectTyped(sc->sc_ah, "GGRP", &arg, &buf, + ACPI_TYPE_PACKAGE); + if (ACPI_FAILURE(s)) { + device_printf(sc->sc_dev, "GGRP not found\n"); + return (ENXIO); + } + + bp = buf.Pointer; + sc->sc_asens_all = malloc(sizeof(*sc->sc_asens_all) * bp->Package.Count, + M_DEVBUF, M_WAITOK | M_ZERO); + v = t = f = 0; + for (i = 0; i < bp->Package.Count; i++) { + sensor = &sc->sc_asens_all[i]; + err = aibs_add_sensor(sc, &bp->Package.Elements[i], sensor, + &descr); + if (err != 0) + continue; + + switch (sensor->t) { + case AIBS_SENS_TYPE_VOLT: + name = "volt"; + so = &sc->sc_volt_sysctl; + s_idx = &v; + break; + case AIBS_SENS_TYPE_TEMP: + name = "temp"; + so = &sc->sc_temp_sysctl; + s_idx = &t; + break; + case AIBS_SENS_TYPE_FAN: + name = "fan"; + so = &sc->sc_fan_sysctl; + s_idx = &f; + break; + default: + panic("add_sensor succeeded for unknown sensor type %d", + sensor->t); + } + + if (*so == NULL) { + /* sysctl subtree for sensors of this type */ + *so = SYSCTL_ADD_NODE(device_get_sysctl_ctx(sc->sc_dev), + SYSCTL_CHILDREN(device_get_sysctl_tree(sc->sc_dev)), + sensor->t, name, CTLFLAG_RD, NULL, NULL); + } + aibs_sensor_added(sc, *so, name, *s_idx, sensor, descr); + *s_idx += 1; + } + + AcpiOsFree(buf.Pointer); + return (0); +} + +static int +aibs_attach_sif(struct aibs_softc *sc, int st) { + char name[] = "?SIF"; ACPI_STATUS s; ACPI_BUFFER b; ACPI_OBJECT *bp, *o; - int i, n; const char *node; - char name[] = "?SIF"; struct aibs_sensor *as; - struct sysctl_oid *so; + struct sysctl_oid **so; + int i, n; + int err; switch (st) { - case AIBS_VOLT: + case AIBS_SENS_TYPE_VOLT: node = "volt"; name[0] = 'V'; + so = &sc->sc_volt_sysctl; break; - case AIBS_TEMP: + case AIBS_SENS_TYPE_TEMP: node = "temp"; name[0] = 'T'; + so = &sc->sc_temp_sysctl; break; - case AIBS_FAN: + case AIBS_SENS_TYPE_FAN: node = "fan"; name[0] = 'F'; + so = &sc->sc_fan_sysctl; break; default: - return; + panic("Unsupported sensor type %d", st); } b.Length = ACPI_ALLOCATE_BUFFER; @@ -164,7 +365,7 @@ aibs_attach_sif(struct aibs_softc *sc, e ACPI_TYPE_PACKAGE); if (ACPI_FAILURE(s)) { device_printf(sc->sc_dev, "%s not found\n", name); - return; + return (ENXIO); } bp = b.Pointer; @@ -172,14 +373,14 @@ aibs_attach_sif(struct aibs_softc *sc, e if (o[0].Type != ACPI_TYPE_INTEGER) { device_printf(sc->sc_dev, "%s[0]: invalid type\n", name); AcpiOsFree(b.Pointer); - return; + return (ENXIO); } n = o[0].Integer.Value; if (bp->Package.Count - 1 < n) { device_printf(sc->sc_dev, "%s: invalid package\n", name); AcpiOsFree(b.Pointer); - return; + return (ENXIO); } else if (bp->Package.Count - 1 > n) { int on = n; @@ -193,76 +394,37 @@ aibs_attach_sif(struct aibs_softc *sc, e device_printf(sc->sc_dev, "%s: no members in the package\n", name); AcpiOsFree(b.Pointer); - return; + return (ENXIO); } - as = malloc(sizeof(*as) * n, M_DEVBUF, M_NOWAIT | M_ZERO); - if (as == NULL) { - device_printf(sc->sc_dev, "%s: malloc fail\n", name); - AcpiOsFree(b.Pointer); - return; - } + as = malloc(sizeof(*as) * n, M_DEVBUF, M_WAITOK | M_ZERO); switch (st) { - case AIBS_VOLT: + case AIBS_SENS_TYPE_VOLT: sc->sc_asens_volt = as; break; - case AIBS_TEMP: + case AIBS_SENS_TYPE_TEMP: sc->sc_asens_temp = as; break; - case AIBS_FAN: + case AIBS_SENS_TYPE_FAN: sc->sc_asens_fan = as; break; } /* sysctl subtree for sensors of this type */ - so = SYSCTL_ADD_NODE(device_get_sysctl_ctx(sc->sc_dev), + *so = SYSCTL_ADD_NODE(device_get_sysctl_ctx(sc->sc_dev), SYSCTL_CHILDREN(device_get_sysctl_tree(sc->sc_dev)), st, node, CTLFLAG_RD, NULL, NULL); for (i = 0, o++; i < n; i++, o++) { - ACPI_OBJECT *oi; - char si[3]; - const char *desc; - - /* acpica5 automatically evaluates the referenced package */ - if (o[0].Type != ACPI_TYPE_PACKAGE) { - device_printf(sc->sc_dev, - "%s: %i: not a package: %i type\n", - name, i, o[0].Type); - continue; - } - oi = o[0].Package.Elements; - if (o[0].Package.Count != 5 || - oi[0].Type != ACPI_TYPE_INTEGER || - oi[1].Type != ACPI_TYPE_STRING || - oi[2].Type != ACPI_TYPE_INTEGER || - oi[3].Type != ACPI_TYPE_INTEGER || - oi[4].Type != ACPI_TYPE_INTEGER) { - device_printf(sc->sc_dev, - "%s: %i: invalid package\n", - name, i); - continue; - } - as[i].i = oi[0].Integer.Value; - desc = oi[1].String.Pointer; - as[i].l = oi[2].Integer.Value; - as[i].h = oi[3].Integer.Value; - as[i].t = st; -#ifdef AIBS_VERBOSE - device_printf(sc->sc_dev, "%c%i: " - "0x%08"PRIx64" %20s %5"PRIi64" / %5"PRIi64" " - "0x%"PRIx64"\n", - name[0], i, - (uint64_t)as[i].i, desc, (int64_t)as[i].l, - (int64_t)as[i].h, (uint64_t)oi[4].Integer.Value); -#endif - snprintf(si, sizeof(si), "%i", i); - SYSCTL_ADD_PROC(device_get_sysctl_ctx(sc->sc_dev), - SYSCTL_CHILDREN(so), i, si, CTLTYPE_INT | CTLFLAG_RD, - sc, st, aibs_sysctl, st == AIBS_TEMP ? "IK" : "I", desc); + const char *descr; + + err = aibs_add_sensor(sc, o, &as[i], &descr); + if (err == 0) + aibs_sensor_added(sc, *so, node, i, &as[i], descr); } AcpiOsFree(b.Pointer); + return (0); } static int @@ -276,7 +438,9 @@ aibs_detach(device_t dev) free(sc->sc_asens_temp, M_DEVBUF); if (sc->sc_asens_fan != NULL) free(sc->sc_asens_fan, M_DEVBUF); - return 0; + if (sc->sc_asens_all != NULL) + free(sc->sc_asens_all, M_DEVBUF); + return (0); } #ifdef AIBS_VERBOSE @@ -289,39 +453,33 @@ static int aibs_sysctl(SYSCTL_HANDLER_ARGS) { struct aibs_softc *sc = arg1; - enum aibs_type st = arg2; + struct aibs_sensor *sensor = (void *)arg2; int i = oidp->oid_number; ACPI_STATUS rs; ACPI_OBJECT p, *bp; ACPI_OBJECT_LIST mp; ACPI_BUFFER b; char *name; - struct aibs_sensor *as; ACPI_INTEGER v, l, h; int so[3]; - switch (st) { - case AIBS_VOLT: + switch (sensor->t) { + case AIBS_SENS_TYPE_VOLT: name = "RVLT"; - as = sc->sc_asens_volt; break; - case AIBS_TEMP: + case AIBS_SENS_TYPE_TEMP: name = "RTMP"; - as = sc->sc_asens_temp; break; - case AIBS_FAN: + case AIBS_SENS_TYPE_FAN: name = "RFAN"; - as = sc->sc_asens_fan; break; default: - return ENOENT; + return (ENOENT); } - if (as == NULL) - return ENOENT; - l = as[i].l; - h = as[i].h; + l = sensor->l; + h = sensor->h; p.Type = ACPI_TYPE_INTEGER; - p.Integer.Value = as[i].i; + p.Integer.Value = sensor->i; mp.Count = 1; mp.Pointer = &p; b.Length = ACPI_ALLOCATE_BUFFER; @@ -333,26 +491,91 @@ aibs_sysctl(SYSCTL_HANDLER_ARGS) "%s: %i: evaluation failed\n", name, i); ACPI_SERIAL_END(aibs); - return EIO; + return (EIO); } bp = b.Pointer; v = bp->Integer.Value; AcpiOsFree(b.Pointer); ACPI_SERIAL_END(aibs); - switch (st) { - case AIBS_VOLT: + switch (sensor->t) { + case AIBS_SENS_TYPE_VOLT: + break; + case AIBS_SENS_TYPE_TEMP: + v += 2731; + l += 2731; + h += 2731; + break; + case AIBS_SENS_TYPE_FAN: + break; + } + so[0] = v; + so[1] = l; + so[2] = h; + return (sysctl_handle_opaque(oidp, &so, sizeof(so), req)); +} + +static int +aibs_sysctl_ggrp(SYSCTL_HANDLER_ARGS) +{ + struct aibs_softc *sc = arg1; + struct aibs_sensor *sensor = (void *)arg2; + ACPI_STATUS rs; + ACPI_OBJECT p, *bp; + ACPI_OBJECT_LIST arg; + ACPI_BUFFER buf; + ACPI_INTEGER v, l, h; + int so[3]; + uint32_t *ret; + uint32_t cmd[3]; + + cmd[0] = sensor->i; + cmd[1] = 0; + cmd[2] = 0; + p.Type = ACPI_TYPE_BUFFER; + p.Buffer.Pointer = (void *)cmd; + p.Buffer.Length = sizeof(cmd); + arg.Count = 1; + arg.Pointer = &p; + buf.Pointer = NULL; + buf.Length = ACPI_ALLOCATE_BUFFER; + ACPI_SERIAL_BEGIN(aibs); + rs = AcpiEvaluateObjectTyped(sc->sc_ah, "GITM", &arg, &buf, + ACPI_TYPE_BUFFER); + ACPI_SERIAL_END(aibs); + if (ACPI_FAILURE(rs)) { + device_printf(sc->sc_dev, "GITM evaluation failed\n"); + return (EIO); + } + bp = buf.Pointer; + if (bp->Buffer.Length < 8) { + device_printf(sc->sc_dev, "GITM returned short buffer\n"); + return (EIO); + } + ret = (uint32_t *)bp->Buffer.Pointer; + if (ret[0] == 0) { + device_printf(sc->sc_dev, "GITM returned error status\n"); + return (EINVAL); + } + v = ret[1]; + AcpiOsFree(buf.Pointer); + + l = sensor->l; + h = sensor->h; + + switch (sensor->t) { + case AIBS_SENS_TYPE_VOLT: break; - case AIBS_TEMP: + case AIBS_SENS_TYPE_TEMP: v += 2731; l += 2731; h += 2731; break; - case AIBS_FAN: + case AIBS_SENS_TYPE_FAN: break; } so[0] = v; so[1] = l; so[2] = h; - return sysctl_handle_opaque(oidp, &so, sizeof(so), req); + return (sysctl_handle_opaque(oidp, &so, sizeof(so), req)); } From owner-svn-src-all@freebsd.org Sat Oct 15 09:54:23 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B3B84C111ED; Sat, 15 Oct 2016 09:54:23 +0000 (UTC) (envelope-from andrew@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 83EF3DBB; Sat, 15 Oct 2016 09:54:23 +0000 (UTC) (envelope-from andrew@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9F9sMkv070815; Sat, 15 Oct 2016 09:54:22 GMT (envelope-from andrew@FreeBSD.org) Received: (from andrew@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9F9sM3W070814; Sat, 15 Oct 2016 09:54:22 GMT (envelope-from andrew@FreeBSD.org) Message-Id: <201610150954.u9F9sM3W070814@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: andrew set sender to andrew@FreeBSD.org using -f From: Andrew Turner Date: Sat, 15 Oct 2016 09:54:22 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307349 - head/sys/arm64/arm64 X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 Oct 2016 09:54:23 -0000 Author: andrew Date: Sat Oct 15 09:54:22 2016 New Revision: 307349 URL: https://svnweb.freebsd.org/changeset/base/307349 Log: Check we are in a critical section when calling vfp_discard. As we may call it with a NULL thread pointer only check when it is non-NULL. Obtained from: ABT Systems Ltd Sponsored by: The FreeBSD Foundation Modified: head/sys/arm64/arm64/vfp.c Modified: head/sys/arm64/arm64/vfp.c ============================================================================== --- head/sys/arm64/arm64/vfp.c Sat Oct 15 09:10:35 2016 (r307348) +++ head/sys/arm64/arm64/vfp.c Sat Oct 15 09:54:22 2016 (r307349) @@ -79,6 +79,10 @@ void vfp_discard(struct thread *td) { +#ifdef INVARIANTS + if (td != NULL) + CRITICAL_ASSERT(td); +#endif if (PCPU_GET(fpcurthread) == td) PCPU_SET(fpcurthread, NULL); From owner-svn-src-all@freebsd.org Sat Oct 15 10:29:35 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 5BE35C11BDA; Sat, 15 Oct 2016 10:29:35 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 36BFCDC4; Sat, 15 Oct 2016 10:29:35 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9FATYTh082413; Sat, 15 Oct 2016 10:29:34 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9FATY8s082409; Sat, 15 Oct 2016 10:29:34 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201610151029.u9FATY8s082409@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Sat, 15 Oct 2016 10:29:33 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307350 - in head: sys/cam/ctl usr.sbin/ctladm X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 Oct 2016 10:29:35 -0000 Author: mav Date: Sat Oct 15 10:29:33 2016 New Revision: 307350 URL: https://svnweb.freebsd.org/changeset/base/307350 Log: Add LUN options to limit UNMAP and WRITE SAME sizes. CTL itself has no limits on on UNMAP and WRITE SAME sizes. But depending on backends large requests may take too much time. To avoid that new configuration options allow to hint initiator maximal sizes it should not exceed. MFC after: 2 weeks Modified: head/sys/cam/ctl/ctl.c head/sys/cam/ctl/ctl.h head/sys/cam/ctl/ctl_backend.c head/usr.sbin/ctladm/ctladm.8 Modified: head/sys/cam/ctl/ctl.c ============================================================================== --- head/sys/cam/ctl/ctl.c Sat Oct 15 09:54:22 2016 (r307349) +++ head/sys/cam/ctl/ctl.c Sat Oct 15 10:29:33 2016 (r307350) @@ -9903,6 +9903,7 @@ ctl_inquiry_evpd_block_limits(struct ctl { struct scsi_vpd_block_limits *bl_ptr; struct ctl_lun *lun; + uint64_t ival; lun = (struct ctl_lun *)ctsio->io_hdr.ctl_private[CTL_PRIV_LUN].ptr; @@ -9941,8 +9942,14 @@ ctl_inquiry_evpd_block_limits(struct ctl if (lun != NULL) { scsi_ulto4b(lun->be_lun->opttxferlen, bl_ptr->opt_txfer_len); if (lun->be_lun->flags & CTL_LUN_FLAG_UNMAP) { - scsi_ulto4b(0xffffffff, bl_ptr->max_unmap_lba_cnt); - scsi_ulto4b(0xffffffff, bl_ptr->max_unmap_blk_cnt); + ival = 0xffffffff; + ctl_get_opt_number(&lun->be_lun->options, + "unmap_max_lba", &ival); + scsi_ulto4b(ival, bl_ptr->max_unmap_lba_cnt); + ival = 0xffffffff; + ctl_get_opt_number(&lun->be_lun->options, + "unmap_max_descr", &ival); + scsi_ulto4b(ival, bl_ptr->max_unmap_blk_cnt); if (lun->be_lun->ublockexp != 0) { scsi_ulto4b((1 << lun->be_lun->ublockexp), bl_ptr->opt_unmap_grain); @@ -9956,8 +9963,10 @@ ctl_inquiry_evpd_block_limits(struct ctl scsi_ulto4b(0, bl_ptr->atomic_transfer_length_granularity); scsi_ulto4b(0, bl_ptr->max_atomic_transfer_length_with_atomic_boundary); scsi_ulto4b(0, bl_ptr->max_atomic_boundary_size); + ival = UINT64_MAX; + ctl_get_opt_number(&lun->be_lun->options, "write_same_max_lba", &ival); + scsi_u64to8b(ival, bl_ptr->max_write_same_length); } - scsi_u64to8b(UINT64_MAX, bl_ptr->max_write_same_length); ctl_set_success(ctsio); ctsio->io_hdr.flags |= CTL_FLAG_ALLOCATED; Modified: head/sys/cam/ctl/ctl.h ============================================================================== --- head/sys/cam/ctl/ctl.h Sat Oct 15 09:54:22 2016 (r307349) +++ head/sys/cam/ctl/ctl.h Sat Oct 15 10:29:33 2016 (r307350) @@ -217,6 +217,7 @@ void ctl_update_opts(ctl_options_t *opts struct ctl_be_arg *args); void ctl_free_opts(ctl_options_t *opts); char * ctl_get_opt(ctl_options_t *opts, const char *name); +int ctl_get_opt_number(ctl_options_t *opts, const char *name, uint64_t *num); int ctl_expand_number(const char *buf, uint64_t *num); #endif /* _KERNEL */ Modified: head/sys/cam/ctl/ctl_backend.c ============================================================================== --- head/sys/cam/ctl/ctl_backend.c Sat Oct 15 09:54:22 2016 (r307349) +++ head/sys/cam/ctl/ctl_backend.c Sat Oct 15 10:29:33 2016 (r307350) @@ -243,3 +243,14 @@ ctl_get_opt(ctl_options_t *opts, const c } return (NULL); } + +int +ctl_get_opt_number(ctl_options_t *opts, const char *name, uint64_t *val) +{ + const char *value; + + value = ctl_get_opt(opts, name); + if (value == NULL) + return (-2); + return (ctl_expand_number(value, val)); +} Modified: head/usr.sbin/ctladm/ctladm.8 ============================================================================== --- head/usr.sbin/ctladm/ctladm.8 Sat Oct 15 09:54:22 2016 (r307349) +++ head/usr.sbin/ctladm/ctladm.8 Sat Oct 15 10:29:33 2016 (r307350) @@ -35,7 +35,7 @@ .\" $Id: //depot/users/kenm/FreeBSD-test2/usr.sbin/ctladm/ctladm.8#3 $ .\" $FreeBSD$ .\" -.Dd September 26, 2015 +.Dd October 15, 2016 .Dt CTLADM 8 .Os .Sh NAME @@ -905,6 +905,13 @@ Specifies nominal form factor of the dev 2 -- 3.5", 3 -- 2.5", 4 -- 1.8", 5 -- less then 1.8". .It Va unmap Set to "on", enables UNMAP support for the LUN, if supported by the backend. +.It Va unmap_max_lba +.It Va unmap_max_descr +Specify maximum allowed number of LBAs and block descriptors per UNMAP +command to report in Block Limits VPD page. +.It Va write_same_max_lba +Specify maximum allowed number of LBAs per WRITE SAME command to report +in Block Limits VPD page. .It Va avail-threshold .It Va used-threshold .It Va pool-avail-threshold From owner-svn-src-all@freebsd.org Sat Oct 15 10:53:31 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 55B8EC12171; Sat, 15 Oct 2016 10:53:31 +0000 (UTC) (envelope-from andrew@fubar.geek.nz) Received: from kif.fubar.geek.nz (kif.fubar.geek.nz [178.62.119.249]) by mx1.freebsd.org (Postfix) with ESMTP id 1B1309BA; Sat, 15 Oct 2016 10:53:30 +0000 (UTC) (envelope-from andrew@fubar.geek.nz) Received: from zapp (5ec3950e.skybroadband.com [94.195.149.14]) by kif.fubar.geek.nz (Postfix) with ESMTPSA id A7B57D84ED; Sat, 15 Oct 2016 10:52:54 +0000 (UTC) Date: Sat, 15 Oct 2016 11:52:53 +0100 From: Andrew Turner To: Oleksandr Tymoshenko Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r307257 - in head/sys: arm/broadcom/bcm2835 arm64/broadcom arm64/broadcom/bcm2837 arm64/conf conf Message-ID: <20161015115253.053550b7@zapp> In-Reply-To: References: <201610140337.u9E3baB7077179@repo.freebsd.org> <20161014093123.606cb8f3@zapp> X-Mailer: Claws Mail 3.14.0 (GTK+ 2.24.29; amd64-portbld-freebsd12.0) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 Oct 2016 10:53:31 -0000 On Fri, 14 Oct 2016 10:23:24 -0700 Oleksandr Tymoshenko wrote: > > On Oct 14, 2016, at 1:31 AM, Andrew Turner > > wrote: > > > > On Fri, 14 Oct 2016 03:37:36 +0000 (UTC) > > Oleksandr Tymoshenko > > > wrote: > >> > >> Added: head/sys/arm64/conf/RPI3 > > > > Why a new kernel config and not GENERIC? > I thought about it. But no SMP support yet. When we have SMP support > we can get rid of RPI3 config. The RPI3 config should then include GENERIC and add nooption SMP. We should possible name it GENERIC-UP or similar. Andrew From owner-svn-src-all@freebsd.org Sat Oct 15 11:41:44 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 4B4DFC12314; Sat, 15 Oct 2016 11:41:44 +0000 (UTC) (envelope-from def@FreeBSD.org) Received: from troz.pl (troz.pl [37.187.125.115]) by mx1.freebsd.org (Postfix) with ESMTP id DA188171; Sat, 15 Oct 2016 11:41:43 +0000 (UTC) (envelope-from def@FreeBSD.org) Received: from [192.168.0.2] (unknown [185.118.250.9]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by troz.pl (Postfix) with ESMTPSA id 28D6C994; Sat, 15 Oct 2016 13:41:42 +0200 (CEST) Subject: Re: svn commit: r307321 - in head/sys/arm64: arm64 include To: Andrew Turner , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org References: <201610141553.u9EFrmT7062155@repo.freebsd.org> From: Konrad Witaszczyk Message-ID: Date: Sat, 15 Oct 2016 13:41:38 +0200 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <201610141553.u9EFrmT7062155@repo.freebsd.org> Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="LrR0ev3DmqnFePiuhcL61Fu1ljARN0KKN" X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 Oct 2016 11:41:44 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --LrR0ev3DmqnFePiuhcL61Fu1ljARN0KKN Content-Type: multipart/mixed; boundary="naRKO9CPQCK5o11CPCjgv7mm4qx6HpxMf"; protected-headers="v1" From: Konrad Witaszczyk To: Andrew Turner , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Message-ID: Subject: Re: svn commit: r307321 - in head/sys/arm64: arm64 include References: <201610141553.u9EFrmT7062155@repo.freebsd.org> In-Reply-To: <201610141553.u9EFrmT7062155@repo.freebsd.org> --naRKO9CPQCK5o11CPCjgv7mm4qx6HpxMf Content-Type: multipart/mixed; boundary="------------0F29FCD2389F98BF52E7E1FC" This is a multi-part message in MIME format. --------------0F29FCD2389F98BF52E7E1FC Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable Hi Andrew, On 10/14/2016 17:53, Andrew Turner wrote: > Author: andrew > Date: Fri Oct 14 15:53:48 2016 > New Revision: 307321 > URL: https://svnweb.freebsd.org/changeset/base/307321 >=20 > Log: > Rework how we store the VFP registers in the pcb. This will be used w= hen > creating a floating-point context within the kernel without having to= move > the stored values in memory. > =20 > Sponsored by: The FreeBSD Foundation >=20 > Modified: > head/sys/arm64/arm64/machdep.c > head/sys/arm64/arm64/vfp.c > head/sys/arm64/arm64/vm_machdep.c > head/sys/arm64/include/pcb.h > head/sys/arm64/include/vfp.h [...] > Modified: head/sys/arm64/include/pcb.h > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D > --- head/sys/arm64/include/pcb.h Fri Oct 14 15:16:44 2016 (r307320) > +++ head/sys/arm64/include/pcb.h Fri Oct 14 15:53:48 2016 (r307321) > @@ -31,6 +31,8 @@ > =20 > #ifndef LOCORE > =20 > +#include > + > struct trapframe; > =20 > #define PCB_LR 30 > @@ -49,13 +51,17 @@ struct pcb { > #define PCB_SINGLE_STEP_SHIFT 0 > #define PCB_SINGLE_STEP (1 << PCB_SINGLE_STEP_SHIFT) > =20 > - /* Place last to simplify the asm to access the rest if the struct */= > - __uint128_t pcb_vfp[32]; > - uint32_t pcb_fpcr; > - uint32_t pcb_fpsr; > + struct vfpstate *pcb_fpusaved; > int pcb_fpflags; > #define PCB_FP_STARTED 0x01 > u_int pcb_vfpcpu; /* Last cpu this thread ran VFP code */ > + > + /* > + * The userspace VFP state. The pcb_fpusaved pointer will point to > + * this unless the kernel has allocated a VFP context. > + * Place last to simplify the asm to access the rest if the struct. > + */ > + struct vfpstate pcb_fpustate; > }; > =20 > #ifdef _KERNEL >=20 > Modified: head/sys/arm64/include/vfp.h > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D > --- head/sys/arm64/include/vfp.h Fri Oct 14 15:16:44 2016 (r307320) > +++ head/sys/arm64/include/vfp.h Fri Oct 14 15:53:48 2016 (r307321) > @@ -35,6 +35,12 @@ > #ifdef _KERNEL > =20 > #ifndef LOCORE > +struct vfpstate { > + __uint128_t vfp_regs[32]; > + uint32_t vfp_fpcr; > + uint32_t vfp_fpsr; > +}; > + > void vfp_init(void); > void vfp_discard(struct thread *); > void vfp_restore_state(void); These changes break buildworld for arm64: In file included from /usr/home/def/FreeBSD/ekcd/repo/lib/libutil/kinfo_g= etfile.c:5: In file included from /usr/obj/arm64.aarch64/usr/home/def/FreeBSD/ekcd/repo/tmp/usr/include/sys= /user.h:38: /usr/obj/arm64.aarch64/usr/home/def/FreeBSD/ekcd/repo/tmp/usr/include/mac= hine/pcb.h:64:18: error: field has incomplete type 'struct vfpstate' struct vfpstate pcb_fpustate; ^ /usr/obj/arm64.aarch64/usr/home/def/FreeBSD/ekcd/repo/tmp/usr/include/mac= hine/pcb.h:54:9: note: forward declaration of 'struct vfpstate' struct vfpstate *pcb_fpusaved; ^ 1 error generated. --- kinfo_getfile.o --- *** [kinfo_getfile.o] Error code 1 You might want to consider making vfpstate available for userland as in a= rm case. If so I'm attaching a patch for it. Konrad --------------0F29FCD2389F98BF52E7E1FC Content-Type: text/x-patch; name="vfpstate.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="vfpstate.patch" diff --git a/sys/arm64/include/vfp.h b/sys/arm64/include/vfp.h index de99118..9429247 100644 --- a/sys/arm64/include/vfp.h +++ b/sys/arm64/include/vfp.h @@ -32,15 +32,15 @@ #ifndef _MACHINE_VFP_H_ #define _MACHINE_VFP_H_ =20 -#ifdef _KERNEL - #ifndef LOCORE + struct vfpstate { __uint128_t vfp_regs[32]; uint32_t vfp_fpcr; uint32_t vfp_fpsr; }; =20 +#ifdef _KERNEL void vfp_init(void); void vfp_discard(struct thread *); void vfp_restore_state(void); --------------0F29FCD2389F98BF52E7E1FC-- --naRKO9CPQCK5o11CPCjgv7mm4qx6HpxMf-- --LrR0ev3DmqnFePiuhcL61Fu1ljARN0KKN Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQJ8BAEBCgBmBQJYAhX1XxSAAAAAAC4AKGlzc3Vlci1mcHJAbm90YXRpb25zLm9w ZW5wZ3AuZmlmdGhob3JzZW1hbi5uZXRGREI1MzAxNjZGNTBCM0NCRUQ5QjZGNzdF MUMxMjI1QjBCMjZBNEYwAAoJEOHBIlsLJqTwJPAQAJIuw61OdSgvS2Rr4WCa3MQf 6z2U1hYtSboIl8KLtFbkGSoqA6t6ef9pWmIUkZTIDTxXqawymL+5uqFuNI/H6aDZ gQNte91zrM0MYYEPEX/5nhWUbHbk8xfVaVa0zXhXP7dXZuWP3YGOjyjaNswjqA6o yDKPKLgDK5HAwfhsc0m5K12DhQ4vnJfMO9AziQlVTJJ8nfmbeC5EbvMd3L1v34se cLkHh2ElUTVK63MrkrAZbdOhgDy9tibO2CSA4twJO5g+LBIA4cNC0t7ZBwBRC/bn s4JKWpO0dHAj1PyyJ7A348yRFOWcg+z4jhGXnPsXKo3nK5Zedi810k75rNErBhz+ p9YjWdCWwmtX+sj4gKVoY3h8uEUXNvYIovec1Em51UtufaWIbBQfrWleDNnM7W8X /FD0+E379AgxOrAXsEvch6QKWo4CjGI6PALyawPXnfx6rJrNVKslRFhX+Yi2iph+ 0T+b01WRNFwdvqZythzM4tdG+IFwhFtcNRfZGTYekZ+g01YO/SUvhy0Rm2PExKyl ifxgnaGvjv0EauFVtG2zm0vsyqEsynSgxs79TnTk1ftBDIMTkO1Aemhj/1/7Lm/i dd4rcpXaznAuly15kQB3jfUJ3gXaBH14IryA/TCM+wO/xpLa9wYZG1fGjALp7iap ato1jTzqojr7J+usqVLi =7uVE -----END PGP SIGNATURE----- --LrR0ev3DmqnFePiuhcL61Fu1ljARN0KKN-- From owner-svn-src-all@freebsd.org Sat Oct 15 12:07:39 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 5DA96C110EC; Sat, 15 Oct 2016 12:07:39 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 1F30F1B3; Sat, 15 Oct 2016 12:07:39 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9FC7chs019657; Sat, 15 Oct 2016 12:07:38 GMT (envelope-from bapt@FreeBSD.org) Received: (from bapt@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9FC7bwq019651; Sat, 15 Oct 2016 12:07:37 GMT (envelope-from bapt@FreeBSD.org) Message-Id: <201610151207.u9FC7bwq019651@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bapt set sender to bapt@FreeBSD.org using -f From: Baptiste Daroussin Date: Sat, 15 Oct 2016 12:07:37 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307351 - in head: . etc/mtree gnu/usr.bin gnu/usr.bin/rcs share/doc/psd share/doc/psd/13.rcs tools/build/mk tools/build/options X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 Oct 2016 12:07:39 -0000 Author: bapt Date: Sat Oct 15 12:07:37 2016 New Revision: 307351 URL: https://svnweb.freebsd.org/changeset/base/307351 Log: Remove GNU rcs from base. GNU rcs is still available as a package: - rcs: Latest GPLv3 GNU rcs version. - rcs57: Copy of the latest version of GNU rcs (GPLv2) from base. Relnotes: yes Deleted: head/gnu/usr.bin/rcs/ head/share/doc/psd/13.rcs/ head/tools/build/options/WITH_RCS Modified: head/ObsoleteFiles.inc head/UPDATING head/etc/mtree/BSD.usr.dist head/gnu/usr.bin/Makefile head/share/doc/psd/Makefile head/tools/build/mk/OptionalObsoleteFiles.inc Modified: head/ObsoleteFiles.inc ============================================================================== --- head/ObsoleteFiles.inc Sat Oct 15 10:29:33 2016 (r307350) +++ head/ObsoleteFiles.inc Sat Oct 15 12:07:37 2016 (r307351) @@ -38,6 +38,30 @@ # xargs -n1 | sort | uniq -d; # done +# 20161015: Remove GNU rcs +OLD_FILES+=usr/bin/ci +OLD_FILES+=usr/bin/co +OLD_FILES+=usr/bin/merge +OLD_FILES+=usr/bin/rcs +OLD_FILES+=usr/bin/rcsclean +OLD_FILES+=usr/bin/rcsdiff +OLD_FILES+=usr/bin/rcsfreeze +OLD_FILES+=usr/bin/rcsmerge +OLD_FILES+=usr/bin/rlog +OLD_FILES+=usr/share/doc/psd/13.rcs/paper.ascii.gz +OLD_FILES+=usr/share/doc/psd/13.rcs/rcs_func.ascii.gz +OLD_DIRS+=usr/share/doc/psd/13.rcs +OLD_FILES+=usr/share/man/man1/ci.1.gz +OLD_FILES+=usr/share/man/man1/co.1.gz +OLD_FILES+=usr/share/man/man1/merge.1.gz +OLD_FILES+=usr/share/man/man1/rcs.1.gz +OLD_FILES+=usr/share/man/man1/rcsclean.1.gz +OLD_FILES+=usr/share/man/man1/rcsdiff.1.gz +OLD_FILES+=usr/share/man/man1/rcsfreeze.1.gz +OLD_FILES+=usr/share/man/man1/rcsintro.1.gz +OLD_FILES+=usr/share/man/man1/rcsmerge.1.gz +OLD_FILES+=usr/share/man/man1/rlog.1.gz +OLD_FILES+=usr/share/man/man5/rcsfile.5.gz # 20161010: remove link to removed m_getclr(9) macro OLD_FILES+=usr/share/man/man9/m_getclr.9.gz # 20161003: MK_ELFCOPY_AS_OBJCOPY option retired Modified: head/UPDATING ============================================================================== --- head/UPDATING Sat Oct 15 10:29:33 2016 (r307350) +++ head/UPDATING Sat Oct 15 12:07:37 2016 (r307351) @@ -31,6 +31,11 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 12 disable the most expensive debugging functionality run "ln -s 'abort:false,junk:false' /etc/malloc.conf".) +20161015: + GNU rcs has been removed rom base. It is available as packages: + - rcs: Latest GPLv3 GNU rcs version. + - rcs57: Copy of the latest version of GNU rcs (GPLv2) from base. + 20161008: Use of the cc_cdg, cc_chd, cc_hd, or cc_vegas congestion control modules now requires that the kernel configuration contain the Modified: head/etc/mtree/BSD.usr.dist ============================================================================== --- head/etc/mtree/BSD.usr.dist Sat Oct 15 10:29:33 2016 (r307350) +++ head/etc/mtree/BSD.usr.dist Sat Oct 15 12:07:37 2016 (r307351) @@ -228,8 +228,6 @@ .. 12.make .. - 13.rcs - .. 15.yacc .. 16.lex Modified: head/gnu/usr.bin/Makefile ============================================================================== --- head/gnu/usr.bin/Makefile Sat Oct 15 10:29:33 2016 (r307350) +++ head/gnu/usr.bin/Makefile Sat Oct 15 12:07:37 2016 (r307351) @@ -11,7 +11,6 @@ SUBDIR= ${_binutils} \ ${_gperf} \ grep \ ${_groff} \ - ${_rcs} \ ${_tests} SUBDIR_DEPEND_gdb= ${_binutils} @@ -29,10 +28,6 @@ _groff= groff _dtc= dtc .endif -.if ${MK_RCS} != "no" -_rcs= rcs -.endif - .if ${MK_TESTS} != "no" _tests= tests .endif Modified: head/share/doc/psd/Makefile ============================================================================== --- head/share/doc/psd/Makefile Sat Oct 15 10:29:33 2016 (r307350) +++ head/share/doc/psd/Makefile Sat Oct 15 12:07:37 2016 (r307351) @@ -20,7 +20,6 @@ SUBDIR= title \ 05.sysman \ 06.Clang \ 12.make \ - 13.rcs \ 15.yacc \ 16.lex \ 17.m4 \ Modified: head/tools/build/mk/OptionalObsoleteFiles.inc ============================================================================== --- head/tools/build/mk/OptionalObsoleteFiles.inc Sat Oct 15 10:29:33 2016 (r307350) +++ head/tools/build/mk/OptionalObsoleteFiles.inc Sat Oct 15 12:07:37 2016 (r307351) @@ -6810,29 +6810,6 @@ OLD_FILES+=usr/share/man/man8/rshd.8.gz OLD_FILES+=usr/share/man/man8/rwhod.8.gz .endif -.if ${MK_RCS} == no -OLD_FILES+=usr/bin/ci -OLD_FILES+=usr/bin/co -OLD_FILES+=usr/bin/merge -OLD_FILES+=usr/bin/rcs -OLD_FILES+=usr/bin/rcsclean -OLD_FILES+=usr/bin/rcsdiff -OLD_FILES+=usr/bin/rcsfreeze -OLD_FILES+=usr/bin/rcsmerge -OLD_FILES+=usr/bin/rlog -OLD_FILES+=usr/share/man/man1/ci.1.gz -OLD_FILES+=usr/share/man/man1/co.1.gz -OLD_FILES+=usr/share/man/man1/merge.1.gz -OLD_FILES+=usr/share/man/man1/rcs.1.gz -OLD_FILES+=usr/share/man/man1/rcsclean.1.gz -OLD_FILES+=usr/share/man/man1/rcsdiff.1.gz -OLD_FILES+=usr/share/man/man1/rcsfreeze.1.gz -OLD_FILES+=usr/share/man/man1/rcsintro.1.gz -OLD_FILES+=usr/share/man/man1/rcsmerge.1.gz -OLD_FILES+=usr/share/man/man1/rlog.1.gz -OLD_FILES+=usr/share/man/man5/rcsfile.5.gz -.endif - #.if ${MK_RESCUE} == no # to be filled in or replaced with a special target #.endif From owner-svn-src-all@freebsd.org Sat Oct 15 12:11:31 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B8260C112D4; Sat, 15 Oct 2016 12:11:31 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 89F0C77D; Sat, 15 Oct 2016 12:11:31 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9FCBUB3022015; Sat, 15 Oct 2016 12:11:30 GMT (envelope-from bapt@FreeBSD.org) Received: (from bapt@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9FCBUG0022014; Sat, 15 Oct 2016 12:11:30 GMT (envelope-from bapt@FreeBSD.org) Message-Id: <201610151211.u9FCBUG0022014@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bapt set sender to bapt@FreeBSD.org using -f From: Baptiste Daroussin Date: Sat, 15 Oct 2016 12:11:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307352 - head/share/man/man5 X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 Oct 2016 12:11:31 -0000 Author: bapt Date: Sat Oct 15 12:11:30 2016 New Revision: 307352 URL: https://svnweb.freebsd.org/changeset/base/307352 Log: Regen Modified: head/share/man/man5/src.conf.5 Modified: head/share/man/man5/src.conf.5 ============================================================================== --- head/share/man/man5/src.conf.5 Sat Oct 15 12:07:37 2016 (r307351) +++ head/share/man/man5/src.conf.5 Sat Oct 15 12:11:30 2016 (r307352) @@ -1,7 +1,7 @@ .\" DO NOT EDIT-- this file is automatically generated. .\" from FreeBSD: head/tools/build/options/makeman 306729 2016-10-05 20:12:00Z emaste .\" $FreeBSD$ -.Dd October 10, 2016 +.Dd October 15, 2016 .Dt SRC.CONF 5 .Os .Sh NAME @@ -1322,11 +1322,6 @@ This includes .Xr rlogin 1 , .Xr rsh 1 , etc. -.It Va WITH_RCS -.\" from FreeBSD: head/tools/build/options/WITH_RCS 305931 2016-09-18 15:01:11Z bapt -Set to build -.Xr rcs 1 -and related utilities. .It Va WITHOUT_RESCUE .\" from FreeBSD: head/tools/build/options/WITHOUT_RESCUE 156932 2006-03-21 07:50:50Z ru Set to not build From owner-svn-src-all@freebsd.org Sat Oct 15 12:22:07 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C60C1C11A88; Sat, 15 Oct 2016 12:22:07 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 60AE1E47; Sat, 15 Oct 2016 12:22:07 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9FCM65s026966; Sat, 15 Oct 2016 12:22:06 GMT (envelope-from bapt@FreeBSD.org) Received: (from bapt@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9FCM6bt026965; Sat, 15 Oct 2016 12:22:06 GMT (envelope-from bapt@FreeBSD.org) Message-Id: <201610151222.u9FCM6bt026965@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bapt set sender to bapt@FreeBSD.org using -f From: Baptiste Daroussin Date: Sat, 15 Oct 2016 12:22:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307353 - stable/11/share/misc X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 Oct 2016 12:22:07 -0000 Author: bapt Date: Sat Oct 15 12:22:06 2016 New Revision: 307353 URL: https://svnweb.freebsd.org/changeset/base/307353 Log: MFC r306854 Update pci_vendors to 2016-10-03 Modified: stable/11/share/misc/pci_vendors Directory Properties: stable/11/ (props changed) Modified: stable/11/share/misc/pci_vendors ============================================================================== --- stable/11/share/misc/pci_vendors Sat Oct 15 12:11:30 2016 (r307352) +++ stable/11/share/misc/pci_vendors Sat Oct 15 12:22:06 2016 (r307353) @@ -3,8 +3,8 @@ # # List of PCI ID's # -# Version: 2016.05.23 -# Date: 2016-05-23 03:15:02 +# Version: 2016.10.03 +# Date: 2016-10-03 03:15:01 # # Maintained by Albert Pool, Martin Mares, and other volunteers from # the PCI ID Project at http://pci-ids.ucw.cz/. @@ -244,6 +244,19 @@ 1000 1000 LSI53C895A PCI to Ultra2 SCSI Controller 0013 53c875a 1000 1000 LSI53C875A PCI to Ultra SCSI Controller + 0014 MegaRAID Tri-Mode SAS3516 + 1d49 0602 ThinkSystem RAID 930-16i 4GB Flash PCIe 12Gb Adapter + 0016 MegaRAID Tri-Mode SAS3508 + 1d49 0601 ThinkSystem RAID 930-8i 2GB Flash PCIe 12Gb Adapter + 1d49 0603 ThinkSystem RAID 930-24i 4GB Flash PCIe 12Gb Adapter + 1d49 0604 ThinkSystem RAID 930-8e 4GB Flash PCIe 12Gb Adapter + 0017 MegaRAID Tri-Mode SAS3408 + 1d49 0500 ThinkSystem RAID 530-8i PCIe 12Gb Adapter + 1d49 0502 ThinkSystem RAID 530-8i Dense Adapter + 001b MegaRAID Tri-Mode SAS3504 + 1d49 0605 ThinkSystem RAID 930-4i 2GB Flash Flex Adapter + 001c MegaRAID Tri-Mode SAS3404 + 1d49 0501 ThinkSystem RAID 530-4i Flex Adapter 0020 53c1010 Ultra3 SCSI Adapter 1000 1000 LSI53C1010-33 PCI to Dual Channel Ultra160 SCSI Controller 107b 1040 Server Onboard 53C1010-33 @@ -351,6 +364,8 @@ 005c SAS1064A PCI-X Fusion-MPT SAS 005d MegaRAID SAS-3 3108 [Invader] 1000 9361 MegaRAID SAS 9361-8i + 1000 9364 MegaRAID SAS 9364-8i + 1000 936a MegaRAID SAS 9364-8i 1028 1f41 PERC H830 Adapter 1028 1f42 PERC H730P Adapter 1028 1f43 PERC H730 Adapter @@ -363,6 +378,7 @@ 1028 1f54 PERC FD33xD 17aa 1052 ThinkServer RAID 720i 17aa 1053 ThinkServer RAID 720ix + 1d49 0600 ThinkSystem RAID 730-8i 1GB Cache PCIe 12Gb Adapter 005e SAS1066 PCI-X Fusion-MPT SAS 005f MegaRAID SAS-3 3008 [Fury] 1028 1f44 PERC H330 Adapter @@ -506,6 +522,7 @@ 0087 SAS2308 PCI-Express Fusion-MPT SAS-2 1000 3020 9207-8i SAS2.1 HBA 1000 3040 9207-8e SAS2.1 HBA + 1000 3050 SAS9217-8i 1590 0044 H220i 008f 53c875J 1092 8000 FirePort 40 SCSI Controller @@ -516,8 +533,20 @@ 0095 SAS3108 PCI-Express Fusion-MPT SAS-3 0096 SAS3004 PCI-Express Fusion-MPT SAS-3 0097 SAS3008 PCI-Express Fusion-MPT SAS-3 + 1000 3090 SAS9311-8i + 1000 30e0 SAS9300-8i 1028 1f45 12GB/s HBA internal 1028 1f46 12Gbps HBA + 00ab SAS3516 Fusion-MPT Tri-Mode RAID On Chip (ROC) + 00ac SAS3416 Fusion-MPT Tri-Mode I/O Controller Chip (IOC) + 1d49 0201 ThinkSystem 9400-16i PCIe 12Gb HBA + 1d49 0203 ThinkSystem 9400-16e PCIe 12Gb HBA + 00ae SAS3508 Fusion-MPT Tri-Mode RAID On Chip (ROC) + 00af SAS3408 Fusion-MPT Tri-Mode I/O Controller Chip (IOC) + 1d49 0200 ThinkSystem 9400-8i PCIe 12Gb HBA + 1d49 0202 ThinkSystem 9400-8e PCIe 12Gb HBA + 00be SAS3504 Fusion-MPT Tri-Mode RAID On Chip (ROC) + 00bf SAS3404 Fusion-MPT Tri-Mode I/O Controller Chip (IOC) 00c0 SAS3324 PCI-Express Fusion-MPT SAS-3 00c1 SAS3324 PCI-Express Fusion-MPT SAS-3 00c2 SAS3324 PCI-Express Fusion-MPT SAS-3 @@ -533,6 +562,9 @@ 1000 9390 MegaRAID SAS 9380-8i8e 00cf MegaRAID SAS-3 3324 [Intruder] 1000 9370 MegaRAID SAS 9361-24i + 00d0 SAS3716 Fusion-MPT Tri-Mode RAID Controller Chip (ROC) + 00d1 SAS3616 Fusion-MPT Tri-Mode I/O Controller Chip (IOC) + 00d3 MegaRAID Tri-Mode SAS3716W 0407 MegaRAID 1000 0530 MegaRAID 530 SCSI 320-0X RAID Controller 1000 0531 MegaRAID 531 SCSI 320-4X RAID Controller @@ -1389,23 +1421,23 @@ 5a11 RD890 Northbridge only single slot PCI-e GFX Hydra part 5a12 RD890 Northbridge only dual slot (2x8) PCI-e GFX Hydra part 15d9 a811 H8DGU - 5a13 RD890 PCI to PCI bridge (external gfx0 port A) - 5a14 RD890 PCI to PCI bridge (external gfx0 port B) + 5a13 RD890S/SR5650 Host Bridge + 5a14 RD9x0/RX980 Host Bridge 5a15 RD890 PCI to PCI bridge (PCI express gpp port A) - 5a16 RD890 PCI to PCI bridge (PCI express gpp port B) - 5a17 RD890 PCI to PCI bridge (PCI express gpp port C) - 5a18 RD890 PCI to PCI bridge (PCI express gpp port D) + 5a16 RD890/RD9x0/RX980 PCI to PCI bridge (PCI Express GFX port 0) + 5a17 RD890/RD9x0 PCI to PCI bridge (PCI Express GFX port 1) + 5a18 RD890/RD9x0/RX980 PCI to PCI bridge (PCI Express GPP Port 0) 15d9 a811 H8DGU - 5a19 RD890 PCI to PCI bridge (PCI express gpp port E) - 5a1a RD890 PCI to PCI bridge (PCI express gpp port F) - 5a1b RD890 PCI to PCI bridge (PCI express gpp port G) - 5a1c RD890 PCI to PCI bridge (PCI express gpp port H) - 5a1d RD890 PCI to PCI bridge (external gfx1 port A) - 5a1e RD890 PCI to PCI bridge (external gfx1 port B) - 5a1f RD890 PCI to PCI bridge (NB-SB link) + 5a19 RD890/RD9x0/RX980 PCI to PCI bridge (PCI Express GPP Port 1) + 5a1a RD890/RD9x0/RX980 PCI to PCI bridge (PCI Express GPP Port 2) + 5a1b RD890/RD9x0/RX980 PCI to PCI bridge (PCI Express GPP Port 3) + 5a1c RD890/RD9x0/RX980 PCI to PCI bridge (PCI Express GPP Port 4) + 5a1d RD890/RD9x0/RX980 PCI to PCI bridge (PCI Express GPP Port 5) + 5a1e RD890/RD9x0/RX980 PCI to PCI bridge (PCI Express GPP2 Port 0) + 5a1f RD890/RD990 PCI to PCI bridge (PCI Express GFX2 port 0) 15d9 a811 H8DGU - 5a20 RD890S PCI Express bridge for GPP2 port 1 - 5a23 RD990 I/O Memory Management Unit (IOMMU) + 5a20 RD890/RD990 PCI to PCI bridge (PCI Express GFX2 port 1) + 5a23 RD890S/RD990 I/O Memory Management Unit (IOMMU) 5a31 RC410 Host Bridge 5a33 RS400 Host Bridge 5a34 RS4xx PCI Express Port [ext gfx] @@ -1527,6 +1559,7 @@ 6649 Bonaire [FirePro W5100] 1002 0b0c FirePro W4300 103c 0b0c Bonaire [FirePro W4300] + 103c 230c FirePro W5100 6650 Bonaire 6651 Bonaire 6658 Bonaire XTX [Radeon R7 260X/360] @@ -1566,6 +1599,7 @@ 17aa 390c Radeon R5 M330 6663 Sun PRO [Radeon HD 8570A/8570M] 1025 0846 Radeon HD 8570A + 17aa 3805 Radeon HD 8570M 6664 Jet XT [Radeon R5 M240] 6665 Jet PRO [Radeon R5 M230] 17aa 368f Radeon R5 A230 @@ -2100,6 +2134,7 @@ 1462 8036 Radeon HD 8990 OEM 148c 8990 Radeon HD 8990 OEM 679e Tahiti LE [Radeon HD 7870 XT] + 1787 2328 Radeon HD 7870 Black Edition 2 GB GDDR5 [2GBD5-2DHV3E] 679f Tahiti 67a0 Hawaii XT GL [FirePro W9100] 1002 0335 FirePro S9150 @@ -2150,15 +2185,31 @@ 67b1 Hawaii PRO [Radeon R9 290/390] 1043 04dd STRIX R9 390 148c 2358 Radeon R9 390 + 174b e324 Sapphire Nitro R9 390 67b9 Vesuvius [Radeon R9 295X2] 67be Hawaii LE 67c0 Ellesmere [Polaris10] - 67df Ellesmere [Polaris10] + 67df Ellesmere [Radeon RX 470/480] + 1002 0b37 Radeon RX 480 + 1043 04a8 Radeon RX 480 + 1043 04b0 Radeon RX 470 + 1043 04fb Radeon RX 480 + 1462 3411 Radeon RX 470 + 1462 3413 Radeon RX 480 + 148c 2372 Radeon RX 480 + 148c 2373 Radeon RX 470 + 1682 9470 Radeon RX 470 + 1682 9480 Radeon RX 480 + 174b e347 Radeon RX 470/480 + 174b e349 Radeon RX 470 + 1787 a470 Radeon RX 470 + 1787 a480 Radeon RX 480 67e0 Baffin [Polaris11] 67e1 Baffin [Polaris11] 67e8 Baffin [Polaris11] 67e9 Baffin [Polaris11] 67eb Baffin [Polaris11] + 67ef Baffin [Radeon RX 460] 67ff Baffin [Polaris11] 6800 Wimbledon XT [Radeon HD 7970M] 1002 0124 Radeon HD 7970M @@ -2980,6 +3031,7 @@ 72b3 RV560 [Radeon X1650 GT] (Secondary) 7300 Fiji [Radeon R9 FURY / NANO Series] 1002 0b36 Radeon R9 FURY X / NANO + 1002 1b36 Radeon Pro Duo 1043 049e Radeon R9 FURY 1043 04a0 Radeon R9 FURY X 174b e329 Radeon R9 FURY @@ -3174,7 +3226,7 @@ 95cc RV620 GL [FirePro V3700] 95cd RV620 [FirePro 2450] 95cf RV620 GL [FirePro 2260] - 960f RS780 HDMI Audio [Radeon (HD) 3000 Series] + 960f RS780 HDMI Audio [Radeon 3000/3100 / HD 3200/3300] 9610 RS780 [Radeon HD 3200] 1458 d000 GA-MA78GM-S2H Motherboard 9611 RS780C [Radeon 3100] @@ -3275,7 +3327,7 @@ 9917 Trinity [Radeon HD 7620G] 9918 Trinity [Radeon HD 7600G] 9919 Trinity [Radeon HD 7500G] - 9920 Liverpool Graphics + 9920 Liverpool [Playstation 4 APU] 9921 Liverpool HDMI/DP Audio Controller 9990 Trinity [Radeon HD 7520G] 9991 Trinity [Radeon HD 7540D] @@ -3295,40 +3347,41 @@ 99a0 Trinity [Radeon HD 7520G] 99a2 Trinity [Radeon HD 7420G] 99a4 Trinity [Radeon HD 7400G] - aa00 R600 HDMI Audio [Radeon HD 2900 Series] + aa00 R600 HDMI Audio [Radeon HD 2900 GT/PRO/XT] + aa01 RV635 HDMI Audio [Radeon HD 3650/3730/3750] aa08 RV630 HDMI Audio [Radeon HD 2600 Series] - aa10 RV610 HDMI Audio [Radeon HD 2350/2400 Series] + aa10 RV610 HDMI Audio [Radeon HD 2350 PRO / 2400 PRO/XT / HD 3410] 174b aa10 Radeon HD 2400 PRO 18bc aa10 Radeon HD 2400 PRO aa18 RV670/680 HDMI Audio [Radeon HD 3690/3800 Series] - aa20 RV635 HDMI Audio [Radeon HD 3600 Series] - aa28 RV620 HDMI Audio [Radeon HD 3400 Series] + aa20 RV635 HDMI Audio [Radeon HD 3650/3730/3750] + aa28 RV620 HDMI Audio [Radeon HD 3450/3470/3550/3570] aa30 RV770 HDMI Audio [Radeon HD 4850/4870] 174b aa30 Radeon HD 4850 512MB GDDR3 PCI-E Dual Slot Fansink aa38 RV710/730 HDMI Audio [Radeon HD 4000 series] 103c 3628 dv6-1190en - aa50 Cypress HDMI Audio [Radeon HD 5800 Series] + aa50 Cypress HDMI Audio [Radeon HD 5830/5850/5870 / 6850/6870 Rebrand] aa58 Juniper HDMI Audio [Radeon HD 5700 Series] # 5500, 5600 and mobile 5700 series aa60 Redwood HDMI Audio [Radeon HD 5000 Series] 1025 033d Mobility Radeon HD 5650 1025 0347 Aspire 7740G - aa68 Cedar HDMI Audio [Radeon HD 5400/6300 Series] + aa68 Cedar HDMI Audio [Radeon HD 5400/6300/7300 Series] 1028 aa68 XPS 8300 - aa80 Cayman/Antilles HDMI Audio [Radeon HD 6900 Series] + aa80 Cayman/Antilles HDMI Audio [Radeon HD 6930/6950/6970/6990] aa88 Barts HDMI Audio [Radeon HD 6800 Series] - aa90 Turks/Whistler HDMI Audio [Radeon HD 6000 Series] + aa90 Turks HDMI Audio [Radeon HD 6500/6600 / 6700M Series] 1028 04a3 Precision M4600 aa98 Caicos HDMI Audio [Radeon HD 6400 Series] 174b aa98 Radeon HD 6450 1GB DDR3 - aaa0 Tahiti XT HDMI Audio [Radeon HD 7970 Series] + aaa0 Tahiti HDMI Audio [Radeon HD 7870 XT / 7950/7970] aab0 Cape Verde/Pitcairn HDMI Audio [Radeon HD 7700/7800 Series] aac0 Tobago HDMI Audio [Radeon R7 360 / R9 360 OEM] - aac8 Hawaii HDMI Audio + aac8 Hawaii HDMI Audio [Radeon R9 290/290X / 390/390X] # I have a Tonga card and this is the HDMI Audio part aad8 Tonga HDMI Audio [Radeon R9 285/380] 174b aad8 Radeon R9 285/380 HDMI Audio - aae8 Fiji HDMI/DP Audio Controller + aae8 Fiji HDMI/DP Audio [Radeon R9 Nano / FURY/FURY X] ac00 Theater 600 Pro ac02 TV Wonder HD 600 PCIe ac12 Theater HD T507 (DVB-T) TV tuner/capture device @@ -3751,6 +3804,7 @@ 04da PCI-E IPR SAS+ Adapter (ASIC) 1014 04fb PCIe3 x16 20GB Cache 12Gb Quad SAS RAID+ Adapter(580B) 1014 04fc PCIe3 x8 12Gb Quad SAS RAID+ Adapter(580A) + 04ed Internal Shared Memory (ISM) virtual PCI device 3022 QLA3022 Network Adapter 4022 QLA3022 Network Adapter ffff MPIC-2 interrupt controller @@ -4421,6 +4475,11 @@ 102b 2241 M9138 LP PCIe x16 102b 2280 M9188 ATX PCIe x16 102b 22c0 M9128 LP PCIe x16 + 0550 SV2 + 102b 00c0 MURA-IPX-I4EF + 102b 00c1 MURA-IPX-I4DF + 102b 00c3 MURA-IPX-I4DHF + 102b 00c5 MURA-IPX-I4EHF 0d10 MGA Ultima/Impression 1000 MGA G100 [Productiva] 102b ff01 Productiva G100 @@ -5947,8 +6006,14 @@ 1077 029a QLE2742 Dual Port 32Gb Fibre Channel to PCIe Adapter 1077 029b QLE2690 Single Port 16Gb Fibre Channel to PCIe Adapter 1077 029c QLE2692 Dual Port 16Gb Fibre Channel to PCIe Adapter + 1077 02a7 QLE2690 Single Port 16Gb FC to PCIe Gen3 x8 Adapter + 1077 02a8 QLE2692 Dual Port 16Gb FC to PCIe Gen3 x8 Adapter + 1077 02ab QLE2740 Single Port 32Gb FC to PCIe Gen3 x8 Adapter + 1077 02ac QLE2742 Dual Port 32Gb FC to PCIe Gen3 x8 Adapter 1590 00f9 HPE StoreFabric SN1100Q 16Gb Single Port Fibre Channel Host Bus Adapter 1590 00fa HPE StoreFabric SN1100Q 16Gb Dual Port Fibre Channel Host Bus Adapter + 1590 0203 HPE StoreFabric SN1600Q 32Gb Single Port Fibre Channel Host Bus Adapter + 1590 0204 HPE StoreFabric SN1600Q 32Gb Dual Port Fibre Channel Host Bus Adapter 2300 QLA2300 64-bit Fibre Channel Adapter 2312 ISP2312-based 2Gb Fibre Channel to PCI-X HBA 103c 0131 2Gb Fibre Channel - Single port [A7538A] @@ -7308,9 +7373,11 @@ 8696 PEX 8696 96-lane, 24-Port PCI Express Gen 2 (5.0 GT/s) Multi-Root Switch 8717 PEX 8717 16-lane, 8-Port PCI Express Gen 3 (8.0 GT/s) Switch with DMA 8718 PEX 8718 16-Lane, 5-Port PCI Express Gen 3 (8.0 GT/s) Switch + 8724 PEX 8724 24-Lane, 6-Port PCI Express Gen 3 (8 GT/s) Switch, 19 x 19mm FCBGA 8732 PEX 8732 32-lane, 8-Port PCI Express Gen 3 (8.0 GT/s) Switch 8734 PEX 8734 32-lane, 8-Port PCI Express Gen 3 (8.0GT/s) Switch 8747 PEX 8747 48-Lane, 5-Port PCI Express Gen 3 (8.0 GT/s) Switch + 8748 PEX 8748 48-Lane, 12-Port PCI Express Gen 3 (8 GT/s) Switch, 27 x 27mm FCBGA # This is the Non-Transparent-Bridge Virtualized Port as presented by the PLX PEX 8732 chip, the physical bridges show up at 10b5:8732 87b0 PEX 8732 32-lane, 8-Port PCI Express Gen 3 (8.0 GT/s) Switch 1093 7761 PXIe-8830mc @@ -7450,6 +7517,7 @@ 1885 0700 Tsunami FPGA PMC with Altera Stratix S40 1885 0701 Tsunami FPGA PMC with Altera Stratix S30 9733 PEX 9733 33-lane, 9-port PCI Express Gen 3 (8.0 GT/s) Switch + 1d49 0001 ThinkSystem P310W-4P NVMe Switch Card 9749 PEX 9749 49-lane, 13-port PCI Express Gen 3 (8.0 GT/s) Switch a100 Blackmagic Design DeckLink bb04 B&B 3PCIOSD1A Isolated PCI Serial @@ -9992,6 +10060,7 @@ 10c3 GT218 [GeForce 8400 GS Rev. 3] 10c5 GT218 [GeForce 405] 10d8 GT218 [NVS 300] + 10f0 GP104 High Definition Audio Controller 1140 GF117M [GeForce 610M/710M/810M/820M / GT 620M/625M/630M/720M] 1019 0799 GeForce 820M 1019 999f GeForce GT 720M @@ -10187,7 +10256,7 @@ 144d c0e3 NVS 5200M 144d c0e4 NVS 5200M 144d c10d GeForce 820M - 144d c652 GeForce GT 620M + 144d c652 GeForce GT 620M on NP300E5C series laptop 144d c709 GeForce 710M 144d c711 GeForce 710M 144d c736 GeForce 710M @@ -10518,7 +10587,9 @@ 13ba GM107GL [Quadro K2200] 13bb GM107GL [Quadro K620] 13bc GM107GL [Quadro K1200] - 13bd GM107GL [GRID M40] + 13bd GM107GL [Tesla M10] + 10de 110a GRID M40 + 10de 1160 Tesla M10 13c0 GM204 [GeForce GTX 980] 1043 8504 GTX980-4GD5 13c1 GM204 @@ -10535,6 +10606,7 @@ 13f8 GM204GLM [Quadro M5000M] 13f9 GM204GLM [Quadro M4000M] 13fa GM204GLM [Quadro M3000M] + 10de 11c9 Quadro M3000 SE 13fb GM204GLM [Quadro M5500] 1401 GM206 [GeForce GTX 960] 1402 GM206 [GeForce GTX 950] @@ -10543,17 +10615,54 @@ 1427 GM206M [GeForce GTX 965M] 1430 GM206GL [Quadro M2000] 1431 GM206GL [Tesla M4] + 15f0 GP100GL + 15f1 GP100GL + 15f8 GP100GL + 15f9 GP100GL 1617 GM204M [GeForce GTX 980M] 1618 GM204M [GeForce GTX 970M] 1619 GM204M [GeForce GTX 965M] 161a GM204M [GeForce GTX 980] 1667 GM204M [GeForce GTX 965M] + 1725 GP100 + 172e GP100 + 172f GP100 17c2 GM200 [GeForce GTX TITAN X] 17c8 GM200 [GeForce GTX 980 Ti] 17f0 GM200GL [Quadro M6000] 17f1 GM200GL [Quadro M6000 24GB] 17fd GM200GL [Tesla M40] + 1b00 GP102 [TITAN X] + 1b01 GP102 + 1b30 GP102GL [Quadro P6000] + 1b70 GP102GL + 1b78 GP102GL 1b80 GP104 [GeForce GTX 1080] + 1b81 GP104 [GeForce GTX 1070] + 1b82 GP104 + 1b83 GP104 + 1ba0 GP104M [GeForce GTX 1080] + 1ba1 GP104M [GeForce GTX 1070] + 1bb0 GP104GL [Quadro P5000] + 1bb1 GP104GL + 1bb4 GP104GL + 1be0 GP104M [GeForce GTX 1080] + 1be1 GP104M [GeForce GTX 1070] + 1c00 GP106 + 1c01 GP106 + 1c02 GP106 [GeForce GTX 1060 3GB] + 1c03 GP106 [GeForce GTX 1060 6GB] + 1c20 GP106M [GeForce GTX 1060] + 1c30 GP106GL + 1c60 GP106M [GeForce GTX 1060] + 1c70 GP106GL + 1c80 GP107 + 1c81 GP107 + 1c82 GP107 [GeForce GTX 1050 Ti] + 1ca7 GP107GL + 1ca8 GP107GL + 1caa GP107GL + 1d01 GP108 10df Emulex Corporation 0720 OneConnect NIC (Skyhawk) 103c 1934 FlexFabric 20Gb 2-port 650M Adapter @@ -10723,6 +10832,7 @@ 5250 RTS5250 PCI Express Card Reader 525a RTS525A PCI Express Card Reader 5286 RTS5286 PCI Express Card Reader + 5287 RTL8411B PCI Express Card Reader 5288 RTS5288 PCI Express Card Reader 5289 RTL8411 PCI Express Card Reader 1043 1457 K55A Laptop @@ -10738,6 +10848,7 @@ 11ec 8129 RTL8111/8168 PCIe Gigabit Ethernet (misconfigured) 8136 RTL8101/2/6E PCI Express Fast/Gigabit Ethernet controller 103c 1985 Pavilion 17-e163sg Notebook PC + 103c 2a8c Compaq 500B Microtower 103c 2ab1 Pavilion p6774 103c 30cc Pavilion dv6700 1179 ff64 RTL8102E PCI-E Fast Ethernet NIC @@ -10804,6 +10915,7 @@ 1028 0283 Vostro 220 1028 04b2 Vostro 3350 1028 04da Vostro 3750 + 1028 06f3 Latitude 3570 103c 1611 Pavilion DM1Z-3000 103c 1950 ProBook 450/455 103c 2a6f Asus IPIBL-LB Motherboard @@ -10815,7 +10927,8 @@ 1043 8505 P8 series motherboard 105b 0d7c D270S/D250S Motherboard 10ec 8168 RTL8111/8168 PCI Express Gigabit Ethernet controller - 1458 e000 Motherboard + 144d c652 RTL8168 on a NP300E5C series laptop + 1458 e000 Onboard Ethernet 1462 238c Onboard RTL8111b on MSI P965 Platinum Mainboard 1462 368c K9AG Neo2 1462 4180 Wind PC MS-7418 @@ -10845,10 +10958,12 @@ 8173 RTL8192SE Wireless LAN Controller 8174 RTL8192SE Wireless LAN Controller 8176 RTL8188CE 802.11b/g/n WiFi Adapter + 1043 84b5 PCE-N10 1a3b 1139 AW-NE139H Half-size Mini PCIe Card 8177 RTL8191CE PCIe Wireless Network Adapter 8178 RTL8192CE PCIe Wireless Network Adapter 8179 RTL8188EE Wireless Network Adapter + 103c 197d RTL8188EE mini-PCIe card 8180 RTL8180L 802.11b MAC 1385 4700 MA521 802.11b Wireless PC Card 1737 0019 WPC11v4 802.11b Wireless-B Notebook Adapter @@ -10858,6 +10973,7 @@ 8191 RTL8192CE PCIe Wireless Network Adapter 8192 RTL8192E/RTL8192SE Wireless LAN Controller 8193 RTL8192DE Wireless LAN Controller + 8196 RTL8196 Integrated PCI-e Bridge 8197 SmartLAN56 56K Modem 8199 RTL8187SE Wireless LAN Controller 1462 6894 MN54G2 / MS-6894 Wireless Mini PCIe Card @@ -10886,6 +11002,8 @@ 3fc4 RME Digi9652 (Hammerfall) 3fc5 RME Hammerfall DSP 3fc6 RME Hammerfall DSP MADI + 7038 FPGA Card XC7VX690T + 17aa 402f FPGA XC7VX690T-3FFG1157E 8380 Ellips ProfiXpress Profibus Master 8381 Ellips Santos Frame Grabber d154 Copley Controls CAN card (PCI-CAN-02) @@ -10930,46 +11048,88 @@ 9500 INI-950 SCSI Adapter 9502 INI-950P Ultra Wide SCSI Adapter 1102 Creative Labs - 0002 SB Live! EMU10k1 + 0002 EMU10k1 [Sound Blaster Live! Series] 100a 1102 SB Live! 5.1 Digital OEM SB0220 EMU10K1-JFF - 1102 0020 CT4850 SBLive! Value + 1102 0020 CT4670/4850 SBLive! Value 1102 0021 CT4620 SBLive! - 1102 002f SBLive! mainboard implementation - 1102 100a SB Live! 5.1 Digital OEM [SB0220] + 1102 002f M002/M003 Integrated SBLive! + 1102 100a SB0220/0229 SBLive! 5.1 Digital OEM 1102 4001 E-mu APS 1102 8022 CT4780 SBLive! Value 1102 8023 CT4790 SoundBlaster PCI512 1102 8024 CT4760 SBLive! - 1102 8025 SBLive! Mainboard Implementation + 1102 8025 CT1140/SB0040 Integrated SBLive! 1102 8026 CT4830 SBLive! Value 1102 8027 CT4832 SBLive! Value - 1102 8028 CT4760 SBLive! OEM version + 1102 8028 CT4870 SBLive! Value + 1102 8029 CT4872 SBLive! Value + 1102 802a CT4890 SoundBlaster PCI256 + 1102 802b CT4891 SoundBlaster PCI256 1102 8031 CT4831 SBLive! Value + 1102 8032 CT4871 SBLive! Value + 1102 8033 CT4893 SoundBlaster PCI256 + 1102 8035 CT0060 SBLive! 1102 8040 CT4760 SBLive! + 1102 8050 CT4750 SoundBlaster PCI512 1102 8051 CT4850 SBLive! Value - 1102 8061 SBLive! Player 5.1 - 1102 8064 SBLive! 5.1 Model SB0100 - 1102 8065 SBLive! 5.1 Digital Model SB0220 - 1102 8066 Live! 5.1 Digital [SB0228] - 1102 8067 SBLive! 5.1 eMicro 28028 - 0004 SB Audigy - 1102 0051 SB0090 Audigy Player - 1102 0053 SB0090 Audigy Player/OEM - 1102 0058 SB0090 Audigy Player/OEM - 1102 1002 SB Audigy2 Platinum - 1102 1003 SB0350 Audigy 2 - 1102 1007 SB0240 Audigy 2 Platinum 6.1 - 1102 1009 SB Audigy2 OEM HP - 1102 2001 SB Audigy 2 ZS Platinum Pro - 1102 2002 SB Audigy 2 ZS (SB0350) - 1102 4001 E-MU 1010 + 1102 8061 SB060 SBLive! Player 5.1 + 1102 8062 SB0100 SBLive! 5.1 + 1102 8063 DXW Integrated SBLive! 5.1 + 1102 8064 SB0100/SB0102 SBLive! 5.1 + 1102 8065 SB0220/0222 SBLive! 5.1 Digital + 1102 8066 SB0228 SBLive! 5.1 Digital + 1102 8067 SB0220 SBLive! 5.1 + 1102 8068 CT0061 SBLive! + 1102 8069 SB0101 SBLive! 5.1 Value + 1102 806a SB0103 SBLive! 5.1 + 1102 806b SB0105 SBLive! 5.1 + 1102 806c SB0221 SBLive! 5.1 + 1102 8071 SB0150 SoundBlaster PCI512 +# EMU8008 PCI version of emu8000 chip + 0003 SB AWE64(D) + 0004 EMU10k2/CA0100/CA0102/CA10200 [Sound Blaster Audigy Series] + 1102 0040 SB0090 Audigy Player +# Probably an early engineering sample + 1102 0041 CT4820 SBLive!2 + 1102 0042 CT0070 Audigy + 1102 0043 CT0072 Audigy + 1102 0051 SB0090 Audigy Player/Platinum (EX) + 1102 0052 SB0162 Audigy ES + 1102 0053 CT0090/SB0092 Audigy Player/OEM + 1102 0054 SB0161 Audigy ES + 1102 0055 SB0192 Audigy + 1102 0056 SB0191 Audigy + 1102 0057 SB0091 Audigy + 1102 0058 SB0095 Audigy Player/OEM + 1102 0059 SB0230 Audigy + 1102 005a SB0231 Audigy + 1102 005b SB0232 Audigy + 1102 005c SB0238 Audigy + 1102 1002 SB0240 Audigy 2 Platinum 6.1 + 1102 1003 SB0350 Audigy 2 / SB0243 Audigy 2 OEM + 1102 1004 SB0242 Audigy 2 + 1102 1005 SB0280 Audigy 2 Platinum Ex + 1102 1006 SB0245 Audigy 2 OEM + 1102 1007 SB0240/SB0244 Audigy 2 Platinum + 1102 1008 SB0320 Audigy 2 + 1102 1009 SB0249 Audigy 2 OEM + 1102 100a SB0246 Audigy 2 + 1102 2001 SB0360 Audigy 2 ZS Platinum Pro + 1102 2002 SB0350 Audigy 2 ZS + 1102 2003 SB0352 Audigy 2 ZS + 1102 2004 SB0355 Audigy 2 ZS + 1102 2005 SB0359 Audigy 2 ZS + 1102 2006 SB035x Audigy 2 OEM + 1102 2007 SB0380 Audigy 4 Pro + 1102 4001 E-MU 1010 [MAEM8810] 1102 4002 E-MU 0404 - 0005 SB X-Fi + 1102 4003 E-MU 1010 + 0005 EMU20k1 [Sound Blaster X-Fi Series] 1102 0021 X-Fi Platinum 1102 002c X-Fi XtremeGamer FATAL1TY PRO 1102 1003 X-Fi XtremeMusic - 0006 [SB Live! Value] EMU10k1X - 0007 CA0106 Soundblaster + 0006 EMU10k1X [SB Live! Value/OEM Series] + 0007 CA0106/CA0111 [SB Live!/Audigy/X-Fi Series] 1102 0007 SBLive! 24bit 1102 1001 SB0310 Audigy LS 1102 1002 SB0312 Audigy LS @@ -10978,15 +11138,30 @@ 1102 1012 SB0790 X-Fi XA 1102 1013 Soundblaster X-Fi Xtreme Audio 1462 1009 K8N Diamond - 0008 SB0400 Audigy2 Value + 0008 CA0108/CA10300 [Sound Blaster Audigy Series] 1102 0008 EMU0404 Digital Audio System + 1102 1001 SB0400 Audigy 2 Value + 1102 1021 SB0610 Audigy 4 Value + 1102 1022 SBxxx Audigy 2/4 Value + 1102 1023 SB0612 Audigy 2 LS + 1102 1024 SB1550 Audigy 5/Rx + 1102 1101 SBxxxx Audigy 2 SA + 1102 2001 SB0530 Audigy 2 ZS Notebook + 1102 2021 SBxxxx Audigy 4 Notebook + 1102 4002 E-MU 0404 + 1102 4003 E-MU 1010 1102 4004 EMU1010 Digital Audio System [MAEM8960] - 0009 [SB X-Fi Xtreme Audio] CA0110-IBG - 1102 0010 [SB X-Fi Xtreme Audio] CA0110-IBG - 1102 0018 SB1040 - 000b EMU20k2 [X-Fi Titanium Series] + 1102 4005 E-MU 0404 [MAEM8984] + 1102 4007 E-MU 1010 [MAEM8982] + 1102 4201 E-MU 0202 [MAEM8950] + 0009 CA0110 [Sound Blaster X-Fi Xtreme Audio] + 1102 0010 MB0820 Integrated + 1102 0018 SB1040 PCI Express + 000b EMU20k2 [Sound Blaster X-Fi Titanium Series] 1102 0041 SB0880 [SoundBlaster X-Fi Titanium PCI-e] - 0012 SB Recon3D + 1102 0062 SB1270 [SoundBlaster X-Fi Titanium HD] + 0012 Sound Core3D [Sound Blaster Recon3D / Z-Series] + 1102 0010 SB1570 SB Audigy Fx 4001 SB Audigy FireWire Port 1102 0010 SB Audigy FireWire Port 7002 SB Live! Game Port @@ -11900,6 +12075,7 @@ 1093 75ff PXIe-8383mc DMA 1093 7600 PXIe-8383mc DMA 1093 7602 PXIe-8384 + 808e PES24NT24G2 PCI Express Switch # 32 port / 8 lane PCIe Gen 2 packet switch 808f PES32NT8AG2 80cf F32P08xG3 [PCIe boot mode] @@ -12820,7 +12996,7 @@ 103c 30b5 Presario V3242AU 103c 30b7 Presario V6133CL 103c 30cc Pavilion dv6700 - 103c 30cf Pavilion dv9500/9600/9700 series + 103c 30cf Pavilion dv95xx/96xx/97xx/98xx series 1043 1237 A6J-Q008 1043 1967 V6800V 144d c018 X20 IV @@ -13542,6 +13718,16 @@ 8032 ATTO Celerity FC8xEN 117c 003b Celerity FC-82EN Fibre Channel Adapter 117c 003c Celerity FC-84EN Fibre Channel Adapter + 8053 PM8053 SXP 12G 24-port SAS/SATA expander + 8054 PM8054 SXP 12G 36-port SAS/SATA expander + 8055 PM8055 SXP 12G 48-port SAS/SATA expander + 8056 PM8056 SXP 12G 68-port SAS/SATA expander + 8060 PM8060 SRCv 12G eight-port SAS/SATA RoC + 8063 PM8063 SRCv 12G 16-port SAS/SATA RoC + 8070 PM8070 Tachyon SPCv 12G eight-port SAS/SATA controller + 8071 PM8071 Tachyon SPCve 12G eight-port SAS/SATA controller + 8072 PM8072 Tachyon SPCv 12G 16-port SAS/SATA controller + 8073 PM8073 Tachyon SPCve 12G 16-port SAS/SATA controller 11f9 I-Cube Inc 11fa Kasan Electronics Company, Ltd. 11fb Datel Inc @@ -13595,6 +13781,7 @@ 1202 9844 SK-9843 SX dual link 1203 Bayer Corporation, Agfa Division 1204 Lattice Semiconductor Corporation + 1965 SB6501 802.11ad Wireless Network Adapter 1205 Array Corporation 1206 Amdahl Corporation 1208 Parsytec GmbH @@ -13685,6 +13872,7 @@ 1028 04a3 Precision M4600 8331 O2 Flash Memory Card 8520 SD/MMC Card Reader Controller + 8621 SD/MMC Card Reader Controller 1218 Hybricon Corp. 1219 First Virtual Corporation 121a 3Dfx Interactive, Inc. @@ -13906,6 +14094,7 @@ 1969 ES1938/ES1946/ES1969 Solo-1 Audiodrive 1014 0166 ES1969 SOLO-1 AudioDrive on IBM Aptiva Mainboard 125d 8888 Solo-1 Audio Adapter + 125d 8898 ES1938S TTSOLO1-SL [TerraTec 128i PCI] 153b 111b Terratec 128i PCI 1978 ES1978 Maestro 2E 0e11 b112 Armada M700/E500 @@ -14030,13 +14219,13 @@ 0002 DirecPC 1274 Ensoniq 1171 ES1373 / Creative Labs CT5803 [AudioPCI] - 1371 ES1371 / Creative Labs CT2518/ES1373 + 1371 ES1371/ES1373 / Creative Labs CT2518 0e11 0024 AudioPCI on Motherboard Compaq Deskpro 0e11 b1a7 ES1371, ES1373 AudioPCI 1033 80ac ES1371, ES1373 AudioPCI 1042 1854 Tazer 107b 8054 Tabor2 - 1274 1371 AudioPCI 64V/128 / Creative CT4810/CT5803/CT5806 [Sound Blaster PCI] + 1274 1371 Audio PCI 64V/128/5200 / Creative CT4810/CT5803/CT5806 [Sound Blaster PCI] 1274 8001 CT4751 board 1462 6470 ES1371, ES1373 AudioPCI On Motherboard MS-6147 1.1A 1462 6560 ES1371, ES1373 AudioPCI On Motherboard MS-6156 1.10 @@ -14319,7 +14508,7 @@ 12a8 News Datacom 12a9 Xiotech Corporation 12aa SDL Communications, Inc. -12ab Yuan Yuan Enterprise Co., Ltd. +12ab YUAN High-Tech Development Co., Ltd. 0000 MPG160/Kuroutoshikou ITVC15-STVLP 0002 AU8830 [Vortex2] Based Sound Card With A3D Support 0003 T507 (DVB-T) TV tuner/capture device @@ -14868,6 +15057,7 @@ 0206 GPS180PEX GPS Receiver (PCI Express) 0207 GLN180PEX GPS/GLONASS receiver (PCI Express) 0208 GPS180AMC GPS Receiver (PCI Express / MicroTCA / AdvancedMC) + 0209 GRC181PEX GPS/GLONASS/BEIDOU receiver (PCI Express) 0301 TCR510PCI IRIG Timecode Reader 0302 TCR167PCI IRIG Timecode Reader 0303 TCR511PCI IRIG Timecode Reader @@ -15758,6 +15948,7 @@ 5015 T502-BT Unified Wire Ethernet Controller 5016 T580-OCP-SO Unified Wire Ethernet Controller 5017 T520-OCP-SO Unified Wire Ethernet Controller + 5018 T540-BT Unified Wire Ethernet Controller 5080 T540-5080 Unified Wire Ethernet Controller 5081 T540-5081 Unified Wire Ethernet Controller 5082 T504-5082 Unified Wire Ethernet Controller @@ -15804,6 +15995,7 @@ 5415 T502-BT Unified Wire Ethernet Controller 5416 T580-OCP-SO Unified Wire Ethernet Controller 5417 T520-OCP-SO Unified Wire Ethernet Controller + 5418 T540-BT Unified Wire Ethernet Controller 5480 T540-5080 Unified Wire Ethernet Controller 5481 T540-5081 Unified Wire Ethernet Controller 5482 T504-5082 Unified Wire Ethernet Controller @@ -15850,6 +16042,7 @@ 5515 T502-BT Unified Wire Storage Controller 5516 T580-OCP-SO Unified Wire Storage Controller 5517 T520-OCP-SO Unified Wire Storage Controller + 5518 T540-BT Unified Wire Storage Controller 5580 T540-5080 Unified Wire Storage Controller 5581 T540-5081 Unified Wire Storage Controller 5582 T504-5082 Unified Wire Storage Controller @@ -15896,6 +16089,7 @@ 5615 T502-BT Unified Wire Storage Controller 5616 T580-OCP-SO Unified Wire Storage Controller 5617 T520-OCP-SO Unified Wire Storage Controller + 5618 T540-BT Unified Wire Storage Controller 5680 T540-5080 Unified Wire Storage Controller 5681 T540-5081 Unified Wire Storage Controller 5682 T504-5082 Unified Wire Storage Controller @@ -15981,6 +16175,7 @@ 5815 T502-BT Unified Wire Ethernet Controller [VF] 5816 T580-OCP-SO Unified Wire Ethernet Controller [VF] 5817 T520-OCP-SO Unified Wire Ethernet Controller [VF] + 5818 T540-BT Unified Wire Ethernet Controller [VF] 5880 T540-5080 Unified Wire Ethernet Controller [VF] 5881 T540-5081 Unified Wire Ethernet Controller [VF] 5882 T504-5082 Unified Wire Ethernet Controller [VF] @@ -16341,7 +16536,8 @@ 14e1 INVERTEX 14e2 INFOLIBRIA 14e3 AMTELCO -14e4 Broadcom Corporation +# Formerly Broadcom Corporation +14e4 Broadcom Limited 0576 BCM43224 802.11a/b/g/n 0800 Sentry5 Chipcommon I/O Controller 0804 Sentry5 PCI Bridge @@ -16725,15 +16921,41 @@ 103c 1321 Core I/O LAN/SCSI Combo [AB314A] 14e4 0009 NetXtreme BCM5703 1000Base-T 14e4 000a NetXtreme BCM5703 1000Base-SX - 16c8 BCM57301 NetXtreme-C Single-port 10Gb Ethernet - 16c9 BCM57302 NetXtreme-C Dual-port 10Gb/25Gb Ethernet - 16ca BCM57304 NetXtreme-C Dual-port 10Gb/25Gb/40Gb/50Gb Ethernet + 16c8 BCM57301 NetXtreme-C 10Gb Ethernet Controller + 16c9 BCM57302 NetXtreme-C 10Gb/25Gb Ethernet Controller + 16ca BCM57304 NetXtreme-C 10Gb/25Gb/40Gb/50Gb Ethernet Controller 16cb BCM57304 NetXtreme-C Ethernet Virtual Function - 16d0 BCM57402 NetXtreme-E Dual-port 10Gb Ethernet - 16d1 BCM57404 NetXtreme-E Dual-port 10Gb/25Gb Ethernet - 16d2 BCM57406 NetXtreme-E Dual-port 10GBase-T Ethernet + 16cc BCM57417 NetXtreme-E Ethernet Partition + 16ce BCM57311 NetXtreme-C 10Gb RDMA Ethernet Controller + 16cf BCM57312 NetXtreme-C 10Gb/25Gb RDMA Ethernet Controller + 16d0 BCM57402 NetXtreme-E 10Gb Ethernet Controller + 16d1 BCM57404 NetXtreme-E 10Gb/25Gb Ethernet Controller + 16d2 BCM57406 NetXtreme-E 10GBASE-T Ethernet Controller 16d3 BCM57404 NetXtreme-E Ethernet Virtual Function + 16d4 BCM57402 NetXtreme-E Ethernet Partition + 16d5 BCM57407 NetXtreme-E 10GBase-T Ethernet Controller + 16d6 BCM57412 NetXtreme-E 10Gb RDMA Ethernet Controller + 16d7 BCM57414 NetXtreme-E 10Gb/25Gb RDMA Ethernet Controller + 1590 020e Ethernet 25Gb 2-port 631SFP28 Adapter + 1590 0211 Ethernet 25Gb 2-port 631FLR-SFP28 Adapter + 16d8 BCM57416 NetXtreme-E 10GBase-T RDMA Ethernet Controller + 1590 020c Ethernet 10Gb 2-port 535T Adapter + 1590 0212 Ethernet 10Gb 2-port 535FLR-T Adapter + 16d9 BCM57417 NetXtreme-E 10GBASE-T RDMA Ethernet Controller + 108e 4866 Dual Port 10GBase-T Ethernet Controller + 16dc BCM57414 NetXtreme-E Ethernet Virtual Function 16dd NetLink BCM5781 Gigabit Ethernet PCI Express + 16de BCM57412 NetXtreme-E Ethernet Partition + 16df BCM57314 NetXtreme-C 10Gb/25Gb/40Gb/50Gb RDMA Ethernet Controller + 16e1 BCM57314 NetXtreme-C Ethernet Virtual Function + 16e2 BCM57417 NetXtreme-E 10Gb/25Gb RDMA Ethernet Controller + 108e 4866 Dual Port 10Gb/25Gb SFP28 Ethernet Controller + 16e3 BCM57416 NetXtreme-E 10Gb RDMA Ethernet Controller + 16e7 BCM57404 NetXtreme-E Ethernet Partition + 16e8 BCM57406 NetXtreme-E Ethernet Partition + 16e9 BCM57407 NetXtreme-E 25Gb Ethernet Controller + 16ec BCM57414 NetXtreme-E Ethernet Partition + 16ee BCM57416 NetXtreme-E Ethernet Partition 16f3 NetXtreme BCM5727 Gigabit Ethernet PCIe 16f7 NetXtreme BCM5753 Gigabit Ethernet PCI Express 16fd NetXtreme BCM5753M Gigabit Ethernet PCI Express @@ -17282,6 +17504,7 @@ 0070 8010 WinTV HVR-1400 ExpressCard 0070 f038 WinTV HVR-5525 107d 6f22 WinFast PxTV1200 + 12ab d585 PE988J Hybrid ATSC/QAM PCI-E AVS Video Capture (SoftEncoder) 13c2 3013 TT-budget CT2-4500 CI 1461 c039 AVerTV Hybrid Express (A577) 153b 117e Cinergy T PCIe Dual @@ -17432,6 +17655,7 @@ 1410 CB1410 Cardbus Controller 1025 003c CL50 motherboard 1025 005a TravelMate 290 + 103c 30d5 530 Laptop 1411 CB-710/2/4 Cardbus Controller 103c 006a NX9500 1412 CB-712/4 Cardbus Controller @@ -17481,6 +17705,7 @@ 9277 5 Volt Delta Sigma Converter Card 9278 10 Volt Delta Sigma Converter Card 9287 Analog Output Card + 9290 FPGA Card 1543 SILICON Laboratories 3052 Intel 537 [Winmodem] 4c22 Si3036 MC'97 DAA @@ -17657,6 +17882,10 @@ 0209 MT27700 Family [ConnectX-4 Flash Recovery] 020b MT27710 Family [ConnectX-4 Lx Flash Recovery] 020d MT28800 Family [ConnectX-5 Flash Recovery] +# reserved for RM#105916 + 024e MT53100 [Spectrum-2, Flash recovery mode] +# Actual value to be used + 024f MT53100 [Spectrum-2, Flash recovery mode] 0262 MT27710 [ConnectX-4 Lx Programmable] EN 0263 MT27710 [ConnectX-4 Lx Programmable Virtual Function] EN 1002 MT25400 Family [ConnectX-2 Virtual Function] @@ -17691,10 +17920,10 @@ 1014 MT27700 Family [ConnectX-4 Virtual Function] 1015 MT27710 Family [ConnectX-4 Lx] 1016 MT27710 Family [ConnectX-4 Lx Virtual Function] - 1017 MT27800 Family [ConnectX-5, PCIe 3.0] + 1017 MT27800 Family [ConnectX-5] 1018 MT28800 Family [ConnectX-5 Virtual Function] - 1019 MT28800 Family [ConnectX-5, PCIe 4.0] - 101a MT28830 + 1019 MT28800 Family [ConnectX-5 Ex] + 101a MT28800 Family [ConnectX-5 Ex Virtual Function] 101b MT28831 101c MT28840 101d MT28841 @@ -17702,6 +17931,7 @@ 101f MT28851 1020 MT28860 1021 MT28861 + 1974 MT28800 Family [ConnectX-5 PCIe Bridge] 5274 MT21108 InfiniBridge 5a44 MT23108 InfiniHost 5a45 MT23108 [Infinihost HCA Flash Recovery] @@ -17744,6 +17974,9 @@ caf1 ConnectX-4 CAPI Function # Spectrum, 100GbE Switch cb84 MT52100 + cf08 MT53236 + cf6c MT53100 [Spectrum-2, 64 x 100GbE switch] + d2f0 Switch-IB 3 HDR (200Gbps) switch 15b4 CCI/TRIAD 15b5 Cimetrics Inc 15b6 Texas Memory Systems Inc @@ -18015,6 +18248,7 @@ 7181 Proc10a_27S 7191 Proc10a_48S 71a1 Proc10a_66S + 71b1 Proc10A 165d Hsing Tech. Enterprise Co., Ltd. 165f Linux Media Labs, LLC 1020 LMLM4 MPEG-4 encoder @@ -18261,9 +18495,12 @@ 1028 0208 Wireless 1506 WLAN Half Mini-Card 103c 1838 AR9485/HB125 802.11bgn 1×1 Wi-Fi Adapter 105b e044 Unex DHXA-225 + 144d 410e AR9485WB-EG 802.11b/g/n mini-PCIe card on a series 3 laptop 1a3b 1186 AW-NE186H - 0033 AR9580 Wireless Network Adapter + 0033 AR958x 802.11abgn Wireless Network Adapter + 168c a120 AR9582 802.11a/n WLAN Mini-PCIe Adapter 0034 AR9462 Wireless Network Adapter + 1028 0300 Wireless 1802 802.11abgn Adapter 1a56 2003 Killer Wireless-N 1202 Half-size Mini PCIe Card 0036 QCA9565 / AR9565 Wireless Network Adapter 0037 AR9485 Wireless Network Adapter @@ -18393,6 +18630,16 @@ 7005 XMC-7K410CC: User-Configurable Kintex-7 FPGA, 410k logic cells, conduction-cooled 7006 XMC-7A200: User-Configurable Artix-7 FPGA, 200k logic cells with Plug-In I/O 7007 XMC-7A200CC: User-Configurable Conduction-Cooled Artix-7 FPGA, with 200k logic cells + 7011 AP440-1: 32-Channel Isolated Digital Input Module + 7012 AP440-2: 32-Channel Isolated Digital Input Module + 7013 AP440-3: 32-Channel Isolated Digital Input Module + 7014 AP445: 32-Channel Isolated Digital Output Module + 7016 AP470 48-Channel TTL Level Digital Input/Output Module + 7018 AP408: 32-Channel Digital I/O Module + 701a AP220-16 12-Bit, 16-Channel Analog Output Module + 701b AP231-16 16-Bit, 16-Channel Analog Output Module + 7042 AP482 Counter Timer Module with TTL Level Input/Output + 7044 AP484 Counter Timer Module with RS422 Input/Output 16da Advantech Co., Ltd. 0011 INES GPIB-PCI 16df PIKA Technologies Inc. @@ -18494,7 +18741,7 @@ 177d 0003 CN2350 [LiquidIO II] 2-port 10GbE SRIOV Virtual Function 9713 CN23XX [LiquidIO II] NVMe SRIOV Virtual Function 9800 Octeon Fusion CNF75XX Processor - a001 THUNDERX MRML Bridge + a001 ThunderX MRML(Master RML Bridge to RSL devices) a002 THUNDERX PCC Bridge 177d a102 CN88XX PCC Bridge a008 THUNDERX SMMU @@ -18532,15 +18779,24 @@ a026 THUNDERX BGX (Common Ethernet Interface) a027 THUNDERX IOBN a029 THUNDERX NCSI (Network Controller Sideband Interface) - a02a THUNDERX SGP + a02a ThunderX SGPIO (Serial GPIO controller for SATA disk lights) a02b THUNDERX SMI / MDIO Controller a02c THUNDERX DAP (Debug Access Port) a02d THUNDERX PCIERC (PCIe Root Complex) - a02e THUNDERX L2C-TAD + a02e ThunderX L2C-TAD (Level 2 cache tag and data) a02f THUNDERX L2C-CBC a030 THUNDERX L2C-MCI a031 THUNDERX MIO-FUS (Fuse Access Controller) a032 THUNDERX FUSF (Fuse Controller) + a033 THUNDERX Random Number Generator virtual function + a034 THUNDERX Network Interface Controller virtual function + a035 THUNDERX Parallel Bus + a036 ThunderX RAD (RAID acceleration engine) virtual function + a037 THUNDERX ZIP virtual function + a040 THUNDERX CPT Cryptographic Accelerator + a100 THUNDERX CN88XX 48 core SoC + a200 OCTEON TX CN81XX/CN80XX + a300 OCTEON TX CN83XX 1787 Hightech Information System Ltd. 1789 Ennyah Technologies Corp. # also used by Struck Innovative Systeme for joint developments @@ -18600,6 +18856,7 @@ 8083 GL880 USB 1.1 UHCI controller 8084 GL880 USB 2.0 EHCI controller 17aa Lenovo + 402b Intel 82599ES 10Gb 2-port Server Adapter X520-2 17ab Phillips Components 17af Hightech Information System Ltd. 17b3 Hawking Technologies @@ -18612,13 +18869,16 @@ 0017 StorSecure 300 GZIP Compression and AES Encryption Card 17c0 Wistron Corp. 17c2 Newisys, Inc. -17cb Airgo Networks, Inc. +# nee Airgo Networks, Inc. +17cb Qualcomm 0001 AGN100 802.11 a/b/g True MIMO Wireless Card 1385 5c00 WGM511 Pre-N 802.11g Wireless CardBus Adapter 1737 0045 WMP54GX v1 802.11g Wireless-G PCI Adapter with SRX 0002 AGN300 802.11 a/b/g True MIMO Wireless Card 1385 6d00 WPNT511 RangeMax 240 Mbps Wireless CardBus Adapter 1737 0054 WPC54GX4 v1 802.11g Wireless-G Notebook Adapter with SRX400 + 0400 Datacenter Technologies QDF2432 PCI Express Root Port + 0401 Datacenter Technologies QDF2400 PCI Express Root Port 17cc NetChip Technology, Inc 2280 USB 2.0 17cf Z-Com, Inc. @@ -18692,6 +18952,44 @@ 17db Cray Inc 0101 XT Series [Seastar] 3D Toroidal Router 17de KWorld Computer Co. Ltd. +17df Dini Group + 1864 Virtex4 PCI Board w/ QL5064 Bridge [DN7000K10PCI/DN8000K10PCI/DN8000K10PSX/NOTUS] + 1865 Virtex4 ASIC Emulator [DN8000K10PCIe] + 1866 Virtex4 ASIC Emulator Cable Connection [DN8000K10PCI] + 1867 Virtex4 ASIC Emulator Cable Connection [DN8000K10PCIe] + 1868 Virtex4 ASIC Emulator [DN8000K10PCIe-8] + 1900 Virtex5 PCIe ASIC Emulator [DN9000K10PCIe8T/DN9002K10PCIe8T/DN9200K10PCIe8T/DN7006K10PCIe8T/DN7406K10PCIe8T] + 1901 Virtex5 PCIe ASIC Emulator Large BARs [DN9000K10PCIe8T/DN9002K10PCIe8T/DN9200K10PCIe8T/DN7006K10PCIe8T/DN7406K10PCIe8T] + 1902 Virtex5 PCIe ASIC Emulator Low Power [Interceptor] + 1903 Spartan6 PCIe FPGA Accelerator Board [DNBFCS12PCIe] + 1904 Virtex6 PCIe ASIC Emulation Board [DNDUALV6_PCIe4] + 1905 Virtex6 PCIe ASIC Emulation Board [DNV6F6PCIe] + 1906 Virtex6 PCIe ASIC Emulation Board [DN2076K10] + 1907 Virtex6 PCIe ASIC Emulation Board [DNV6F2PCIe] + 1908 Virtex6 PCIe ASIC Emulation Board Large BARs[DNV6F2PCIe] *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-all@freebsd.org Sat Oct 15 12:23:56 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 1C620C11BCA; Sat, 15 Oct 2016 12:23:56 +0000 (UTC) (envelope-from jmcneill@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id ED89716; Sat, 15 Oct 2016 12:23:55 +0000 (UTC) (envelope-from jmcneill@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9FCNt0j027064; Sat, 15 Oct 2016 12:23:55 GMT (envelope-from jmcneill@FreeBSD.org) Received: (from jmcneill@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9FCNtbD027063; Sat, 15 Oct 2016 12:23:55 GMT (envelope-from jmcneill@FreeBSD.org) Message-Id: <201610151223.u9FCNtbD027063@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jmcneill set sender to jmcneill@FreeBSD.org using -f From: Jared McNeill Date: Sat, 15 Oct 2016 12:23:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307354 - head/sys/arm/allwinner/clk X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 Oct 2016 12:23:56 -0000 Author: jmcneill Date: Sat Oct 15 12:23:54 2016 New Revision: 307354 URL: https://svnweb.freebsd.org/changeset/base/307354 Log: Provide a complete A23 PLL1 factor table, from 60MHz to 1872MHz. Modified: head/sys/arm/allwinner/clk/aw_pll.c Modified: head/sys/arm/allwinner/clk/aw_pll.c ============================================================================== --- head/sys/arm/allwinner/clk/aw_pll.c Sat Oct 15 12:22:06 2016 (r307353) +++ head/sys/arm/allwinner/clk/aw_pll.c Sat Oct 15 12:23:54 2016 (r307354) @@ -193,12 +193,76 @@ struct aw_pll_factor { { .n = (_n), .k = (_k), .m = (_m), .p = (_p), .freq = (_freq) } static struct aw_pll_factor aw_a23_pll1_factors[] = { + PLLFACTOR(9, 0, 0, 2, 60000000), + PLLFACTOR(10, 0, 0, 2, 66000000), + PLLFACTOR(11, 0, 0, 2, 72000000), + PLLFACTOR(12, 0, 0, 2, 78000000), + PLLFACTOR(13, 0, 0, 2, 84000000), + PLLFACTOR(14, 0, 0, 2, 90000000), + PLLFACTOR(15, 0, 0, 2, 96000000), + PLLFACTOR(16, 0, 0, 2, 102000000), + PLLFACTOR(17, 0, 0, 2, 108000000), + PLLFACTOR(18, 0, 0, 2, 114000000), + PLLFACTOR(9, 0, 0, 1, 120000000), + PLLFACTOR(10, 0, 0, 1, 132000000), + PLLFACTOR(11, 0, 0, 1, 144000000), + PLLFACTOR(12, 0, 0, 1, 156000000), + PLLFACTOR(13, 0, 0, 1, 168000000), + PLLFACTOR(14, 0, 0, 1, 180000000), + PLLFACTOR(15, 0, 0, 1, 192000000), + PLLFACTOR(16, 0, 0, 1, 204000000), + PLLFACTOR(17, 0, 0, 1, 216000000), + PLLFACTOR(18, 0, 0, 1, 228000000), + PLLFACTOR(9, 0, 0, 0, 240000000), + PLLFACTOR(10, 0, 0, 0, 264000000), + PLLFACTOR(11, 0, 0, 0, 288000000), + PLLFACTOR(12, 0, 0, 0, 312000000), + PLLFACTOR(13, 0, 0, 0, 336000000), + PLLFACTOR(14, 0, 0, 0, 360000000), + PLLFACTOR(15, 0, 0, 0, 384000000), PLLFACTOR(16, 0, 0, 0, 408000000), + PLLFACTOR(17, 0, 0, 0, 432000000), + PLLFACTOR(18, 0, 0, 0, 456000000), + PLLFACTOR(19, 0, 0, 0, 480000000), + PLLFACTOR(20, 0, 0, 0, 504000000), + PLLFACTOR(21, 0, 0, 0, 528000000), + PLLFACTOR(22, 0, 0, 0, 552000000), + PLLFACTOR(23, 0, 0, 0, 576000000), + PLLFACTOR(24, 0, 0, 0, 600000000), + PLLFACTOR(25, 0, 0, 0, 624000000), PLLFACTOR(26, 0, 0, 0, 648000000), + PLLFACTOR(27, 0, 0, 0, 672000000), + PLLFACTOR(28, 0, 0, 0, 696000000), + PLLFACTOR(29, 0, 0, 0, 720000000), + PLLFACTOR(15, 1, 0, 0, 768000000), + PLLFACTOR(10, 2, 0, 0, 792000000), PLLFACTOR(16, 1, 0, 0, 816000000), + PLLFACTOR(17, 1, 0, 0, 864000000), + PLLFACTOR(18, 1, 0, 0, 912000000), + PLLFACTOR(12, 2, 0, 0, 936000000), + PLLFACTOR(19, 1, 0, 0, 960000000), PLLFACTOR(20, 1, 0, 0, 1008000000), + PLLFACTOR(21, 1, 0, 0, 1056000000), + PLLFACTOR(14, 2, 0, 0, 1080000000), + PLLFACTOR(22, 1, 0, 0, 1104000000), + PLLFACTOR(23, 1, 0, 0, 1152000000), PLLFACTOR(24, 1, 0, 0, 1200000000), + PLLFACTOR(16, 2, 0, 0, 1224000000), + PLLFACTOR(25, 1, 0, 0, 1248000000), PLLFACTOR(26, 1, 0, 0, 1296000000), + PLLFACTOR(27, 1, 0, 0, 1344000000), + PLLFACTOR(18, 2, 0, 0, 1368000000), + PLLFACTOR(28, 1, 0, 0, 1392000000), + PLLFACTOR(29, 1, 0, 0, 1440000000), + PLLFACTOR(20, 2, 0, 0, 1512000000), + PLLFACTOR(15, 3, 0, 0, 1536000000), + PLLFACTOR(21, 2, 0, 0, 1584000000), + PLLFACTOR(16, 3, 0, 0, 1632000000), + PLLFACTOR(22, 2, 0, 0, 1656000000), + PLLFACTOR(23, 2, 0, 0, 1728000000), + PLLFACTOR(24, 2, 0, 0, 1800000000), + PLLFACTOR(18, 3, 0, 0, 1824000000), + PLLFACTOR(25, 2, 0, 0, 1872000000), }; enum aw_pll_type { From owner-svn-src-all@freebsd.org Sat Oct 15 12:28:16 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 1A7E2C11D8E; Sat, 15 Oct 2016 12:28:16 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id A981D375; Sat, 15 Oct 2016 12:28:15 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9FCSEQl027250; Sat, 15 Oct 2016 12:28:14 GMT (envelope-from bapt@FreeBSD.org) Received: (from bapt@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9FCSEWb027249; Sat, 15 Oct 2016 12:28:14 GMT (envelope-from bapt@FreeBSD.org) Message-Id: <201610151228.u9FCSEWb027249@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bapt set sender to bapt@FreeBSD.org using -f From: Baptiste Daroussin Date: Sat, 15 Oct 2016 12:28:14 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307355 - stable/10/share/misc X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 Oct 2016 12:28:16 -0000 Author: bapt Date: Sat Oct 15 12:28:14 2016 New Revision: 307355 URL: https://svnweb.freebsd.org/changeset/base/307355 Log: MFC r297289, r300542, r306854 Update pci_vendors to 2016-10-03 Modified: stable/10/share/misc/pci_vendors Directory Properties: stable/10/ (props changed) Modified: stable/10/share/misc/pci_vendors ============================================================================== --- stable/10/share/misc/pci_vendors Sat Oct 15 12:23:54 2016 (r307354) +++ stable/10/share/misc/pci_vendors Sat Oct 15 12:28:14 2016 (r307355) @@ -3,11 +3,11 @@ # # List of PCI ID's # -# Version: 2015.07.31 -# Date: 2015-07-31 03:15:02 +# Version: 2016.10.03 +# Date: 2016-10-03 03:15:01 # -# Maintained by Martin Mares and other volunteers from the -# PCI ID Project at http://pci-ids.ucw.cz/. +# Maintained by Albert Pool, Martin Mares, and other volunteers from +# the PCI ID Project at http://pci-ids.ucw.cz/. # # New data are always welcome, especially if they are accurate. If you have # anything to contribute, please follow the instructions at the web site. @@ -23,6 +23,7 @@ # device device_name <-- single tab # subvendor subdevice subsystem_name <-- two tabs +0001 SafeNet (wrong ID) 0010 Allied Telesis, Inc (Wrong ID) # This is a relabelled RTL-8139 8139 AT-2500TX V3 Ethernet @@ -243,6 +244,19 @@ 1000 1000 LSI53C895A PCI to Ultra2 SCSI Controller 0013 53c875a 1000 1000 LSI53C875A PCI to Ultra SCSI Controller + 0014 MegaRAID Tri-Mode SAS3516 + 1d49 0602 ThinkSystem RAID 930-16i 4GB Flash PCIe 12Gb Adapter + 0016 MegaRAID Tri-Mode SAS3508 + 1d49 0601 ThinkSystem RAID 930-8i 2GB Flash PCIe 12Gb Adapter + 1d49 0603 ThinkSystem RAID 930-24i 4GB Flash PCIe 12Gb Adapter + 1d49 0604 ThinkSystem RAID 930-8e 4GB Flash PCIe 12Gb Adapter + 0017 MegaRAID Tri-Mode SAS3408 + 1d49 0500 ThinkSystem RAID 530-8i PCIe 12Gb Adapter + 1d49 0502 ThinkSystem RAID 530-8i Dense Adapter + 001b MegaRAID Tri-Mode SAS3504 + 1d49 0605 ThinkSystem RAID 930-4i 2GB Flash Flex Adapter + 001c MegaRAID Tri-Mode SAS3404 + 1d49 0501 ThinkSystem RAID 530-4i Flex Adapter 0020 53c1010 Ultra3 SCSI Adapter 1000 1000 LSI53C1010-33 PCI to Dual Channel Ultra160 SCSI Controller 107b 1040 Server Onboard 53C1010-33 @@ -272,6 +286,7 @@ 103c 12c5 Ultra320 SCSI [A7173A] 103c 1323 Core I/O LAN/SCSI Combo [AB314A] 103c 3108 Single Channel Ultra320 SCSI HBA G2 + 103c 322a SC11Xe Ultra320 Single Channel PCIe x4 SCSI Host Bus Adapter (412911-B21) 124b 1170 PMC-USCSI320 # VMware's emulation of this device. Was missing from the list. 15ad 1976 LSI Logic Parallel SCSI Controller @@ -287,6 +302,10 @@ 0050 SAS1064 PCI-X Fusion-MPT SAS 1028 1f04 SAS 5/E 1028 1f09 SAS 5i/R + 0052 MegaRAID SAS-3 3216/3224 [Cutlass] + 0053 MegaRAID SAS-3 3216/3224 [Cutlass] + 1000 9350 MegaRAID SAS 9341-16i + 1000 9351 MegaRAID SAS 9341-24i 0054 SAS1068 PCI-X Fusion-MPT SAS 1028 1f04 SAS 5/E Adapter Controller 1028 1f05 SAS 5/i Adapter Controller @@ -345,6 +364,8 @@ 005c SAS1064A PCI-X Fusion-MPT SAS 005d MegaRAID SAS-3 3108 [Invader] 1000 9361 MegaRAID SAS 9361-8i + 1000 9364 MegaRAID SAS 9364-8i + 1000 936a MegaRAID SAS 9364-8i 1028 1f41 PERC H830 Adapter 1028 1f42 PERC H730P Adapter 1028 1f43 PERC H730 Adapter @@ -357,6 +378,7 @@ 1028 1f54 PERC FD33xD 17aa 1052 ThinkServer RAID 720i 17aa 1053 ThinkServer RAID 720ix + 1d49 0600 ThinkSystem RAID 730-8i 1GB Cache PCIe 12Gb Adapter 005e SAS1066 PCI-X Fusion-MPT SAS 005f MegaRAID SAS-3 3008 [Fury] 1028 1f44 PERC H330 Adapter @@ -364,6 +386,7 @@ 1028 1f4c PERC H330 Mini (for blades) 1028 1f4d PERC H330 Embedded (for monolithic) 1054 306a SAS 3004 iMR ROMB + 1d49 04db ServeRAID M1210 SAS/SATA Controller 0060 MegaRAID SAS 1078 1000 1006 MegaRAID SAS 8888ELP 1000 100a MegaRAID SAS 8708ELP @@ -474,6 +497,21 @@ 007c MegaRAID SAS 1078DE 1014 0395 ServeRAID-AR10is SAS/SATA Controller 007e SSS6200 PCI-Express Flash SSD + 1000 0504 Nytro NWD-BLP4-800 + 1000 0507 Nytro NWD-BLP4-1600 + 1000 0581 Nytro NWD-BLP4-400 + 1000 100d Nytro NWD-BFH6-1200 + 1000 100e Nytro NWD-BFH8-1600 + 1000 107e Nytro NWD-BFH8-3200 + 1000 1310 Nytro XP6302-8B1536 + 1000 1311 Nytro XP6302-8B2048 + 1000 1314 Nytro XP6302-8B4096 + 1000 150c Nytro XP6210-4A2048 + 1000 150f Nytro XP6210-4B2048 + 1000 160b Nytro XP6209-4A1024 + 1000 1613 Nytro XP6209-4B2048 + 108e 050a Nytro ELP4x200_4d_n + 108e 0581 Nytro ELP4x100_4d_n 0080 SAS2208 PCI-Express Fusion-MPT SAS-2 0081 SAS2208 PCI-Express Fusion-MPT SAS-2 0082 SAS2208 PCI-Express Fusion-MPT SAS-2 @@ -482,6 +520,9 @@ 0085 SAS2208 PCI-Express Fusion-MPT SAS-2 0086 SAS2308 PCI-Express Fusion-MPT SAS-2 0087 SAS2308 PCI-Express Fusion-MPT SAS-2 + 1000 3020 9207-8i SAS2.1 HBA + 1000 3040 9207-8e SAS2.1 HBA + 1000 3050 SAS9217-8i 1590 0044 H220i 008f 53c875J 1092 8000 FirePort 40 SCSI Controller @@ -492,8 +533,38 @@ 0095 SAS3108 PCI-Express Fusion-MPT SAS-3 0096 SAS3004 PCI-Express Fusion-MPT SAS-3 0097 SAS3008 PCI-Express Fusion-MPT SAS-3 + 1000 3090 SAS9311-8i + 1000 30e0 SAS9300-8i 1028 1f45 12GB/s HBA internal 1028 1f46 12Gbps HBA + 00ab SAS3516 Fusion-MPT Tri-Mode RAID On Chip (ROC) + 00ac SAS3416 Fusion-MPT Tri-Mode I/O Controller Chip (IOC) + 1d49 0201 ThinkSystem 9400-16i PCIe 12Gb HBA + 1d49 0203 ThinkSystem 9400-16e PCIe 12Gb HBA + 00ae SAS3508 Fusion-MPT Tri-Mode RAID On Chip (ROC) + 00af SAS3408 Fusion-MPT Tri-Mode I/O Controller Chip (IOC) + 1d49 0200 ThinkSystem 9400-8i PCIe 12Gb HBA + 1d49 0202 ThinkSystem 9400-8e PCIe 12Gb HBA + 00be SAS3504 Fusion-MPT Tri-Mode RAID On Chip (ROC) + 00bf SAS3404 Fusion-MPT Tri-Mode I/O Controller Chip (IOC) + 00c0 SAS3324 PCI-Express Fusion-MPT SAS-3 + 00c1 SAS3324 PCI-Express Fusion-MPT SAS-3 + 00c2 SAS3324 PCI-Express Fusion-MPT SAS-3 + 00c3 SAS3324 PCI-Express Fusion-MPT SAS-3 + 00c4 SAS3224 PCI-Express Fusion-MPT SAS-3 + 00c5 SAS3316 PCI-Express Fusion-MPT SAS-3 + 00c6 SAS3316 PCI-Express Fusion-MPT SAS-3 + 00c7 SAS3316 PCI-Express Fusion-MPT SAS-3 + 00c8 SAS3316 PCI-Express Fusion-MPT SAS-3 + 00c9 SAS3216 PCI-Express Fusion-MPT SAS-3 + 00ce MegaRAID SAS-3 3316 [Intruder] + 1000 9371 MegaRAID SAS 9361-16i + 1000 9390 MegaRAID SAS 9380-8i8e + 00cf MegaRAID SAS-3 3324 [Intruder] + 1000 9370 MegaRAID SAS 9361-24i + 00d0 SAS3716 Fusion-MPT Tri-Mode RAID Controller Chip (ROC) + 00d1 SAS3616 Fusion-MPT Tri-Mode I/O Controller Chip (IOC) + 00d3 MegaRAID Tri-Mode SAS3716W 0407 MegaRAID 1000 0530 MegaRAID 530 SCSI 320-0X RAID Controller 1000 0531 MegaRAID 531 SCSI 320-4X RAID Controller @@ -1260,7 +1331,7 @@ 5652 RV410/M26 [Mobility Radeon X700] 5653 RV410/M26 [Mobility Radeon X700] 1025 0080 Aspire 5024WLMi - 103c 0940 HP Compaq NW8240 Mobile Workstation + 103c 0940 Compaq NW8240 Mobile Workstation 5654 264VT [Mach64 VT] 1002 5654 Mach64VT Reference 5655 264VT3 [Mach64 VT3] @@ -1350,23 +1421,23 @@ 5a11 RD890 Northbridge only single slot PCI-e GFX Hydra part 5a12 RD890 Northbridge only dual slot (2x8) PCI-e GFX Hydra part 15d9 a811 H8DGU - 5a13 RD890 PCI to PCI bridge (external gfx0 port A) - 5a14 RD890 PCI to PCI bridge (external gfx0 port B) + 5a13 RD890S/SR5650 Host Bridge + 5a14 RD9x0/RX980 Host Bridge 5a15 RD890 PCI to PCI bridge (PCI express gpp port A) - 5a16 RD890 PCI to PCI bridge (PCI express gpp port B) - 5a17 RD890 PCI to PCI bridge (PCI express gpp port C) - 5a18 RD890 PCI to PCI bridge (PCI express gpp port D) + 5a16 RD890/RD9x0/RX980 PCI to PCI bridge (PCI Express GFX port 0) + 5a17 RD890/RD9x0 PCI to PCI bridge (PCI Express GFX port 1) + 5a18 RD890/RD9x0/RX980 PCI to PCI bridge (PCI Express GPP Port 0) 15d9 a811 H8DGU - 5a19 RD890 PCI to PCI bridge (PCI express gpp port E) - 5a1a RD890 PCI to PCI bridge (PCI express gpp port F) - 5a1b RD890 PCI to PCI bridge (PCI express gpp port G) - 5a1c RD890 PCI to PCI bridge (PCI express gpp port H) - 5a1d RD890 PCI to PCI bridge (external gfx1 port A) - 5a1e RD890 PCI to PCI bridge (external gfx1 port B) - 5a1f RD890 PCI to PCI bridge (NB-SB link) + 5a19 RD890/RD9x0/RX980 PCI to PCI bridge (PCI Express GPP Port 1) + 5a1a RD890/RD9x0/RX980 PCI to PCI bridge (PCI Express GPP Port 2) + 5a1b RD890/RD9x0/RX980 PCI to PCI bridge (PCI Express GPP Port 3) + 5a1c RD890/RD9x0/RX980 PCI to PCI bridge (PCI Express GPP Port 4) + 5a1d RD890/RD9x0/RX980 PCI to PCI bridge (PCI Express GPP Port 5) + 5a1e RD890/RD9x0/RX980 PCI to PCI bridge (PCI Express GPP2 Port 0) + 5a1f RD890/RD990 PCI to PCI bridge (PCI Express GFX2 port 0) 15d9 a811 H8DGU - 5a20 RD890S PCI Express bridge for GPP2 port 1 - 5a23 RD990 I/O Memory Management Unit (IOMMU) + 5a20 RD890/RD990 PCI to PCI bridge (PCI Express GFX2 port 1) + 5a23 RD890S/RD990 I/O Memory Management Unit (IOMMU) 5a31 RC410 Host Bridge 5a33 RS400 Host Bridge 5a34 RS4xx PCI Express Port [ext gfx] @@ -1486,6 +1557,9 @@ 6646 Bonaire XT [Radeon R9 M280X] 6647 Bonaire PRO [Radeon R9 M270X] 6649 Bonaire [FirePro W5100] + 1002 0b0c FirePro W4300 + 103c 0b0c Bonaire [FirePro W4300] + 103c 230c FirePro W5100 6650 Bonaire 6651 Bonaire 6658 Bonaire XTX [Radeon R7 260X/360] @@ -1515,10 +1589,17 @@ 1462 3271 Radeon R9 360 OEM 1682 7360 Radeon R7 360 6660 Sun XT [Radeon HD 8670A/8670M/8690M / R5 M330] + 1028 05ea Radeon HD 8670M + 1028 06bf Radeon R5 M335 + 103c 1970 Radeon HD 8670M + 103c 80be Radeon R5 M330 + 103c 8136 Radeon R5 M330 + 17aa 3804 Radeon R5 M330 17aa 3809 Radeon R5 M330 17aa 390c Radeon R5 M330 6663 Sun PRO [Radeon HD 8570A/8570M] 1025 0846 Radeon HD 8570A + 17aa 3805 Radeon HD 8570M 6664 Jet XT [Radeon R5 M240] 6665 Jet PRO [Radeon R5 M230] 17aa 368f Radeon R5 A230 @@ -2053,9 +2134,11 @@ 1462 8036 Radeon HD 8990 OEM 148c 8990 Radeon HD 8990 OEM 679e Tahiti LE [Radeon HD 7870 XT] + 1787 2328 Radeon HD 7870 Black Edition 2 GB GDDR5 [2GBD5-2DHV3E] 679f Tahiti 67a0 Hawaii XT GL [FirePro W9100] 1002 0335 FirePro S9150 + 1002 0735 FirePro S9170 1028 031f FirePro W9100 1028 0335 FirePro S9150 67a1 Hawaii PRO GL [FirePro W8100] @@ -2065,29 +2148,69 @@ 67a8 Hawaii 67a9 Hawaii 67aa Hawaii - 67b0 Hawaii XT [Radeon R9 290X] + 67b0 Hawaii XT / Grenada XT [Radeon R9 290X/390X] + 1028 0b00 Grenada XT [Radeon R9 390X] + 103c 6566 Radeon R9 390X 1043 046a R9 290X DirectCU II 1043 046c R9 290X DirectCU II OC 1043 0474 Matrix R9 290X Platinum 1043 0476 ARES III + 1043 04d7 Radeon R9 390X + 1043 04db Radeon R9 390X + 1043 04df Radeon R9 390X + 1043 04e9 Radeon R9 390X 1458 227c R9 290X WindForce 3X OC 1458 2281 R9 290X WindForce 3X OC 1458 228c R9 290X WindForce 3X 1458 228d R9 290X WindForce 3X OC 1458 2290 R9 290X WindForce 3X + 1458 22bc Radeon R9 390X + 1458 22c1 Grenada PRO [Radeon R9 390] + 1462 2015 Radeon R9 390X 1462 3070 R9 290X Lightning 1462 3071 R9 290X Lightning 1462 3072 R9 290X Lightning LE 1462 3080 R9 290X Gaming 1462 3082 R9 290X Gaming OC 148c 2347 Devil 13 Dual Core R9 290X + 148c 2357 Grenada XT [Radeon R9 390X] 1682 9290 Double Dissipation R9 290X + 1682 9395 Grenada XT [Radeon R9 390X] + 174b 0e34 Radeon R9 390X 174b e282 Vapor-X R9 290X Tri-X OC 174b e285 R9 290X Tri-X OC + 174b e324 Grenada XT2 [Radeon R9 390X] 1787 2020 R9 290X IceQ X² Turbo - 67b1 Hawaii PRO [Radeon R9 290] + 1787 2357 Grenada XT [Radeon R9 390X] + 67b1 Hawaii PRO [Radeon R9 290/390] + 1043 04dd STRIX R9 390 + 148c 2358 Radeon R9 390 + 174b e324 Sapphire Nitro R9 390 67b9 Vesuvius [Radeon R9 295X2] 67be Hawaii LE + 67c0 Ellesmere [Polaris10] + 67df Ellesmere [Radeon RX 470/480] + 1002 0b37 Radeon RX 480 + 1043 04a8 Radeon RX 480 + 1043 04b0 Radeon RX 470 + 1043 04fb Radeon RX 480 + 1462 3411 Radeon RX 470 + 1462 3413 Radeon RX 480 + 148c 2372 Radeon RX 480 + 148c 2373 Radeon RX 470 + 1682 9470 Radeon RX 470 + 1682 9480 Radeon RX 480 + 174b e347 Radeon RX 470/480 + 174b e349 Radeon RX 470 + 1787 a470 Radeon RX 470 + 1787 a480 Radeon RX 480 + 67e0 Baffin [Polaris11] + 67e1 Baffin [Polaris11] + 67e8 Baffin [Polaris11] + 67e9 Baffin [Polaris11] + 67eb Baffin [Polaris11] + 67ef Baffin [Radeon RX 460] + 67ff Baffin [Polaris11] 6800 Wimbledon XT [Radeon HD 7970M] 1002 0124 Radeon HD 7970M 8086 2110 Radeon HD 7970M @@ -2103,7 +2226,7 @@ 1002 0310 FirePro S7000 1002 0420 Radeon Sky 500 6809 Pitcairn LE GL [FirePro W5000] - 6810 Curacao XT [Radeon R7 370 / R9 270X/370 OEM] + 6810 Curacao XT / Trinidad XT [Radeon R7 370 / R9 270X/370X] 148c 0908 Radeon R9 370 OEM 1682 7370 Radeon R7 370 6811 Curacao PRO [Radeon R7 370 / R9 270/370 OEM] @@ -2743,20 +2866,49 @@ 174b e180 Radeon HD 7350 17af 3015 Radeon HD 7350 68fe Cedar LE - 6900 Topaz XT [Radeon R7 M260/M265] - 1028 0640 Radeon R7 M265 + 6900 Topaz XT [Radeon R7 M260/M265 / M340/M360] + 1025 1056 Radeon R7 M360 / R8 M365DX + 1028 0640 Radeon R7 M260/M265 + 1028 0643 Radeon R7 M260/M265 + 1028 067f Radeon R7 M260 + 1028 130a Radeon R7 M260 + 103c 2263 Radeon R7 M260 103c 2269 Radeon R7 M260 + 103c 22c6 Radeon R7 M260 103c 22c8 Radeon R7 M260 + 103c 808c Radeon R7 M260 + 103c 8099 Radeon R7 M360 + 103c 80b5 Radeon R7 M360 + 103c 80b9 Radeon R7 M360 + 103c 811c Radeon R7 M340 + 10cf 1906 Radeon R7 M260 + 1170 9979 Radeon R7 M360 1179 f903 Radeon R7 M260 + 1179 f922 Radeon R7 M260 + 1179 f923 Radeon R7 M260 1179 f934 Radeon R7 M260 + 17aa 3822 Radeon R7 M360 + 17aa 3824 Radeon R7 M360 + 17aa 5021 Radeon R7 M260 6901 Topaz PRO [Radeon R5 M255] + 103c 1318 Radeon R6 M255DX 6921 Amethyst XT [Radeon R9 M295X] - 6929 Tonga PRO GL [FirePro Series] + 6929 Tonga XT GL [FirePro S7150] 692b Tonga PRO GL [FirePro W7100] - 692f Tonga XT GL [FirePro W8100] - 6938 Amethyst XT [Radeon R9 M295X Mac Edition] + 692f Tonga XTV GL [FirePro S7150V] + 6938 Tonga XT / Amethyst XT [Radeon R9 380X / R9 M295X] + 1043 04f5 Radeon R9 380X + 1043 04f7 Radeon R9 380X + 106b 013a Radeon R9 M295X Mac Edition + 1458 22c8 Radeon R9 380X + 148c 2350 Radeon R9 380X + 1682 9385 Radeon R9 380X + 174b e308 Radeon R9 380X Nitro 4G D5 + 17af 2006 Radeon R9 380X 6939 Tonga PRO [Radeon R9 285/380] 148c 9380 Radeon R9 380 +# Make naming scheme consistent + 174b e308 Radeon R9 380 Nitro 4G D5 700f RS100 AGP Bridge 7010 RS200/RS250 AGP Bridge 7100 R520 [Radeon X1800 XT] @@ -2877,7 +3029,12 @@ 72a8 RV570 [Radeon X1950 GT] (Secondary) 72b1 RV560 [Radeon X1650 XT] (Secondary) 72b3 RV560 [Radeon X1650 GT] (Secondary) - 7300 Fiji XT [Radeon R9 FURY X] + 7300 Fiji [Radeon R9 FURY / NANO Series] + 1002 0b36 Radeon R9 FURY X / NANO + 1002 1b36 Radeon Pro Duo + 1043 049e Radeon R9 FURY + 1043 04a0 Radeon R9 FURY X + 174b e329 Radeon R9 FURY 7833 RS350 Host Bridge 7834 RS350 [Radeon 9100 PRO/XT IGP] 7835 RS350M [Mobility Radeon 9000 IGP] @@ -3069,7 +3226,7 @@ 95cc RV620 GL [FirePro V3700] 95cd RV620 [FirePro 2450] 95cf RV620 GL [FirePro 2260] - 960f RS780 HDMI Audio [Radeon (HD) 3000 Series] + 960f RS780 HDMI Audio [Radeon 3000/3100 / HD 3200/3300] 9610 RS780 [Radeon HD 3200] 1458 d000 GA-MA78GM-S2H Motherboard 9611 RS780C [Radeon 3100] @@ -3144,10 +3301,12 @@ 985f Mullins 9874 Carrizo 9900 Trinity [Radeon HD 7660G] + 103c 1985 Pavilion 17-e163sg Notebook PC # AMD A10-5800K CPU 9901 Trinity [Radeon HD 7660D] 9902 Trinity HDMI Audio Controller 103c 194e ProBook 455 G1 Notebook + 103c 1985 Pavilion 17-e163sg Notebook PC 9903 Trinity [Radeon HD 7640G] 103c 194e ProBook 455 G1 Notebook 103c 1952 ProBook 455 G1 Notebook @@ -3168,6 +3327,8 @@ 9917 Trinity [Radeon HD 7620G] 9918 Trinity [Radeon HD 7600G] 9919 Trinity [Radeon HD 7500G] + 9920 Liverpool [Playstation 4 APU] + 9921 Liverpool HDMI/DP Audio Controller 9990 Trinity [Radeon HD 7520G] 9991 Trinity [Radeon HD 7540D] 9992 Trinity [Radeon HD 7420G] @@ -3186,34 +3347,41 @@ 99a0 Trinity [Radeon HD 7520G] 99a2 Trinity [Radeon HD 7420G] 99a4 Trinity [Radeon HD 7400G] - aa00 R600 HDMI Audio [Radeon HD 2900 Series] + aa00 R600 HDMI Audio [Radeon HD 2900 GT/PRO/XT] + aa01 RV635 HDMI Audio [Radeon HD 3650/3730/3750] aa08 RV630 HDMI Audio [Radeon HD 2600 Series] - aa10 RV610 HDMI Audio [Radeon HD 2350/2400 Series] + aa10 RV610 HDMI Audio [Radeon HD 2350 PRO / 2400 PRO/XT / HD 3410] 174b aa10 Radeon HD 2400 PRO 18bc aa10 Radeon HD 2400 PRO aa18 RV670/680 HDMI Audio [Radeon HD 3690/3800 Series] - aa20 RV635 HDMI Audio [Radeon HD 3600 Series] - aa28 RV620 HDMI Audio [Radeon HD 3400 Series] + aa20 RV635 HDMI Audio [Radeon HD 3650/3730/3750] + aa28 RV620 HDMI Audio [Radeon HD 3450/3470/3550/3570] aa30 RV770 HDMI Audio [Radeon HD 4850/4870] 174b aa30 Radeon HD 4850 512MB GDDR3 PCI-E Dual Slot Fansink aa38 RV710/730 HDMI Audio [Radeon HD 4000 series] 103c 3628 dv6-1190en - aa50 Cypress HDMI Audio [Radeon HD 5800 Series] + aa50 Cypress HDMI Audio [Radeon HD 5830/5850/5870 / 6850/6870 Rebrand] aa58 Juniper HDMI Audio [Radeon HD 5700 Series] # 5500, 5600 and mobile 5700 series aa60 Redwood HDMI Audio [Radeon HD 5000 Series] 1025 033d Mobility Radeon HD 5650 1025 0347 Aspire 7740G - aa68 Cedar HDMI Audio [Radeon HD 5400/6300 Series] + aa68 Cedar HDMI Audio [Radeon HD 5400/6300/7300 Series] 1028 aa68 XPS 8300 - aa80 Cayman/Antilles HDMI Audio [Radeon HD 6900 Series] + aa80 Cayman/Antilles HDMI Audio [Radeon HD 6930/6950/6970/6990] aa88 Barts HDMI Audio [Radeon HD 6800 Series] - aa90 Turks/Whistler HDMI Audio [Radeon HD 6000 Series] + aa90 Turks HDMI Audio [Radeon HD 6500/6600 / 6700M Series] 1028 04a3 Precision M4600 aa98 Caicos HDMI Audio [Radeon HD 6400 Series] 174b aa98 Radeon HD 6450 1GB DDR3 - aaa0 Tahiti XT HDMI Audio [Radeon HD 7970 Series] + aaa0 Tahiti HDMI Audio [Radeon HD 7870 XT / 7950/7970] aab0 Cape Verde/Pitcairn HDMI Audio [Radeon HD 7700/7800 Series] + aac0 Tobago HDMI Audio [Radeon R7 360 / R9 360 OEM] + aac8 Hawaii HDMI Audio [Radeon R9 290/290X / 390/390X] +# I have a Tonga card and this is the HDMI Audio part + aad8 Tonga HDMI Audio [Radeon R9 285/380] + 174b aad8 Radeon R9 285/380 HDMI Audio + aae8 Fiji HDMI/DP Audio [Radeon R9 Nano / FURY/FURY X] ac00 Theater 600 Pro ac02 TV Wonder HD 600 PCIe ac12 Theater HD T507 (DVB-T) TV tuner/capture device @@ -3630,9 +3798,13 @@ 1014 049a PCIe3 x16 SAS RAID Internal Adapter 6Gb (57EE) 1014 04c7 PCIe3 x 8 Cache SAS RAID Internal Adapter 6GB(2CCA) 1014 04c8 PCIe3 x 8 Cache SAS RAID Internal Adapter 6GB(2CD2) - 1014 0c49 PCIe3 x 8 Cache SAS RAID Internal Adapter 6GB(2CCD) + 1014 04c9 PCIe3 x 8 Cache SAS RAID Internal Adapter 6GB(2CCD) 044b GenWQE Accelerator Adapter 04aa Flash Adapter 90 (PCIe2 0.9TB) + 04da PCI-E IPR SAS+ Adapter (ASIC) + 1014 04fb PCIe3 x16 20GB Cache 12Gb Quad SAS RAID+ Adapter(580B) + 1014 04fc PCIe3 x8 12Gb Quad SAS RAID+ Adapter(580A) + 04ed Internal Shared Memory (ISM) virtual PCI device 3022 QLA3022 Network Adapter 4022 QLA3022 Network Adapter ffff MPIC-2 interrupt controller @@ -3727,9 +3899,12 @@ 1404 Family 15h (Models 10h-1fh) Processor Function 4 1405 Family 15h (Models 10h-1fh) Processor Function 5 1410 Family 15h (Models 10h-1fh) Processor Root Complex + 103c 1985 Pavilion 17-e163sg Notebook PC 1412 Family 15h (Models 10h-1fh) Processor Root Port + 1022 1234 Trinity A-series APU 1413 Family 15h (Models 10h-1fh) Processor Root Port 1414 Family 15h (Models 10h-1fh) Processor Root Port + 1022 1234 Trinity A-series APU 1415 Family 15h (Models 10h-1fh) Processor Root Port 1416 Family 15h (Models 10h-1fh) Processor Root Port 1417 Family 15h (Models 10h-1fh) Processor Root Port @@ -3744,7 +3919,11 @@ 1422 Family 15h (Models 30h-3fh) Processor Root Complex 1423 Family 15h (Models 30h-3fh) I/O Memory Management Unit 1426 Family 15h (Models 30h-3fh) Processor Root Port + 1436 Liverpool Processor Root Complex + 1437 Liverpool I/O Memory Management Unit + 1438 Liverpool Processor Root Port 1439 Family 16h Processor Functions 5:1 + 145b Zeppelin Non-Transparent Bridge 1510 Family 14h Processor Root Complex 174b 1001 PURE Fusion Mini 1512 Family 14h Processor Root Port @@ -3890,27 +4069,34 @@ 7802 FCH SATA Controller [RAID mode] 7803 FCH SATA Controller [RAID mode] 7804 FCH SATA Controller [AHCI mode] + 103c 1985 Pavilion 17-e163sg Notebook PC 7805 FCH SATA Controller [RAID mode] 7806 FCH SD Flash Controller 7807 FCH USB OHCI Controller 103c 194e ProBook 455 G1 Notebook + 103c 1985 Pavilion 17-e163sg Notebook PC 7808 FCH USB EHCI Controller 103c 194e ProBook 455 G1 Notebook + 103c 1985 Pavilion 17-e163sg Notebook PC 7809 FCH USB OHCI Controller 103c 194e ProBook 455 G1 Notebook 780b FCH SMBus Controller 103c 194e ProBook 455 G1 Notebook + 103c 1985 Pavilion 17-e163sg Notebook PC 780c FCH IDE Controller 780d FCH Azalia Controller 103c 194e ProBook 455 G1 Notebook + 103c 1985 Pavilion 17-e163sg Notebook PC 1043 8444 F2A85-M Series 780e FCH LPC Bridge 103c 194e ProBook 455 G1 Notebook + 103c 1985 Pavilion 17-e163sg Notebook PC 780f FCH PCI Bridge 7812 FCH USB XHCI Controller 7813 FCH SD Flash Controller 7814 FCH USB XHCI Controller 103c 194e ProBook 455 G1 Notebook + 103c 1985 Pavilion 17-e163sg Notebook PC 7900 FCH SATA Controller [IDE mode] 7901 FCH SATA Controller [AHCI mode] 7902 FCH SATA Controller [RAID mode] @@ -3923,6 +4109,7 @@ 790f FCH PCI Bridge 7914 FCH USB XHCI Controller 9600 RS780 Host Bridge + 1043 82ee M378A-CM Motherboard 1043 82f1 M3A78-EH Motherboard 9601 RS880 Host Bridge 1019 2120 A785GM-M @@ -4288,6 +4475,11 @@ 102b 2241 M9138 LP PCIe x16 102b 2280 M9188 ATX PCIe x16 102b 22c0 M9128 LP PCIe x16 + 0550 SV2 + 102b 00c0 MURA-IPX-I4EF + 102b 00c1 MURA-IPX-I4DF + 102b 00c3 MURA-IPX-I4DHF + 102b 00c5 MURA-IPX-I4EHF 0d10 MGA Ultima/Impression 1000 MGA G100 [Productiva] 102b ff01 Productiva G100 @@ -4479,6 +4671,7 @@ 103c 1293 USB add-in card 103c 1294 USB 2.0 add-in card 1179 0001 USB + 1186 0035 DUB-C2 USB 2.0 2-port 32-bit cardbus controller 12ee 7000 Root Hub 14c2 0105 PTI-205N USB 2.0 Host Controller 1799 0001 Root Hub @@ -4510,6 +4703,7 @@ 00ce uPD72871 [Firewarden] IEEE1394a OHCI 1.0 Link/1-port PHY Controller 00df Vr4131 00e0 uPD72010x USB 2.0 Controller + 1186 f100 DUB-C2 USB 2.0 2-port 32-bit cardbus controller 12ee 7001 Root hub 14c2 0205 PTI-205N USB 2.0 Host Controller 1799 0002 Root Hub @@ -4796,30 +4990,30 @@ 103c 3212 Smart Array E200 3239 Smart Array Gen9 Controllers 103c 21bd P244br - 103c 21be Smart Array + 103c 21be P741m 103c 21bf H240ar 103c 21c0 P440ar - 103c 21c1 Smart Array + 103c 21c1 P840ar 103c 21c2 P440 103c 21c3 P441 103c 21c4 Smart Array - 103c 21c5 Smart Array + 103c 21c5 P841 103c 21c6 H244br 103c 21c7 H240 103c 21c8 H241 103c 21c9 Smart Array - 103c 21ca Smart Array + 103c 21ca P246br 103c 21cb P840 103c 21cc Smart Array - 103c 21cd Smart Array - 103c 21ce Smart Array + 103c 21cd P240nr + 103c 21ce H240nr 323a Smart Array G6 controllers 103c 3241 Smart Array P212 103c 3243 Smart Array P410 103c 3245 Smart Array P410i 103c 3247 Smart Array P411 103c 3249 Smart Array P812 - 103c 324a HP Smart Array 712m (Mezzanine RAID controller) + 103c 324a Smart Array 712m (Mezzanine RAID controller) 103c 324b Smart Array P711m (Mezzanine RAID controller) 323b Smart Array Gen8 Controllers 103c 3350 P222 @@ -5140,6 +5334,7 @@ 803b 5-in-1 Multimedia Card Reader (SD/MMC/MS/MS PRO/xD) 103c 309f nx9420 103c 30a3 Compaq nw8440 + 104d 8212 VAIO VGN-N21E 104d 902d VAIO VGN-NR120E 803c PCIxx12 SDA Standard Compliant SD Host Controller 103c 309f nx9420 @@ -5171,6 +5366,7 @@ 1395 2201 WL22-PC 16ab 8501 WL-8305 IEEE802.11b+ Wireless LAN PCI Adapter 8401 ACX 100 22Mbps Wireless Interface + 8888 Multicore DSP+ARM KeyStone II SOC 9000 Wireless Interface (of unknown type) 9065 TMS320DM642 9066 ACX 111 54Mbps Wireless Interface @@ -5294,6 +5490,14 @@ 8056 Rockwell HCF 56K modem 808a Memory Stick Controller 81ce SxS Pro memory card + 908f Aeolia ACPI + 909e Aeolia Ethernet Controller (Marvell Yukon 2 Family) + 909f Aeolia SATA AHCI Controller + 90a0 Aeolia SD/MMC Host Controller + 90a1 Aeolia PCI Express Glue and Miscellaneous Devices + 90a2 Aeolia DMA Controller + 90a3 Aeolia Memory (DDR3/SPM) + 90a4 Aeolia USB 3.0 xHCI Host Controller 104e Oak Technology, Inc 0017 OTI-64017 0107 OTI-107 [Spitfire] @@ -5435,7 +5639,6 @@ 6400 MPC190 Security Processor (S1 family, encryption) 6405 MPC184 Security Processor (S1 family) 1058 Electronics & Telecommunications RSH -# Formerly: Teknor Industrial Computers Inc 1059 Kontron 105a Promise Technology, Inc. 0d30 PDC20265 (FastTrak100 Lite/Ultra100) @@ -5701,6 +5904,7 @@ 0074 U4 HT Bridge # should be 14e4:1645 1645 Broadcom NetXtreme BCM5701 Gigabit Ethernet + 2001 PCI Express SSD 106c Hynix Semiconductor 8139 8139c 100BaseTX Ethernet Controller 8801 Dual Pentium ISA/PCI Motherboard @@ -5757,13 +5961,59 @@ 101e 8493 QLA12160 on AMI MegaRAID 1240 ISP1240 SCSI Host Adapter 1280 ISP1280 SCSI Host Adapter + 1634 FastLinQ QL45000 Series 40GbE Controller + 1077 e4f1 FastLinQ QL45212H 40GbE Adapter + 1077 e4f2 FastLinQ QL45211H 40GbE Adapter + 1077 e4f3 FastLinQ QL45412H 40GbE Adapter + 1077 e4f4 FastLinQ QL45411H 40GbE Adapter + 1644 FastLinQ QL45000 Series 100GbE Controller + 1077 e4f8 FastLinQ QL45611H 100GbE Adapter + 1656 FastLinQ QL45000 Series 25GbE Controller + 1077 02a7 QL45212-DE 25GbE Adapter + 1077 e4f6 FastLinQ QL45211H 25GbE Adapter + 1077 e4f7 FastLinQ QL45212H 25GbE Adapter + 165c FastLinQ QL45000 Series 40GbE Controller (FCoE) + 1077 e4f1 FastLinQ QL45462H 40GbE FCoE Adapter + 1077 e4f2 FastLinQ QL45461H 40GbE FCoE Adapter + 165e FastLinQ QL45000 Series 40GbE Controller (iSCSI) + 1077 e4f1 FastLinQ QL45462H 40GbE iSCSI Adapter + 1077 e4f2 FastLinQ QL45461H 40GbE iSCSI Adapter + 1664 FastLinQ QL45000 Series Gigabit Ethernet Controller (SR-IOV VF) + 1077 e4f1 FastLinQ QL45462H 40GbE Adapter (SR-IOV VF) + 1077 e4f2 FastLinQ QL45461H 40GbE Adapter (SR-IOV VF) + 1077 e4f3 FastLinQ QL45412H 40GbE Adapter (SR-IOV VF) + 1077 e4f4 FastLinQ QL45411H 40GbE Adapter (SR-IOV VF) + 1077 e4f6 FastLinQ QL45211H 25GbE Adapter (SR-IOV VF) + 1077 e4f7 FastLinQ QL45212H 25GbE Adapter (SR-IOV VF) + 1077 e4f8 FastLinQ QL45611H 100GbE Adapter (SR-IOV VF) 2020 ISP2020A Fast!SCSI Basic Adapter 2031 ISP8324-based 16Gb Fibre Channel to PCI Express Adapter + 103c 17e7 HP SN1000Q 16Gb Single Port Fibre Channel Adapter + 103c 17e8 HP SN1000Q 16Gb Dual Port Fibre Channel Adapter + 103c 1939 HP QMH2672 16Gb Dual Port Fibre Channel Adapter 103c 8002 3830C 16G Fibre Channel Host Bus Adapter + 2071 ISP2714-based 16/32Gb Fibre Channel to PCIe Adapter + 1077 0283 QLE2764 Quad Port 32Gb Fibre Channel to PCIe Adapter + 1077 029e QLE2694 Quad Port 16Gb Fibre Channel to PCIe Adapter + 1077 02a2 QLE2694L Quad Port 16Gb Fibre Channel to PCIe Adapter + 1077 02ad QLE2694U Quad Port 16/32Gb Fibre Channel to PCIe Adapter 2100 QLA2100 64-bit Fibre Channel Adapter 1077 0001 QLA2100 64-bit Fibre Channel Adapter 2200 QLA2200 64-bit Fibre Channel Adapter 1077 0002 QLA2200 + 2261 ISP2722-based 16/32Gb Fibre Channel to PCIe Adapter + 1077 0299 QLE2740 Single Port 32Gb Fibre Channel to PCIe Adapter + 1077 029a QLE2742 Dual Port 32Gb Fibre Channel to PCIe Adapter + 1077 029b QLE2690 Single Port 16Gb Fibre Channel to PCIe Adapter + 1077 029c QLE2692 Dual Port 16Gb Fibre Channel to PCIe Adapter + 1077 02a7 QLE2690 Single Port 16Gb FC to PCIe Gen3 x8 Adapter + 1077 02a8 QLE2692 Dual Port 16Gb FC to PCIe Gen3 x8 Adapter + 1077 02ab QLE2740 Single Port 32Gb FC to PCIe Gen3 x8 Adapter + 1077 02ac QLE2742 Dual Port 32Gb FC to PCIe Gen3 x8 Adapter + 1590 00f9 HPE StoreFabric SN1100Q 16Gb Single Port Fibre Channel Host Bus Adapter + 1590 00fa HPE StoreFabric SN1100Q 16Gb Dual Port Fibre Channel Host Bus Adapter + 1590 0203 HPE StoreFabric SN1600Q 32Gb Single Port Fibre Channel Host Bus Adapter + 1590 0204 HPE StoreFabric SN1600Q 32Gb Dual Port Fibre Channel Host Bus Adapter 2300 QLA2300 64-bit Fibre Channel Adapter 2312 ISP2312-based 2Gb Fibre Channel to PCI-X HBA 103c 0131 2Gb Fibre Channel - Single port [A7538A] @@ -5776,7 +6026,9 @@ 103c 7040 FC1142SR 4Gb 1-port PCIe Fibre Channel Host Bus Adapter [HPAE311A] 2532 ISP2532-based 8Gb Fibre Channel to PCI Express HBA 103c 3262 StorageWorks 81Q + 103c 3263 StorageWorks 82Q 1077 0167 QME2572 Dual Port FC8 HBA Mezzanine + 1590 00fc HPE StoreFabric 84Q 8Gb Quad Port Fibre Channel Host Bus Adapter 3022 ISP4022-based Ethernet NIC 3032 ISP4032-based Ethernet IPv6 NIC 4010 ISP4010-based iSCSI TOE HBA @@ -5994,6 +6246,7 @@ 1093 National Instruments 0160 PCI-DIO-96 0162 PCI-MIO-16XE-50 + 0fe1 PXI-8320 1150 PCI-6533 (PCI-DIO-32HS) 1170 PCI-MIO-16XE-10 1180 PCI-MIO-16E-1 @@ -6085,7 +6338,10 @@ 7004 PXI-6551 700b PXI-5421 700c PCI-5421 + 701a VXIpc-87xB + 701b VXIpc-770 7023 PXI-2593 + 7027 PCI-MXI-2 Universal 702c PXI-7831R 702d PCI-7831R 702e PXI-7811R @@ -6354,6 +6610,7 @@ 731d PXI-2536 7322 PXIe-6124 7327 PXI-6529 + 732c VXI-8360T 7331 PXIe-5602 7332 PXIe-5601 7333 PXI-5900 @@ -6493,6 +6750,7 @@ 75e5 PXI-6683 75e6 PXI-6683H 75ef PXIe-5632 + 761c VXI-8360LT 761f PXI-2540 7620 PXIe-2540 7621 PXI-2541 @@ -6523,6 +6781,7 @@ 76a3 PXIe-6535B 76a4 PXIe-6536B 76a5 PXIe-6537B + 783e PXI-8368 9020 PXI-2501 9030 PXI-2503 9040 PXI-2527 @@ -6532,6 +6791,7 @@ 9080 PXI-2580 9090 PCI-4021 90a0 PXI-4021 + a001 PCI-MXI-2 b001 PCI-1408 b011 PXI-1408 b021 PCI-1424 @@ -6621,7 +6881,9 @@ 1093 762b PXIe-4138 1093 762c PXIe-4144 1093 762d PXIe-4145 + 1093 762e PXIe-5606 1093 7644 PXIe-4841 + 1093 764a PCIe-8237R-S 1093 7658 PXIe-5162 (4CH) 1093 76ab PXIe-4322 1093 76ad PXIe-4112 @@ -6629,14 +6891,25 @@ 1093 76b5 PXIe-7971R 1093 76b6 PXIe-7972R 1093 76b7 PXIe-7975R + 1093 76b8 PXIe-5696 + 1093 76b9 PXIe-5654 1093 76c8 PXIe-6614 1093 76c9 PXIe-6612 1093 76cb PXIe-5646R 1093 76cc PXIe-5162 (2CH) + 1093 76ce CVS-1459 1093 76d0 PXIe-5160 (2CH) 1093 76d1 PXIe-5160 (4CH) 1093 76dc PXIe-4610 + 1093 76ec PXIe-2524 + 1093 76ed PXIe-2525 + 1093 76ee PXIe-2526 + 1093 76ef PXIe-2737 + 1093 76f0 PXIe-2738 + 1093 76f1 PXIe-2739 1093 76fb PCIe-1473R-LX110 + 1093 76fc PXIe-5105 + 1093 76fd PXIe-5114 1093 76fe PXIe-5644R 1093 76ff PXIe-5644R 1093 7700 PXIe-5644R @@ -6645,24 +6918,49 @@ 1093 7703 PXIe-5645R 1093 770c PXIe-4139 1093 7711 PXIe-4464 + 1093 7712 PXIe-4463 1093 7716 PCIe-6612 + 1093 771d Unconfigured CA4 Switch 1093 771e PXIe-4339 1093 7735 cRIO-9033 + 1093 773e PXIe-5624R 1093 774b cRIO-9031 1093 774d cRIO-9034 1093 7755 cRIO-9030 + 1093 7768 PXIe-2747 + 1093 7769 PXIe-2748 + 1093 776a PXIe-2746 1093 7777 PXIe-7976R 1093 7782 PXIe-5646R 1093 7783 PXIe-5646R 1093 7784 PXIe-5646R + 1093 7790 PXIe-5170R (4CH) + 1093 7791 PXIe-5170R (8CH) + 1093 7793 PXIe-5171R (8CH) 1093 77a5 PXIe-6345 1093 77a6 PXIe-6355 1093 77a7 PXIe-6365 1093 77a8 PXIe-6375 + 1093 77aa CVS-1458 + 1093 77ad IC-3173 1093 77b4 PXIe-7820R 1093 77b5 PXIe-7821R 1093 77b6 PXIe-7822R 1093 77b9 cRIO-9038 + 1093 77ba PXIe-4136 + 1093 77bb PXIe-4137 + 1093 77c0 PXIe-5624R + 1093 77c1 PXIe-5624R + 1093 77c2 PXIe-5624R + 1093 77ca PXIe-6738 + 1093 77cb PXIe-6739 + 1093 77db cRIO-9035 + 1093 77dc cRIO-9036 + 1093 77dd cRIO-9039 + 1093 7802 PXIe-4302 + 1093 7803 PXIe-4303 + 1093 7805 PXIe-4305 + 1093 788e PXIe-4304 c801 PCI-GPIB c811 PCI-GPIB+ c821 PXI-GPIB @@ -6700,6 +6998,13 @@ e251 PXI-8460 (2 ports) e261 PCI-CAN/DS e271 PXI-8462 + f110 VMEpc-650 + f120 VXIpc-650 + fe00 VXIpc-87x + fe41 VXIpc-860 + fe51 VXIpc-74x + fe61 VXIpc-850 + fe70 VXIpc-880 1094 First International Computers [FIC] # nee CMD Technology Inc 1095 Silicon Image, Inc. @@ -7068,11 +7373,14 @@ 8696 PEX 8696 96-lane, 24-Port PCI Express Gen 2 (5.0 GT/s) Multi-Root Switch 8717 PEX 8717 16-lane, 8-Port PCI Express Gen 3 (8.0 GT/s) Switch with DMA 8718 PEX 8718 16-Lane, 5-Port PCI Express Gen 3 (8.0 GT/s) Switch + 8724 PEX 8724 24-Lane, 6-Port PCI Express Gen 3 (8 GT/s) Switch, 19 x 19mm FCBGA 8732 PEX 8732 32-lane, 8-Port PCI Express Gen 3 (8.0 GT/s) Switch 8734 PEX 8734 32-lane, 8-Port PCI Express Gen 3 (8.0GT/s) Switch 8747 PEX 8747 48-Lane, 5-Port PCI Express Gen 3 (8.0 GT/s) Switch + 8748 PEX 8748 48-Lane, 12-Port PCI Express Gen 3 (8 GT/s) Switch, 27 x 27mm FCBGA # This is the Non-Transparent-Bridge Virtualized Port as presented by the PLX PEX 8732 chip, the physical bridges show up at 10b5:8732 87b0 PEX 8732 32-lane, 8-Port PCI Express Gen 3 (8.0 GT/s) Switch + 1093 7761 PXIe-8830mc 9016 PLX 9016 8-port serial controller 9030 PCI9030 32-bit 33MHz PCI <-> IOBus Bridge 10b5 2695 Hilscher CIF50-PB/DPS Profibus @@ -7084,6 +7392,7 @@ 10b5 3025 Alpermann+Velte PCL PCI L (3V/5V): Timecode Reader Board 10b5 3068 Alpermann+Velte PCL PCI HD (3V/5V): Timecode Reader Board 10b5 3463 Alpermann+Velte PCL PCI D (v2) (3V/5V): Timecode Reader Board + 10b5 3591 PLURA PCL PCI L (v2) (3.3V/5V): Time Code Reader Board 12fe 0111 CPCI-ASIO4 (ESD 4-port Serial Interface Board) 1369 9c01 VX222v2 1369 9d01 VX222-Mic @@ -7096,7 +7405,7 @@ 1369 a801 LCM200 1397 3136 4xS0-ISDN PCI Adapter 1397 3137 S2M-E1-ISDN PCI Adapter - 1518 0200 Kontron ThinkIO-C + 1518 0200 ThinkIO-C 15ed 1002 MCCS 8-port Serial Hot Swap 15ed 1003 MCCS 16-port Serial Hot Swap # MIL-STD-1553B Board @@ -7193,7 +7502,7 @@ 10b5 1123 Sectra KK631 encryption board 10b5 9080 9080 [real subsystem ID not set] 12d9 0002 PCI Prosody Card - 12df 4422 4422PCI ["Do-All" Telemetry Data Aquisition System] + 12df 4422 4422PCI ["Do-All" Telemetry Data Acquisition System] 1369 9601 PCX822np 1369 a102 PCX822v2 1369 a201 PCX442 @@ -7208,6 +7517,7 @@ 1885 0700 Tsunami FPGA PMC with Altera Stratix S40 1885 0701 Tsunami FPGA PMC with Altera Stratix S30 9733 PEX 9733 33-lane, 9-port PCI Express Gen 3 (8.0 GT/s) Switch + 1d49 0001 ThinkSystem P310W-4P NVMe Switch Card 9749 PEX 9749 49-lane, 13-port PCI Express Gen 3 (8.0 GT/s) Switch a100 Blackmagic Design DeckLink bb04 B&B 3PCIOSD1A Isolated PCI Serial @@ -7889,7 +8199,7 @@ 1043 0c11 A7N8X Mainboard a0a0 03b4 UK79G-1394 motherboard 006a nForce2 AC97 Audio Controler (MCP) - 1043 8095 nForce2 AC97 Audio Controler (MCP) + 1043 8095 nForce2 AC97 Audio Controller (MCP) a0a0 0304 UK79G-1394 motherboard 006b nForce Audio Processing Unit 10de 006b nForce2 MCP Audio Processing Unit @@ -8751,7 +9061,7 @@ 0446 MCP65 SMBus 103c 30cf Pavilion dv9668eg Laptop 0447 MCP65 SMU - 103c 30cf Pavilion dv9668eg Laptop + 103c 30cf Pavilion dv9500/9600/9700 series 0448 MCP65 IDE 103c 30cf Pavilion dv9668eg Laptop 0449 MCP65 PCI bridge @@ -9575,6 +9885,8 @@ 0f00 GF108 [GeForce GT 630] 0f01 GF108 [GeForce GT 620] 0f02 GF108 [GeForce GT 730] + 0f06 GF108 [GeForce GT 730] + 0fb0 GM200 High Definition Audio 0fbb GM204 High Definition Audio Controller 0fc0 GK107 [GeForce GT 640 OEM] 0fc1 GK107 [GeForce GT 640] @@ -9619,6 +9931,7 @@ 0fea GK107M [GeForce GT 755M Mac Edition] 0fec GK107M [GeForce 710A] 0fed GK107M [GeForce 820M] + 0fee GK107M [GeForce 810M] 0fef GK107GL [GRID K340] 0ff1 GK107 [NVS 1000] 0ff2 GK107GL [GRID K1] @@ -9715,6 +10028,7 @@ 103c 2afb GeForce 705A 17aa 309d GeForce 705A 17aa 30b1 GeForce 800A + 17aa 30f3 GeForce 705A 17aa 36a1 GeForce 800A 107c GF119 [NVS 315] 107d GF119 [NVS 310] @@ -9746,7 +10060,9 @@ 10c3 GT218 [GeForce 8400 GS Rev. 3] 10c5 GT218 [GeForce 405] 10d8 GT218 [NVS 300] + 10f0 GP104 High Definition Audio Controller 1140 GF117M [GeForce 610M/710M/810M/820M / GT 620M/625M/630M/720M] + 1019 0799 GeForce 820M 1019 999f GeForce GT 720M 1025 0600 GeForce GT 620M 1025 0606 GeForce GT 620M @@ -9846,6 +10162,7 @@ *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-all@freebsd.org Sat Oct 15 12:33:00 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B20D5C13037; Sat, 15 Oct 2016 12:33:00 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 84337B7B; Sat, 15 Oct 2016 12:33:00 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9FCWxYL031428; Sat, 15 Oct 2016 12:32:59 GMT (envelope-from bapt@FreeBSD.org) Received: (from bapt@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9FCWxt1031427; Sat, 15 Oct 2016 12:32:59 GMT (envelope-from bapt@FreeBSD.org) Message-Id: <201610151232.u9FCWxt1031427@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bapt set sender to bapt@FreeBSD.org using -f From: Baptiste Daroussin Date: Sat, 15 Oct 2016 12:32:59 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307356 - head X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 Oct 2016 12:33:00 -0000 Author: bapt Date: Sat Oct 15 12:32:59 2016 New Revision: 307356 URL: https://svnweb.freebsd.org/changeset/base/307356 Log: Fix typo Reported by: "N.J. Mann" Modified: head/UPDATING Modified: head/UPDATING ============================================================================== --- head/UPDATING Sat Oct 15 12:28:14 2016 (r307355) +++ head/UPDATING Sat Oct 15 12:32:59 2016 (r307356) @@ -32,7 +32,7 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 12 "ln -s 'abort:false,junk:false' /etc/malloc.conf".) 20161015: - GNU rcs has been removed rom base. It is available as packages: + GNU rcs has been removed from base. It is available as packages: - rcs: Latest GPLv3 GNU rcs version. - rcs57: Copy of the latest version of GNU rcs (GPLv2) from base. From owner-svn-src-all@freebsd.org Sat Oct 15 12:35:17 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B523CC130E8; Sat, 15 Oct 2016 12:35:17 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 6CCB6DEE; Sat, 15 Oct 2016 12:35:17 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9FCZGtS031760; Sat, 15 Oct 2016 12:35:16 GMT (envelope-from bapt@FreeBSD.org) Received: (from bapt@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9FCZGPg031759; Sat, 15 Oct 2016 12:35:16 GMT (envelope-from bapt@FreeBSD.org) Message-Id: <201610151235.u9FCZGPg031759@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bapt set sender to bapt@FreeBSD.org using -f From: Baptiste Daroussin Date: Sat, 15 Oct 2016 12:35:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307357 - stable/11/tools/build/options X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 Oct 2016 12:35:17 -0000 Author: bapt Date: Sat Oct 15 12:35:16 2016 New Revision: 307357 URL: https://svnweb.freebsd.org/changeset/base/307357 Log: MFC r306877 Remove the WITH_FMAKE option left over from r284464 Deleted: stable/11/tools/build/options/WITH_FMAKE Modified: Directory Properties: stable/11/ (props changed) From owner-svn-src-all@freebsd.org Sat Oct 15 12:37:58 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E19E2C13188; Sat, 15 Oct 2016 12:37:58 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id BC020102B; Sat, 15 Oct 2016 12:37:58 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9FCbvlT032020; Sat, 15 Oct 2016 12:37:57 GMT (envelope-from bapt@FreeBSD.org) Received: (from bapt@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9FCbvuQ032018; Sat, 15 Oct 2016 12:37:57 GMT (envelope-from bapt@FreeBSD.org) Message-Id: <201610151237.u9FCbvuQ032018@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bapt set sender to bapt@FreeBSD.org using -f From: Baptiste Daroussin Date: Sat, 15 Oct 2016 12:37:57 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307358 - stable/11/contrib/tzcode/zic X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 Oct 2016 12:37:59 -0000 Author: bapt Date: Sat Oct 15 12:37:57 2016 New Revision: 307358 URL: https://svnweb.freebsd.org/changeset/base/307358 Log: MFC r306852 Incorporate a change from OpenBSD by millert@OpenBSD.org Don't warn about valid time zone abbreviations. POSIX through 2000 says that an abbreviation cannot start with ':', and cannot contain ',', '-', '+', NUL, or a digit. POSIX from 2001 on changes this rule to say that an abbreviation can contain only '-', '+', and alphanumeric characters from the portable character set in the current locale. To be portable to both sets of rules, an abbreviation must therefore use only ASCII letters." Adapted from tzcode2015f. This is needed to be able to update tzdata to a newer version Modified: stable/11/contrib/tzcode/zic/zdump.c stable/11/contrib/tzcode/zic/zic.c Directory Properties: stable/11/ (props changed) Modified: stable/11/contrib/tzcode/zic/zdump.c ============================================================================== --- stable/11/contrib/tzcode/zic/zdump.c Sat Oct 15 12:35:16 2016 (r307357) +++ stable/11/contrib/tzcode/zic/zdump.c Sat Oct 15 12:37:57 2016 (r307358) @@ -212,24 +212,16 @@ const char * const zone; return; cp = abbrp; wp = NULL; - while (isascii((unsigned char) *cp) && isalpha((unsigned char) *cp)) + while (isascii((unsigned char) *cp) && + (isalnum((unsigned char)*cp) || *cp == '-' || *cp == '+')) ++cp; - if (cp - abbrp == 0) - wp = _("lacks alphabetic at start"); - else if (cp - abbrp < 3) - wp = _("has fewer than 3 alphabetics"); + if (cp - abbrp < 3) + wp = _("has fewer than 3 characters"); else if (cp - abbrp > 6) - wp = _("has more than 6 alphabetics"); - if (wp == NULL && (*cp == '+' || *cp == '-')) { - ++cp; - if (isascii((unsigned char) *cp) && - isdigit((unsigned char) *cp)) - if (*cp++ == '1' && *cp >= '0' && *cp <= '4') - ++cp; - if (*cp != '\0') - wp = _("differs from POSIX standard"); - } - if (wp == NULL) + wp = _("has more than 6 characters"); + else if (*cp) + wp = "has characters other than ASCII alphanumerics, '-' or '+'"; + else return; (void) fflush(stdout); (void) fprintf(stderr, Modified: stable/11/contrib/tzcode/zic/zic.c ============================================================================== --- stable/11/contrib/tzcode/zic/zic.c Sat Oct 15 12:35:16 2016 (r307357) +++ stable/11/contrib/tzcode/zic/zic.c Sat Oct 15 12:37:57 2016 (r307358) @@ -2615,29 +2615,15 @@ const char * const string; register const char * cp; register char * wp; - /* - ** Want one to ZIC_MAX_ABBR_LEN_WO_WARN alphabetics - ** optionally followed by a + or - and a number from 1 to 14. - */ cp = string; wp = NULL; while (isascii((unsigned char) *cp) && - isalpha((unsigned char) *cp)) + (isalnum((unsigned char)*cp) || *cp == '-' || *cp == '+')) ++cp; - if (cp - string == 0) -wp = _("time zone abbreviation lacks alphabetic at start"); if (noise && cp - string > 3) -wp = _("time zone abbreviation has more than 3 alphabetics"); +wp = _("time zone abbreviation has more than 3 characters"); if (cp - string > ZIC_MAX_ABBR_LEN_WO_WARN) -wp = _("time zone abbreviation has too many alphabetics"); - if (wp == NULL && (*cp == '+' || *cp == '-')) { - ++cp; - if (isascii((unsigned char) *cp) && - isdigit((unsigned char) *cp)) - if (*cp++ == '1' && - *cp >= '0' && *cp <= '4') - ++cp; - } +wp = _("time zone abbreviation has too many characters"); if (*cp != '\0') wp = _("time zone abbreviation differs from POSIX standard"); if (wp != NULL) { From owner-svn-src-all@freebsd.org Sat Oct 15 12:38:23 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 2554AC131D5; Sat, 15 Oct 2016 12:38:23 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id F306D1178; Sat, 15 Oct 2016 12:38:22 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9FCcMO3032081; Sat, 15 Oct 2016 12:38:22 GMT (envelope-from bapt@FreeBSD.org) Received: (from bapt@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9FCcMNs032079; Sat, 15 Oct 2016 12:38:22 GMT (envelope-from bapt@FreeBSD.org) Message-Id: <201610151238.u9FCcMNs032079@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bapt set sender to bapt@FreeBSD.org using -f From: Baptiste Daroussin Date: Sat, 15 Oct 2016 12:38:22 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307359 - stable/10/contrib/tzcode/zic X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 Oct 2016 12:38:23 -0000 Author: bapt Date: Sat Oct 15 12:38:21 2016 New Revision: 307359 URL: https://svnweb.freebsd.org/changeset/base/307359 Log: MFC r306852 Incorporate a change from OpenBSD by millert@OpenBSD.org Don't warn about valid time zone abbreviations. POSIX through 2000 says that an abbreviation cannot start with ':', and cannot contain ',', '-', '+', NUL, or a digit. POSIX from 2001 on changes this rule to say that an abbreviation can contain only '-', '+', and alphanumeric characters from the portable character set in the current locale. To be portable to both sets of rules, an abbreviation must therefore use only ASCII letters." Adapted from tzcode2015f. This is needed to be able to update tzdata to a newer version Modified: stable/10/contrib/tzcode/zic/zdump.c stable/10/contrib/tzcode/zic/zic.c Directory Properties: stable/10/ (props changed) Modified: stable/10/contrib/tzcode/zic/zdump.c ============================================================================== --- stable/10/contrib/tzcode/zic/zdump.c Sat Oct 15 12:37:57 2016 (r307358) +++ stable/10/contrib/tzcode/zic/zdump.c Sat Oct 15 12:38:21 2016 (r307359) @@ -212,24 +212,16 @@ const char * const zone; return; cp = abbrp; wp = NULL; - while (isascii((unsigned char) *cp) && isalpha((unsigned char) *cp)) + while (isascii((unsigned char) *cp) && + (isalnum((unsigned char)*cp) || *cp == '-' || *cp == '+')) ++cp; - if (cp - abbrp == 0) - wp = _("lacks alphabetic at start"); - else if (cp - abbrp < 3) - wp = _("has fewer than 3 alphabetics"); + if (cp - abbrp < 3) + wp = _("has fewer than 3 characters"); else if (cp - abbrp > 6) - wp = _("has more than 6 alphabetics"); - if (wp == NULL && (*cp == '+' || *cp == '-')) { - ++cp; - if (isascii((unsigned char) *cp) && - isdigit((unsigned char) *cp)) - if (*cp++ == '1' && *cp >= '0' && *cp <= '4') - ++cp; - if (*cp != '\0') - wp = _("differs from POSIX standard"); - } - if (wp == NULL) + wp = _("has more than 6 characters"); + else if (*cp) + wp = "has characters other than ASCII alphanumerics, '-' or '+'"; + else return; (void) fflush(stdout); (void) fprintf(stderr, Modified: stable/10/contrib/tzcode/zic/zic.c ============================================================================== --- stable/10/contrib/tzcode/zic/zic.c Sat Oct 15 12:37:57 2016 (r307358) +++ stable/10/contrib/tzcode/zic/zic.c Sat Oct 15 12:38:21 2016 (r307359) @@ -2615,29 +2615,15 @@ const char * const string; register const char * cp; register char * wp; - /* - ** Want one to ZIC_MAX_ABBR_LEN_WO_WARN alphabetics - ** optionally followed by a + or - and a number from 1 to 14. - */ cp = string; wp = NULL; while (isascii((unsigned char) *cp) && - isalpha((unsigned char) *cp)) + (isalnum((unsigned char)*cp) || *cp == '-' || *cp == '+')) ++cp; - if (cp - string == 0) -wp = _("time zone abbreviation lacks alphabetic at start"); if (noise && cp - string > 3) -wp = _("time zone abbreviation has more than 3 alphabetics"); +wp = _("time zone abbreviation has more than 3 characters"); if (cp - string > ZIC_MAX_ABBR_LEN_WO_WARN) -wp = _("time zone abbreviation has too many alphabetics"); - if (wp == NULL && (*cp == '+' || *cp == '-')) { - ++cp; - if (isascii((unsigned char) *cp) && - isdigit((unsigned char) *cp)) - if (*cp++ == '1' && - *cp >= '0' && *cp <= '4') - ++cp; - } +wp = _("time zone abbreviation has too many characters"); if (*cp != '\0') wp = _("time zone abbreviation differs from POSIX standard"); if (wp != NULL) { From owner-svn-src-all@freebsd.org Sat Oct 15 12:38:52 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 008FAC13221; Sat, 15 Oct 2016 12:38:52 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id D1CAF12D0; Sat, 15 Oct 2016 12:38:51 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9FCcp2n032145; Sat, 15 Oct 2016 12:38:51 GMT (envelope-from bapt@FreeBSD.org) Received: (from bapt@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9FCcokb032143; Sat, 15 Oct 2016 12:38:50 GMT (envelope-from bapt@FreeBSD.org) Message-Id: <201610151238.u9FCcokb032143@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bapt set sender to bapt@FreeBSD.org using -f From: Baptiste Daroussin Date: Sat, 15 Oct 2016 12:38:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r307360 - stable/9/contrib/tzcode/zic X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 Oct 2016 12:38:52 -0000 Author: bapt Date: Sat Oct 15 12:38:50 2016 New Revision: 307360 URL: https://svnweb.freebsd.org/changeset/base/307360 Log: MFC r306852 Incorporate a change from OpenBSD by millert@OpenBSD.org Don't warn about valid time zone abbreviations. POSIX through 2000 says that an abbreviation cannot start with ':', and cannot contain ',', '-', '+', NUL, or a digit. POSIX from 2001 on changes this rule to say that an abbreviation can contain only '-', '+', and alphanumeric characters from the portable character set in the current locale. To be portable to both sets of rules, an abbreviation must therefore use only ASCII letters." Adapted from tzcode2015f. This is needed to be able to update tzdata to a newer version Modified: stable/9/contrib/tzcode/zic/zdump.c stable/9/contrib/tzcode/zic/zic.c Directory Properties: stable/9/ (props changed) stable/9/contrib/ (props changed) stable/9/contrib/tzcode/ (props changed) stable/9/contrib/tzcode/zic/ (props changed) Modified: stable/9/contrib/tzcode/zic/zdump.c ============================================================================== --- stable/9/contrib/tzcode/zic/zdump.c Sat Oct 15 12:38:21 2016 (r307359) +++ stable/9/contrib/tzcode/zic/zdump.c Sat Oct 15 12:38:50 2016 (r307360) @@ -212,24 +212,16 @@ const char * const zone; return; cp = abbrp; wp = NULL; - while (isascii((unsigned char) *cp) && isalpha((unsigned char) *cp)) + while (isascii((unsigned char) *cp) && + (isalnum((unsigned char)*cp) || *cp == '-' || *cp == '+')) ++cp; - if (cp - abbrp == 0) - wp = _("lacks alphabetic at start"); - else if (cp - abbrp < 3) - wp = _("has fewer than 3 alphabetics"); + if (cp - abbrp < 3) + wp = _("has fewer than 3 characters"); else if (cp - abbrp > 6) - wp = _("has more than 6 alphabetics"); - if (wp == NULL && (*cp == '+' || *cp == '-')) { - ++cp; - if (isascii((unsigned char) *cp) && - isdigit((unsigned char) *cp)) - if (*cp++ == '1' && *cp >= '0' && *cp <= '4') - ++cp; - if (*cp != '\0') - wp = _("differs from POSIX standard"); - } - if (wp == NULL) + wp = _("has more than 6 characters"); + else if (*cp) + wp = "has characters other than ASCII alphanumerics, '-' or '+'"; + else return; (void) fflush(stdout); (void) fprintf(stderr, Modified: stable/9/contrib/tzcode/zic/zic.c ============================================================================== --- stable/9/contrib/tzcode/zic/zic.c Sat Oct 15 12:38:21 2016 (r307359) +++ stable/9/contrib/tzcode/zic/zic.c Sat Oct 15 12:38:50 2016 (r307360) @@ -2615,29 +2615,15 @@ const char * const string; register const char * cp; register char * wp; - /* - ** Want one to ZIC_MAX_ABBR_LEN_WO_WARN alphabetics - ** optionally followed by a + or - and a number from 1 to 14. - */ cp = string; wp = NULL; while (isascii((unsigned char) *cp) && - isalpha((unsigned char) *cp)) + (isalnum((unsigned char)*cp) || *cp == '-' || *cp == '+')) ++cp; - if (cp - string == 0) -wp = _("time zone abbreviation lacks alphabetic at start"); if (noise && cp - string > 3) -wp = _("time zone abbreviation has more than 3 alphabetics"); +wp = _("time zone abbreviation has more than 3 characters"); if (cp - string > ZIC_MAX_ABBR_LEN_WO_WARN) -wp = _("time zone abbreviation has too many alphabetics"); - if (wp == NULL && (*cp == '+' || *cp == '-')) { - ++cp; - if (isascii((unsigned char) *cp) && - isdigit((unsigned char) *cp)) - if (*cp++ == '1' && - *cp >= '0' && *cp <= '4') - ++cp; - } +wp = _("time zone abbreviation has too many characters"); if (*cp != '\0') wp = _("time zone abbreviation differs from POSIX standard"); if (wp != NULL) { From owner-svn-src-all@freebsd.org Sat Oct 15 12:41:13 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 8B9CAC132A9; Sat, 15 Oct 2016 12:41:13 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 3E18D1638; Sat, 15 Oct 2016 12:41:13 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9FCfCSs034314; Sat, 15 Oct 2016 12:41:12 GMT (envelope-from bapt@FreeBSD.org) Received: (from bapt@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9FCfCPc034309; Sat, 15 Oct 2016 12:41:12 GMT (envelope-from bapt@FreeBSD.org) Message-Id: <201610151241.u9FCfCPc034309@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bapt set sender to bapt@FreeBSD.org using -f From: Baptiste Daroussin Date: Sat, 15 Oct 2016 12:41:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307361 - stable/11/contrib/tzdata X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 Oct 2016 12:41:13 -0000 Author: bapt Date: Sat Oct 15 12:41:11 2016 New Revision: 307361 URL: https://svnweb.freebsd.org/changeset/base/307361 Log: MFC r306853 Import tzdata 2016g Modified: stable/11/contrib/tzdata/africa stable/11/contrib/tzdata/antarctica stable/11/contrib/tzdata/asia stable/11/contrib/tzdata/australasia stable/11/contrib/tzdata/backward stable/11/contrib/tzdata/etcetera stable/11/contrib/tzdata/europe stable/11/contrib/tzdata/factory stable/11/contrib/tzdata/leap-seconds.list stable/11/contrib/tzdata/leapseconds stable/11/contrib/tzdata/northamerica stable/11/contrib/tzdata/southamerica stable/11/contrib/tzdata/zone.tab stable/11/contrib/tzdata/zone1970.tab Directory Properties: stable/11/ (props changed) Modified: stable/11/contrib/tzdata/africa ============================================================================== --- stable/11/contrib/tzdata/africa Sat Oct 15 12:38:50 2016 (r307360) +++ stable/11/contrib/tzdata/africa Sat Oct 15 12:41:11 2016 (r307361) @@ -343,6 +343,12 @@ Rule Egypt 2007 only - Sep Thu>=1 24:00 # decision to abandon DST permanently. See Ahram Online 2015-04-24. # http://english.ahram.org.eg/NewsContent/1/64/128509/Egypt/Politics-/Sisi-cancels-daylight-saving-time-in-Egypt.aspx +# From Steffen Thorsen (2016-04-29): +# Egypt will have DST from July 7 until the end of October.... +# http://english.ahram.org.eg/NewsContentP/1/204655/Egypt/Daylight-savings-time-returning-to-Egypt-on--July.aspx +# From Mina Samuel (2016-07-04): +# Egyptian government took the decision to cancel the DST, + Rule Egypt 2008 only - Aug lastThu 24:00 0 - Rule Egypt 2009 only - Aug 20 24:00 0 - Rule Egypt 2010 only - Aug 10 24:00 0 - @@ -458,7 +464,7 @@ Zone Africa/Monrovia -0:43:08 - LMT 1882 # http://www.libyaherald.com/2013/10/24/correction-no-time-change-tomorrow/ # # From Paul Eggert (2013-10-25): -# For now, assume they're reverting to the pre-2012 rules of permanent UTC+2. +# For now, assume they're reverting to the pre-2012 rules of permanent UT +02. # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S Rule Libya 1951 only - Oct 14 2:00 1:00 S @@ -858,11 +864,11 @@ Rule Morocco 2009 only - Aug 21 0:00 0 Rule Morocco 2010 only - May 2 0:00 1:00 S Rule Morocco 2010 only - Aug 8 0:00 0 - Rule Morocco 2011 only - Apr 3 0:00 1:00 S -Rule Morocco 2011 only - Jul 31 0 0 - +Rule Morocco 2011 only - Jul 31 0:00 0 - Rule Morocco 2012 2013 - Apr lastSun 2:00 1:00 S -Rule Morocco 2012 only - Sep 30 3:00 0 - Rule Morocco 2012 only - Jul 20 3:00 0 - Rule Morocco 2012 only - Aug 20 2:00 1:00 S +Rule Morocco 2012 only - Sep 30 3:00 0 - Rule Morocco 2013 only - Jul 7 3:00 0 - Rule Morocco 2013 only - Aug 10 2:00 1:00 S Rule Morocco 2013 max - Oct lastSun 3:00 0 - Modified: stable/11/contrib/tzdata/antarctica ============================================================================== --- stable/11/contrib/tzdata/antarctica Sat Oct 15 12:38:50 2016 (r307360) +++ stable/11/contrib/tzdata/antarctica Sat Oct 15 12:41:11 2016 (r307361) @@ -10,10 +10,8 @@ # http://www.spri.cam.ac.uk/bob/periant.htm # for information. # Unless otherwise specified, we have no time zone information. -# -# Except for the French entries, -# I made up all time zone abbreviations mentioned here; corrections welcome! -# FORMAT is 'zzz' and GMTOFF is 0 for locations while uninhabited. + +# FORMAT is '-00' and GMTOFF is 0 for locations while uninhabited. # Argentina - year-round bases # Belgrano II, Confin Coast, -770227-0343737, since 1972-02-05 @@ -29,7 +27,7 @@ # previously sealers and scientific personnel wintered # Margaret Turner reports # http://web.archive.org/web/20021204222245/http://www.dstc.qut.edu.au/DST/marg/daylight.html -# (1999-09-30) that they're UTC+5, with no DST; +# (1999-09-30) that they're UT +05, with no DST; # presumably this is when they have visitors. # # year-round bases @@ -67,24 +65,23 @@ # http://www.timeanddate.com/news/time/antartica-time-changes-2010.html # Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Antarctica/Casey 0 - zzz 1969 - 8:00 - AWST 2009 Oct 18 2:00 - # Australian Western Std Time - 11:00 - CAST 2010 Mar 5 2:00 # Casey Time - 8:00 - AWST 2011 Oct 28 2:00 - 11:00 - CAST 2012 Feb 21 17:00u - 8:00 - AWST -Zone Antarctica/Davis 0 - zzz 1957 Jan 13 - 7:00 - DAVT 1964 Nov # Davis Time - 0 - zzz 1969 Feb - 7:00 - DAVT 2009 Oct 18 2:00 - 5:00 - DAVT 2010 Mar 10 20:00u - 7:00 - DAVT 2011 Oct 28 2:00 - 5:00 - DAVT 2012 Feb 21 20:00u - 7:00 - DAVT -Zone Antarctica/Mawson 0 - zzz 1954 Feb 13 - 6:00 - MAWT 2009 Oct 18 2:00 # Mawson Time - 5:00 - MAWT +Zone Antarctica/Casey 0 - -00 1969 + 8:00 - +08 2009 Oct 18 2:00 + 11:00 - +11 2010 Mar 5 2:00 + 8:00 - +08 2011 Oct 28 2:00 + 11:00 - +11 2012 Feb 21 17:00u + 8:00 - +08 +Zone Antarctica/Davis 0 - -00 1957 Jan 13 + 7:00 - +07 1964 Nov + 0 - -00 1969 Feb + 7:00 - +07 2009 Oct 18 2:00 + 5:00 - +05 2010 Mar 10 20:00u + 7:00 - +07 2011 Oct 28 2:00 + 5:00 - +05 2012 Feb 21 20:00u + 7:00 - +07 +Zone Antarctica/Mawson 0 - -00 1954 Feb 13 + 6:00 - +06 2009 Oct 18 2:00 + 5:00 - +05 # References: # Casey Weather (1998-02-26) # http://www.antdiv.gov.au/aad/exop/sfo/casey/casey_aws.html @@ -137,8 +134,8 @@ Zone Antarctica/Mawson 0 - zzz 1954 Feb # fishing stations operated variously 1819/1931 # # Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Indian/Kerguelen 0 - zzz 1950 # Port-aux-Français - 5:00 - TFT # ISO code TF Time +Zone Indian/Kerguelen 0 - -00 1950 # Port-aux-Français + 5:00 - +05 # # year-round base in the main continent # Dumont d'Urville, ÃŽle des Pétrels, -6640+14001, since 1956-11 @@ -148,10 +145,10 @@ Zone Indian/Kerguelen 0 - zzz 1950 # Por # It was destroyed by fire on 1952-01-14. # # Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Antarctica/DumontDUrville 0 - zzz 1947 - 10:00 - PMT 1952 Jan 14 # Port-Martin Time - 0 - zzz 1956 Nov - 10:00 - DDUT # Dumont-d'Urville Time +Zone Antarctica/DumontDUrville 0 - -00 1947 + 10:00 - +10 1952 Jan 14 + 0 - -00 1956 Nov + 10:00 - +10 # France & Italy - year-round base # Concordia, -750600+1232000, since 2005 @@ -176,8 +173,8 @@ Zone Antarctica/DumontDUrville 0 - zzz 1 # was established on 1957-01-29. Since Syowa station is still the main # station of Japan, it's appropriate for the principal location. # Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Antarctica/Syowa 0 - zzz 1957 Jan 29 - 3:00 - SYOT # Syowa Time +Zone Antarctica/Syowa 0 - -00 1957 Jan 29 + 3:00 - +03 # See: # NIPR Antarctic Research Activities (1999-08-17) # http://www.nipr.ac.jp/english/ara01.html @@ -214,19 +211,19 @@ Zone Antarctica/Syowa 0 - zzz 1957 Jan 2 # correct, but they should be quite close to the actual dates. # # From Paul Eggert (2014-03-21): -# The CET-switching Troll rules require zic from tzcode 2014b or later, so as +# The CET-switching Troll rules require zic from tz 2014b or later, so as # suggested by Bengt-Inge Larsson comment them out for now, and approximate # with only UTC and CEST. Uncomment them when 2014b is more prevalent. # # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -#Rule Troll 2005 max - Mar 1 1:00u 1:00 CET -Rule Troll 2005 max - Mar lastSun 1:00u 2:00 CEST -#Rule Troll 2005 max - Oct lastSun 1:00u 1:00 CET -#Rule Troll 2004 max - Nov 7 1:00u 0:00 UTC +#Rule Troll 2005 max - Mar 1 1:00u 1:00 +01 +Rule Troll 2005 max - Mar lastSun 1:00u 2:00 +02 +#Rule Troll 2005 max - Oct lastSun 1:00u 1:00 +01 +#Rule Troll 2004 max - Nov 7 1:00u 0:00 +00 # Remove the following line when uncommenting the above '#Rule' lines. -Rule Troll 2004 max - Oct lastSun 1:00u 0:00 UTC +Rule Troll 2004 max - Oct lastSun 1:00u 0:00 +00 # Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Antarctica/Troll 0 - zzz 2005 Feb 12 +Zone Antarctica/Troll 0 - -00 2005 Feb 12 0:00 Troll %s # Poland - year-round base @@ -265,10 +262,10 @@ Zone Antarctica/Troll 0 - zzz 2005 Feb 1 # changes during the year and does not necessarily correspond to mean # solar noon. So the Vostok time might have been whatever the clocks # happened to be during their visit. So we still don't really know what time -# it is at Vostok. But we'll guess UTC+6. +# it is at Vostok. But we'll guess +06. # -Zone Antarctica/Vostok 0 - zzz 1957 Dec 16 - 6:00 - VOST # Vostok time +Zone Antarctica/Vostok 0 - -00 1957 Dec 16 + 6:00 - +06 # S Africa - year-round bases # Marion Island, -4653+03752 @@ -300,8 +297,8 @@ Zone Antarctica/Vostok 0 - zzz 1957 Dec # says Rothera is -03 all year. # # Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Antarctica/Rothera 0 - zzz 1976 Dec 1 - -3:00 - ROTT # Rothera time +Zone Antarctica/Rothera 0 - -00 1976 Dec 1 + -3:00 - -03 # Uruguay - year round base # Artigas, King George Island, -621104-0585107 Modified: stable/11/contrib/tzdata/asia ============================================================================== --- stable/11/contrib/tzdata/asia Sat Oct 15 12:38:50 2016 (r307360) +++ stable/11/contrib/tzdata/asia Sat Oct 15 12:41:11 2016 (r307361) @@ -79,13 +79,9 @@ Rule E-EurAsia 1979 1995 - Sep lastSun Rule E-EurAsia 1996 max - Oct lastSun 0:00 0 - Rule RussiaAsia 1981 1984 - Apr 1 0:00 1:00 S Rule RussiaAsia 1981 1983 - Oct 1 0:00 0 - -Rule RussiaAsia 1984 1991 - Sep lastSun 2:00s 0 - -Rule RussiaAsia 1985 1991 - Mar lastSun 2:00s 1:00 S -Rule RussiaAsia 1992 only - Mar lastSat 23:00 1:00 S -Rule RussiaAsia 1992 only - Sep lastSat 23:00 0 - -Rule RussiaAsia 1993 max - Mar lastSun 2:00s 1:00 S -Rule RussiaAsia 1993 1995 - Sep lastSun 2:00s 0 - -Rule RussiaAsia 1996 max - Oct lastSun 2:00s 0 - +Rule RussiaAsia 1984 1995 - Sep lastSun 2:00s 0 - +Rule RussiaAsia 1985 2011 - Mar lastSun 2:00s 1:00 S +Rule RussiaAsia 1996 2011 - Oct lastSun 2:00s 0 - # Afghanistan # Zone NAME GMTOFF RULES FORMAT [UNTIL] @@ -120,31 +116,37 @@ Zone Asia/Kabul 4:36:48 - LMT 1890 # http://www.worldtimezone.com/dst_news/dst_news_armenia03.html # Zone NAME GMTOFF RULES FORMAT [UNTIL] Zone Asia/Yerevan 2:58:00 - LMT 1924 May 2 - 3:00 - YERT 1957 Mar # Yerevan Time - 4:00 RussiaAsia YER%sT 1991 Mar 31 2:00s - 3:00 1:00 YERST 1991 Sep 23 # independence - 3:00 RussiaAsia AM%sT 1995 Sep 24 2:00s - 4:00 - AMT 1997 - 4:00 RussiaAsia AM%sT 2012 Mar 25 2:00s - 4:00 - AMT + 3:00 - +03 1957 Mar + 4:00 RussiaAsia +04/+05 1991 Mar 31 2:00s + 3:00 RussiaAsia +03/+04 1995 Sep 24 2:00s + 4:00 - +04 1997 + 4:00 RussiaAsia +04/+05 # Azerbaijan + # From Rustam Aliyev of the Azerbaijan Internet Forum (2005-10-23): # According to the resolution of Cabinet of Ministers, 1997 # From Paul Eggert (2015-09-17): It was Resolution No. 21 (1997-03-17). # http://code.az/files/daylight_res.pdf + +# From Steffen Thorsen (2016-03-17): +# ... the Azerbaijani Cabinet of Ministers has cancelled switching to +# daylight saving time.... +# http://www.azernews.az/azerbaijan/94137.html +# http://vestnikkavkaza.net/news/Azerbaijani-Cabinet-of-Ministers-cancels-daylight-saving-time.html +# http://en.apa.az/xeber_azerbaijan_abolishes_daylight_savings_ti_240862.html + # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule Azer 1997 max - Mar lastSun 4:00 1:00 S -Rule Azer 1997 max - Oct lastSun 5:00 0 - +Rule Azer 1997 2015 - Mar lastSun 4:00 1:00 S +Rule Azer 1997 2015 - Oct lastSun 5:00 0 - # Zone NAME GMTOFF RULES FORMAT [UNTIL] Zone Asia/Baku 3:19:24 - LMT 1924 May 2 - 3:00 - BAKT 1957 Mar # Baku Time - 4:00 RussiaAsia BAK%sT 1991 Mar 31 2:00s - 3:00 1:00 BAKST 1991 Aug 30 # independence - 3:00 RussiaAsia AZ%sT 1992 Sep lastSat 23:00 - 4:00 - AZT 1996 # Azerbaijan Time - 4:00 EUAsia AZ%sT 1997 - 4:00 Azer AZ%sT + 3:00 - +03 1957 Mar + 4:00 RussiaAsia +04/+05 1991 Mar 31 2:00s + 3:00 RussiaAsia +03/+04 1992 Sep lastSun 2:00s + 4:00 - +04 1996 + 4:00 EUAsia +04/+05 1997 + 4:00 Azer +04/+05 # Bahrain # See Asia/Qatar. @@ -263,7 +265,7 @@ Zone Asia/Brunei 7:39:40 - LMT 1926 Mar # Milne says 6:24:40 was the meridian of the time ball observatory at Rangoon. # Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Asia/Rangoon 6:24:40 - LMT 1880 # or Yangon +Zone Asia/Yangon 6:24:40 - LMT 1880 # or Rangoon 6:24:40 - RMT 1920 # Rangoon Mean Time? 6:30 - BURT 1942 May # Burma Time 9:00 - JST 1945 May 3 @@ -378,7 +380,7 @@ Rule PRC 1987 1991 - Apr Sun>=10 0:00 1: # Lewiston (ME) Daily Sun (1939-05-29), p 17, said "Even the time is # different - the occupied districts going by Tokyo time, an hour # ahead of that prevailing in the rest of Shanghai." Guess that the -# Xujiahui Observatory was under French control and stuck with UT+8. +# Xujiahui Observatory was under French control and stuck with UT +08. # # In earlier versions of this file, China had many separate Zone entries, but # this was based on what were apparently incorrect data in Shanks & Pottenger. @@ -387,26 +389,26 @@ Rule PRC 1987 1991 - Apr Sun>=10 0:00 1: # Proposed in 1918 and theoretically in effect until 1949 (although in practice # mainly observed in coastal areas), the five zones were: # -# Changbai Time ("Long-white Time", Long-white = Heilongjiang area) UT+8.5 +# Changbai Time ("Long-white Time", Long-white = Heilongjiang area) UT +08:30 # Asia/Harbin (currently a link to Asia/Shanghai) # Heilongjiang (except Mohe county), Jilin # -# Zhongyuan Time ("Central plain Time") UT+8 +# Zhongyuan Time ("Central plain Time") UT +08 # Asia/Shanghai # most of China # This currently represents most other zones as well, # as apparently these regions have been the same since 1970. # Milne gives 8:05:43.2 for Xujiahui Observatory time; round to nearest. -# Guo says Shanghai switched to UT+8 "from the end of the 19th century". +# Guo says Shanghai switched to UT +08 "from the end of the 19th century". # -# Long-shu Time (probably due to Long and Shu being two names of that area) UT+7 +# Long-shu Time (probably due to Long and Shu being two names of the area) UT +07 # Asia/Chongqing (currently a link to Asia/Shanghai) # Guangxi, Guizhou, Hainan, Ningxia, Sichuan, Shaanxi, and Yunnan; # most of Gansu; west Inner Mongolia; west Qinghai; and the Guangdong # counties Deqing, Enping, Kaiping, Luoding, Taishan, Xinxing, # Yangchun, Yangjiang, Yu'nan, and Yunfu. # -# Xin-zang Time ("Xinjiang-Tibet Time") UT+6 +# Xin-zang Time ("Xinjiang-Tibet Time") UT +06 # Asia/Urumqi # This currently represents Kunlun Time as well, # as apparently the two regions have been the same since 1970. @@ -419,7 +421,7 @@ Rule PRC 1987 1991 - Apr Sun>=10 0:00 1: # Shihezi, Changji, Yanqi, Heshuo, Tuokexun, Tulufan, Shanshan, Hami, # Fukang, Kuitun, Kumukuli, Miquan, Qitai, and Turfan. # -# Kunlun Time UT+5.5 +# Kunlun Time UT +05:30 # Asia/Kashgar (currently a link to Asia/Urumqi) # West Tibet, including Pulan, Aheqi, Shufu, Shule; # West Xinjiang, including Aksu, Atushi, Yining, Hetian, Cele, Luopu, Nileke, @@ -435,7 +437,7 @@ Rule PRC 1987 1991 - Apr Sun>=10 0:00 1: # # On the other hand, ethnic Uyghurs, who make up about half the # population of Xinjiang, typically use "Xinjiang time" which is two -# hours behind Beijing time, or UTC +0600. The government of the Xinjiang +# hours behind Beijing time, or UT +06. The government of the Xinjiang # Uyghur Autonomous Region, (XAUR, or just Xinjiang for short) as well as # local governments such as the Ãœrümqi city government use both times in # publications, referring to what is popularly called Xinjiang time as @@ -491,8 +493,8 @@ Rule PRC 1987 1991 - Apr Sun>=10 0:00 1: # having the same time as Beijing. # From Paul Eggert (2014-06-30): -# In the early days of the PRC, Tibet was given its own time zone (UT+6) but -# this was withdrawn in 1959 and never reinstated; see Tubten Khétsun, +# In the early days of the PRC, Tibet was given its own time zone (UT +06) +# but this was withdrawn in 1959 and never reinstated; see Tubten Khétsun, # Memories of life in Lhasa under Chinese Rule, Columbia U Press, ISBN # 978-0231142861 (2008), translator's introduction by Matthew Akester, p x. # As this is before our 1970 cutoff, Tibet doesn't need a separate zone. @@ -506,12 +508,12 @@ Rule PRC 1987 1991 - Apr Sun>=10 0:00 1: # Republics, the Soviet Union, the Kuomintang, and the People's Republic of # China, and tracking down all these organizations' timekeeping rules would be # quite a trick. Approximate this lost history by a transition from LMT to -# XJT at the start of 1928, the year of accession of the warlord Jin Shuren, +# UT +06 at the start of 1928, the year of accession of the warlord Jin Shuren, # which happens to be the date given by Shanks & Pottenger (no doubt as a -# guess) as the transition from LMT. Ignore the usage of UT+8 before -# 1986-02-01 under the theory that the transition date to UT+8 is unknown and +# guess) as the transition from LMT. Ignore the usage of +08 before +# 1986-02-01 under the theory that the transition date to +08 is unknown and # that the sort of users who prefer Asia/Urumqi now typically ignored the -# UT+8 mandate back then. +# +08 mandate back then. # Zone NAME GMTOFF RULES FORMAT [UNTIL] # Beijing time, used throughout China; represented by Shanghai. @@ -716,7 +718,7 @@ Zone Asia/Hong_Kong 7:36:42 - LMT 1904 O # be found from historical government announcement database. # From Paul Eggert (2014-07-03): -# As per Yu-Cheng Chuang, say that Taiwan was at UT+9 from 1937-10-01 +# As per Yu-Cheng Chuang, say that Taiwan was at UT +09 from 1937-10-01 # until 1945-09-21 at 01:00, overriding Shanks & Pottenger. # Likewise, use Yu-Cheng Chuang's data for DST in Taiwan. @@ -830,16 +832,15 @@ Link Asia/Nicosia Europe/Nicosia # Zone NAME GMTOFF RULES FORMAT [UNTIL] Zone Asia/Tbilisi 2:59:11 - LMT 1880 2:59:11 - TBMT 1924 May 2 # Tbilisi Mean Time - 3:00 - TBIT 1957 Mar # Tbilisi Time - 4:00 RussiaAsia TBI%sT 1991 Mar 31 2:00s - 3:00 1:00 TBIST 1991 Apr 9 # independence - 3:00 RussiaAsia GE%sT 1992 # Georgia Time - 3:00 E-EurAsia GE%sT 1994 Sep lastSun - 4:00 E-EurAsia GE%sT 1996 Oct lastSun - 4:00 1:00 GEST 1997 Mar lastSun - 4:00 E-EurAsia GE%sT 2004 Jun 27 - 3:00 RussiaAsia GE%sT 2005 Mar lastSun 2:00 - 4:00 - GET + 3:00 - +03 1957 Mar + 4:00 RussiaAsia +04/+05 1991 Mar 31 2:00s + 3:00 RussiaAsia +03/+04 1992 + 3:00 E-EurAsia +03/+04 1994 Sep lastSun + 4:00 E-EurAsia +04/+05 1996 Oct lastSun + 4:00 1:00 +05 1997 Mar lastSun + 4:00 E-EurAsia +04/+05 2004 Jun 27 + 3:00 RussiaAsia +03/+04 2005 Mar lastSun 2:00 + 4:00 - +04 # East Timor @@ -874,6 +875,15 @@ Zone Asia/Dili 8:22:20 - LMT 1912 Jan 1 9:00 - TLT # India + +# From Ian P. Beacock, in "A brief history of (modern) time", The Atlantic +# http://www.theatlantic.com/technology/archive/2015/12/the-creation-of-modern-time/421419/ +# (2015-12-22): +# In January 1906, several thousand cotton-mill workers rioted on the +# outskirts of Bombay.... They were protesting the proposed abolition of +# local time in favor of Indian Standard Time.... Journalists called this +# dispute the "Battle of the Clocks." It lasted nearly half a century. + # Zone NAME GMTOFF RULES FORMAT [UNTIL] Zone Asia/Kolkata 5:53:28 - LMT 1880 # Kolkata 5:53:20 - HMT 1941 Oct # Howrah Mean Time? @@ -907,7 +917,7 @@ Zone Asia/Kolkata 5:53:28 - LMT 1880 # These would be the earliest possible times for a change. # Régimes horaires pour le monde entier, by Henri Le Corre, (Éditions # Traditionnelles, 1987, Paris) says that Java and Madura switched -# from JST to UTC+07:30 on 1945-09-23, and gives 1944-09-01 for Jayapura +# from UT +09 to +07:30 on 1945-09-23, and gives 1944-09-01 for Jayapura # (Hollandia). For now, assume all Indonesian locations other than Jayapura # switched on 1945-09-23. # @@ -918,11 +928,11 @@ Zone Asia/Kolkata 5:53:28 - LMT 1880 # summary published by the Time and Frequency Laboratory of the # Research Center for Calibration, Instrumentation and Metrology, # Indonesia, (2006-09-29). -# The abbreviations are: +# The time zone abbreviations and UT offsets are: # -# WIB - UTC+7 - Waktu Indonesia Barat (Indonesia western time) -# WITA - UTC+8 - Waktu Indonesia Tengah (Indonesia central time) -# WIT - UTC+9 - Waktu Indonesia Timur (Indonesia eastern time) +# WIB - +07 - Waktu Indonesia Barat (Indonesia western time) +# WITA - +08 - Waktu Indonesia Tengah (Indonesia central time) +# WIT - +09 - Waktu Indonesia Timur (Indonesia eastern time) # # Zone NAME GMTOFF RULES FORMAT [UNTIL] # Java, Sumatra @@ -1084,8 +1094,15 @@ Rule Iran 2032 2033 - Mar 21 0:00 1:00 D Rule Iran 2032 2033 - Sep 21 0:00 0 S Rule Iran 2034 2035 - Mar 22 0:00 1:00 D Rule Iran 2034 2035 - Sep 22 0:00 0 S -Rule Iran 2036 2037 - Mar 21 0:00 1:00 D -Rule Iran 2036 2037 - Sep 21 0:00 0 S +# +# The following rules are approximations starting in the year 2038. +# These are the best post-2037 approximations available, given the +# restrictions of a single rule using a Gregorian-based data format. +# At some point this table will need to be extended, though quite +# possibly Iran will change the rules first. +Rule Iran 2036 max - Mar 21 0:00 1:00 D +Rule Iran 2036 max - Sep 21 0:00 0 S + # Zone NAME GMTOFF RULES FORMAT [UNTIL] Zone Asia/Tehran 3:25:44 - LMT 1916 3:25:44 - TMT 1946 # Tehran Mean Time @@ -1542,23 +1559,6 @@ Zone Asia/Amman 2:23:44 - LMT 1931 # Kazakhstan -# From Paul Eggert (1996-11-22): -# Andrew Evtichov (1996-04-13) writes that Kazakhstan -# stayed in sync with Moscow after 1990, and that Aqtobe (formerly Aktyubinsk) -# and Aqtau (formerly Shevchenko) are the largest cities in their zones. -# Guess that Aqtau and Aqtobe diverged in 1995, since that's the first time -# IATA SSIM mentions a third time zone in Kazakhstan. - -# From Paul Eggert (2006-03-22): -# German Iofis, ELSI, Almaty (2001-10-09) reports that Kazakhstan uses -# RussiaAsia rules, instead of switching at 00:00 as the IATA has it. -# Go with Shanks & Pottenger, who have them always using RussiaAsia rules. -# Also go with the following claims of Shanks & Pottenger: -# -# - Kazakhstan did not observe DST in 1991. -# - Qyzylorda switched from +5:00 to +6:00 on 1992-01-19 02:00. -# - Oral switched from +5:00 to +4:00 in spring 1989. - # From Kazakhstan Embassy's News Bulletin No. 11 # (2005-03-21): # The Government of Kazakhstan passed a resolution March 15 abolishing @@ -1575,61 +1575,232 @@ Zone Asia/Amman 2:23:44 - LMT 1931 # everything else.... I guess that would make Kazakhstan time zones # de jure UTC+5 and UTC+6 respectively. +# From Stepan Golosunov (2016-03-27) ([*] means see later comments below): +# Review of the linked documents from http://adilet.zan.kz/ +# produced the following data for post-1991 Kazakhstan: +# +# 0. Act of the Cabinet of Ministers of the USSR +# from 1991-02-04 No. 20 +# http://pravo.gov.ru/proxy/ips/?docbody=&nd=102010545 +# removed the extra hour ("decree time") on the territory of the USSR +# starting with the last Sunday of March 1991. +# It also allowed (but not mandated) Kazakh SSR, Kirghiz SSR, Tajik SSR, +# Turkmen SSR and Uzbek SSR to not have "summer" time. +# +# The 1992-01-13 act also refers to the act of the Cabinet of Ministers +# of the Kazakh SSR from 1991-03-20 No. 170 "About the act of the Cabinet +# of Ministers of the USSR from 1991-02-04 No. 20" but I didn't found its +# text. +# +# According to Izvestia newspaper No. 68 (23334) from 1991-03-20 +# (page 6; available at http://libinfo.org/newsr/newsr2574.djvu via +# http://libinfo.org/index.php?id=58564) on 1991-03-31 at 2:00 during +# transition to "summer" time: +# Republic of Georgia, Latvian SSR, Lithuanian SSR, SSR Moldova, +# Estonian SSR; Komi ASSR; Kaliningrad oblast; Nenets autonomous okrug +# were to move clocks 1 hour forward. +# Kazakh SSR (excluding Uralsk oblast); Republic of Kyrgyzstan, Tajik +# SSR; Andijan, Jizzakh, Namangan, Sirdarya, Tashkent, Fergana oblasts +# of the Uzbek SSR were to move clocks 1 hour backwards. +# Other territories were to not move clocks. +# When the "summer" time would end on 1991-09-29, clocks were to be +# moved 1 hour backwards on the territory of the USSR excluding +# Kazakhstan, Kirghizia, Uzbekistan, Turkmenia, Tajikistan. +# +# Apparently there were last minute changes. Apparently Kazakh act No. 170 +# was one of such changes. +# +# https://ru.wikipedia.org/wiki/Декретное Ð²Ñ€ÐµÐ¼Ñ +# claims that Sovetskaya Rossiya newspaper on 1991-03-29 published that +# Nenets autonomous okrug, Komi and Kazakhstan (excluding Uralsk oblast) +# were to not move clocks and Uralsk oblast was to move clocks +# forward; on 1991-09-29 Kazakhstan was to move clocks backwards. +# (Probably there were changes even after that publication. There is an +# article claiming that Kaliningrad oblast decided on 1991-03-29 to not +# move clocks.) +# +# This implies that on 1991-03-31 Asia/Oral remained on +04/+05 while +# the rest of Kazakhstan switched from +06/+07 to +05/06 or from +05/06 +# to +04/+05. It's unclear how Kzyl-Orda oblast moved into the fifth +# time belt. (By switching from +04/+05 to +05/+06 on 1991-09-29?) ... +# +# 1. Act of the Cabinet of Ministers of the Republic of Kazakhstan +# from 1992-01-13 No. 28 +# http://adilet.zan.kz/rus/docs/P920000028_ +# (text includes modification from the 1996 act) +# introduced new rules for calculation of time, mirroring Russian +# 1992-01-08 act. It specified that time would be calculated +# according to time belts plus extra hour ("decree time"), moved clocks +# on the whole territory of Kazakhstan 1 hour forward on 1992-01-19 at +# 2:00, specified DST rules. It acknowledged that Kazakhstan was +# located in the fourth and the fifth time belts and specified the +# border between them to be located east of Kustanay and Aktyubinsk +# oblasts (notably including Turgai and Kzyl-Orda oblasts into the fifth +# time belt). +# +# This means switch on 1992-01-19 at 2:00 from +04/+05 to +05/+06 for +# Asia/Aqtau, Asia/Aqtobe, Asia/Oral, Atyrau and Kustanay oblasts; from +# +05/+06 to +06/+07 for Asia/Almaty and Asia/Qyzylorda (and Arkalyk) [*].... +# +# 2. Act of the Cabinet of Ministers of the Republic of Kazakhstan +# from 1992-03-27 No. 284 +# http://adilet.zan.kz/rus/docs/P920000284_ +# cancels extra hour ("decree time") for Uralsk and Kzyl-Orda oblasts +# since the last Sunday of March 1992, while keeping them in the fourth +# and the fifth time belts respectively. +# +# 3. Order of the Prime Minister of the Republic of Kazakhstan +# from 1994-09-23 No. 384 +# http://adilet.zan.kz/rus/docs/R940000384_ +# cancels the extra hour ("decree time") on the territory of Mangystau +# oblast since the last Sunday of September 1994 (saying that time on +# the territory would correspond to the third time belt as a +# result).... +# +# 4. Act of the Government of the Republic of Kazakhstan +# from 1996-05-08 No. 575 +# http://adilet.zan.kz/rus/docs/P960000575_ +# amends the 1992-01-13 act to end summer time in October instead +# of September, mirroring identical Russian change from 1996-04-23 act. +# +# 5. Act of the Government of the Republic of Kazakhstan +# from 1999-03-26 No. 305 +# http://adilet.zan.kz/rus/docs/P990000305_ +# cancels the extra hour ("decree time") for Atyrau oblast since the +# last Sunday of March 1999 while retaining the oblast in the fourth +# time belt. +# +# This means change from +05/+06 to +04/+05. +# +# There is no zone for Atyrau currently (listed under Asia/Aqtau in +# zone1970.tab).[*] +# +# 6. Act of the Government of the Republic of Kazakhstan +# from 2000-11-23 No. 1749 +# http://adilet.zan.kz/rus/archive/docs/P000001749_/23.11.2000 +# replaces the previous five documents. +# +# The only changes I noticed are in definition of the border between the +# fourth and the fifth time belts. They account for changes in spelling +# and administrative division (splitting of Turgai oblast in 1997 +# probably changed time in territories incorporated into Kostanay oblast +# (including Arkalyk) from +06/+07 to +05/+06) and move Kyzylorda oblast +# from being in the fifth time belt and not using decree time into the +# fourth time belt (no change in practice).[*] +# +# 7. Act of the Government of the Republic of Kazakhstan +# from 2003-12-29 No. 1342 +# http://adilet.zan.kz/rus/docs/P030001342_ +# modified the 2000-11-23 act. No relevant changes, apparently. +# +# 8. Act of the Government of the Republic of Kazakhstan +# from 2004-07-20 No. 775 +# http://adilet.zan.kz/rus/archive/docs/P040000775_/20.07.2004 +# modified the 2000-11-23 act to move Kostanay and Kyzylorda oblasts into +# the fifth time belt and add Aktobe oblast to the list of regions not +# using extra hour ("decree time"), leaving Kazakhstan with only 2 time +# zones (+04/+05 and +06/+07). The changes were to be implemented +# during DST transitions in 2004 and 2005 but the acts got radically +# amended before implementation happened. +# +# 9. Act of the Government of the Republic of Kazakhstan +# from 2004-09-15 No. 1059 +# http://adilet.zan.kz/rus/docs/P040001059_ +# modified the 2000-11-23 act to remove exceptions from the "decree time" +# (leaving Kazakhstan in +05/+06 and +06/+07 zones), amended the +# 2004-07-20 act to implement changes for Atyrau, West Kazakhstan, +# Kostanay, Kyzylorda and Mangystau oblasts by not moving clocks +# during the 2014 transition to "winter" time. +# +# This means transition from +04/+05 to +05/+06 for Atyrau oblast (no +# zone currently), Asia/Oral, Asia/Aqtau and transition from +05/+06 to +# +06/+07 for Kostanay oblast (Kostanay and Arkalyk, no zones currently) +# and Asia/Qyzylorda on 2004-10-31 at 3:00....[*] +# +# 10. Act of the Government of the Republic of Kazakhstan +# from 2005-03-15 No. 231 +# http://adilet.zan.kz/rus/docs/P050000231_ +# removes DST provisions from the 2000-11-23 act, removes most of the +# (already implemented) provisions from the 2004-07-20 and 2004-09-15 +# acts, comes into effect 10 days after official publication. +# The only practical effect seems to be the abolition of the summer +# time. +# +# Unamended version of the act of the Government of the Russian Federation +# No. 23 from 1992-01-08 [See 'europe' file for details]. +# Kazakh 1992-01-13 act appears to provide the same rules and 1992-03-27 +# act was to be enacted on the last Sunday of March 1992. + +# From Paul Eggert (2016-04-15): +# The tables below should reflect Stepan Golosunov's remarks above, +# except for the items marked "[*]" which I haven't gotten to yet. +# It looks like we will need new zones Asia/Atyrau and Asia/Qostanay +# to handle changes from 1992 through 2004 that we did not previously +# know about. + # # Zone NAME GMTOFF RULES FORMAT [UNTIL] # # Almaty (formerly Alma-Ata), representing most locations in Kazakhstan +# This includes KZ-AKM, KZ-ALA, KZ-ALM, KZ-AST, KZ-BAY, KZ-VOS, KZ-ZHA, +# KZ-KAR, KZ-SEV, KZ-PAV, and KZ-YUZ. Zone Asia/Almaty 5:07:48 - LMT 1924 May 2 # or Alma-Ata - 5:00 - ALMT 1930 Jun 21 # Alma-Ata Time - 6:00 RussiaAsia ALM%sT 1991 - 6:00 - ALMT 1992 - 6:00 RussiaAsia ALM%sT 2005 Mar 15 - 6:00 - ALMT -# Qyzylorda (aka Kyzylorda, Kizilorda, Kzyl-Orda, etc.) + 5:00 - +05 1930 Jun 21 + 6:00 RussiaAsia +06/+07 1991 Mar 31 2:00s + 5:00 RussiaAsia +05/+06 1992 Jan 19 2:00s + 6:00 RussiaAsia +06/+07 2004 Oct 31 2:00s + 6:00 - +06 +# Qyzylorda (aka Kyzylorda, Kizilorda, Kzyl-Orda, etc.) (KZ-KZY) Zone Asia/Qyzylorda 4:21:52 - LMT 1924 May 2 - 4:00 - KIZT 1930 Jun 21 # Kizilorda Time - 5:00 - KIZT 1981 Apr 1 - 5:00 1:00 KIZST 1981 Oct 1 - 6:00 - KIZT 1982 Apr 1 - 5:00 RussiaAsia KIZ%sT 1991 - 5:00 - KIZT 1991 Dec 16 # independence - 5:00 - QYZT 1992 Jan 19 2:00 - 6:00 RussiaAsia QYZ%sT 2005 Mar 15 - 6:00 - QYZT -# Aqtobe (aka Aktobe, formerly Aktyubinsk) + 4:00 - +04 1930 Jun 21 + 5:00 - +05 1981 Apr 1 + 5:00 1:00 +06 1981 Oct 1 + 6:00 - +06 1982 Apr 1 + 5:00 RussiaAsia +05/+06 1991 Mar 31 2:00s + 4:00 RussiaAsia +04/+05 1991 Sep 29 2:00s + 5:00 RussiaAsia +05/+06 1992 Jan 19 2:00s + 6:00 RussiaAsia +06/+07 1992 Mar 29 2:00s + 5:00 RussiaAsia +05/+06 2004 Oct 31 2:00s + 6:00 - +06 +# Aqtobe (aka Aktobe, formerly Aktyubinsk) (KZ-AKT) Zone Asia/Aqtobe 3:48:40 - LMT 1924 May 2 - 4:00 - AKTT 1930 Jun 21 # Aktyubinsk Time - 5:00 - AKTT 1981 Apr 1 - 5:00 1:00 AKTST 1981 Oct 1 - 6:00 - AKTT 1982 Apr 1 - 5:00 RussiaAsia AKT%sT 1991 - 5:00 - AKTT 1991 Dec 16 # independence - 5:00 RussiaAsia AQT%sT 2005 Mar 15 # Aqtobe Time - 5:00 - AQTT -# Mangghystau + 4:00 - +04 1930 Jun 21 + 5:00 - +05 1981 Apr 1 + 5:00 1:00 +06 1981 Oct 1 + 6:00 - +06 1982 Apr 1 + 5:00 RussiaAsia +05/+06 1991 Mar 31 2:00s + 4:00 RussiaAsia +04/+05 1992 Jan 19 2:00s + 5:00 RussiaAsia +05/+06 2004 Oct 31 2:00s + 5:00 - +05 +# Qostanay (KZ-KUS) + +# Mangghystau (KZ-MAN) # Aqtau was not founded until 1963, but it represents an inhabited region, # so include time stamps before 1963. Zone Asia/Aqtau 3:21:04 - LMT 1924 May 2 - 4:00 - FORT 1930 Jun 21 # Fort Shevchenko T - 5:00 - FORT 1963 - 5:00 - SHET 1981 Oct 1 # Shevchenko Time - 6:00 - SHET 1982 Apr 1 - 5:00 RussiaAsia SHE%sT 1991 - 5:00 - SHET 1991 Dec 16 # independence - 5:00 RussiaAsia AQT%sT 1995 Mar lastSun 2:00 # Aqtau Time - 4:00 RussiaAsia AQT%sT 2005 Mar 15 - 5:00 - AQTT -# West Kazakhstan + 4:00 - +04 1930 Jun 21 + 5:00 - +05 1963 + 5:00 - +05 1981 Oct 1 + 6:00 - +06 1982 Apr 1 + 5:00 RussiaAsia +05/+06 1991 Mar 31 2:00s + 4:00 RussiaAsia +04/+05 1992 Jan 19 2:00s + 5:00 RussiaAsia +05/+06 1994 Sep 25 2:00s + 4:00 RussiaAsia +04/+05 2004 Oct 31 2:00s + 5:00 - +05 + +# West Kazakhstan (KZ-ZAP) +# From Paul Eggert (2016-03-18): +# The 1989 transition is from USSR act No. 227 (1989-03-14). Zone Asia/Oral 3:25:24 - LMT 1924 May 2 # or Ural'sk - 4:00 - URAT 1930 Jun 21 # Ural'sk time - 5:00 - URAT 1981 Apr 1 - 5:00 1:00 URAST 1981 Oct 1 - 6:00 - URAT 1982 Apr 1 - 5:00 RussiaAsia URA%sT 1989 Mar 26 2:00 - 4:00 RussiaAsia URA%sT 1991 - 4:00 - URAT 1991 Dec 16 # independence - 4:00 RussiaAsia ORA%sT 2005 Mar 15 # Oral Time - 5:00 - ORAT + 4:00 - +04 1930 Jun 21 + 5:00 - +05 1981 Apr 1 + 5:00 1:00 +06 1981 Oct 1 + 6:00 - +06 1982 Apr 1 + 5:00 RussiaAsia +05/+06 1989 Mar 26 2:00s + 4:00 RussiaAsia +04/+05 1992 Jan 19 2:00s + 5:00 RussiaAsia +05/+06 1992 Mar 29 2:00s + 4:00 RussiaAsia +04/+05 2004 Oct 31 2:00s + 5:00 - +05 # Kyrgyzstan (Kirgizstan) # Transitions through 1991 are from Shanks & Pottenger. @@ -1650,11 +1821,11 @@ Rule Kyrgyz 1997 2005 - Mar lastSun 2:30 Rule Kyrgyz 1997 2004 - Oct lastSun 2:30 0 - # Zone NAME GMTOFF RULES FORMAT [UNTIL] Zone Asia/Bishkek 4:58:24 - LMT 1924 May 2 - 5:00 - FRUT 1930 Jun 21 # Frunze Time - 6:00 RussiaAsia FRU%sT 1991 Mar 31 2:00s - 5:00 1:00 FRUST 1991 Aug 31 2:00 # independence - 5:00 Kyrgyz KG%sT 2005 Aug 12 # Kyrgyzstan Time - 6:00 - KGT + 5:00 - +05 1930 Jun 21 + 6:00 RussiaAsia +06/+07 1991 Mar 31 2:00s + 5:00 RussiaAsia +05/+06 1991 Aug 31 2:00 + 5:00 Kyrgyz +05/+06 2005 Aug 12 + 6:00 - +06 ############################################################################### @@ -1693,25 +1864,24 @@ Rule ROK 1957 1960 - Sep Sun>=18 0:00 0 Rule ROK 1987 1988 - May Sun>=8 2:00 1:00 D Rule ROK 1987 1988 - Oct Sun>=8 3:00 0 S -# From Paul Eggert (2014-10-30): +# From Paul Eggert (2016-08-23): # The Korean Wikipedia entry gives the following sources for UT offsets: # -# 1908: Official Journal Article No. 3994 (Edict No. 5) +# 1908: Official Journal Article No. 3994 (decree No. 5) # 1912: Governor-General of Korea Official Gazette Issue No. 367 # (Announcement No. 338) # 1954: Presidential Decree No. 876 (1954-03-17) # 1961: Law No. 676 (1961-08-07) -# 1987: Law No. 3919 (1986-12-31) # -# The Wikipedia entry also has confusing information about a change -# to UT+9 in April 1910, but then what would be the point of the later change -# to UT+9 on 1912-01-01? Omit the 1910 change for now. +# (Another source "1987: Law No. 3919 (1986-12-31)" was in the 2014-10-30 +# edition of the Korean Wikipedia entry.) # # I guessed that time zone abbreviations through 1945 followed the same # rules as discussed under Taiwan, with nominal switches from JST to KST # when the respective cities were taken over by the Allies after WWII. # -# For Pyongyang we have no information; guess no changes since World War II. +# For Pyongyang, guess no changes from World War II until 2015, as we +# have no information otherwise. # From Steffen Thorsen (2015-08-07): # According to many news sources, North Korea is going to change to @@ -1871,7 +2041,7 @@ Zone Indian/Maldives 4:54:00 - LMT 1880 # Bill Bonnet (2005-05-19) reports that the US Embassy in Ulaanbaatar says # there is only one time zone and that DST is observed, citing Microsoft # Windows XP as the source. Risto Nykänen (2005-05-16) reports that -# travelmongolia.org says there are two time zones (UTC+7, UTC+8) with no DST. +# travelmongolia.org says there are two time zones (UT +07, +08) with no DST. # Oscar van Vlijmen (2005-05-20) reports that the Mongolian Embassy in # Washington, DC says there are two time zones, with DST observed. # He also found @@ -2111,8 +2281,8 @@ Zone Asia/Kathmandu 5:41:16 - LMT 1920 # http://www.app.com.pk/en_/index.php?option=com_content&task=view&id=99374&Itemid=2 # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule Pakistan 2002 only - Apr Sun>=2 0:01 1:00 S -Rule Pakistan 2002 only - Oct Sun>=2 0:01 0 - +Rule Pakistan 2002 only - Apr Sun>=2 0:00 1:00 S +Rule Pakistan 2002 only - Oct Sun>=2 0:00 0 - Rule Pakistan 2008 only - Jun 1 0:00 1:00 S Rule Pakistan 2008 2009 - Nov 1 0:00 0 - Rule Pakistan 2009 only - Apr 15 0:00 1:00 S @@ -2380,6 +2550,16 @@ Zone Asia/Karachi 4:28:12 - LMT 1907 # http://www.timeanddate.com/time/change/gaza-strip/gaza # http://www.timeanddate.com/time/change/west-bank/hebron +# From Hannah Kreitem (2016-03-09): +# http://www.palestinecabinet.gov.ps/WebSite/ar/ViewDetails?ID=31728 +# [Google translation]: "The Council also decided to start daylight +# saving in Palestine as of one o'clock on Saturday morning, +# 2016-03-26, to provide the clock 60 minutes ahead." +# +# From Paul Eggert (2016-03-12): +# Predict spring transitions on March's last Saturday at 01:00 from now on. +# Leave fall predictions alone for now. + # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S Rule EgyptAsia 1957 only - May 10 0:00 1:00 S Rule EgyptAsia 1957 1958 - Oct 1 0:00 0 - @@ -2408,7 +2588,8 @@ Rule Palestine 2012 2014 - Mar lastThu 2 Rule Palestine 2012 only - Sep 21 1:00 0 - Rule Palestine 2013 only - Sep Fri>=21 0:00 0 - Rule Palestine 2014 max - Oct Fri>=21 0:00 0 - -Rule Palestine 2015 max - Mar lastFri 24:00 1:00 S +Rule Palestine 2015 only - Mar lastFri 24:00 1:00 S +Rule Palestine 2016 max - Mar lastSat 1:00 1:00 S # Zone NAME GMTOFF RULES FORMAT [UNTIL] Zone Asia/Gaza 2:17:52 - LMT 1900 Oct @@ -2496,7 +2677,7 @@ Link Asia/Qatar Asia/Bahrain # earlier date. # # Shanks & Pottenger also state that until 1968-05-01 Saudi Arabia had two -# time zones; the other zone, at UTC+4, was in the far eastern part of +# time zones; the other zone, at UT +04, was in the far eastern part of # the country. Ignore this, as it's before our 1970 cutoff. # # Zone NAME GMTOFF RULES FORMAT [UNTIL] @@ -2765,10 +2946,10 @@ Zone Asia/Damascus 2:25:12 - LMT 1920 # # From Shanks & Pottenger. # Zone NAME GMTOFF RULES FORMAT [UNTIL] Zone Asia/Dushanbe 4:35:12 - LMT 1924 May 2 - 5:00 - DUST 1930 Jun 21 # Dushanbe Time - 6:00 RussiaAsia DUS%sT 1991 Mar 31 2:00s - 5:00 1:00 DUSST 1991 Sep 9 2:00s - 5:00 - TJT # Tajikistan Time + 5:00 - +05 1930 Jun 21 + 6:00 RussiaAsia +06/+07 1991 Mar 31 2:00s + 5:00 1:00 +05/+06 1991 Sep 9 2:00s + 5:00 - +05 # Thailand # Zone NAME GMTOFF RULES FORMAT [UNTIL] @@ -2782,11 +2963,10 @@ Link Asia/Bangkok Asia/Vientiane # Laos # From Shanks & Pottenger. # Zone NAME GMTOFF RULES FORMAT [UNTIL] Zone Asia/Ashgabat 3:53:32 - LMT 1924 May 2 # or Ashkhabad - 4:00 - ASHT 1930 Jun 21 # Ashkhabad Time - 5:00 RussiaAsia ASH%sT 1991 Mar 31 2:00 - 4:00 RussiaAsia ASH%sT 1991 Oct 27 # independence - 4:00 RussiaAsia TM%sT 1992 Jan 19 2:00 - 5:00 - TMT + 4:00 - +04 1930 Jun 21 + 5:00 RussiaAsia +05/+06 1991 Mar 31 2:00 + 4:00 RussiaAsia +04/+05 1992 Jan 19 2:00 + 5:00 - +05 # United Arab Emirates # Zone NAME GMTOFF RULES FORMAT [UNTIL] @@ -2798,20 +2978,18 @@ Link Asia/Dubai Asia/Muscat # Oman # Byalokoz 1919 says Uzbekistan was 4:27:53. # Zone NAME GMTOFF RULES FORMAT [UNTIL] Zone Asia/Samarkand 4:27:53 - LMT 1924 May 2 - 4:00 - SAMT 1930 Jun 21 # Samarkand Time - 5:00 - SAMT 1981 Apr 1 - 5:00 1:00 SAMST 1981 Oct 1 - 6:00 - TAST 1982 Apr 1 # Tashkent Time - 5:00 RussiaAsia SAM%sT 1991 Sep 1 # independence - 5:00 RussiaAsia UZ%sT 1992 - 5:00 - UZT + 4:00 - +04 1930 Jun 21 + 5:00 - +05 1981 Apr 1 + 5:00 1:00 +06 1981 Oct 1 + 6:00 - +06 1982 Apr 1 + 5:00 RussiaAsia +05/+06 1992 + 5:00 - +05 # Milne says Tashkent was 4:37:10.8; round to nearest. Zone Asia/Tashkent 4:37:11 - LMT 1924 May 2 - 5:00 - TAST 1930 Jun 21 # Tashkent Time - 6:00 RussiaAsia TAS%sT 1991 Mar 31 2:00 - 5:00 RussiaAsia TAS%sT 1991 Sep 1 # independence - 5:00 RussiaAsia UZ%sT 1992 - 5:00 - UZT + 5:00 - +05 1930 Jun 21 + 6:00 RussiaAsia +06/+07 1991 Mar 31 2:00 + 5:00 RussiaAsia +05/+06 1992 + 5:00 - +05 # Vietnam Modified: stable/11/contrib/tzdata/australasia ============================================================================== --- stable/11/contrib/tzdata/australasia Sat Oct 15 12:38:50 2016 (r307360) +++ stable/11/contrib/tzdata/australasia Sat Oct 15 12:41:11 2016 (r307361) @@ -60,6 +60,14 @@ Zone Australia/Eucla 8:35:28 - LMT 1895 # Hamilton is the largest, but there is also a Hamilton in Victoria, # so use Lindeman. # +# From J William Piggott (2016-02-20): +# There is no location named Holiday Islands in Queensland Australia; holiday +# islands is a colloquial term used globally. Hayman and Lindeman are at the +# north and south extremes of the Whitsunday Islands archipelago, and +# Hamilton is in between; it is reasonable to believe that this time zone +# applies to all of the Whitsundays. +# http://www.australia.gov.au/about-australia/australian-story/austn-islands +# # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S Rule AQ 1971 only - Oct lastSun 2:00s 1:00 D Rule AQ 1972 only - Feb lastSun 2:00s 0 S @@ -235,11 +243,11 @@ Zone Australia/Lord_Howe 10:36:20 - LMT # will produce a binary file with an [A]EST-type as the first 32-bit type; # this is required for correct handling of times before 1916 by # pre-2013 versions of localtime. -Zone Antarctica/Macquarie 0 - zzz 1899 Nov +Zone Antarctica/Macquarie 0 - -00 1899 Nov 10:00 - AEST 1916 Oct 1 2:00 10:00 1:00 AEDT 1917 Feb 10:00 Aus AE%sT 1919 Apr 1 0:00s - 0 - zzz 1948 Mar 25 + 0 - -00 1948 Mar 25 10:00 Aus AE%sT 1967 10:00 AT AE%sT 2010 Apr 4 3:00 11:00 - MIST # Macquarie I Standard Time @@ -537,7 +545,7 @@ Zone Pacific/Port_Moresby 9:48:40 - LMT # Base the Bougainville entry on the Arawa-Kieta region, which appears to have # the most people even though it was devastated in the Bougainville Civil War. # -# Although Shanks gives 1942-03-15 / 1943-11-01 for JST, these dates +# Although Shanks gives 1942-03-15 / 1943-11-01 for UT +09, these dates # are apparently rough guesswork from the starts of military campaigns. # The World War II entries below are instead based on Arawa-Kieta. # The Japanese occupied Kieta in July 1942, @@ -545,8 +553,8 @@ Zone Pacific/Port_Moresby 9:48:40 - LMT # http://pwencycl.kgbudge.com/B/o/Bougainville.htm # and seem to have controlled it until their 1945-08-21 surrender. # -# The Autonomous Region of Bougainville plans to switch from UTC+10 to UTC+11 -# on 2014-12-28 at 02:00. They call UTC+11 "Bougainville Standard Time"; +# The Autonomous Region of Bougainville switched from UT +10 to +11 +# on 2014-12-28 at 02:00. They call +11 "Bougainville Standard Time"; # abbreviate this as BST. See: # http://www.bougainville24.com/bougainville-issues/bougainville-gets-own-timezone/ # @@ -612,7 +620,7 @@ Link Pacific/Pago_Pago Pacific/Midway # # From Paul Eggert (2014-06-27): # The International Date Line Act 2011 # http://www.parliament.gov.ws/images/ACTS/International_Date_Line_Act__2011_-_Eng.pdf -# changed Samoa from UTC-11 to UTC+13, effective "12 o'clock midnight, on +# changed Samoa from UT -11 to +13, effective "12 o'clock midnight, on # Thursday 29th December 2011". The International Date Line was adjusted # accordingly. @@ -707,7 +715,7 @@ Zone Pacific/Funafuti 11:56:52 - LMT 190 # 1886-1891; Baker was similar but exact dates are not known. # Inhabited by civilians 1935-1942; U.S. military bases 1943-1944; # uninhabited thereafter. -# Howland observed Hawaii Standard Time (UT-10:30) in 1937; +# Howland observed Hawaii Standard Time (UT -10:30) in 1937; # see page 206 of Elgen M. Long and Marie K. Long, # Amelia Earhart: the Mystery Solved, Simon & Schuster (2000). # So most likely Howland and Baker observed Hawaii Time from 1935 @@ -1465,7 +1473,7 @@ Zone Pacific/Wallis 12:15:20 - LMT 1901 # Zealand time. I understand that is the time they keep locally, anyhow." # For now, assume this practice goes back to the introduction of standard time # in New Zealand, as this would make Chatham Islands time almost exactly match -# LMT back when New Zealand was at UTC+11:30; also, assume Chatham Islands did +# LMT back when New Zealand was at UT +11:30; also, assume Chatham Islands did # not observe New Zealand's prewar DST. *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-all@freebsd.org Sat Oct 15 12:41:42 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C7199C133CB; Sat, 15 Oct 2016 12:41:42 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 7E90917F7; Sat, 15 Oct 2016 12:41:42 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9FCff7u035045; Sat, 15 Oct 2016 12:41:41 GMT (envelope-from bapt@FreeBSD.org) Received: (from bapt@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9FCff94035040; Sat, 15 Oct 2016 12:41:41 GMT (envelope-from bapt@FreeBSD.org) Message-Id: <201610151241.u9FCff94035040@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bapt set sender to bapt@FreeBSD.org using -f From: Baptiste Daroussin Date: Sat, 15 Oct 2016 12:41:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307362 - stable/10/contrib/tzdata X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 Oct 2016 12:41:42 -0000 Author: bapt Date: Sat Oct 15 12:41:41 2016 New Revision: 307362 URL: https://svnweb.freebsd.org/changeset/base/307362 Log: MFC r306853 Import tzdata 2016g Modified: stable/10/contrib/tzdata/africa stable/10/contrib/tzdata/antarctica stable/10/contrib/tzdata/asia stable/10/contrib/tzdata/australasia stable/10/contrib/tzdata/backward stable/10/contrib/tzdata/etcetera stable/10/contrib/tzdata/europe stable/10/contrib/tzdata/factory stable/10/contrib/tzdata/leap-seconds.list stable/10/contrib/tzdata/leapseconds stable/10/contrib/tzdata/northamerica stable/10/contrib/tzdata/southamerica stable/10/contrib/tzdata/zone.tab stable/10/contrib/tzdata/zone1970.tab Directory Properties: stable/10/ (props changed) Modified: stable/10/contrib/tzdata/africa ============================================================================== --- stable/10/contrib/tzdata/africa Sat Oct 15 12:41:11 2016 (r307361) +++ stable/10/contrib/tzdata/africa Sat Oct 15 12:41:41 2016 (r307362) @@ -343,6 +343,12 @@ Rule Egypt 2007 only - Sep Thu>=1 24:00 # decision to abandon DST permanently. See Ahram Online 2015-04-24. # http://english.ahram.org.eg/NewsContent/1/64/128509/Egypt/Politics-/Sisi-cancels-daylight-saving-time-in-Egypt.aspx +# From Steffen Thorsen (2016-04-29): +# Egypt will have DST from July 7 until the end of October.... +# http://english.ahram.org.eg/NewsContentP/1/204655/Egypt/Daylight-savings-time-returning-to-Egypt-on--July.aspx +# From Mina Samuel (2016-07-04): +# Egyptian government took the decision to cancel the DST, + Rule Egypt 2008 only - Aug lastThu 24:00 0 - Rule Egypt 2009 only - Aug 20 24:00 0 - Rule Egypt 2010 only - Aug 10 24:00 0 - @@ -458,7 +464,7 @@ Zone Africa/Monrovia -0:43:08 - LMT 1882 # http://www.libyaherald.com/2013/10/24/correction-no-time-change-tomorrow/ # # From Paul Eggert (2013-10-25): -# For now, assume they're reverting to the pre-2012 rules of permanent UTC+2. +# For now, assume they're reverting to the pre-2012 rules of permanent UT +02. # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S Rule Libya 1951 only - Oct 14 2:00 1:00 S @@ -858,11 +864,11 @@ Rule Morocco 2009 only - Aug 21 0:00 0 Rule Morocco 2010 only - May 2 0:00 1:00 S Rule Morocco 2010 only - Aug 8 0:00 0 - Rule Morocco 2011 only - Apr 3 0:00 1:00 S -Rule Morocco 2011 only - Jul 31 0 0 - +Rule Morocco 2011 only - Jul 31 0:00 0 - Rule Morocco 2012 2013 - Apr lastSun 2:00 1:00 S -Rule Morocco 2012 only - Sep 30 3:00 0 - Rule Morocco 2012 only - Jul 20 3:00 0 - Rule Morocco 2012 only - Aug 20 2:00 1:00 S +Rule Morocco 2012 only - Sep 30 3:00 0 - Rule Morocco 2013 only - Jul 7 3:00 0 - Rule Morocco 2013 only - Aug 10 2:00 1:00 S Rule Morocco 2013 max - Oct lastSun 3:00 0 - Modified: stable/10/contrib/tzdata/antarctica ============================================================================== --- stable/10/contrib/tzdata/antarctica Sat Oct 15 12:41:11 2016 (r307361) +++ stable/10/contrib/tzdata/antarctica Sat Oct 15 12:41:41 2016 (r307362) @@ -10,10 +10,8 @@ # http://www.spri.cam.ac.uk/bob/periant.htm # for information. # Unless otherwise specified, we have no time zone information. -# -# Except for the French entries, -# I made up all time zone abbreviations mentioned here; corrections welcome! -# FORMAT is 'zzz' and GMTOFF is 0 for locations while uninhabited. + +# FORMAT is '-00' and GMTOFF is 0 for locations while uninhabited. # Argentina - year-round bases # Belgrano II, Confin Coast, -770227-0343737, since 1972-02-05 @@ -29,7 +27,7 @@ # previously sealers and scientific personnel wintered # Margaret Turner reports # http://web.archive.org/web/20021204222245/http://www.dstc.qut.edu.au/DST/marg/daylight.html -# (1999-09-30) that they're UTC+5, with no DST; +# (1999-09-30) that they're UT +05, with no DST; # presumably this is when they have visitors. # # year-round bases @@ -67,24 +65,23 @@ # http://www.timeanddate.com/news/time/antartica-time-changes-2010.html # Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Antarctica/Casey 0 - zzz 1969 - 8:00 - AWST 2009 Oct 18 2:00 - # Australian Western Std Time - 11:00 - CAST 2010 Mar 5 2:00 # Casey Time - 8:00 - AWST 2011 Oct 28 2:00 - 11:00 - CAST 2012 Feb 21 17:00u - 8:00 - AWST -Zone Antarctica/Davis 0 - zzz 1957 Jan 13 - 7:00 - DAVT 1964 Nov # Davis Time - 0 - zzz 1969 Feb - 7:00 - DAVT 2009 Oct 18 2:00 - 5:00 - DAVT 2010 Mar 10 20:00u - 7:00 - DAVT 2011 Oct 28 2:00 - 5:00 - DAVT 2012 Feb 21 20:00u - 7:00 - DAVT -Zone Antarctica/Mawson 0 - zzz 1954 Feb 13 - 6:00 - MAWT 2009 Oct 18 2:00 # Mawson Time - 5:00 - MAWT +Zone Antarctica/Casey 0 - -00 1969 + 8:00 - +08 2009 Oct 18 2:00 + 11:00 - +11 2010 Mar 5 2:00 + 8:00 - +08 2011 Oct 28 2:00 + 11:00 - +11 2012 Feb 21 17:00u + 8:00 - +08 +Zone Antarctica/Davis 0 - -00 1957 Jan 13 + 7:00 - +07 1964 Nov + 0 - -00 1969 Feb + 7:00 - +07 2009 Oct 18 2:00 + 5:00 - +05 2010 Mar 10 20:00u + 7:00 - +07 2011 Oct 28 2:00 + 5:00 - +05 2012 Feb 21 20:00u + 7:00 - +07 +Zone Antarctica/Mawson 0 - -00 1954 Feb 13 + 6:00 - +06 2009 Oct 18 2:00 + 5:00 - +05 # References: # Casey Weather (1998-02-26) # http://www.antdiv.gov.au/aad/exop/sfo/casey/casey_aws.html @@ -137,8 +134,8 @@ Zone Antarctica/Mawson 0 - zzz 1954 Feb # fishing stations operated variously 1819/1931 # # Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Indian/Kerguelen 0 - zzz 1950 # Port-aux-Français - 5:00 - TFT # ISO code TF Time +Zone Indian/Kerguelen 0 - -00 1950 # Port-aux-Français + 5:00 - +05 # # year-round base in the main continent # Dumont d'Urville, ÃŽle des Pétrels, -6640+14001, since 1956-11 @@ -148,10 +145,10 @@ Zone Indian/Kerguelen 0 - zzz 1950 # Por # It was destroyed by fire on 1952-01-14. # # Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Antarctica/DumontDUrville 0 - zzz 1947 - 10:00 - PMT 1952 Jan 14 # Port-Martin Time - 0 - zzz 1956 Nov - 10:00 - DDUT # Dumont-d'Urville Time +Zone Antarctica/DumontDUrville 0 - -00 1947 + 10:00 - +10 1952 Jan 14 + 0 - -00 1956 Nov + 10:00 - +10 # France & Italy - year-round base # Concordia, -750600+1232000, since 2005 @@ -176,8 +173,8 @@ Zone Antarctica/DumontDUrville 0 - zzz 1 # was established on 1957-01-29. Since Syowa station is still the main # station of Japan, it's appropriate for the principal location. # Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Antarctica/Syowa 0 - zzz 1957 Jan 29 - 3:00 - SYOT # Syowa Time +Zone Antarctica/Syowa 0 - -00 1957 Jan 29 + 3:00 - +03 # See: # NIPR Antarctic Research Activities (1999-08-17) # http://www.nipr.ac.jp/english/ara01.html @@ -214,19 +211,19 @@ Zone Antarctica/Syowa 0 - zzz 1957 Jan 2 # correct, but they should be quite close to the actual dates. # # From Paul Eggert (2014-03-21): -# The CET-switching Troll rules require zic from tzcode 2014b or later, so as +# The CET-switching Troll rules require zic from tz 2014b or later, so as # suggested by Bengt-Inge Larsson comment them out for now, and approximate # with only UTC and CEST. Uncomment them when 2014b is more prevalent. # # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -#Rule Troll 2005 max - Mar 1 1:00u 1:00 CET -Rule Troll 2005 max - Mar lastSun 1:00u 2:00 CEST -#Rule Troll 2005 max - Oct lastSun 1:00u 1:00 CET -#Rule Troll 2004 max - Nov 7 1:00u 0:00 UTC +#Rule Troll 2005 max - Mar 1 1:00u 1:00 +01 +Rule Troll 2005 max - Mar lastSun 1:00u 2:00 +02 +#Rule Troll 2005 max - Oct lastSun 1:00u 1:00 +01 +#Rule Troll 2004 max - Nov 7 1:00u 0:00 +00 # Remove the following line when uncommenting the above '#Rule' lines. -Rule Troll 2004 max - Oct lastSun 1:00u 0:00 UTC +Rule Troll 2004 max - Oct lastSun 1:00u 0:00 +00 # Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Antarctica/Troll 0 - zzz 2005 Feb 12 +Zone Antarctica/Troll 0 - -00 2005 Feb 12 0:00 Troll %s # Poland - year-round base @@ -265,10 +262,10 @@ Zone Antarctica/Troll 0 - zzz 2005 Feb 1 # changes during the year and does not necessarily correspond to mean # solar noon. So the Vostok time might have been whatever the clocks # happened to be during their visit. So we still don't really know what time -# it is at Vostok. But we'll guess UTC+6. +# it is at Vostok. But we'll guess +06. # -Zone Antarctica/Vostok 0 - zzz 1957 Dec 16 - 6:00 - VOST # Vostok time +Zone Antarctica/Vostok 0 - -00 1957 Dec 16 + 6:00 - +06 # S Africa - year-round bases # Marion Island, -4653+03752 @@ -300,8 +297,8 @@ Zone Antarctica/Vostok 0 - zzz 1957 Dec # says Rothera is -03 all year. # # Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Antarctica/Rothera 0 - zzz 1976 Dec 1 - -3:00 - ROTT # Rothera time +Zone Antarctica/Rothera 0 - -00 1976 Dec 1 + -3:00 - -03 # Uruguay - year round base # Artigas, King George Island, -621104-0585107 Modified: stable/10/contrib/tzdata/asia ============================================================================== --- stable/10/contrib/tzdata/asia Sat Oct 15 12:41:11 2016 (r307361) +++ stable/10/contrib/tzdata/asia Sat Oct 15 12:41:41 2016 (r307362) @@ -79,13 +79,9 @@ Rule E-EurAsia 1979 1995 - Sep lastSun Rule E-EurAsia 1996 max - Oct lastSun 0:00 0 - Rule RussiaAsia 1981 1984 - Apr 1 0:00 1:00 S Rule RussiaAsia 1981 1983 - Oct 1 0:00 0 - -Rule RussiaAsia 1984 1991 - Sep lastSun 2:00s 0 - -Rule RussiaAsia 1985 1991 - Mar lastSun 2:00s 1:00 S -Rule RussiaAsia 1992 only - Mar lastSat 23:00 1:00 S -Rule RussiaAsia 1992 only - Sep lastSat 23:00 0 - -Rule RussiaAsia 1993 max - Mar lastSun 2:00s 1:00 S -Rule RussiaAsia 1993 1995 - Sep lastSun 2:00s 0 - -Rule RussiaAsia 1996 max - Oct lastSun 2:00s 0 - +Rule RussiaAsia 1984 1995 - Sep lastSun 2:00s 0 - +Rule RussiaAsia 1985 2011 - Mar lastSun 2:00s 1:00 S +Rule RussiaAsia 1996 2011 - Oct lastSun 2:00s 0 - # Afghanistan # Zone NAME GMTOFF RULES FORMAT [UNTIL] @@ -120,31 +116,37 @@ Zone Asia/Kabul 4:36:48 - LMT 1890 # http://www.worldtimezone.com/dst_news/dst_news_armenia03.html # Zone NAME GMTOFF RULES FORMAT [UNTIL] Zone Asia/Yerevan 2:58:00 - LMT 1924 May 2 - 3:00 - YERT 1957 Mar # Yerevan Time - 4:00 RussiaAsia YER%sT 1991 Mar 31 2:00s - 3:00 1:00 YERST 1991 Sep 23 # independence - 3:00 RussiaAsia AM%sT 1995 Sep 24 2:00s - 4:00 - AMT 1997 - 4:00 RussiaAsia AM%sT 2012 Mar 25 2:00s - 4:00 - AMT + 3:00 - +03 1957 Mar + 4:00 RussiaAsia +04/+05 1991 Mar 31 2:00s + 3:00 RussiaAsia +03/+04 1995 Sep 24 2:00s + 4:00 - +04 1997 + 4:00 RussiaAsia +04/+05 # Azerbaijan + # From Rustam Aliyev of the Azerbaijan Internet Forum (2005-10-23): # According to the resolution of Cabinet of Ministers, 1997 # From Paul Eggert (2015-09-17): It was Resolution No. 21 (1997-03-17). # http://code.az/files/daylight_res.pdf + +# From Steffen Thorsen (2016-03-17): +# ... the Azerbaijani Cabinet of Ministers has cancelled switching to +# daylight saving time.... +# http://www.azernews.az/azerbaijan/94137.html +# http://vestnikkavkaza.net/news/Azerbaijani-Cabinet-of-Ministers-cancels-daylight-saving-time.html +# http://en.apa.az/xeber_azerbaijan_abolishes_daylight_savings_ti_240862.html + # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule Azer 1997 max - Mar lastSun 4:00 1:00 S -Rule Azer 1997 max - Oct lastSun 5:00 0 - +Rule Azer 1997 2015 - Mar lastSun 4:00 1:00 S +Rule Azer 1997 2015 - Oct lastSun 5:00 0 - # Zone NAME GMTOFF RULES FORMAT [UNTIL] Zone Asia/Baku 3:19:24 - LMT 1924 May 2 - 3:00 - BAKT 1957 Mar # Baku Time - 4:00 RussiaAsia BAK%sT 1991 Mar 31 2:00s - 3:00 1:00 BAKST 1991 Aug 30 # independence - 3:00 RussiaAsia AZ%sT 1992 Sep lastSat 23:00 - 4:00 - AZT 1996 # Azerbaijan Time - 4:00 EUAsia AZ%sT 1997 - 4:00 Azer AZ%sT + 3:00 - +03 1957 Mar + 4:00 RussiaAsia +04/+05 1991 Mar 31 2:00s + 3:00 RussiaAsia +03/+04 1992 Sep lastSun 2:00s + 4:00 - +04 1996 + 4:00 EUAsia +04/+05 1997 + 4:00 Azer +04/+05 # Bahrain # See Asia/Qatar. @@ -263,7 +265,7 @@ Zone Asia/Brunei 7:39:40 - LMT 1926 Mar # Milne says 6:24:40 was the meridian of the time ball observatory at Rangoon. # Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Asia/Rangoon 6:24:40 - LMT 1880 # or Yangon +Zone Asia/Yangon 6:24:40 - LMT 1880 # or Rangoon 6:24:40 - RMT 1920 # Rangoon Mean Time? 6:30 - BURT 1942 May # Burma Time 9:00 - JST 1945 May 3 @@ -378,7 +380,7 @@ Rule PRC 1987 1991 - Apr Sun>=10 0:00 1: # Lewiston (ME) Daily Sun (1939-05-29), p 17, said "Even the time is # different - the occupied districts going by Tokyo time, an hour # ahead of that prevailing in the rest of Shanghai." Guess that the -# Xujiahui Observatory was under French control and stuck with UT+8. +# Xujiahui Observatory was under French control and stuck with UT +08. # # In earlier versions of this file, China had many separate Zone entries, but # this was based on what were apparently incorrect data in Shanks & Pottenger. @@ -387,26 +389,26 @@ Rule PRC 1987 1991 - Apr Sun>=10 0:00 1: # Proposed in 1918 and theoretically in effect until 1949 (although in practice # mainly observed in coastal areas), the five zones were: # -# Changbai Time ("Long-white Time", Long-white = Heilongjiang area) UT+8.5 +# Changbai Time ("Long-white Time", Long-white = Heilongjiang area) UT +08:30 # Asia/Harbin (currently a link to Asia/Shanghai) # Heilongjiang (except Mohe county), Jilin # -# Zhongyuan Time ("Central plain Time") UT+8 +# Zhongyuan Time ("Central plain Time") UT +08 # Asia/Shanghai # most of China # This currently represents most other zones as well, # as apparently these regions have been the same since 1970. # Milne gives 8:05:43.2 for Xujiahui Observatory time; round to nearest. -# Guo says Shanghai switched to UT+8 "from the end of the 19th century". +# Guo says Shanghai switched to UT +08 "from the end of the 19th century". # -# Long-shu Time (probably due to Long and Shu being two names of that area) UT+7 +# Long-shu Time (probably due to Long and Shu being two names of the area) UT +07 # Asia/Chongqing (currently a link to Asia/Shanghai) # Guangxi, Guizhou, Hainan, Ningxia, Sichuan, Shaanxi, and Yunnan; # most of Gansu; west Inner Mongolia; west Qinghai; and the Guangdong # counties Deqing, Enping, Kaiping, Luoding, Taishan, Xinxing, # Yangchun, Yangjiang, Yu'nan, and Yunfu. # -# Xin-zang Time ("Xinjiang-Tibet Time") UT+6 +# Xin-zang Time ("Xinjiang-Tibet Time") UT +06 # Asia/Urumqi # This currently represents Kunlun Time as well, # as apparently the two regions have been the same since 1970. @@ -419,7 +421,7 @@ Rule PRC 1987 1991 - Apr Sun>=10 0:00 1: # Shihezi, Changji, Yanqi, Heshuo, Tuokexun, Tulufan, Shanshan, Hami, # Fukang, Kuitun, Kumukuli, Miquan, Qitai, and Turfan. # -# Kunlun Time UT+5.5 +# Kunlun Time UT +05:30 # Asia/Kashgar (currently a link to Asia/Urumqi) # West Tibet, including Pulan, Aheqi, Shufu, Shule; # West Xinjiang, including Aksu, Atushi, Yining, Hetian, Cele, Luopu, Nileke, @@ -435,7 +437,7 @@ Rule PRC 1987 1991 - Apr Sun>=10 0:00 1: # # On the other hand, ethnic Uyghurs, who make up about half the # population of Xinjiang, typically use "Xinjiang time" which is two -# hours behind Beijing time, or UTC +0600. The government of the Xinjiang +# hours behind Beijing time, or UT +06. The government of the Xinjiang # Uyghur Autonomous Region, (XAUR, or just Xinjiang for short) as well as # local governments such as the Ãœrümqi city government use both times in # publications, referring to what is popularly called Xinjiang time as @@ -491,8 +493,8 @@ Rule PRC 1987 1991 - Apr Sun>=10 0:00 1: # having the same time as Beijing. # From Paul Eggert (2014-06-30): -# In the early days of the PRC, Tibet was given its own time zone (UT+6) but -# this was withdrawn in 1959 and never reinstated; see Tubten Khétsun, +# In the early days of the PRC, Tibet was given its own time zone (UT +06) +# but this was withdrawn in 1959 and never reinstated; see Tubten Khétsun, # Memories of life in Lhasa under Chinese Rule, Columbia U Press, ISBN # 978-0231142861 (2008), translator's introduction by Matthew Akester, p x. # As this is before our 1970 cutoff, Tibet doesn't need a separate zone. @@ -506,12 +508,12 @@ Rule PRC 1987 1991 - Apr Sun>=10 0:00 1: # Republics, the Soviet Union, the Kuomintang, and the People's Republic of # China, and tracking down all these organizations' timekeeping rules would be # quite a trick. Approximate this lost history by a transition from LMT to -# XJT at the start of 1928, the year of accession of the warlord Jin Shuren, +# UT +06 at the start of 1928, the year of accession of the warlord Jin Shuren, # which happens to be the date given by Shanks & Pottenger (no doubt as a -# guess) as the transition from LMT. Ignore the usage of UT+8 before -# 1986-02-01 under the theory that the transition date to UT+8 is unknown and +# guess) as the transition from LMT. Ignore the usage of +08 before +# 1986-02-01 under the theory that the transition date to +08 is unknown and # that the sort of users who prefer Asia/Urumqi now typically ignored the -# UT+8 mandate back then. +# +08 mandate back then. # Zone NAME GMTOFF RULES FORMAT [UNTIL] # Beijing time, used throughout China; represented by Shanghai. @@ -716,7 +718,7 @@ Zone Asia/Hong_Kong 7:36:42 - LMT 1904 O # be found from historical government announcement database. # From Paul Eggert (2014-07-03): -# As per Yu-Cheng Chuang, say that Taiwan was at UT+9 from 1937-10-01 +# As per Yu-Cheng Chuang, say that Taiwan was at UT +09 from 1937-10-01 # until 1945-09-21 at 01:00, overriding Shanks & Pottenger. # Likewise, use Yu-Cheng Chuang's data for DST in Taiwan. @@ -830,16 +832,15 @@ Link Asia/Nicosia Europe/Nicosia # Zone NAME GMTOFF RULES FORMAT [UNTIL] Zone Asia/Tbilisi 2:59:11 - LMT 1880 2:59:11 - TBMT 1924 May 2 # Tbilisi Mean Time - 3:00 - TBIT 1957 Mar # Tbilisi Time - 4:00 RussiaAsia TBI%sT 1991 Mar 31 2:00s - 3:00 1:00 TBIST 1991 Apr 9 # independence - 3:00 RussiaAsia GE%sT 1992 # Georgia Time - 3:00 E-EurAsia GE%sT 1994 Sep lastSun - 4:00 E-EurAsia GE%sT 1996 Oct lastSun - 4:00 1:00 GEST 1997 Mar lastSun - 4:00 E-EurAsia GE%sT 2004 Jun 27 - 3:00 RussiaAsia GE%sT 2005 Mar lastSun 2:00 - 4:00 - GET + 3:00 - +03 1957 Mar + 4:00 RussiaAsia +04/+05 1991 Mar 31 2:00s + 3:00 RussiaAsia +03/+04 1992 + 3:00 E-EurAsia +03/+04 1994 Sep lastSun + 4:00 E-EurAsia +04/+05 1996 Oct lastSun + 4:00 1:00 +05 1997 Mar lastSun + 4:00 E-EurAsia +04/+05 2004 Jun 27 + 3:00 RussiaAsia +03/+04 2005 Mar lastSun 2:00 + 4:00 - +04 # East Timor @@ -874,6 +875,15 @@ Zone Asia/Dili 8:22:20 - LMT 1912 Jan 1 9:00 - TLT # India + +# From Ian P. Beacock, in "A brief history of (modern) time", The Atlantic +# http://www.theatlantic.com/technology/archive/2015/12/the-creation-of-modern-time/421419/ +# (2015-12-22): +# In January 1906, several thousand cotton-mill workers rioted on the +# outskirts of Bombay.... They were protesting the proposed abolition of +# local time in favor of Indian Standard Time.... Journalists called this +# dispute the "Battle of the Clocks." It lasted nearly half a century. + # Zone NAME GMTOFF RULES FORMAT [UNTIL] Zone Asia/Kolkata 5:53:28 - LMT 1880 # Kolkata 5:53:20 - HMT 1941 Oct # Howrah Mean Time? @@ -907,7 +917,7 @@ Zone Asia/Kolkata 5:53:28 - LMT 1880 # These would be the earliest possible times for a change. # Régimes horaires pour le monde entier, by Henri Le Corre, (Éditions # Traditionnelles, 1987, Paris) says that Java and Madura switched -# from JST to UTC+07:30 on 1945-09-23, and gives 1944-09-01 for Jayapura +# from UT +09 to +07:30 on 1945-09-23, and gives 1944-09-01 for Jayapura # (Hollandia). For now, assume all Indonesian locations other than Jayapura # switched on 1945-09-23. # @@ -918,11 +928,11 @@ Zone Asia/Kolkata 5:53:28 - LMT 1880 # summary published by the Time and Frequency Laboratory of the # Research Center for Calibration, Instrumentation and Metrology, # Indonesia, (2006-09-29). -# The abbreviations are: +# The time zone abbreviations and UT offsets are: # -# WIB - UTC+7 - Waktu Indonesia Barat (Indonesia western time) -# WITA - UTC+8 - Waktu Indonesia Tengah (Indonesia central time) -# WIT - UTC+9 - Waktu Indonesia Timur (Indonesia eastern time) +# WIB - +07 - Waktu Indonesia Barat (Indonesia western time) +# WITA - +08 - Waktu Indonesia Tengah (Indonesia central time) +# WIT - +09 - Waktu Indonesia Timur (Indonesia eastern time) # # Zone NAME GMTOFF RULES FORMAT [UNTIL] # Java, Sumatra @@ -1084,8 +1094,15 @@ Rule Iran 2032 2033 - Mar 21 0:00 1:00 D Rule Iran 2032 2033 - Sep 21 0:00 0 S Rule Iran 2034 2035 - Mar 22 0:00 1:00 D Rule Iran 2034 2035 - Sep 22 0:00 0 S -Rule Iran 2036 2037 - Mar 21 0:00 1:00 D -Rule Iran 2036 2037 - Sep 21 0:00 0 S +# +# The following rules are approximations starting in the year 2038. +# These are the best post-2037 approximations available, given the +# restrictions of a single rule using a Gregorian-based data format. +# At some point this table will need to be extended, though quite +# possibly Iran will change the rules first. +Rule Iran 2036 max - Mar 21 0:00 1:00 D +Rule Iran 2036 max - Sep 21 0:00 0 S + # Zone NAME GMTOFF RULES FORMAT [UNTIL] Zone Asia/Tehran 3:25:44 - LMT 1916 3:25:44 - TMT 1946 # Tehran Mean Time @@ -1542,23 +1559,6 @@ Zone Asia/Amman 2:23:44 - LMT 1931 # Kazakhstan -# From Paul Eggert (1996-11-22): -# Andrew Evtichov (1996-04-13) writes that Kazakhstan -# stayed in sync with Moscow after 1990, and that Aqtobe (formerly Aktyubinsk) -# and Aqtau (formerly Shevchenko) are the largest cities in their zones. -# Guess that Aqtau and Aqtobe diverged in 1995, since that's the first time -# IATA SSIM mentions a third time zone in Kazakhstan. - -# From Paul Eggert (2006-03-22): -# German Iofis, ELSI, Almaty (2001-10-09) reports that Kazakhstan uses -# RussiaAsia rules, instead of switching at 00:00 as the IATA has it. -# Go with Shanks & Pottenger, who have them always using RussiaAsia rules. -# Also go with the following claims of Shanks & Pottenger: -# -# - Kazakhstan did not observe DST in 1991. -# - Qyzylorda switched from +5:00 to +6:00 on 1992-01-19 02:00. -# - Oral switched from +5:00 to +4:00 in spring 1989. - # From Kazakhstan Embassy's News Bulletin No. 11 # (2005-03-21): # The Government of Kazakhstan passed a resolution March 15 abolishing @@ -1575,61 +1575,232 @@ Zone Asia/Amman 2:23:44 - LMT 1931 # everything else.... I guess that would make Kazakhstan time zones # de jure UTC+5 and UTC+6 respectively. +# From Stepan Golosunov (2016-03-27) ([*] means see later comments below): +# Review of the linked documents from http://adilet.zan.kz/ +# produced the following data for post-1991 Kazakhstan: +# +# 0. Act of the Cabinet of Ministers of the USSR +# from 1991-02-04 No. 20 +# http://pravo.gov.ru/proxy/ips/?docbody=&nd=102010545 +# removed the extra hour ("decree time") on the territory of the USSR +# starting with the last Sunday of March 1991. +# It also allowed (but not mandated) Kazakh SSR, Kirghiz SSR, Tajik SSR, +# Turkmen SSR and Uzbek SSR to not have "summer" time. +# +# The 1992-01-13 act also refers to the act of the Cabinet of Ministers +# of the Kazakh SSR from 1991-03-20 No. 170 "About the act of the Cabinet +# of Ministers of the USSR from 1991-02-04 No. 20" but I didn't found its +# text. +# +# According to Izvestia newspaper No. 68 (23334) from 1991-03-20 +# (page 6; available at http://libinfo.org/newsr/newsr2574.djvu via +# http://libinfo.org/index.php?id=58564) on 1991-03-31 at 2:00 during +# transition to "summer" time: +# Republic of Georgia, Latvian SSR, Lithuanian SSR, SSR Moldova, +# Estonian SSR; Komi ASSR; Kaliningrad oblast; Nenets autonomous okrug +# were to move clocks 1 hour forward. +# Kazakh SSR (excluding Uralsk oblast); Republic of Kyrgyzstan, Tajik +# SSR; Andijan, Jizzakh, Namangan, Sirdarya, Tashkent, Fergana oblasts +# of the Uzbek SSR were to move clocks 1 hour backwards. +# Other territories were to not move clocks. +# When the "summer" time would end on 1991-09-29, clocks were to be +# moved 1 hour backwards on the territory of the USSR excluding +# Kazakhstan, Kirghizia, Uzbekistan, Turkmenia, Tajikistan. +# +# Apparently there were last minute changes. Apparently Kazakh act No. 170 +# was one of such changes. +# +# https://ru.wikipedia.org/wiki/Декретное Ð²Ñ€ÐµÐ¼Ñ +# claims that Sovetskaya Rossiya newspaper on 1991-03-29 published that +# Nenets autonomous okrug, Komi and Kazakhstan (excluding Uralsk oblast) +# were to not move clocks and Uralsk oblast was to move clocks +# forward; on 1991-09-29 Kazakhstan was to move clocks backwards. +# (Probably there were changes even after that publication. There is an +# article claiming that Kaliningrad oblast decided on 1991-03-29 to not +# move clocks.) +# +# This implies that on 1991-03-31 Asia/Oral remained on +04/+05 while +# the rest of Kazakhstan switched from +06/+07 to +05/06 or from +05/06 +# to +04/+05. It's unclear how Kzyl-Orda oblast moved into the fifth +# time belt. (By switching from +04/+05 to +05/+06 on 1991-09-29?) ... +# +# 1. Act of the Cabinet of Ministers of the Republic of Kazakhstan +# from 1992-01-13 No. 28 +# http://adilet.zan.kz/rus/docs/P920000028_ +# (text includes modification from the 1996 act) +# introduced new rules for calculation of time, mirroring Russian +# 1992-01-08 act. It specified that time would be calculated +# according to time belts plus extra hour ("decree time"), moved clocks +# on the whole territory of Kazakhstan 1 hour forward on 1992-01-19 at +# 2:00, specified DST rules. It acknowledged that Kazakhstan was +# located in the fourth and the fifth time belts and specified the +# border between them to be located east of Kustanay and Aktyubinsk +# oblasts (notably including Turgai and Kzyl-Orda oblasts into the fifth +# time belt). +# +# This means switch on 1992-01-19 at 2:00 from +04/+05 to +05/+06 for +# Asia/Aqtau, Asia/Aqtobe, Asia/Oral, Atyrau and Kustanay oblasts; from +# +05/+06 to +06/+07 for Asia/Almaty and Asia/Qyzylorda (and Arkalyk) [*].... +# +# 2. Act of the Cabinet of Ministers of the Republic of Kazakhstan +# from 1992-03-27 No. 284 +# http://adilet.zan.kz/rus/docs/P920000284_ +# cancels extra hour ("decree time") for Uralsk and Kzyl-Orda oblasts +# since the last Sunday of March 1992, while keeping them in the fourth +# and the fifth time belts respectively. +# +# 3. Order of the Prime Minister of the Republic of Kazakhstan +# from 1994-09-23 No. 384 +# http://adilet.zan.kz/rus/docs/R940000384_ +# cancels the extra hour ("decree time") on the territory of Mangystau +# oblast since the last Sunday of September 1994 (saying that time on +# the territory would correspond to the third time belt as a +# result).... +# +# 4. Act of the Government of the Republic of Kazakhstan +# from 1996-05-08 No. 575 +# http://adilet.zan.kz/rus/docs/P960000575_ +# amends the 1992-01-13 act to end summer time in October instead +# of September, mirroring identical Russian change from 1996-04-23 act. +# +# 5. Act of the Government of the Republic of Kazakhstan +# from 1999-03-26 No. 305 +# http://adilet.zan.kz/rus/docs/P990000305_ +# cancels the extra hour ("decree time") for Atyrau oblast since the +# last Sunday of March 1999 while retaining the oblast in the fourth +# time belt. +# +# This means change from +05/+06 to +04/+05. +# +# There is no zone for Atyrau currently (listed under Asia/Aqtau in +# zone1970.tab).[*] +# +# 6. Act of the Government of the Republic of Kazakhstan +# from 2000-11-23 No. 1749 +# http://adilet.zan.kz/rus/archive/docs/P000001749_/23.11.2000 +# replaces the previous five documents. +# +# The only changes I noticed are in definition of the border between the +# fourth and the fifth time belts. They account for changes in spelling +# and administrative division (splitting of Turgai oblast in 1997 +# probably changed time in territories incorporated into Kostanay oblast +# (including Arkalyk) from +06/+07 to +05/+06) and move Kyzylorda oblast +# from being in the fifth time belt and not using decree time into the +# fourth time belt (no change in practice).[*] +# +# 7. Act of the Government of the Republic of Kazakhstan +# from 2003-12-29 No. 1342 +# http://adilet.zan.kz/rus/docs/P030001342_ +# modified the 2000-11-23 act. No relevant changes, apparently. +# +# 8. Act of the Government of the Republic of Kazakhstan +# from 2004-07-20 No. 775 +# http://adilet.zan.kz/rus/archive/docs/P040000775_/20.07.2004 +# modified the 2000-11-23 act to move Kostanay and Kyzylorda oblasts into +# the fifth time belt and add Aktobe oblast to the list of regions not +# using extra hour ("decree time"), leaving Kazakhstan with only 2 time +# zones (+04/+05 and +06/+07). The changes were to be implemented +# during DST transitions in 2004 and 2005 but the acts got radically +# amended before implementation happened. +# +# 9. Act of the Government of the Republic of Kazakhstan +# from 2004-09-15 No. 1059 +# http://adilet.zan.kz/rus/docs/P040001059_ +# modified the 2000-11-23 act to remove exceptions from the "decree time" +# (leaving Kazakhstan in +05/+06 and +06/+07 zones), amended the +# 2004-07-20 act to implement changes for Atyrau, West Kazakhstan, +# Kostanay, Kyzylorda and Mangystau oblasts by not moving clocks +# during the 2014 transition to "winter" time. +# +# This means transition from +04/+05 to +05/+06 for Atyrau oblast (no +# zone currently), Asia/Oral, Asia/Aqtau and transition from +05/+06 to +# +06/+07 for Kostanay oblast (Kostanay and Arkalyk, no zones currently) +# and Asia/Qyzylorda on 2004-10-31 at 3:00....[*] +# +# 10. Act of the Government of the Republic of Kazakhstan +# from 2005-03-15 No. 231 +# http://adilet.zan.kz/rus/docs/P050000231_ +# removes DST provisions from the 2000-11-23 act, removes most of the +# (already implemented) provisions from the 2004-07-20 and 2004-09-15 +# acts, comes into effect 10 days after official publication. +# The only practical effect seems to be the abolition of the summer +# time. +# +# Unamended version of the act of the Government of the Russian Federation +# No. 23 from 1992-01-08 [See 'europe' file for details]. +# Kazakh 1992-01-13 act appears to provide the same rules and 1992-03-27 +# act was to be enacted on the last Sunday of March 1992. + +# From Paul Eggert (2016-04-15): +# The tables below should reflect Stepan Golosunov's remarks above, +# except for the items marked "[*]" which I haven't gotten to yet. +# It looks like we will need new zones Asia/Atyrau and Asia/Qostanay +# to handle changes from 1992 through 2004 that we did not previously +# know about. + # # Zone NAME GMTOFF RULES FORMAT [UNTIL] # # Almaty (formerly Alma-Ata), representing most locations in Kazakhstan +# This includes KZ-AKM, KZ-ALA, KZ-ALM, KZ-AST, KZ-BAY, KZ-VOS, KZ-ZHA, +# KZ-KAR, KZ-SEV, KZ-PAV, and KZ-YUZ. Zone Asia/Almaty 5:07:48 - LMT 1924 May 2 # or Alma-Ata - 5:00 - ALMT 1930 Jun 21 # Alma-Ata Time - 6:00 RussiaAsia ALM%sT 1991 - 6:00 - ALMT 1992 - 6:00 RussiaAsia ALM%sT 2005 Mar 15 - 6:00 - ALMT -# Qyzylorda (aka Kyzylorda, Kizilorda, Kzyl-Orda, etc.) + 5:00 - +05 1930 Jun 21 + 6:00 RussiaAsia +06/+07 1991 Mar 31 2:00s + 5:00 RussiaAsia +05/+06 1992 Jan 19 2:00s + 6:00 RussiaAsia +06/+07 2004 Oct 31 2:00s + 6:00 - +06 +# Qyzylorda (aka Kyzylorda, Kizilorda, Kzyl-Orda, etc.) (KZ-KZY) Zone Asia/Qyzylorda 4:21:52 - LMT 1924 May 2 - 4:00 - KIZT 1930 Jun 21 # Kizilorda Time - 5:00 - KIZT 1981 Apr 1 - 5:00 1:00 KIZST 1981 Oct 1 - 6:00 - KIZT 1982 Apr 1 - 5:00 RussiaAsia KIZ%sT 1991 - 5:00 - KIZT 1991 Dec 16 # independence - 5:00 - QYZT 1992 Jan 19 2:00 - 6:00 RussiaAsia QYZ%sT 2005 Mar 15 - 6:00 - QYZT -# Aqtobe (aka Aktobe, formerly Aktyubinsk) + 4:00 - +04 1930 Jun 21 + 5:00 - +05 1981 Apr 1 + 5:00 1:00 +06 1981 Oct 1 + 6:00 - +06 1982 Apr 1 + 5:00 RussiaAsia +05/+06 1991 Mar 31 2:00s + 4:00 RussiaAsia +04/+05 1991 Sep 29 2:00s + 5:00 RussiaAsia +05/+06 1992 Jan 19 2:00s + 6:00 RussiaAsia +06/+07 1992 Mar 29 2:00s + 5:00 RussiaAsia +05/+06 2004 Oct 31 2:00s + 6:00 - +06 +# Aqtobe (aka Aktobe, formerly Aktyubinsk) (KZ-AKT) Zone Asia/Aqtobe 3:48:40 - LMT 1924 May 2 - 4:00 - AKTT 1930 Jun 21 # Aktyubinsk Time - 5:00 - AKTT 1981 Apr 1 - 5:00 1:00 AKTST 1981 Oct 1 - 6:00 - AKTT 1982 Apr 1 - 5:00 RussiaAsia AKT%sT 1991 - 5:00 - AKTT 1991 Dec 16 # independence - 5:00 RussiaAsia AQT%sT 2005 Mar 15 # Aqtobe Time - 5:00 - AQTT -# Mangghystau + 4:00 - +04 1930 Jun 21 + 5:00 - +05 1981 Apr 1 + 5:00 1:00 +06 1981 Oct 1 + 6:00 - +06 1982 Apr 1 + 5:00 RussiaAsia +05/+06 1991 Mar 31 2:00s + 4:00 RussiaAsia +04/+05 1992 Jan 19 2:00s + 5:00 RussiaAsia +05/+06 2004 Oct 31 2:00s + 5:00 - +05 +# Qostanay (KZ-KUS) + +# Mangghystau (KZ-MAN) # Aqtau was not founded until 1963, but it represents an inhabited region, # so include time stamps before 1963. Zone Asia/Aqtau 3:21:04 - LMT 1924 May 2 - 4:00 - FORT 1930 Jun 21 # Fort Shevchenko T - 5:00 - FORT 1963 - 5:00 - SHET 1981 Oct 1 # Shevchenko Time - 6:00 - SHET 1982 Apr 1 - 5:00 RussiaAsia SHE%sT 1991 - 5:00 - SHET 1991 Dec 16 # independence - 5:00 RussiaAsia AQT%sT 1995 Mar lastSun 2:00 # Aqtau Time - 4:00 RussiaAsia AQT%sT 2005 Mar 15 - 5:00 - AQTT -# West Kazakhstan + 4:00 - +04 1930 Jun 21 + 5:00 - +05 1963 + 5:00 - +05 1981 Oct 1 + 6:00 - +06 1982 Apr 1 + 5:00 RussiaAsia +05/+06 1991 Mar 31 2:00s + 4:00 RussiaAsia +04/+05 1992 Jan 19 2:00s + 5:00 RussiaAsia +05/+06 1994 Sep 25 2:00s + 4:00 RussiaAsia +04/+05 2004 Oct 31 2:00s + 5:00 - +05 + +# West Kazakhstan (KZ-ZAP) +# From Paul Eggert (2016-03-18): +# The 1989 transition is from USSR act No. 227 (1989-03-14). Zone Asia/Oral 3:25:24 - LMT 1924 May 2 # or Ural'sk - 4:00 - URAT 1930 Jun 21 # Ural'sk time - 5:00 - URAT 1981 Apr 1 - 5:00 1:00 URAST 1981 Oct 1 - 6:00 - URAT 1982 Apr 1 - 5:00 RussiaAsia URA%sT 1989 Mar 26 2:00 - 4:00 RussiaAsia URA%sT 1991 - 4:00 - URAT 1991 Dec 16 # independence - 4:00 RussiaAsia ORA%sT 2005 Mar 15 # Oral Time - 5:00 - ORAT + 4:00 - +04 1930 Jun 21 + 5:00 - +05 1981 Apr 1 + 5:00 1:00 +06 1981 Oct 1 + 6:00 - +06 1982 Apr 1 + 5:00 RussiaAsia +05/+06 1989 Mar 26 2:00s + 4:00 RussiaAsia +04/+05 1992 Jan 19 2:00s + 5:00 RussiaAsia +05/+06 1992 Mar 29 2:00s + 4:00 RussiaAsia +04/+05 2004 Oct 31 2:00s + 5:00 - +05 # Kyrgyzstan (Kirgizstan) # Transitions through 1991 are from Shanks & Pottenger. @@ -1650,11 +1821,11 @@ Rule Kyrgyz 1997 2005 - Mar lastSun 2:30 Rule Kyrgyz 1997 2004 - Oct lastSun 2:30 0 - # Zone NAME GMTOFF RULES FORMAT [UNTIL] Zone Asia/Bishkek 4:58:24 - LMT 1924 May 2 - 5:00 - FRUT 1930 Jun 21 # Frunze Time - 6:00 RussiaAsia FRU%sT 1991 Mar 31 2:00s - 5:00 1:00 FRUST 1991 Aug 31 2:00 # independence - 5:00 Kyrgyz KG%sT 2005 Aug 12 # Kyrgyzstan Time - 6:00 - KGT + 5:00 - +05 1930 Jun 21 + 6:00 RussiaAsia +06/+07 1991 Mar 31 2:00s + 5:00 RussiaAsia +05/+06 1991 Aug 31 2:00 + 5:00 Kyrgyz +05/+06 2005 Aug 12 + 6:00 - +06 ############################################################################### @@ -1693,25 +1864,24 @@ Rule ROK 1957 1960 - Sep Sun>=18 0:00 0 Rule ROK 1987 1988 - May Sun>=8 2:00 1:00 D Rule ROK 1987 1988 - Oct Sun>=8 3:00 0 S -# From Paul Eggert (2014-10-30): +# From Paul Eggert (2016-08-23): # The Korean Wikipedia entry gives the following sources for UT offsets: # -# 1908: Official Journal Article No. 3994 (Edict No. 5) +# 1908: Official Journal Article No. 3994 (decree No. 5) # 1912: Governor-General of Korea Official Gazette Issue No. 367 # (Announcement No. 338) # 1954: Presidential Decree No. 876 (1954-03-17) # 1961: Law No. 676 (1961-08-07) -# 1987: Law No. 3919 (1986-12-31) # -# The Wikipedia entry also has confusing information about a change -# to UT+9 in April 1910, but then what would be the point of the later change -# to UT+9 on 1912-01-01? Omit the 1910 change for now. +# (Another source "1987: Law No. 3919 (1986-12-31)" was in the 2014-10-30 +# edition of the Korean Wikipedia entry.) # # I guessed that time zone abbreviations through 1945 followed the same # rules as discussed under Taiwan, with nominal switches from JST to KST # when the respective cities were taken over by the Allies after WWII. # -# For Pyongyang we have no information; guess no changes since World War II. +# For Pyongyang, guess no changes from World War II until 2015, as we +# have no information otherwise. # From Steffen Thorsen (2015-08-07): # According to many news sources, North Korea is going to change to @@ -1871,7 +2041,7 @@ Zone Indian/Maldives 4:54:00 - LMT 1880 # Bill Bonnet (2005-05-19) reports that the US Embassy in Ulaanbaatar says # there is only one time zone and that DST is observed, citing Microsoft # Windows XP as the source. Risto Nykänen (2005-05-16) reports that -# travelmongolia.org says there are two time zones (UTC+7, UTC+8) with no DST. +# travelmongolia.org says there are two time zones (UT +07, +08) with no DST. # Oscar van Vlijmen (2005-05-20) reports that the Mongolian Embassy in # Washington, DC says there are two time zones, with DST observed. # He also found @@ -2111,8 +2281,8 @@ Zone Asia/Kathmandu 5:41:16 - LMT 1920 # http://www.app.com.pk/en_/index.php?option=com_content&task=view&id=99374&Itemid=2 # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule Pakistan 2002 only - Apr Sun>=2 0:01 1:00 S -Rule Pakistan 2002 only - Oct Sun>=2 0:01 0 - +Rule Pakistan 2002 only - Apr Sun>=2 0:00 1:00 S +Rule Pakistan 2002 only - Oct Sun>=2 0:00 0 - Rule Pakistan 2008 only - Jun 1 0:00 1:00 S Rule Pakistan 2008 2009 - Nov 1 0:00 0 - Rule Pakistan 2009 only - Apr 15 0:00 1:00 S @@ -2380,6 +2550,16 @@ Zone Asia/Karachi 4:28:12 - LMT 1907 # http://www.timeanddate.com/time/change/gaza-strip/gaza # http://www.timeanddate.com/time/change/west-bank/hebron +# From Hannah Kreitem (2016-03-09): +# http://www.palestinecabinet.gov.ps/WebSite/ar/ViewDetails?ID=31728 +# [Google translation]: "The Council also decided to start daylight +# saving in Palestine as of one o'clock on Saturday morning, +# 2016-03-26, to provide the clock 60 minutes ahead." +# +# From Paul Eggert (2016-03-12): +# Predict spring transitions on March's last Saturday at 01:00 from now on. +# Leave fall predictions alone for now. + # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S Rule EgyptAsia 1957 only - May 10 0:00 1:00 S Rule EgyptAsia 1957 1958 - Oct 1 0:00 0 - @@ -2408,7 +2588,8 @@ Rule Palestine 2012 2014 - Mar lastThu 2 Rule Palestine 2012 only - Sep 21 1:00 0 - Rule Palestine 2013 only - Sep Fri>=21 0:00 0 - Rule Palestine 2014 max - Oct Fri>=21 0:00 0 - -Rule Palestine 2015 max - Mar lastFri 24:00 1:00 S +Rule Palestine 2015 only - Mar lastFri 24:00 1:00 S +Rule Palestine 2016 max - Mar lastSat 1:00 1:00 S # Zone NAME GMTOFF RULES FORMAT [UNTIL] Zone Asia/Gaza 2:17:52 - LMT 1900 Oct @@ -2496,7 +2677,7 @@ Link Asia/Qatar Asia/Bahrain # earlier date. # # Shanks & Pottenger also state that until 1968-05-01 Saudi Arabia had two -# time zones; the other zone, at UTC+4, was in the far eastern part of +# time zones; the other zone, at UT +04, was in the far eastern part of # the country. Ignore this, as it's before our 1970 cutoff. # # Zone NAME GMTOFF RULES FORMAT [UNTIL] @@ -2765,10 +2946,10 @@ Zone Asia/Damascus 2:25:12 - LMT 1920 # # From Shanks & Pottenger. # Zone NAME GMTOFF RULES FORMAT [UNTIL] Zone Asia/Dushanbe 4:35:12 - LMT 1924 May 2 - 5:00 - DUST 1930 Jun 21 # Dushanbe Time - 6:00 RussiaAsia DUS%sT 1991 Mar 31 2:00s - 5:00 1:00 DUSST 1991 Sep 9 2:00s - 5:00 - TJT # Tajikistan Time + 5:00 - +05 1930 Jun 21 + 6:00 RussiaAsia +06/+07 1991 Mar 31 2:00s + 5:00 1:00 +05/+06 1991 Sep 9 2:00s + 5:00 - +05 # Thailand # Zone NAME GMTOFF RULES FORMAT [UNTIL] @@ -2782,11 +2963,10 @@ Link Asia/Bangkok Asia/Vientiane # Laos # From Shanks & Pottenger. # Zone NAME GMTOFF RULES FORMAT [UNTIL] Zone Asia/Ashgabat 3:53:32 - LMT 1924 May 2 # or Ashkhabad - 4:00 - ASHT 1930 Jun 21 # Ashkhabad Time - 5:00 RussiaAsia ASH%sT 1991 Mar 31 2:00 - 4:00 RussiaAsia ASH%sT 1991 Oct 27 # independence - 4:00 RussiaAsia TM%sT 1992 Jan 19 2:00 - 5:00 - TMT + 4:00 - +04 1930 Jun 21 + 5:00 RussiaAsia +05/+06 1991 Mar 31 2:00 + 4:00 RussiaAsia +04/+05 1992 Jan 19 2:00 + 5:00 - +05 # United Arab Emirates # Zone NAME GMTOFF RULES FORMAT [UNTIL] @@ -2798,20 +2978,18 @@ Link Asia/Dubai Asia/Muscat # Oman # Byalokoz 1919 says Uzbekistan was 4:27:53. # Zone NAME GMTOFF RULES FORMAT [UNTIL] Zone Asia/Samarkand 4:27:53 - LMT 1924 May 2 - 4:00 - SAMT 1930 Jun 21 # Samarkand Time - 5:00 - SAMT 1981 Apr 1 - 5:00 1:00 SAMST 1981 Oct 1 - 6:00 - TAST 1982 Apr 1 # Tashkent Time - 5:00 RussiaAsia SAM%sT 1991 Sep 1 # independence - 5:00 RussiaAsia UZ%sT 1992 - 5:00 - UZT + 4:00 - +04 1930 Jun 21 + 5:00 - +05 1981 Apr 1 + 5:00 1:00 +06 1981 Oct 1 + 6:00 - +06 1982 Apr 1 + 5:00 RussiaAsia +05/+06 1992 + 5:00 - +05 # Milne says Tashkent was 4:37:10.8; round to nearest. Zone Asia/Tashkent 4:37:11 - LMT 1924 May 2 - 5:00 - TAST 1930 Jun 21 # Tashkent Time - 6:00 RussiaAsia TAS%sT 1991 Mar 31 2:00 - 5:00 RussiaAsia TAS%sT 1991 Sep 1 # independence - 5:00 RussiaAsia UZ%sT 1992 - 5:00 - UZT + 5:00 - +05 1930 Jun 21 + 6:00 RussiaAsia +06/+07 1991 Mar 31 2:00 + 5:00 RussiaAsia +05/+06 1992 + 5:00 - +05 # Vietnam Modified: stable/10/contrib/tzdata/australasia ============================================================================== --- stable/10/contrib/tzdata/australasia Sat Oct 15 12:41:11 2016 (r307361) +++ stable/10/contrib/tzdata/australasia Sat Oct 15 12:41:41 2016 (r307362) @@ -60,6 +60,14 @@ Zone Australia/Eucla 8:35:28 - LMT 1895 # Hamilton is the largest, but there is also a Hamilton in Victoria, # so use Lindeman. # +# From J William Piggott (2016-02-20): +# There is no location named Holiday Islands in Queensland Australia; holiday +# islands is a colloquial term used globally. Hayman and Lindeman are at the +# north and south extremes of the Whitsunday Islands archipelago, and +# Hamilton is in between; it is reasonable to believe that this time zone +# applies to all of the Whitsundays. +# http://www.australia.gov.au/about-australia/australian-story/austn-islands +# # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S Rule AQ 1971 only - Oct lastSun 2:00s 1:00 D Rule AQ 1972 only - Feb lastSun 2:00s 0 S @@ -235,11 +243,11 @@ Zone Australia/Lord_Howe 10:36:20 - LMT # will produce a binary file with an [A]EST-type as the first 32-bit type; # this is required for correct handling of times before 1916 by # pre-2013 versions of localtime. -Zone Antarctica/Macquarie 0 - zzz 1899 Nov +Zone Antarctica/Macquarie 0 - -00 1899 Nov 10:00 - AEST 1916 Oct 1 2:00 10:00 1:00 AEDT 1917 Feb 10:00 Aus AE%sT 1919 Apr 1 0:00s - 0 - zzz 1948 Mar 25 + 0 - -00 1948 Mar 25 10:00 Aus AE%sT 1967 10:00 AT AE%sT 2010 Apr 4 3:00 11:00 - MIST # Macquarie I Standard Time @@ -537,7 +545,7 @@ Zone Pacific/Port_Moresby 9:48:40 - LMT # Base the Bougainville entry on the Arawa-Kieta region, which appears to have # the most people even though it was devastated in the Bougainville Civil War. # -# Although Shanks gives 1942-03-15 / 1943-11-01 for JST, these dates +# Although Shanks gives 1942-03-15 / 1943-11-01 for UT +09, these dates # are apparently rough guesswork from the starts of military campaigns. # The World War II entries below are instead based on Arawa-Kieta. # The Japanese occupied Kieta in July 1942, @@ -545,8 +553,8 @@ Zone Pacific/Port_Moresby 9:48:40 - LMT # http://pwencycl.kgbudge.com/B/o/Bougainville.htm # and seem to have controlled it until their 1945-08-21 surrender. # -# The Autonomous Region of Bougainville plans to switch from UTC+10 to UTC+11 -# on 2014-12-28 at 02:00. They call UTC+11 "Bougainville Standard Time"; +# The Autonomous Region of Bougainville switched from UT +10 to +11 +# on 2014-12-28 at 02:00. They call +11 "Bougainville Standard Time"; # abbreviate this as BST. See: # http://www.bougainville24.com/bougainville-issues/bougainville-gets-own-timezone/ # @@ -612,7 +620,7 @@ Link Pacific/Pago_Pago Pacific/Midway # # From Paul Eggert (2014-06-27): # The International Date Line Act 2011 # http://www.parliament.gov.ws/images/ACTS/International_Date_Line_Act__2011_-_Eng.pdf -# changed Samoa from UTC-11 to UTC+13, effective "12 o'clock midnight, on +# changed Samoa from UT -11 to +13, effective "12 o'clock midnight, on # Thursday 29th December 2011". The International Date Line was adjusted # accordingly. @@ -707,7 +715,7 @@ Zone Pacific/Funafuti 11:56:52 - LMT 190 # 1886-1891; Baker was similar but exact dates are not known. # Inhabited by civilians 1935-1942; U.S. military bases 1943-1944; # uninhabited thereafter. -# Howland observed Hawaii Standard Time (UT-10:30) in 1937; +# Howland observed Hawaii Standard Time (UT -10:30) in 1937; # see page 206 of Elgen M. Long and Marie K. Long, # Amelia Earhart: the Mystery Solved, Simon & Schuster (2000). # So most likely Howland and Baker observed Hawaii Time from 1935 @@ -1465,7 +1473,7 @@ Zone Pacific/Wallis 12:15:20 - LMT 1901 # Zealand time. I understand that is the time they keep locally, anyhow." # For now, assume this practice goes back to the introduction of standard time # in New Zealand, as this would make Chatham Islands time almost exactly match -# LMT back when New Zealand was at UTC+11:30; also, assume Chatham Islands did +# LMT back when New Zealand was at UT +11:30; also, assume Chatham Islands did # not observe New Zealand's prewar DST. *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-all@freebsd.org Sat Oct 15 12:42:49 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 1DC8DC13445; Sat, 15 Oct 2016 12:42:49 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id C793019F9; Sat, 15 Oct 2016 12:42:48 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9FCgmBg035724; Sat, 15 Oct 2016 12:42:48 GMT (envelope-from bapt@FreeBSD.org) Received: (from bapt@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9FCgllg035719; Sat, 15 Oct 2016 12:42:47 GMT (envelope-from bapt@FreeBSD.org) Message-Id: <201610151242.u9FCgllg035719@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bapt set sender to bapt@FreeBSD.org using -f From: Baptiste Daroussin Date: Sat, 15 Oct 2016 12:42:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r307363 - stable/9/contrib/tzdata X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 Oct 2016 12:42:49 -0000 Author: bapt Date: Sat Oct 15 12:42:47 2016 New Revision: 307363 URL: https://svnweb.freebsd.org/changeset/base/307363 Log: MFC r306853 Import tzdata 2016g Modified: stable/9/contrib/tzdata/africa stable/9/contrib/tzdata/antarctica stable/9/contrib/tzdata/asia stable/9/contrib/tzdata/australasia stable/9/contrib/tzdata/backward stable/9/contrib/tzdata/etcetera stable/9/contrib/tzdata/europe stable/9/contrib/tzdata/factory stable/9/contrib/tzdata/leap-seconds.list stable/9/contrib/tzdata/leapseconds stable/9/contrib/tzdata/northamerica stable/9/contrib/tzdata/southamerica stable/9/contrib/tzdata/zone.tab stable/9/contrib/tzdata/zone1970.tab Directory Properties: stable/9/ (props changed) stable/9/contrib/ (props changed) stable/9/contrib/tzdata/ (props changed) Modified: stable/9/contrib/tzdata/africa ============================================================================== --- stable/9/contrib/tzdata/africa Sat Oct 15 12:41:41 2016 (r307362) +++ stable/9/contrib/tzdata/africa Sat Oct 15 12:42:47 2016 (r307363) @@ -343,6 +343,12 @@ Rule Egypt 2007 only - Sep Thu>=1 24:00 # decision to abandon DST permanently. See Ahram Online 2015-04-24. # http://english.ahram.org.eg/NewsContent/1/64/128509/Egypt/Politics-/Sisi-cancels-daylight-saving-time-in-Egypt.aspx +# From Steffen Thorsen (2016-04-29): +# Egypt will have DST from July 7 until the end of October.... +# http://english.ahram.org.eg/NewsContentP/1/204655/Egypt/Daylight-savings-time-returning-to-Egypt-on--July.aspx +# From Mina Samuel (2016-07-04): +# Egyptian government took the decision to cancel the DST, + Rule Egypt 2008 only - Aug lastThu 24:00 0 - Rule Egypt 2009 only - Aug 20 24:00 0 - Rule Egypt 2010 only - Aug 10 24:00 0 - @@ -458,7 +464,7 @@ Zone Africa/Monrovia -0:43:08 - LMT 1882 # http://www.libyaherald.com/2013/10/24/correction-no-time-change-tomorrow/ # # From Paul Eggert (2013-10-25): -# For now, assume they're reverting to the pre-2012 rules of permanent UTC+2. +# For now, assume they're reverting to the pre-2012 rules of permanent UT +02. # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S Rule Libya 1951 only - Oct 14 2:00 1:00 S @@ -858,11 +864,11 @@ Rule Morocco 2009 only - Aug 21 0:00 0 Rule Morocco 2010 only - May 2 0:00 1:00 S Rule Morocco 2010 only - Aug 8 0:00 0 - Rule Morocco 2011 only - Apr 3 0:00 1:00 S -Rule Morocco 2011 only - Jul 31 0 0 - +Rule Morocco 2011 only - Jul 31 0:00 0 - Rule Morocco 2012 2013 - Apr lastSun 2:00 1:00 S -Rule Morocco 2012 only - Sep 30 3:00 0 - Rule Morocco 2012 only - Jul 20 3:00 0 - Rule Morocco 2012 only - Aug 20 2:00 1:00 S +Rule Morocco 2012 only - Sep 30 3:00 0 - Rule Morocco 2013 only - Jul 7 3:00 0 - Rule Morocco 2013 only - Aug 10 2:00 1:00 S Rule Morocco 2013 max - Oct lastSun 3:00 0 - Modified: stable/9/contrib/tzdata/antarctica ============================================================================== --- stable/9/contrib/tzdata/antarctica Sat Oct 15 12:41:41 2016 (r307362) +++ stable/9/contrib/tzdata/antarctica Sat Oct 15 12:42:47 2016 (r307363) @@ -10,10 +10,8 @@ # http://www.spri.cam.ac.uk/bob/periant.htm # for information. # Unless otherwise specified, we have no time zone information. -# -# Except for the French entries, -# I made up all time zone abbreviations mentioned here; corrections welcome! -# FORMAT is 'zzz' and GMTOFF is 0 for locations while uninhabited. + +# FORMAT is '-00' and GMTOFF is 0 for locations while uninhabited. # Argentina - year-round bases # Belgrano II, Confin Coast, -770227-0343737, since 1972-02-05 @@ -29,7 +27,7 @@ # previously sealers and scientific personnel wintered # Margaret Turner reports # http://web.archive.org/web/20021204222245/http://www.dstc.qut.edu.au/DST/marg/daylight.html -# (1999-09-30) that they're UTC+5, with no DST; +# (1999-09-30) that they're UT +05, with no DST; # presumably this is when they have visitors. # # year-round bases @@ -67,24 +65,23 @@ # http://www.timeanddate.com/news/time/antartica-time-changes-2010.html # Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Antarctica/Casey 0 - zzz 1969 - 8:00 - AWST 2009 Oct 18 2:00 - # Australian Western Std Time - 11:00 - CAST 2010 Mar 5 2:00 # Casey Time - 8:00 - AWST 2011 Oct 28 2:00 - 11:00 - CAST 2012 Feb 21 17:00u - 8:00 - AWST -Zone Antarctica/Davis 0 - zzz 1957 Jan 13 - 7:00 - DAVT 1964 Nov # Davis Time - 0 - zzz 1969 Feb - 7:00 - DAVT 2009 Oct 18 2:00 - 5:00 - DAVT 2010 Mar 10 20:00u - 7:00 - DAVT 2011 Oct 28 2:00 - 5:00 - DAVT 2012 Feb 21 20:00u - 7:00 - DAVT -Zone Antarctica/Mawson 0 - zzz 1954 Feb 13 - 6:00 - MAWT 2009 Oct 18 2:00 # Mawson Time - 5:00 - MAWT +Zone Antarctica/Casey 0 - -00 1969 + 8:00 - +08 2009 Oct 18 2:00 + 11:00 - +11 2010 Mar 5 2:00 + 8:00 - +08 2011 Oct 28 2:00 + 11:00 - +11 2012 Feb 21 17:00u + 8:00 - +08 +Zone Antarctica/Davis 0 - -00 1957 Jan 13 + 7:00 - +07 1964 Nov + 0 - -00 1969 Feb + 7:00 - +07 2009 Oct 18 2:00 + 5:00 - +05 2010 Mar 10 20:00u + 7:00 - +07 2011 Oct 28 2:00 + 5:00 - +05 2012 Feb 21 20:00u + 7:00 - +07 +Zone Antarctica/Mawson 0 - -00 1954 Feb 13 + 6:00 - +06 2009 Oct 18 2:00 + 5:00 - +05 # References: # Casey Weather (1998-02-26) # http://www.antdiv.gov.au/aad/exop/sfo/casey/casey_aws.html @@ -137,8 +134,8 @@ Zone Antarctica/Mawson 0 - zzz 1954 Feb # fishing stations operated variously 1819/1931 # # Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Indian/Kerguelen 0 - zzz 1950 # Port-aux-Français - 5:00 - TFT # ISO code TF Time +Zone Indian/Kerguelen 0 - -00 1950 # Port-aux-Français + 5:00 - +05 # # year-round base in the main continent # Dumont d'Urville, ÃŽle des Pétrels, -6640+14001, since 1956-11 @@ -148,10 +145,10 @@ Zone Indian/Kerguelen 0 - zzz 1950 # Por # It was destroyed by fire on 1952-01-14. # # Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Antarctica/DumontDUrville 0 - zzz 1947 - 10:00 - PMT 1952 Jan 14 # Port-Martin Time - 0 - zzz 1956 Nov - 10:00 - DDUT # Dumont-d'Urville Time +Zone Antarctica/DumontDUrville 0 - -00 1947 + 10:00 - +10 1952 Jan 14 + 0 - -00 1956 Nov + 10:00 - +10 # France & Italy - year-round base # Concordia, -750600+1232000, since 2005 @@ -176,8 +173,8 @@ Zone Antarctica/DumontDUrville 0 - zzz 1 # was established on 1957-01-29. Since Syowa station is still the main # station of Japan, it's appropriate for the principal location. # Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Antarctica/Syowa 0 - zzz 1957 Jan 29 - 3:00 - SYOT # Syowa Time +Zone Antarctica/Syowa 0 - -00 1957 Jan 29 + 3:00 - +03 # See: # NIPR Antarctic Research Activities (1999-08-17) # http://www.nipr.ac.jp/english/ara01.html @@ -214,19 +211,19 @@ Zone Antarctica/Syowa 0 - zzz 1957 Jan 2 # correct, but they should be quite close to the actual dates. # # From Paul Eggert (2014-03-21): -# The CET-switching Troll rules require zic from tzcode 2014b or later, so as +# The CET-switching Troll rules require zic from tz 2014b or later, so as # suggested by Bengt-Inge Larsson comment them out for now, and approximate # with only UTC and CEST. Uncomment them when 2014b is more prevalent. # # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -#Rule Troll 2005 max - Mar 1 1:00u 1:00 CET -Rule Troll 2005 max - Mar lastSun 1:00u 2:00 CEST -#Rule Troll 2005 max - Oct lastSun 1:00u 1:00 CET -#Rule Troll 2004 max - Nov 7 1:00u 0:00 UTC +#Rule Troll 2005 max - Mar 1 1:00u 1:00 +01 +Rule Troll 2005 max - Mar lastSun 1:00u 2:00 +02 +#Rule Troll 2005 max - Oct lastSun 1:00u 1:00 +01 +#Rule Troll 2004 max - Nov 7 1:00u 0:00 +00 # Remove the following line when uncommenting the above '#Rule' lines. -Rule Troll 2004 max - Oct lastSun 1:00u 0:00 UTC +Rule Troll 2004 max - Oct lastSun 1:00u 0:00 +00 # Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Antarctica/Troll 0 - zzz 2005 Feb 12 +Zone Antarctica/Troll 0 - -00 2005 Feb 12 0:00 Troll %s # Poland - year-round base @@ -265,10 +262,10 @@ Zone Antarctica/Troll 0 - zzz 2005 Feb 1 # changes during the year and does not necessarily correspond to mean # solar noon. So the Vostok time might have been whatever the clocks # happened to be during their visit. So we still don't really know what time -# it is at Vostok. But we'll guess UTC+6. +# it is at Vostok. But we'll guess +06. # -Zone Antarctica/Vostok 0 - zzz 1957 Dec 16 - 6:00 - VOST # Vostok time +Zone Antarctica/Vostok 0 - -00 1957 Dec 16 + 6:00 - +06 # S Africa - year-round bases # Marion Island, -4653+03752 @@ -300,8 +297,8 @@ Zone Antarctica/Vostok 0 - zzz 1957 Dec # says Rothera is -03 all year. # # Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Antarctica/Rothera 0 - zzz 1976 Dec 1 - -3:00 - ROTT # Rothera time +Zone Antarctica/Rothera 0 - -00 1976 Dec 1 + -3:00 - -03 # Uruguay - year round base # Artigas, King George Island, -621104-0585107 Modified: stable/9/contrib/tzdata/asia ============================================================================== --- stable/9/contrib/tzdata/asia Sat Oct 15 12:41:41 2016 (r307362) +++ stable/9/contrib/tzdata/asia Sat Oct 15 12:42:47 2016 (r307363) @@ -79,13 +79,9 @@ Rule E-EurAsia 1979 1995 - Sep lastSun Rule E-EurAsia 1996 max - Oct lastSun 0:00 0 - Rule RussiaAsia 1981 1984 - Apr 1 0:00 1:00 S Rule RussiaAsia 1981 1983 - Oct 1 0:00 0 - -Rule RussiaAsia 1984 1991 - Sep lastSun 2:00s 0 - -Rule RussiaAsia 1985 1991 - Mar lastSun 2:00s 1:00 S -Rule RussiaAsia 1992 only - Mar lastSat 23:00 1:00 S -Rule RussiaAsia 1992 only - Sep lastSat 23:00 0 - -Rule RussiaAsia 1993 max - Mar lastSun 2:00s 1:00 S -Rule RussiaAsia 1993 1995 - Sep lastSun 2:00s 0 - -Rule RussiaAsia 1996 max - Oct lastSun 2:00s 0 - +Rule RussiaAsia 1984 1995 - Sep lastSun 2:00s 0 - +Rule RussiaAsia 1985 2011 - Mar lastSun 2:00s 1:00 S +Rule RussiaAsia 1996 2011 - Oct lastSun 2:00s 0 - # Afghanistan # Zone NAME GMTOFF RULES FORMAT [UNTIL] @@ -120,31 +116,37 @@ Zone Asia/Kabul 4:36:48 - LMT 1890 # http://www.worldtimezone.com/dst_news/dst_news_armenia03.html # Zone NAME GMTOFF RULES FORMAT [UNTIL] Zone Asia/Yerevan 2:58:00 - LMT 1924 May 2 - 3:00 - YERT 1957 Mar # Yerevan Time - 4:00 RussiaAsia YER%sT 1991 Mar 31 2:00s - 3:00 1:00 YERST 1991 Sep 23 # independence - 3:00 RussiaAsia AM%sT 1995 Sep 24 2:00s - 4:00 - AMT 1997 - 4:00 RussiaAsia AM%sT 2012 Mar 25 2:00s - 4:00 - AMT + 3:00 - +03 1957 Mar + 4:00 RussiaAsia +04/+05 1991 Mar 31 2:00s + 3:00 RussiaAsia +03/+04 1995 Sep 24 2:00s + 4:00 - +04 1997 + 4:00 RussiaAsia +04/+05 # Azerbaijan + # From Rustam Aliyev of the Azerbaijan Internet Forum (2005-10-23): # According to the resolution of Cabinet of Ministers, 1997 # From Paul Eggert (2015-09-17): It was Resolution No. 21 (1997-03-17). # http://code.az/files/daylight_res.pdf + +# From Steffen Thorsen (2016-03-17): +# ... the Azerbaijani Cabinet of Ministers has cancelled switching to +# daylight saving time.... +# http://www.azernews.az/azerbaijan/94137.html +# http://vestnikkavkaza.net/news/Azerbaijani-Cabinet-of-Ministers-cancels-daylight-saving-time.html +# http://en.apa.az/xeber_azerbaijan_abolishes_daylight_savings_ti_240862.html + # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule Azer 1997 max - Mar lastSun 4:00 1:00 S -Rule Azer 1997 max - Oct lastSun 5:00 0 - +Rule Azer 1997 2015 - Mar lastSun 4:00 1:00 S +Rule Azer 1997 2015 - Oct lastSun 5:00 0 - # Zone NAME GMTOFF RULES FORMAT [UNTIL] Zone Asia/Baku 3:19:24 - LMT 1924 May 2 - 3:00 - BAKT 1957 Mar # Baku Time - 4:00 RussiaAsia BAK%sT 1991 Mar 31 2:00s - 3:00 1:00 BAKST 1991 Aug 30 # independence - 3:00 RussiaAsia AZ%sT 1992 Sep lastSat 23:00 - 4:00 - AZT 1996 # Azerbaijan Time - 4:00 EUAsia AZ%sT 1997 - 4:00 Azer AZ%sT + 3:00 - +03 1957 Mar + 4:00 RussiaAsia +04/+05 1991 Mar 31 2:00s + 3:00 RussiaAsia +03/+04 1992 Sep lastSun 2:00s + 4:00 - +04 1996 + 4:00 EUAsia +04/+05 1997 + 4:00 Azer +04/+05 # Bahrain # See Asia/Qatar. @@ -263,7 +265,7 @@ Zone Asia/Brunei 7:39:40 - LMT 1926 Mar # Milne says 6:24:40 was the meridian of the time ball observatory at Rangoon. # Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Asia/Rangoon 6:24:40 - LMT 1880 # or Yangon +Zone Asia/Yangon 6:24:40 - LMT 1880 # or Rangoon 6:24:40 - RMT 1920 # Rangoon Mean Time? 6:30 - BURT 1942 May # Burma Time 9:00 - JST 1945 May 3 @@ -378,7 +380,7 @@ Rule PRC 1987 1991 - Apr Sun>=10 0:00 1: # Lewiston (ME) Daily Sun (1939-05-29), p 17, said "Even the time is # different - the occupied districts going by Tokyo time, an hour # ahead of that prevailing in the rest of Shanghai." Guess that the -# Xujiahui Observatory was under French control and stuck with UT+8. +# Xujiahui Observatory was under French control and stuck with UT +08. # # In earlier versions of this file, China had many separate Zone entries, but # this was based on what were apparently incorrect data in Shanks & Pottenger. @@ -387,26 +389,26 @@ Rule PRC 1987 1991 - Apr Sun>=10 0:00 1: # Proposed in 1918 and theoretically in effect until 1949 (although in practice # mainly observed in coastal areas), the five zones were: # -# Changbai Time ("Long-white Time", Long-white = Heilongjiang area) UT+8.5 +# Changbai Time ("Long-white Time", Long-white = Heilongjiang area) UT +08:30 # Asia/Harbin (currently a link to Asia/Shanghai) # Heilongjiang (except Mohe county), Jilin # -# Zhongyuan Time ("Central plain Time") UT+8 +# Zhongyuan Time ("Central plain Time") UT +08 # Asia/Shanghai # most of China # This currently represents most other zones as well, # as apparently these regions have been the same since 1970. # Milne gives 8:05:43.2 for Xujiahui Observatory time; round to nearest. -# Guo says Shanghai switched to UT+8 "from the end of the 19th century". +# Guo says Shanghai switched to UT +08 "from the end of the 19th century". # -# Long-shu Time (probably due to Long and Shu being two names of that area) UT+7 +# Long-shu Time (probably due to Long and Shu being two names of the area) UT +07 # Asia/Chongqing (currently a link to Asia/Shanghai) # Guangxi, Guizhou, Hainan, Ningxia, Sichuan, Shaanxi, and Yunnan; # most of Gansu; west Inner Mongolia; west Qinghai; and the Guangdong # counties Deqing, Enping, Kaiping, Luoding, Taishan, Xinxing, # Yangchun, Yangjiang, Yu'nan, and Yunfu. # -# Xin-zang Time ("Xinjiang-Tibet Time") UT+6 +# Xin-zang Time ("Xinjiang-Tibet Time") UT +06 # Asia/Urumqi # This currently represents Kunlun Time as well, # as apparently the two regions have been the same since 1970. @@ -419,7 +421,7 @@ Rule PRC 1987 1991 - Apr Sun>=10 0:00 1: # Shihezi, Changji, Yanqi, Heshuo, Tuokexun, Tulufan, Shanshan, Hami, # Fukang, Kuitun, Kumukuli, Miquan, Qitai, and Turfan. # -# Kunlun Time UT+5.5 +# Kunlun Time UT +05:30 # Asia/Kashgar (currently a link to Asia/Urumqi) # West Tibet, including Pulan, Aheqi, Shufu, Shule; # West Xinjiang, including Aksu, Atushi, Yining, Hetian, Cele, Luopu, Nileke, @@ -435,7 +437,7 @@ Rule PRC 1987 1991 - Apr Sun>=10 0:00 1: # # On the other hand, ethnic Uyghurs, who make up about half the # population of Xinjiang, typically use "Xinjiang time" which is two -# hours behind Beijing time, or UTC +0600. The government of the Xinjiang +# hours behind Beijing time, or UT +06. The government of the Xinjiang # Uyghur Autonomous Region, (XAUR, or just Xinjiang for short) as well as # local governments such as the Ãœrümqi city government use both times in # publications, referring to what is popularly called Xinjiang time as @@ -491,8 +493,8 @@ Rule PRC 1987 1991 - Apr Sun>=10 0:00 1: # having the same time as Beijing. # From Paul Eggert (2014-06-30): -# In the early days of the PRC, Tibet was given its own time zone (UT+6) but -# this was withdrawn in 1959 and never reinstated; see Tubten Khétsun, +# In the early days of the PRC, Tibet was given its own time zone (UT +06) +# but this was withdrawn in 1959 and never reinstated; see Tubten Khétsun, # Memories of life in Lhasa under Chinese Rule, Columbia U Press, ISBN # 978-0231142861 (2008), translator's introduction by Matthew Akester, p x. # As this is before our 1970 cutoff, Tibet doesn't need a separate zone. @@ -506,12 +508,12 @@ Rule PRC 1987 1991 - Apr Sun>=10 0:00 1: # Republics, the Soviet Union, the Kuomintang, and the People's Republic of # China, and tracking down all these organizations' timekeeping rules would be # quite a trick. Approximate this lost history by a transition from LMT to -# XJT at the start of 1928, the year of accession of the warlord Jin Shuren, +# UT +06 at the start of 1928, the year of accession of the warlord Jin Shuren, # which happens to be the date given by Shanks & Pottenger (no doubt as a -# guess) as the transition from LMT. Ignore the usage of UT+8 before -# 1986-02-01 under the theory that the transition date to UT+8 is unknown and +# guess) as the transition from LMT. Ignore the usage of +08 before +# 1986-02-01 under the theory that the transition date to +08 is unknown and # that the sort of users who prefer Asia/Urumqi now typically ignored the -# UT+8 mandate back then. +# +08 mandate back then. # Zone NAME GMTOFF RULES FORMAT [UNTIL] # Beijing time, used throughout China; represented by Shanghai. @@ -716,7 +718,7 @@ Zone Asia/Hong_Kong 7:36:42 - LMT 1904 O # be found from historical government announcement database. # From Paul Eggert (2014-07-03): -# As per Yu-Cheng Chuang, say that Taiwan was at UT+9 from 1937-10-01 +# As per Yu-Cheng Chuang, say that Taiwan was at UT +09 from 1937-10-01 # until 1945-09-21 at 01:00, overriding Shanks & Pottenger. # Likewise, use Yu-Cheng Chuang's data for DST in Taiwan. @@ -830,16 +832,15 @@ Link Asia/Nicosia Europe/Nicosia # Zone NAME GMTOFF RULES FORMAT [UNTIL] Zone Asia/Tbilisi 2:59:11 - LMT 1880 2:59:11 - TBMT 1924 May 2 # Tbilisi Mean Time - 3:00 - TBIT 1957 Mar # Tbilisi Time - 4:00 RussiaAsia TBI%sT 1991 Mar 31 2:00s - 3:00 1:00 TBIST 1991 Apr 9 # independence - 3:00 RussiaAsia GE%sT 1992 # Georgia Time - 3:00 E-EurAsia GE%sT 1994 Sep lastSun - 4:00 E-EurAsia GE%sT 1996 Oct lastSun - 4:00 1:00 GEST 1997 Mar lastSun - 4:00 E-EurAsia GE%sT 2004 Jun 27 - 3:00 RussiaAsia GE%sT 2005 Mar lastSun 2:00 - 4:00 - GET + 3:00 - +03 1957 Mar + 4:00 RussiaAsia +04/+05 1991 Mar 31 2:00s + 3:00 RussiaAsia +03/+04 1992 + 3:00 E-EurAsia +03/+04 1994 Sep lastSun + 4:00 E-EurAsia +04/+05 1996 Oct lastSun + 4:00 1:00 +05 1997 Mar lastSun + 4:00 E-EurAsia +04/+05 2004 Jun 27 + 3:00 RussiaAsia +03/+04 2005 Mar lastSun 2:00 + 4:00 - +04 # East Timor @@ -874,6 +875,15 @@ Zone Asia/Dili 8:22:20 - LMT 1912 Jan 1 9:00 - TLT # India + +# From Ian P. Beacock, in "A brief history of (modern) time", The Atlantic +# http://www.theatlantic.com/technology/archive/2015/12/the-creation-of-modern-time/421419/ +# (2015-12-22): +# In January 1906, several thousand cotton-mill workers rioted on the +# outskirts of Bombay.... They were protesting the proposed abolition of +# local time in favor of Indian Standard Time.... Journalists called this +# dispute the "Battle of the Clocks." It lasted nearly half a century. + # Zone NAME GMTOFF RULES FORMAT [UNTIL] Zone Asia/Kolkata 5:53:28 - LMT 1880 # Kolkata 5:53:20 - HMT 1941 Oct # Howrah Mean Time? @@ -907,7 +917,7 @@ Zone Asia/Kolkata 5:53:28 - LMT 1880 # These would be the earliest possible times for a change. # Régimes horaires pour le monde entier, by Henri Le Corre, (Éditions # Traditionnelles, 1987, Paris) says that Java and Madura switched -# from JST to UTC+07:30 on 1945-09-23, and gives 1944-09-01 for Jayapura +# from UT +09 to +07:30 on 1945-09-23, and gives 1944-09-01 for Jayapura # (Hollandia). For now, assume all Indonesian locations other than Jayapura # switched on 1945-09-23. # @@ -918,11 +928,11 @@ Zone Asia/Kolkata 5:53:28 - LMT 1880 # summary published by the Time and Frequency Laboratory of the # Research Center for Calibration, Instrumentation and Metrology, # Indonesia, (2006-09-29). -# The abbreviations are: +# The time zone abbreviations and UT offsets are: # -# WIB - UTC+7 - Waktu Indonesia Barat (Indonesia western time) -# WITA - UTC+8 - Waktu Indonesia Tengah (Indonesia central time) -# WIT - UTC+9 - Waktu Indonesia Timur (Indonesia eastern time) +# WIB - +07 - Waktu Indonesia Barat (Indonesia western time) +# WITA - +08 - Waktu Indonesia Tengah (Indonesia central time) +# WIT - +09 - Waktu Indonesia Timur (Indonesia eastern time) # # Zone NAME GMTOFF RULES FORMAT [UNTIL] # Java, Sumatra @@ -1084,8 +1094,15 @@ Rule Iran 2032 2033 - Mar 21 0:00 1:00 D Rule Iran 2032 2033 - Sep 21 0:00 0 S Rule Iran 2034 2035 - Mar 22 0:00 1:00 D Rule Iran 2034 2035 - Sep 22 0:00 0 S -Rule Iran 2036 2037 - Mar 21 0:00 1:00 D -Rule Iran 2036 2037 - Sep 21 0:00 0 S +# +# The following rules are approximations starting in the year 2038. +# These are the best post-2037 approximations available, given the +# restrictions of a single rule using a Gregorian-based data format. +# At some point this table will need to be extended, though quite +# possibly Iran will change the rules first. +Rule Iran 2036 max - Mar 21 0:00 1:00 D +Rule Iran 2036 max - Sep 21 0:00 0 S + # Zone NAME GMTOFF RULES FORMAT [UNTIL] Zone Asia/Tehran 3:25:44 - LMT 1916 3:25:44 - TMT 1946 # Tehran Mean Time @@ -1542,23 +1559,6 @@ Zone Asia/Amman 2:23:44 - LMT 1931 # Kazakhstan -# From Paul Eggert (1996-11-22): -# Andrew Evtichov (1996-04-13) writes that Kazakhstan -# stayed in sync with Moscow after 1990, and that Aqtobe (formerly Aktyubinsk) -# and Aqtau (formerly Shevchenko) are the largest cities in their zones. -# Guess that Aqtau and Aqtobe diverged in 1995, since that's the first time -# IATA SSIM mentions a third time zone in Kazakhstan. - -# From Paul Eggert (2006-03-22): -# German Iofis, ELSI, Almaty (2001-10-09) reports that Kazakhstan uses -# RussiaAsia rules, instead of switching at 00:00 as the IATA has it. -# Go with Shanks & Pottenger, who have them always using RussiaAsia rules. -# Also go with the following claims of Shanks & Pottenger: -# -# - Kazakhstan did not observe DST in 1991. -# - Qyzylorda switched from +5:00 to +6:00 on 1992-01-19 02:00. -# - Oral switched from +5:00 to +4:00 in spring 1989. - # From Kazakhstan Embassy's News Bulletin No. 11 # (2005-03-21): # The Government of Kazakhstan passed a resolution March 15 abolishing @@ -1575,61 +1575,232 @@ Zone Asia/Amman 2:23:44 - LMT 1931 # everything else.... I guess that would make Kazakhstan time zones # de jure UTC+5 and UTC+6 respectively. +# From Stepan Golosunov (2016-03-27) ([*] means see later comments below): +# Review of the linked documents from http://adilet.zan.kz/ +# produced the following data for post-1991 Kazakhstan: +# +# 0. Act of the Cabinet of Ministers of the USSR +# from 1991-02-04 No. 20 +# http://pravo.gov.ru/proxy/ips/?docbody=&nd=102010545 +# removed the extra hour ("decree time") on the territory of the USSR +# starting with the last Sunday of March 1991. +# It also allowed (but not mandated) Kazakh SSR, Kirghiz SSR, Tajik SSR, +# Turkmen SSR and Uzbek SSR to not have "summer" time. +# +# The 1992-01-13 act also refers to the act of the Cabinet of Ministers +# of the Kazakh SSR from 1991-03-20 No. 170 "About the act of the Cabinet +# of Ministers of the USSR from 1991-02-04 No. 20" but I didn't found its +# text. +# +# According to Izvestia newspaper No. 68 (23334) from 1991-03-20 +# (page 6; available at http://libinfo.org/newsr/newsr2574.djvu via +# http://libinfo.org/index.php?id=58564) on 1991-03-31 at 2:00 during +# transition to "summer" time: +# Republic of Georgia, Latvian SSR, Lithuanian SSR, SSR Moldova, +# Estonian SSR; Komi ASSR; Kaliningrad oblast; Nenets autonomous okrug +# were to move clocks 1 hour forward. +# Kazakh SSR (excluding Uralsk oblast); Republic of Kyrgyzstan, Tajik +# SSR; Andijan, Jizzakh, Namangan, Sirdarya, Tashkent, Fergana oblasts +# of the Uzbek SSR were to move clocks 1 hour backwards. +# Other territories were to not move clocks. +# When the "summer" time would end on 1991-09-29, clocks were to be +# moved 1 hour backwards on the territory of the USSR excluding +# Kazakhstan, Kirghizia, Uzbekistan, Turkmenia, Tajikistan. +# +# Apparently there were last minute changes. Apparently Kazakh act No. 170 +# was one of such changes. +# +# https://ru.wikipedia.org/wiki/Декретное Ð²Ñ€ÐµÐ¼Ñ +# claims that Sovetskaya Rossiya newspaper on 1991-03-29 published that +# Nenets autonomous okrug, Komi and Kazakhstan (excluding Uralsk oblast) +# were to not move clocks and Uralsk oblast was to move clocks +# forward; on 1991-09-29 Kazakhstan was to move clocks backwards. +# (Probably there were changes even after that publication. There is an +# article claiming that Kaliningrad oblast decided on 1991-03-29 to not +# move clocks.) +# +# This implies that on 1991-03-31 Asia/Oral remained on +04/+05 while +# the rest of Kazakhstan switched from +06/+07 to +05/06 or from +05/06 +# to +04/+05. It's unclear how Kzyl-Orda oblast moved into the fifth +# time belt. (By switching from +04/+05 to +05/+06 on 1991-09-29?) ... +# +# 1. Act of the Cabinet of Ministers of the Republic of Kazakhstan +# from 1992-01-13 No. 28 +# http://adilet.zan.kz/rus/docs/P920000028_ +# (text includes modification from the 1996 act) +# introduced new rules for calculation of time, mirroring Russian +# 1992-01-08 act. It specified that time would be calculated +# according to time belts plus extra hour ("decree time"), moved clocks +# on the whole territory of Kazakhstan 1 hour forward on 1992-01-19 at +# 2:00, specified DST rules. It acknowledged that Kazakhstan was +# located in the fourth and the fifth time belts and specified the +# border between them to be located east of Kustanay and Aktyubinsk +# oblasts (notably including Turgai and Kzyl-Orda oblasts into the fifth +# time belt). +# +# This means switch on 1992-01-19 at 2:00 from +04/+05 to +05/+06 for +# Asia/Aqtau, Asia/Aqtobe, Asia/Oral, Atyrau and Kustanay oblasts; from +# +05/+06 to +06/+07 for Asia/Almaty and Asia/Qyzylorda (and Arkalyk) [*].... +# +# 2. Act of the Cabinet of Ministers of the Republic of Kazakhstan +# from 1992-03-27 No. 284 +# http://adilet.zan.kz/rus/docs/P920000284_ +# cancels extra hour ("decree time") for Uralsk and Kzyl-Orda oblasts +# since the last Sunday of March 1992, while keeping them in the fourth +# and the fifth time belts respectively. +# +# 3. Order of the Prime Minister of the Republic of Kazakhstan +# from 1994-09-23 No. 384 +# http://adilet.zan.kz/rus/docs/R940000384_ +# cancels the extra hour ("decree time") on the territory of Mangystau +# oblast since the last Sunday of September 1994 (saying that time on +# the territory would correspond to the third time belt as a +# result).... +# +# 4. Act of the Government of the Republic of Kazakhstan +# from 1996-05-08 No. 575 +# http://adilet.zan.kz/rus/docs/P960000575_ +# amends the 1992-01-13 act to end summer time in October instead +# of September, mirroring identical Russian change from 1996-04-23 act. +# +# 5. Act of the Government of the Republic of Kazakhstan +# from 1999-03-26 No. 305 +# http://adilet.zan.kz/rus/docs/P990000305_ +# cancels the extra hour ("decree time") for Atyrau oblast since the +# last Sunday of March 1999 while retaining the oblast in the fourth +# time belt. +# +# This means change from +05/+06 to +04/+05. +# +# There is no zone for Atyrau currently (listed under Asia/Aqtau in +# zone1970.tab).[*] +# +# 6. Act of the Government of the Republic of Kazakhstan +# from 2000-11-23 No. 1749 +# http://adilet.zan.kz/rus/archive/docs/P000001749_/23.11.2000 +# replaces the previous five documents. +# +# The only changes I noticed are in definition of the border between the +# fourth and the fifth time belts. They account for changes in spelling +# and administrative division (splitting of Turgai oblast in 1997 +# probably changed time in territories incorporated into Kostanay oblast +# (including Arkalyk) from +06/+07 to +05/+06) and move Kyzylorda oblast +# from being in the fifth time belt and not using decree time into the +# fourth time belt (no change in practice).[*] +# +# 7. Act of the Government of the Republic of Kazakhstan +# from 2003-12-29 No. 1342 +# http://adilet.zan.kz/rus/docs/P030001342_ +# modified the 2000-11-23 act. No relevant changes, apparently. +# +# 8. Act of the Government of the Republic of Kazakhstan +# from 2004-07-20 No. 775 +# http://adilet.zan.kz/rus/archive/docs/P040000775_/20.07.2004 +# modified the 2000-11-23 act to move Kostanay and Kyzylorda oblasts into +# the fifth time belt and add Aktobe oblast to the list of regions not +# using extra hour ("decree time"), leaving Kazakhstan with only 2 time +# zones (+04/+05 and +06/+07). The changes were to be implemented +# during DST transitions in 2004 and 2005 but the acts got radically +# amended before implementation happened. +# +# 9. Act of the Government of the Republic of Kazakhstan +# from 2004-09-15 No. 1059 +# http://adilet.zan.kz/rus/docs/P040001059_ +# modified the 2000-11-23 act to remove exceptions from the "decree time" +# (leaving Kazakhstan in +05/+06 and +06/+07 zones), amended the +# 2004-07-20 act to implement changes for Atyrau, West Kazakhstan, +# Kostanay, Kyzylorda and Mangystau oblasts by not moving clocks +# during the 2014 transition to "winter" time. +# +# This means transition from +04/+05 to +05/+06 for Atyrau oblast (no +# zone currently), Asia/Oral, Asia/Aqtau and transition from +05/+06 to +# +06/+07 for Kostanay oblast (Kostanay and Arkalyk, no zones currently) +# and Asia/Qyzylorda on 2004-10-31 at 3:00....[*] +# +# 10. Act of the Government of the Republic of Kazakhstan +# from 2005-03-15 No. 231 +# http://adilet.zan.kz/rus/docs/P050000231_ +# removes DST provisions from the 2000-11-23 act, removes most of the +# (already implemented) provisions from the 2004-07-20 and 2004-09-15 +# acts, comes into effect 10 days after official publication. +# The only practical effect seems to be the abolition of the summer +# time. +# +# Unamended version of the act of the Government of the Russian Federation +# No. 23 from 1992-01-08 [See 'europe' file for details]. +# Kazakh 1992-01-13 act appears to provide the same rules and 1992-03-27 +# act was to be enacted on the last Sunday of March 1992. + +# From Paul Eggert (2016-04-15): +# The tables below should reflect Stepan Golosunov's remarks above, +# except for the items marked "[*]" which I haven't gotten to yet. +# It looks like we will need new zones Asia/Atyrau and Asia/Qostanay +# to handle changes from 1992 through 2004 that we did not previously +# know about. + # # Zone NAME GMTOFF RULES FORMAT [UNTIL] # # Almaty (formerly Alma-Ata), representing most locations in Kazakhstan +# This includes KZ-AKM, KZ-ALA, KZ-ALM, KZ-AST, KZ-BAY, KZ-VOS, KZ-ZHA, +# KZ-KAR, KZ-SEV, KZ-PAV, and KZ-YUZ. Zone Asia/Almaty 5:07:48 - LMT 1924 May 2 # or Alma-Ata - 5:00 - ALMT 1930 Jun 21 # Alma-Ata Time - 6:00 RussiaAsia ALM%sT 1991 - 6:00 - ALMT 1992 - 6:00 RussiaAsia ALM%sT 2005 Mar 15 - 6:00 - ALMT -# Qyzylorda (aka Kyzylorda, Kizilorda, Kzyl-Orda, etc.) + 5:00 - +05 1930 Jun 21 + 6:00 RussiaAsia +06/+07 1991 Mar 31 2:00s + 5:00 RussiaAsia +05/+06 1992 Jan 19 2:00s + 6:00 RussiaAsia +06/+07 2004 Oct 31 2:00s + 6:00 - +06 +# Qyzylorda (aka Kyzylorda, Kizilorda, Kzyl-Orda, etc.) (KZ-KZY) Zone Asia/Qyzylorda 4:21:52 - LMT 1924 May 2 - 4:00 - KIZT 1930 Jun 21 # Kizilorda Time - 5:00 - KIZT 1981 Apr 1 - 5:00 1:00 KIZST 1981 Oct 1 - 6:00 - KIZT 1982 Apr 1 - 5:00 RussiaAsia KIZ%sT 1991 - 5:00 - KIZT 1991 Dec 16 # independence - 5:00 - QYZT 1992 Jan 19 2:00 - 6:00 RussiaAsia QYZ%sT 2005 Mar 15 - 6:00 - QYZT -# Aqtobe (aka Aktobe, formerly Aktyubinsk) + 4:00 - +04 1930 Jun 21 + 5:00 - +05 1981 Apr 1 + 5:00 1:00 +06 1981 Oct 1 + 6:00 - +06 1982 Apr 1 + 5:00 RussiaAsia +05/+06 1991 Mar 31 2:00s + 4:00 RussiaAsia +04/+05 1991 Sep 29 2:00s + 5:00 RussiaAsia +05/+06 1992 Jan 19 2:00s + 6:00 RussiaAsia +06/+07 1992 Mar 29 2:00s + 5:00 RussiaAsia +05/+06 2004 Oct 31 2:00s + 6:00 - +06 +# Aqtobe (aka Aktobe, formerly Aktyubinsk) (KZ-AKT) Zone Asia/Aqtobe 3:48:40 - LMT 1924 May 2 - 4:00 - AKTT 1930 Jun 21 # Aktyubinsk Time - 5:00 - AKTT 1981 Apr 1 - 5:00 1:00 AKTST 1981 Oct 1 - 6:00 - AKTT 1982 Apr 1 - 5:00 RussiaAsia AKT%sT 1991 - 5:00 - AKTT 1991 Dec 16 # independence - 5:00 RussiaAsia AQT%sT 2005 Mar 15 # Aqtobe Time - 5:00 - AQTT -# Mangghystau + 4:00 - +04 1930 Jun 21 + 5:00 - +05 1981 Apr 1 + 5:00 1:00 +06 1981 Oct 1 + 6:00 - +06 1982 Apr 1 + 5:00 RussiaAsia +05/+06 1991 Mar 31 2:00s + 4:00 RussiaAsia +04/+05 1992 Jan 19 2:00s + 5:00 RussiaAsia +05/+06 2004 Oct 31 2:00s + 5:00 - +05 +# Qostanay (KZ-KUS) + +# Mangghystau (KZ-MAN) # Aqtau was not founded until 1963, but it represents an inhabited region, # so include time stamps before 1963. Zone Asia/Aqtau 3:21:04 - LMT 1924 May 2 - 4:00 - FORT 1930 Jun 21 # Fort Shevchenko T - 5:00 - FORT 1963 - 5:00 - SHET 1981 Oct 1 # Shevchenko Time - 6:00 - SHET 1982 Apr 1 - 5:00 RussiaAsia SHE%sT 1991 - 5:00 - SHET 1991 Dec 16 # independence - 5:00 RussiaAsia AQT%sT 1995 Mar lastSun 2:00 # Aqtau Time - 4:00 RussiaAsia AQT%sT 2005 Mar 15 - 5:00 - AQTT -# West Kazakhstan + 4:00 - +04 1930 Jun 21 + 5:00 - +05 1963 + 5:00 - +05 1981 Oct 1 + 6:00 - +06 1982 Apr 1 + 5:00 RussiaAsia +05/+06 1991 Mar 31 2:00s + 4:00 RussiaAsia +04/+05 1992 Jan 19 2:00s + 5:00 RussiaAsia +05/+06 1994 Sep 25 2:00s + 4:00 RussiaAsia +04/+05 2004 Oct 31 2:00s + 5:00 - +05 + +# West Kazakhstan (KZ-ZAP) +# From Paul Eggert (2016-03-18): +# The 1989 transition is from USSR act No. 227 (1989-03-14). Zone Asia/Oral 3:25:24 - LMT 1924 May 2 # or Ural'sk - 4:00 - URAT 1930 Jun 21 # Ural'sk time - 5:00 - URAT 1981 Apr 1 - 5:00 1:00 URAST 1981 Oct 1 - 6:00 - URAT 1982 Apr 1 - 5:00 RussiaAsia URA%sT 1989 Mar 26 2:00 - 4:00 RussiaAsia URA%sT 1991 - 4:00 - URAT 1991 Dec 16 # independence - 4:00 RussiaAsia ORA%sT 2005 Mar 15 # Oral Time - 5:00 - ORAT + 4:00 - +04 1930 Jun 21 + 5:00 - +05 1981 Apr 1 + 5:00 1:00 +06 1981 Oct 1 + 6:00 - +06 1982 Apr 1 + 5:00 RussiaAsia +05/+06 1989 Mar 26 2:00s + 4:00 RussiaAsia +04/+05 1992 Jan 19 2:00s + 5:00 RussiaAsia +05/+06 1992 Mar 29 2:00s + 4:00 RussiaAsia +04/+05 2004 Oct 31 2:00s + 5:00 - +05 # Kyrgyzstan (Kirgizstan) # Transitions through 1991 are from Shanks & Pottenger. @@ -1650,11 +1821,11 @@ Rule Kyrgyz 1997 2005 - Mar lastSun 2:30 Rule Kyrgyz 1997 2004 - Oct lastSun 2:30 0 - # Zone NAME GMTOFF RULES FORMAT [UNTIL] Zone Asia/Bishkek 4:58:24 - LMT 1924 May 2 - 5:00 - FRUT 1930 Jun 21 # Frunze Time - 6:00 RussiaAsia FRU%sT 1991 Mar 31 2:00s - 5:00 1:00 FRUST 1991 Aug 31 2:00 # independence - 5:00 Kyrgyz KG%sT 2005 Aug 12 # Kyrgyzstan Time - 6:00 - KGT + 5:00 - +05 1930 Jun 21 + 6:00 RussiaAsia +06/+07 1991 Mar 31 2:00s + 5:00 RussiaAsia +05/+06 1991 Aug 31 2:00 + 5:00 Kyrgyz +05/+06 2005 Aug 12 + 6:00 - +06 ############################################################################### @@ -1693,25 +1864,24 @@ Rule ROK 1957 1960 - Sep Sun>=18 0:00 0 Rule ROK 1987 1988 - May Sun>=8 2:00 1:00 D Rule ROK 1987 1988 - Oct Sun>=8 3:00 0 S -# From Paul Eggert (2014-10-30): +# From Paul Eggert (2016-08-23): # The Korean Wikipedia entry gives the following sources for UT offsets: # -# 1908: Official Journal Article No. 3994 (Edict No. 5) +# 1908: Official Journal Article No. 3994 (decree No. 5) # 1912: Governor-General of Korea Official Gazette Issue No. 367 # (Announcement No. 338) # 1954: Presidential Decree No. 876 (1954-03-17) # 1961: Law No. 676 (1961-08-07) -# 1987: Law No. 3919 (1986-12-31) # -# The Wikipedia entry also has confusing information about a change -# to UT+9 in April 1910, but then what would be the point of the later change -# to UT+9 on 1912-01-01? Omit the 1910 change for now. +# (Another source "1987: Law No. 3919 (1986-12-31)" was in the 2014-10-30 +# edition of the Korean Wikipedia entry.) # # I guessed that time zone abbreviations through 1945 followed the same # rules as discussed under Taiwan, with nominal switches from JST to KST # when the respective cities were taken over by the Allies after WWII. # -# For Pyongyang we have no information; guess no changes since World War II. +# For Pyongyang, guess no changes from World War II until 2015, as we +# have no information otherwise. # From Steffen Thorsen (2015-08-07): # According to many news sources, North Korea is going to change to @@ -1871,7 +2041,7 @@ Zone Indian/Maldives 4:54:00 - LMT 1880 # Bill Bonnet (2005-05-19) reports that the US Embassy in Ulaanbaatar says # there is only one time zone and that DST is observed, citing Microsoft # Windows XP as the source. Risto Nykänen (2005-05-16) reports that -# travelmongolia.org says there are two time zones (UTC+7, UTC+8) with no DST. +# travelmongolia.org says there are two time zones (UT +07, +08) with no DST. # Oscar van Vlijmen (2005-05-20) reports that the Mongolian Embassy in # Washington, DC says there are two time zones, with DST observed. # He also found @@ -2111,8 +2281,8 @@ Zone Asia/Kathmandu 5:41:16 - LMT 1920 # http://www.app.com.pk/en_/index.php?option=com_content&task=view&id=99374&Itemid=2 # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule Pakistan 2002 only - Apr Sun>=2 0:01 1:00 S -Rule Pakistan 2002 only - Oct Sun>=2 0:01 0 - +Rule Pakistan 2002 only - Apr Sun>=2 0:00 1:00 S +Rule Pakistan 2002 only - Oct Sun>=2 0:00 0 - Rule Pakistan 2008 only - Jun 1 0:00 1:00 S Rule Pakistan 2008 2009 - Nov 1 0:00 0 - Rule Pakistan 2009 only - Apr 15 0:00 1:00 S @@ -2380,6 +2550,16 @@ Zone Asia/Karachi 4:28:12 - LMT 1907 # http://www.timeanddate.com/time/change/gaza-strip/gaza # http://www.timeanddate.com/time/change/west-bank/hebron +# From Hannah Kreitem (2016-03-09): +# http://www.palestinecabinet.gov.ps/WebSite/ar/ViewDetails?ID=31728 +# [Google translation]: "The Council also decided to start daylight +# saving in Palestine as of one o'clock on Saturday morning, +# 2016-03-26, to provide the clock 60 minutes ahead." +# +# From Paul Eggert (2016-03-12): +# Predict spring transitions on March's last Saturday at 01:00 from now on. +# Leave fall predictions alone for now. + # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S Rule EgyptAsia 1957 only - May 10 0:00 1:00 S Rule EgyptAsia 1957 1958 - Oct 1 0:00 0 - @@ -2408,7 +2588,8 @@ Rule Palestine 2012 2014 - Mar lastThu 2 Rule Palestine 2012 only - Sep 21 1:00 0 - Rule Palestine 2013 only - Sep Fri>=21 0:00 0 - Rule Palestine 2014 max - Oct Fri>=21 0:00 0 - -Rule Palestine 2015 max - Mar lastFri 24:00 1:00 S +Rule Palestine 2015 only - Mar lastFri 24:00 1:00 S +Rule Palestine 2016 max - Mar lastSat 1:00 1:00 S # Zone NAME GMTOFF RULES FORMAT [UNTIL] Zone Asia/Gaza 2:17:52 - LMT 1900 Oct @@ -2496,7 +2677,7 @@ Link Asia/Qatar Asia/Bahrain # earlier date. # # Shanks & Pottenger also state that until 1968-05-01 Saudi Arabia had two -# time zones; the other zone, at UTC+4, was in the far eastern part of +# time zones; the other zone, at UT +04, was in the far eastern part of # the country. Ignore this, as it's before our 1970 cutoff. # # Zone NAME GMTOFF RULES FORMAT [UNTIL] @@ -2765,10 +2946,10 @@ Zone Asia/Damascus 2:25:12 - LMT 1920 # # From Shanks & Pottenger. # Zone NAME GMTOFF RULES FORMAT [UNTIL] Zone Asia/Dushanbe 4:35:12 - LMT 1924 May 2 - 5:00 - DUST 1930 Jun 21 # Dushanbe Time - 6:00 RussiaAsia DUS%sT 1991 Mar 31 2:00s - 5:00 1:00 DUSST 1991 Sep 9 2:00s - 5:00 - TJT # Tajikistan Time + 5:00 - +05 1930 Jun 21 + 6:00 RussiaAsia +06/+07 1991 Mar 31 2:00s + 5:00 1:00 +05/+06 1991 Sep 9 2:00s + 5:00 - +05 # Thailand # Zone NAME GMTOFF RULES FORMAT [UNTIL] @@ -2782,11 +2963,10 @@ Link Asia/Bangkok Asia/Vientiane # Laos # From Shanks & Pottenger. # Zone NAME GMTOFF RULES FORMAT [UNTIL] Zone Asia/Ashgabat 3:53:32 - LMT 1924 May 2 # or Ashkhabad - 4:00 - ASHT 1930 Jun 21 # Ashkhabad Time - 5:00 RussiaAsia ASH%sT 1991 Mar 31 2:00 - 4:00 RussiaAsia ASH%sT 1991 Oct 27 # independence - 4:00 RussiaAsia TM%sT 1992 Jan 19 2:00 - 5:00 - TMT + 4:00 - +04 1930 Jun 21 + 5:00 RussiaAsia +05/+06 1991 Mar 31 2:00 + 4:00 RussiaAsia +04/+05 1992 Jan 19 2:00 + 5:00 - +05 # United Arab Emirates # Zone NAME GMTOFF RULES FORMAT [UNTIL] @@ -2798,20 +2978,18 @@ Link Asia/Dubai Asia/Muscat # Oman # Byalokoz 1919 says Uzbekistan was 4:27:53. # Zone NAME GMTOFF RULES FORMAT [UNTIL] Zone Asia/Samarkand 4:27:53 - LMT 1924 May 2 - 4:00 - SAMT 1930 Jun 21 # Samarkand Time - 5:00 - SAMT 1981 Apr 1 - 5:00 1:00 SAMST 1981 Oct 1 - 6:00 - TAST 1982 Apr 1 # Tashkent Time - 5:00 RussiaAsia SAM%sT 1991 Sep 1 # independence - 5:00 RussiaAsia UZ%sT 1992 - 5:00 - UZT + 4:00 - +04 1930 Jun 21 + 5:00 - +05 1981 Apr 1 + 5:00 1:00 +06 1981 Oct 1 + 6:00 - +06 1982 Apr 1 + 5:00 RussiaAsia +05/+06 1992 + 5:00 - +05 # Milne says Tashkent was 4:37:10.8; round to nearest. Zone Asia/Tashkent 4:37:11 - LMT 1924 May 2 - 5:00 - TAST 1930 Jun 21 # Tashkent Time - 6:00 RussiaAsia TAS%sT 1991 Mar 31 2:00 - 5:00 RussiaAsia TAS%sT 1991 Sep 1 # independence - 5:00 RussiaAsia UZ%sT 1992 - 5:00 - UZT + 5:00 - +05 1930 Jun 21 + 6:00 RussiaAsia +06/+07 1991 Mar 31 2:00 + 5:00 RussiaAsia +05/+06 1992 + 5:00 - +05 # Vietnam Modified: stable/9/contrib/tzdata/australasia ============================================================================== --- stable/9/contrib/tzdata/australasia Sat Oct 15 12:41:41 2016 (r307362) +++ stable/9/contrib/tzdata/australasia Sat Oct 15 12:42:47 2016 (r307363) @@ -60,6 +60,14 @@ Zone Australia/Eucla 8:35:28 - LMT 1895 # Hamilton is the largest, but there is also a Hamilton in Victoria, # so use Lindeman. # +# From J William Piggott (2016-02-20): +# There is no location named Holiday Islands in Queensland Australia; holiday +# islands is a colloquial term used globally. Hayman and Lindeman are at the +# north and south extremes of the Whitsunday Islands archipelago, and +# Hamilton is in between; it is reasonable to believe that this time zone +# applies to all of the Whitsundays. +# http://www.australia.gov.au/about-australia/australian-story/austn-islands +# # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S Rule AQ 1971 only - Oct lastSun 2:00s 1:00 D Rule AQ 1972 only - Feb lastSun 2:00s 0 S @@ -235,11 +243,11 @@ Zone Australia/Lord_Howe 10:36:20 - LMT # will produce a binary file with an [A]EST-type as the first 32-bit type; # this is required for correct handling of times before 1916 by # pre-2013 versions of localtime. -Zone Antarctica/Macquarie 0 - zzz 1899 Nov +Zone Antarctica/Macquarie 0 - -00 1899 Nov 10:00 - AEST 1916 Oct 1 2:00 10:00 1:00 AEDT 1917 Feb 10:00 Aus AE%sT 1919 Apr 1 0:00s - 0 - zzz 1948 Mar 25 + 0 - -00 1948 Mar 25 10:00 Aus AE%sT 1967 10:00 AT AE%sT 2010 Apr 4 3:00 11:00 - MIST # Macquarie I Standard Time @@ -537,7 +545,7 @@ Zone Pacific/Port_Moresby 9:48:40 - LMT # Base the Bougainville entry on the Arawa-Kieta region, which appears to have # the most people even though it was devastated in the Bougainville Civil War. # -# Although Shanks gives 1942-03-15 / 1943-11-01 for JST, these dates +# Although Shanks gives 1942-03-15 / 1943-11-01 for UT +09, these dates # are apparently rough guesswork from the starts of military campaigns. # The World War II entries below are instead based on Arawa-Kieta. # The Japanese occupied Kieta in July 1942, @@ -545,8 +553,8 @@ Zone Pacific/Port_Moresby 9:48:40 - LMT # http://pwencycl.kgbudge.com/B/o/Bougainville.htm # and seem to have controlled it until their 1945-08-21 surrender. # -# The Autonomous Region of Bougainville plans to switch from UTC+10 to UTC+11 -# on 2014-12-28 at 02:00. They call UTC+11 "Bougainville Standard Time"; +# The Autonomous Region of Bougainville switched from UT +10 to +11 +# on 2014-12-28 at 02:00. They call +11 "Bougainville Standard Time"; # abbreviate this as BST. See: # http://www.bougainville24.com/bougainville-issues/bougainville-gets-own-timezone/ # @@ -612,7 +620,7 @@ Link Pacific/Pago_Pago Pacific/Midway # # From Paul Eggert (2014-06-27): # The International Date Line Act 2011 # http://www.parliament.gov.ws/images/ACTS/International_Date_Line_Act__2011_-_Eng.pdf -# changed Samoa from UTC-11 to UTC+13, effective "12 o'clock midnight, on +# changed Samoa from UT -11 to +13, effective "12 o'clock midnight, on # Thursday 29th December 2011". The International Date Line was adjusted # accordingly. @@ -707,7 +715,7 @@ Zone Pacific/Funafuti 11:56:52 - LMT 190 # 1886-1891; Baker was similar but exact dates are not known. # Inhabited by civilians 1935-1942; U.S. military bases 1943-1944; # uninhabited thereafter. -# Howland observed Hawaii Standard Time (UT-10:30) in 1937; +# Howland observed Hawaii Standard Time (UT -10:30) in 1937; # see page 206 of Elgen M. Long and Marie K. Long, # Amelia Earhart: the Mystery Solved, Simon & Schuster (2000). # So most likely Howland and Baker observed Hawaii Time from 1935 @@ -1465,7 +1473,7 @@ Zone Pacific/Wallis 12:15:20 - LMT 1901 # Zealand time. I understand that is the time they keep locally, anyhow." # For now, assume this practice goes back to the introduction of standard time # in New Zealand, as this would make Chatham Islands time almost exactly match -# LMT back when New Zealand was at UTC+11:30; also, assume Chatham Islands did +# LMT back when New Zealand was at UT +11:30; also, assume Chatham Islands did # not observe New Zealand's prewar DST. *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-all@freebsd.org Sat Oct 15 13:16:53 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id EA625C13985; Sat, 15 Oct 2016 13:16:53 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id BAA7F687; Sat, 15 Oct 2016 13:16:53 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9FDGq5k046947; Sat, 15 Oct 2016 13:16:52 GMT (envelope-from bapt@FreeBSD.org) Received: (from bapt@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9FDGqQN046946; Sat, 15 Oct 2016 13:16:52 GMT (envelope-from bapt@FreeBSD.org) Message-Id: <201610151316.u9FDGqQN046946@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bapt set sender to bapt@FreeBSD.org using -f From: Baptiste Daroussin Date: Sat, 15 Oct 2016 13:16:52 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307364 - head/lib/libdevdctl X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 Oct 2016 13:16:54 -0000 Author: bapt Date: Sat Oct 15 13:16:52 2016 New Revision: 307364 URL: https://svnweb.freebsd.org/changeset/base/307364 Log: directly create the socket with SOCK_NONBLOCK instead of calling fcntl(2) Modified: head/lib/libdevdctl/consumer.cc Modified: head/lib/libdevdctl/consumer.cc ============================================================================== --- head/lib/libdevdctl/consumer.cc Sat Oct 15 12:42:47 2016 (r307363) +++ head/lib/libdevdctl/consumer.cc Sat Oct 15 13:16:52 2016 (r307364) @@ -108,11 +108,9 @@ Consumer::ConnectToDevd() strlcpy(devdAddr.sun_path, s_devdSockPath, sizeof(devdAddr.sun_path)); sLen = SUN_LEN(&devdAddr); - m_devdSockFD = socket(AF_UNIX, SOCK_SEQPACKET, 0); + m_devdSockFD = socket(AF_UNIX, SOCK_SEQPACKET | SOCK_NONBLOCK, 0); if (m_devdSockFD == -1) err(1, "Unable to create socket"); - if (fcntl(m_devdSockFD, F_SETFL, O_NONBLOCK) < 0) - err(1, "fcntl"); result = connect(m_devdSockFD, reinterpret_cast(&devdAddr), sLen); From owner-svn-src-all@freebsd.org Sat Oct 15 13:17:28 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 6EE06C139CE; Sat, 15 Oct 2016 13:17:28 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 3E74D853; Sat, 15 Oct 2016 13:17:28 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9FDHR7A047012; Sat, 15 Oct 2016 13:17:27 GMT (envelope-from bapt@FreeBSD.org) Received: (from bapt@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9FDHRt9047011; Sat, 15 Oct 2016 13:17:27 GMT (envelope-from bapt@FreeBSD.org) Message-Id: <201610151317.u9FDHRt9047011@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bapt set sender to bapt@FreeBSD.org using -f From: Baptiste Daroussin Date: Sat, 15 Oct 2016 13:17:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307365 - head/lib/libucl X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 Oct 2016 13:17:28 -0000 Author: bapt Date: Sat Oct 15 13:17:27 2016 New Revision: 307365 URL: https://svnweb.freebsd.org/changeset/base/307365 Log: Use SRCTOP to find the sources of libucl Modified: head/lib/libucl/Makefile Modified: head/lib/libucl/Makefile ============================================================================== --- head/lib/libucl/Makefile Sat Oct 15 13:16:52 2016 (r307364) +++ head/lib/libucl/Makefile Sat Oct 15 13:17:27 2016 (r307365) @@ -1,6 +1,6 @@ # $FreeBSD$ -LIBUCL= ${.CURDIR}/../../contrib/libucl +LIBUCL= ${SRCTOP}/contrib/libucl PACKAGE=lib${LIB} LIB= ucl From owner-svn-src-all@freebsd.org Sat Oct 15 13:27:02 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 7FB18C13D8E; Sat, 15 Oct 2016 13:27:02 +0000 (UTC) (envelope-from jmcneill@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4FC51F39; Sat, 15 Oct 2016 13:27:02 +0000 (UTC) (envelope-from jmcneill@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9FDR1s5050775; Sat, 15 Oct 2016 13:27:01 GMT (envelope-from jmcneill@FreeBSD.org) Received: (from jmcneill@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9FDR1Y0050774; Sat, 15 Oct 2016 13:27:01 GMT (envelope-from jmcneill@FreeBSD.org) Message-Id: <201610151327.u9FDR1Y0050774@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jmcneill set sender to jmcneill@FreeBSD.org using -f From: Jared McNeill Date: Sat, 15 Oct 2016 13:27:01 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307366 - head/sys/arm/allwinner/clk X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 Oct 2016 13:27:02 -0000 Author: jmcneill Date: Sat Oct 15 13:27:01 2016 New Revision: 307366 URL: https://svnweb.freebsd.org/changeset/base/307366 Log: Match "allwinner,sun8i-h3-apb0-gates-clk" compatible string. Modified: head/sys/arm/allwinner/clk/aw_gate.c Modified: head/sys/arm/allwinner/clk/aw_gate.c ============================================================================== --- head/sys/arm/allwinner/clk/aw_gate.c Sat Oct 15 13:17:27 2016 (r307365) +++ head/sys/arm/allwinner/clk/aw_gate.c Sat Oct 15 13:27:01 2016 (r307366) @@ -91,6 +91,8 @@ static struct ofw_compat_data compat_dat { "allwinner,sun8i-h3-bus-gates-clk", (uintptr_t)"Allwinner Bus Clock Gates" }, + { "allwinner,sun8i-h3-apb0-gates-clk", + (uintptr_t)"Allwinner APB0 Clock Gates" }, { "allwinner,sun9i-a80-apbs-gates-clk", (uintptr_t)"Allwinner APBS Clock Gates" }, From owner-svn-src-all@freebsd.org Sat Oct 15 13:39:32 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 1DCFAC121C1; Sat, 15 Oct 2016 13:39:32 +0000 (UTC) (envelope-from arybchik@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id D3EA97B0; Sat, 15 Oct 2016 13:39:31 +0000 (UTC) (envelope-from arybchik@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9FDdUPO054651; Sat, 15 Oct 2016 13:39:30 GMT (envelope-from arybchik@FreeBSD.org) Received: (from arybchik@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9FDdUHP054650; Sat, 15 Oct 2016 13:39:30 GMT (envelope-from arybchik@FreeBSD.org) Message-Id: <201610151339.u9FDdUHP054650@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: arybchik set sender to arybchik@FreeBSD.org using -f From: Andrew Rybchenko Date: Sat, 15 Oct 2016 13:39:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307367 - stable/11/sys/dev/sfxge/common X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 Oct 2016 13:39:32 -0000 Author: arybchik Date: Sat Oct 15 13:39:30 2016 New Revision: 307367 URL: https://svnweb.freebsd.org/changeset/base/307367 Log: MFC r306944 sfxge(4): sync tlv_layout.h with firmwaresrc and update port-mode definition use It fixes driver attach issue to a new firmware which reports a new port-modes. Submitted by: Tom Millington Sponsored by: Solarflare Communications, Inc. Modified: stable/11/sys/dev/sfxge/common/ef10_nic.c stable/11/sys/dev/sfxge/common/ef10_tlv_layout.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/sfxge/common/ef10_nic.c ============================================================================== --- stable/11/sys/dev/sfxge/common/ef10_nic.c Sat Oct 15 13:27:01 2016 (r307366) +++ stable/11/sys/dev/sfxge/common/ef10_nic.c Sat Oct 15 13:39:30 2016 (r307367) @@ -164,6 +164,7 @@ ef10_nic_get_port_mode_bandwidth( break; case TLV_PORT_MODE_10G_10G_10G_10G: case TLV_PORT_MODE_10G_10G_10G_10G_Q: + case TLV_PORT_MODE_10G_10G_10G_10G_Q1_Q2: case TLV_PORT_MODE_10G_10G_10G_10G_Q2: bandwidth = 10000 * 4; break; @@ -1122,8 +1123,7 @@ static struct { { EFX_FAMILY_MEDFORD, (1 << TLV_PORT_MODE_10G) | - (1 << TLV_PORT_MODE_10G_10G) | - (1 << TLV_PORT_MODE_10G_10G_10G_10G), + (1 << TLV_PORT_MODE_10G_10G), 1 }, /* Supported modes requiring 2 outputs per port */ @@ -1140,13 +1140,15 @@ static struct { (1 << TLV_PORT_MODE_40G) | (1 << TLV_PORT_MODE_40G_40G) | (1 << TLV_PORT_MODE_40G_10G_10G) | - (1 << TLV_PORT_MODE_10G_10G_40G), + (1 << TLV_PORT_MODE_10G_10G_40G) | + (1 << TLV_PORT_MODE_10G_10G_10G_10G_Q1_Q2), 2 }, /* Supported modes requiring 4 outputs per port */ { EFX_FAMILY_MEDFORD, (1 << TLV_PORT_MODE_10G_10G_10G_10G_Q) | + (1 << TLV_PORT_MODE_10G_10G_10G_10G_Q1) | (1 << TLV_PORT_MODE_10G_10G_10G_10G_Q2), 4 }, Modified: stable/11/sys/dev/sfxge/common/ef10_tlv_layout.h ============================================================================== --- stable/11/sys/dev/sfxge/common/ef10_tlv_layout.h Sat Oct 15 13:27:01 2016 (r307366) +++ stable/11/sys/dev/sfxge/common/ef10_tlv_layout.h Sat Oct 15 13:39:30 2016 (r307367) @@ -553,12 +553,14 @@ struct tlv_global_port_mode { #define TLV_PORT_MODE_40G (1) /* 40G, single QSFP/40G-KR */ #define TLV_PORT_MODE_10G_10G (2) /* 2x10G, dual SFP/10G-KR or single QSFP */ #define TLV_PORT_MODE_40G_40G (3) /* 40G + 40G, dual QSFP/40G-KR (Greenport, Medford) */ -#define TLV_PORT_MODE_10G_10G_10G_10G (4) /* 2x10G + 2x10G, quad SFP/10G-KR or dual QSFP (Greenport, Medford) */ -#define TLV_PORT_MODE_10G_10G_10G_10G_Q (5) /* 4x10G, single QSFP, cage 0 (Medford) */ +#define TLV_PORT_MODE_10G_10G_10G_10G (4) /* 2x10G + 2x10G, quad SFP/10G-KR or dual QSFP (Greenport) */ +#define TLV_PORT_MODE_10G_10G_10G_10G_Q1 (4) /* 4x10G, single QSFP, cage 0 (Medford) */ +#define TLV_PORT_MODE_10G_10G_10G_10G_Q (5) /* 4x10G, single QSFP, cage 0 (Medford) OBSOLETE DO NOT USE */ #define TLV_PORT_MODE_40G_10G_10G (6) /* 1x40G + 2x10G, dual QSFP (Greenport, Medford) */ #define TLV_PORT_MODE_10G_10G_40G (7) /* 2x10G + 1x40G, dual QSFP (Greenport, Medford) */ #define TLV_PORT_MODE_10G_10G_10G_10G_Q2 (8) /* 4x10G, single QSFP, cage 1 (Medford) */ -#define TLV_PORT_MODE_MAX TLV_PORT_MODE_10G_10G_10G_10G_Q2 +#define TLV_PORT_MODE_10G_10G_10G_10G_Q1_Q2 (9) /* 2x10G + 2x10G, dual QSFP (Medford) */ +#define TLV_PORT_MODE_MAX TLV_PORT_MODE_10G_10G_10G_10G_Q1_Q2 }; /* Type of the v-switch created implicitly by the firmware */ @@ -765,8 +767,8 @@ struct tlv_rx_event_merging_config { #define TLV_RX_EVENT_MERGING_CONFIG_MAX_EVENTS_MAX ((1 << 4) - 1) uint32_t timeout_ns; }; -#define TLV_RX_EVENT_MERGING_MAX_EVENTS_DEFAULT 7 -#define TLV_RX_EVENT_MERGING_TIMEOUT_NS_DEFAULT 8740 +#define TLV_RX_EVENT_MERGING_MAX_EVENTS_DEFAULT (0xffffffff) +#define TLV_RX_EVENT_MERGING_TIMEOUT_NS_DEFAULT (0xffffffff) #define TLV_TAG_PCIE_LINK_SETTINGS (0x101f0000) struct tlv_pcie_link_settings { @@ -791,9 +793,9 @@ struct tlv_tx_event_merging_config { uint32_t timeout_ns; uint32_t qempty_timeout_ns; /* Medford only */ }; -#define TLV_TX_EVENT_MERGING_MAX_EVENTS_DEFAULT 7 -#define TLV_TX_EVENT_MERGING_TIMEOUT_NS_DEFAULT 1400 -#define TLV_TX_EVENT_MERGING_QEMPTY_TIMEOUT_NS_DEFAULT 700 +#define TLV_TX_EVENT_MERGING_MAX_EVENTS_DEFAULT (0xffffffff) +#define TLV_TX_EVENT_MERGING_TIMEOUT_NS_DEFAULT (0xffffffff) +#define TLV_TX_EVENT_MERGING_QEMPTY_TIMEOUT_NS_DEFAULT (0xffffffff) /* Tx vFIFO Low latency configuration * @@ -809,6 +811,20 @@ struct tlv_tx_vfifo_ull_mode { #define TLV_TX_VFIFO_ULL_MODE_DEFAULT 0 }; +/* BIU mode + * + * Medford2 tag for selecting VI window decode (see values below) + */ +#define TLV_TAG_BIU_VI_WINDOW_MODE (0x10280000) +struct tlv_biu_vi_window_mode { + uint32_t tag; + uint32_t length; + uint8_t mode; +#define TLV_BIU_VI_WINDOW_MODE_8K 0 /* 8k per VI, CTPIO not mapped, medford/hunt compatible */ +#define TLV_BIU_VI_WINDOW_MODE_16K 1 /* 16k per VI, CTPIO mapped */ +#define TLV_BIU_VI_WINDOW_MODE_64K 2 /* 64k per VI, CTPIO mapped, POWER-friendly */ +}; + #define TLV_TAG_LICENSE (0x30800000) typedef struct tlv_license { From owner-svn-src-all@freebsd.org Sat Oct 15 13:41:59 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 58AFEC1239E; Sat, 15 Oct 2016 13:41:59 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 2AB3EAC9; Sat, 15 Oct 2016 13:41:59 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9FDfwWf055456; Sat, 15 Oct 2016 13:41:58 GMT (envelope-from bapt@FreeBSD.org) Received: (from bapt@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9FDfwkJ055455; Sat, 15 Oct 2016 13:41:58 GMT (envelope-from bapt@FreeBSD.org) Message-Id: <201610151341.u9FDfwkJ055455@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bapt set sender to bapt@FreeBSD.org using -f From: Baptiste Daroussin Date: Sat, 15 Oct 2016 13:41:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307368 - head/usr.bin/sdiff X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 Oct 2016 13:41:59 -0000 Author: bapt Date: Sat Oct 15 13:41:58 2016 New Revision: 307368 URL: https://svnweb.freebsd.org/changeset/base/307368 Log: Remove the common.h include which is actually not used in sdiff.c Modified: head/usr.bin/sdiff/sdiff.c Modified: head/usr.bin/sdiff/sdiff.c ============================================================================== --- head/usr.bin/sdiff/sdiff.c Sat Oct 15 13:39:30 2016 (r307367) +++ head/usr.bin/sdiff/sdiff.c Sat Oct 15 13:41:58 2016 (r307368) @@ -27,7 +27,6 @@ __FBSDID("$FreeBSD$"); #include #include -#include "common.h" #include "extern.h" #define DIFF_PATH "/usr/bin/diff" From owner-svn-src-all@freebsd.org Sat Oct 15 13:42:39 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 7C31BC123F5; Sat, 15 Oct 2016 13:42:39 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 48866C9D; Sat, 15 Oct 2016 13:42:39 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9FDgcaR058143; Sat, 15 Oct 2016 13:42:38 GMT (envelope-from bapt@FreeBSD.org) Received: (from bapt@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9FDgcpF058142; Sat, 15 Oct 2016 13:42:38 GMT (envelope-from bapt@FreeBSD.org) Message-Id: <201610151342.u9FDgcpF058142@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bapt set sender to bapt@FreeBSD.org using -f From: Baptiste Daroussin Date: Sat, 15 Oct 2016 13:42:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307369 - head/usr.bin/sdiff X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 Oct 2016 13:42:39 -0000 Author: bapt Date: Sat Oct 15 13:42:38 2016 New Revision: 307369 URL: https://svnweb.freebsd.org/changeset/base/307369 Log: Turn editit into a static function Modified: head/usr.bin/sdiff/edit.c Modified: head/usr.bin/sdiff/edit.c ============================================================================== --- head/usr.bin/sdiff/edit.c Sat Oct 15 13:41:58 2016 (r307368) +++ head/usr.bin/sdiff/edit.c Sat Oct 15 13:42:38 2016 (r307369) @@ -24,15 +24,13 @@ __FBSDID("$FreeBSD$"); #include "common.h" #include "extern.h" -int editit(const char *); - /* * Execute an editor on the specified pathname, which is interpreted * from the shell. This means flags may be included. * * Returns -1 on error, or the exit value on success. */ -int +static int editit(const char *pathname) { sig_t sighup, sigint, sigquit, sigchld; From owner-svn-src-all@freebsd.org Sat Oct 15 13:42:54 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 0F8E3C1242B; Sat, 15 Oct 2016 13:42:54 +0000 (UTC) (envelope-from arybchik@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id C6BE9E03; Sat, 15 Oct 2016 13:42:53 +0000 (UTC) (envelope-from arybchik@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9FDgqFt058196; Sat, 15 Oct 2016 13:42:52 GMT (envelope-from arybchik@FreeBSD.org) Received: (from arybchik@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9FDgq57058195; Sat, 15 Oct 2016 13:42:52 GMT (envelope-from arybchik@FreeBSD.org) Message-Id: <201610151342.u9FDgq57058195@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: arybchik set sender to arybchik@FreeBSD.org using -f From: Andrew Rybchenko Date: Sat, 15 Oct 2016 13:42:52 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r307370 - stable/11/sys/dev/sfxge/common X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 Oct 2016 13:42:54 -0000 Author: arybchik Date: Sat Oct 15 13:42:52 2016 New Revision: 307370 URL: https://svnweb.freebsd.org/changeset/base/307370 Log: MFC r307038 sfxge(4): update external port mapping for Medford Extend the mapping table for external port numbering to support port modes which output to the second external port only. Where supported, map from the current port mode rather than inferring from all the available modes. Updated comments for clarity. Submitted by: Richard Houldsworth Sponsored by: Solarflare Communications, Inc. Modified: stable/11/sys/dev/sfxge/common/ef10_nic.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/sfxge/common/ef10_nic.c ============================================================================== --- stable/11/sys/dev/sfxge/common/ef10_nic.c Sat Oct 15 13:42:38 2016 (r307369) +++ stable/11/sys/dev/sfxge/common/ef10_nic.c Sat Oct 15 13:42:52 2016 (r307370) @@ -1099,41 +1099,50 @@ fail1: /* - * The external port mapping is a one-based numbering of the external - * connectors on the board. It does not distinguish off-board separated - * outputs such as multi-headed cables. - * The number of ports that map to each external port connector - * on the board is determined by the chip family and the port modes to - * which the NIC can be configured. The mapping table lists modes with - * port numbering requirements in increasing order. + * Table of mapping schemes from port number to the number of the external + * connector on the board. The external numbering does not distinguish + * off-board separated outputs such as from multi-headed cables. + * + * The count of adjacent port numbers that map to each external port + * and the offset in the numbering, is determined by the chip family and + * current port mode. + * + * For the Huntington family, the current port mode cannot be discovered, + * so the mapping used is instead the last match in the table to the full + * set of port modes to which the NIC can be configured. Therefore the + * ordering of entries in the the mapping table is significant. */ static struct { efx_family_t family; uint32_t modes_mask; - uint32_t stride; + int32_t count; + int32_t offset; } __ef10_external_port_mappings[] = { - /* Supported modes requiring 1 output per port */ + /* Supported modes with 1 output per external port */ { EFX_FAMILY_HUNTINGTON, (1 << TLV_PORT_MODE_10G) | (1 << TLV_PORT_MODE_10G_10G) | (1 << TLV_PORT_MODE_10G_10G_10G_10G), + 1, 1 }, { EFX_FAMILY_MEDFORD, (1 << TLV_PORT_MODE_10G) | (1 << TLV_PORT_MODE_10G_10G), + 1, 1 }, - /* Supported modes requiring 2 outputs per port */ + /* Supported modes with 2 outputs per external port */ { EFX_FAMILY_HUNTINGTON, (1 << TLV_PORT_MODE_40G) | (1 << TLV_PORT_MODE_40G_40G) | (1 << TLV_PORT_MODE_40G_10G_10G) | (1 << TLV_PORT_MODE_10G_10G_40G), - 2 + 2, + 1 }, { EFX_FAMILY_MEDFORD, @@ -1142,15 +1151,22 @@ static struct { (1 << TLV_PORT_MODE_40G_10G_10G) | (1 << TLV_PORT_MODE_10G_10G_40G) | (1 << TLV_PORT_MODE_10G_10G_10G_10G_Q1_Q2), - 2 + 2, + 1 }, - /* Supported modes requiring 4 outputs per port */ + /* Supported modes with 4 outputs per external port */ { EFX_FAMILY_MEDFORD, (1 << TLV_PORT_MODE_10G_10G_10G_10G_Q) | - (1 << TLV_PORT_MODE_10G_10G_10G_10G_Q1) | + (1 << TLV_PORT_MODE_10G_10G_10G_10G_Q1), + 4, + 1, + }, + { + EFX_FAMILY_MEDFORD, (1 << TLV_PORT_MODE_10G_10G_10G_10G_Q2), - 4 + 4, + 2 }, }; @@ -1164,11 +1180,26 @@ ef10_external_port_mapping( int i; uint32_t port_modes; uint32_t matches; - uint32_t stride = 1; /* default 1-1 mapping */ - - if ((rc = efx_mcdi_get_port_modes(enp, &port_modes, NULL)) != 0) { - /* No port mode information available - use default mapping */ - goto out; + uint32_t current; + int32_t count = 1; /* Default 1-1 mapping */ + int32_t offset = 1; /* Default starting external port number */ + + if ((rc = efx_mcdi_get_port_modes(enp, &port_modes, ¤t)) != 0) { + /* + * No current port mode information + * - infer mapping from available modes + */ + if ((rc = efx_mcdi_get_port_modes(enp, + &port_modes, NULL)) != 0) { + /* + * No port mode information available + * - use default mapping + */ + goto out; + } + } else { + /* Only need to scan the current mode */ + port_modes = 1 << current; } /* @@ -1182,7 +1213,8 @@ ef10_external_port_mapping( matches = (__ef10_external_port_mappings[i].modes_mask & port_modes); if (matches != 0) { - stride = __ef10_external_port_mappings[i].stride; + count = __ef10_external_port_mappings[i].count; + offset = __ef10_external_port_mappings[i].offset; port_modes &= ~matches; } } @@ -1196,9 +1228,9 @@ ef10_external_port_mapping( out: /* * Scale as required by last matched mode and then convert to - * one-based numbering + * correctly offset numbering */ - *external_portp = (uint8_t)(port / stride) + 1; + *external_portp = (uint8_t)((port / count) + offset); return (0); fail1: From owner-svn-src-all@freebsd.org Sat Oct 15 13:44:15 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 04035C124FC; Sat, 15 Oct 2016 13:44:15 +0000 (UTC) (envelope-from arybchik@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id B52CBF93; Sat, 15 Oct 2016 13:44:14 +0000 (UTC) (envelope-from arybchik@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9FDiD8M058321; Sat, 15 Oct 2016 13:44:13 GMT (envelope-from arybchik@FreeBSD.org) Received: (from arybchik@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9FDiDTp058319; Sat, 15 Oct 2016 13:44:13 GMT (envelope-from arybchik@FreeBSD.org) Message-Id: <201610151344.u9FDiDTp058319@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: arybchik set sender to arybchik@FreeBSD.org using -f From: Andrew Rybchenko Date: Sat, 15 Oct 2016 13:44:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307371 - stable/10/sys/dev/sfxge/common X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 Oct 2016 13:44:15 -0000 Author: arybchik Date: Sat Oct 15 13:44:13 2016 New Revision: 307371 URL: https://svnweb.freebsd.org/changeset/base/307371 Log: MFC r306944 sfxge(4): sync tlv_layout.h with firmwaresrc and update port-mode definition use It fixes driver attach issue to a new firmware which reports a new port-modes. Submitted by: Tom Millington Sponsored by: Solarflare Communications, Inc. Modified: stable/10/sys/dev/sfxge/common/ef10_nic.c stable/10/sys/dev/sfxge/common/ef10_tlv_layout.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/sfxge/common/ef10_nic.c ============================================================================== --- stable/10/sys/dev/sfxge/common/ef10_nic.c Sat Oct 15 13:42:52 2016 (r307370) +++ stable/10/sys/dev/sfxge/common/ef10_nic.c Sat Oct 15 13:44:13 2016 (r307371) @@ -164,6 +164,7 @@ ef10_nic_get_port_mode_bandwidth( break; case TLV_PORT_MODE_10G_10G_10G_10G: case TLV_PORT_MODE_10G_10G_10G_10G_Q: + case TLV_PORT_MODE_10G_10G_10G_10G_Q1_Q2: case TLV_PORT_MODE_10G_10G_10G_10G_Q2: bandwidth = 10000 * 4; break; @@ -1122,8 +1123,7 @@ static struct { { EFX_FAMILY_MEDFORD, (1 << TLV_PORT_MODE_10G) | - (1 << TLV_PORT_MODE_10G_10G) | - (1 << TLV_PORT_MODE_10G_10G_10G_10G), + (1 << TLV_PORT_MODE_10G_10G), 1 }, /* Supported modes requiring 2 outputs per port */ @@ -1140,13 +1140,15 @@ static struct { (1 << TLV_PORT_MODE_40G) | (1 << TLV_PORT_MODE_40G_40G) | (1 << TLV_PORT_MODE_40G_10G_10G) | - (1 << TLV_PORT_MODE_10G_10G_40G), + (1 << TLV_PORT_MODE_10G_10G_40G) | + (1 << TLV_PORT_MODE_10G_10G_10G_10G_Q1_Q2), 2 }, /* Supported modes requiring 4 outputs per port */ { EFX_FAMILY_MEDFORD, (1 << TLV_PORT_MODE_10G_10G_10G_10G_Q) | + (1 << TLV_PORT_MODE_10G_10G_10G_10G_Q1) | (1 << TLV_PORT_MODE_10G_10G_10G_10G_Q2), 4 }, Modified: stable/10/sys/dev/sfxge/common/ef10_tlv_layout.h ============================================================================== --- stable/10/sys/dev/sfxge/common/ef10_tlv_layout.h Sat Oct 15 13:42:52 2016 (r307370) +++ stable/10/sys/dev/sfxge/common/ef10_tlv_layout.h Sat Oct 15 13:44:13 2016 (r307371) @@ -553,12 +553,14 @@ struct tlv_global_port_mode { #define TLV_PORT_MODE_40G (1) /* 40G, single QSFP/40G-KR */ #define TLV_PORT_MODE_10G_10G (2) /* 2x10G, dual SFP/10G-KR or single QSFP */ #define TLV_PORT_MODE_40G_40G (3) /* 40G + 40G, dual QSFP/40G-KR (Greenport, Medford) */ -#define TLV_PORT_MODE_10G_10G_10G_10G (4) /* 2x10G + 2x10G, quad SFP/10G-KR or dual QSFP (Greenport, Medford) */ -#define TLV_PORT_MODE_10G_10G_10G_10G_Q (5) /* 4x10G, single QSFP, cage 0 (Medford) */ +#define TLV_PORT_MODE_10G_10G_10G_10G (4) /* 2x10G + 2x10G, quad SFP/10G-KR or dual QSFP (Greenport) */ +#define TLV_PORT_MODE_10G_10G_10G_10G_Q1 (4) /* 4x10G, single QSFP, cage 0 (Medford) */ +#define TLV_PORT_MODE_10G_10G_10G_10G_Q (5) /* 4x10G, single QSFP, cage 0 (Medford) OBSOLETE DO NOT USE */ #define TLV_PORT_MODE_40G_10G_10G (6) /* 1x40G + 2x10G, dual QSFP (Greenport, Medford) */ #define TLV_PORT_MODE_10G_10G_40G (7) /* 2x10G + 1x40G, dual QSFP (Greenport, Medford) */ #define TLV_PORT_MODE_10G_10G_10G_10G_Q2 (8) /* 4x10G, single QSFP, cage 1 (Medford) */ -#define TLV_PORT_MODE_MAX TLV_PORT_MODE_10G_10G_10G_10G_Q2 +#define TLV_PORT_MODE_10G_10G_10G_10G_Q1_Q2 (9) /* 2x10G + 2x10G, dual QSFP (Medford) */ +#define TLV_PORT_MODE_MAX TLV_PORT_MODE_10G_10G_10G_10G_Q1_Q2 }; /* Type of the v-switch created implicitly by the firmware */ @@ -765,8 +767,8 @@ struct tlv_rx_event_merging_config { #define TLV_RX_EVENT_MERGING_CONFIG_MAX_EVENTS_MAX ((1 << 4) - 1) uint32_t timeout_ns; }; -#define TLV_RX_EVENT_MERGING_MAX_EVENTS_DEFAULT 7 -#define TLV_RX_EVENT_MERGING_TIMEOUT_NS_DEFAULT 8740 +#define TLV_RX_EVENT_MERGING_MAX_EVENTS_DEFAULT (0xffffffff) +#define TLV_RX_EVENT_MERGING_TIMEOUT_NS_DEFAULT (0xffffffff) #define TLV_TAG_PCIE_LINK_SETTINGS (0x101f0000) struct tlv_pcie_link_settings { @@ -791,9 +793,9 @@ struct tlv_tx_event_merging_config { uint32_t timeout_ns; uint32_t qempty_timeout_ns; /* Medford only */ }; -#define TLV_TX_EVENT_MERGING_MAX_EVENTS_DEFAULT 7 -#define TLV_TX_EVENT_MERGING_TIMEOUT_NS_DEFAULT 1400 -#define TLV_TX_EVENT_MERGING_QEMPTY_TIMEOUT_NS_DEFAULT 700 +#define TLV_TX_EVENT_MERGING_MAX_EVENTS_DEFAULT (0xffffffff) +#define TLV_TX_EVENT_MERGING_TIMEOUT_NS_DEFAULT (0xffffffff) +#define TLV_TX_EVENT_MERGING_QEMPTY_TIMEOUT_NS_DEFAULT (0xffffffff) /* Tx vFIFO Low latency configuration * @@ -809,6 +811,20 @@ struct tlv_tx_vfifo_ull_mode { #define TLV_TX_VFIFO_ULL_MODE_DEFAULT 0 }; +/* BIU mode + * + * Medford2 tag for selecting VI window decode (see values below) + */ +#define TLV_TAG_BIU_VI_WINDOW_MODE (0x10280000) +struct tlv_biu_vi_window_mode { + uint32_t tag; + uint32_t length; + uint8_t mode; +#define TLV_BIU_VI_WINDOW_MODE_8K 0 /* 8k per VI, CTPIO not mapped, medford/hunt compatible */ +#define TLV_BIU_VI_WINDOW_MODE_16K 1 /* 16k per VI, CTPIO mapped */ +#define TLV_BIU_VI_WINDOW_MODE_64K 2 /* 64k per VI, CTPIO mapped, POWER-friendly */ +}; + #define TLV_TAG_LICENSE (0x30800000) typedef struct tlv_license { From owner-svn-src-all@freebsd.org Sat Oct 15 13:45:11 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 10D9DC1257C; Sat, 15 Oct 2016 13:45:11 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id D47D2166; Sat, 15 Oct 2016 13:45:10 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9FDjAN4058426; Sat, 15 Oct 2016 13:45:10 GMT (envelope-from bapt@FreeBSD.org) Received: (from bapt@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9FDj9pN058424; Sat, 15 Oct 2016 13:45:09 GMT (envelope-from bapt@FreeBSD.org) Message-Id: <201610151345.u9FDj9pN058424@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bapt set sender to bapt@FreeBSD.org using -f From: Baptiste Daroussin Date: Sat, 15 Oct 2016 13:45:09 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307372 - head/usr.bin/sdiff X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 Oct 2016 13:45:11 -0000 Author: bapt Date: Sat Oct 15 13:45:09 2016 New Revision: 307372 URL: https://svnweb.freebsd.org/changeset/base/307372 Log: Move cleanup() into the edit.c file which is the only users of that function Remove common.{c,h} Deleted: head/usr.bin/sdiff/common.c head/usr.bin/sdiff/common.h Modified: head/usr.bin/sdiff/Makefile head/usr.bin/sdiff/edit.c Modified: head/usr.bin/sdiff/Makefile ============================================================================== --- head/usr.bin/sdiff/Makefile Sat Oct 15 13:44:13 2016 (r307371) +++ head/usr.bin/sdiff/Makefile Sat Oct 15 13:45:09 2016 (r307372) @@ -3,7 +3,7 @@ .include PROG= sdiff -SRCS= common.c edit.c sdiff.c +SRCS= edit.c sdiff.c WARNS= 3 MAN1= sdiff.1 Modified: head/usr.bin/sdiff/edit.c ============================================================================== --- head/usr.bin/sdiff/edit.c Sat Oct 15 13:44:13 2016 (r307371) +++ head/usr.bin/sdiff/edit.c Sat Oct 15 13:45:09 2016 (r307372) @@ -21,9 +21,17 @@ __FBSDID("$FreeBSD$"); #include #include -#include "common.h" #include "extern.h" +static void +cleanup(const char *filename) +{ + + if (unlink(filename)) + err(2, "could not delete: %s", filename); + exit(2); +} + /* * Execute an editor on the specified pathname, which is interpreted * from the shell. This means flags may be included. From owner-svn-src-all@freebsd.org Sat Oct 15 13:45:13 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 6A3A1C1258C; Sat, 15 Oct 2016 13:45:13 +0000 (UTC) (envelope-from arybchik@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 2AB81167; Sat, 15 Oct 2016 13:45:13 +0000 (UTC) (envelope-from arybchik@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9FDjCSY058471; Sat, 15 Oct 2016 13:45:12 GMT (envelope-from arybchik@FreeBSD.org) Received: (from arybchik@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9FDjCZb058470; Sat, 15 Oct 2016 13:45:12 GMT (envelope-from arybchik@FreeBSD.org) Message-Id: <201610151345.u9FDjCZb058470@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: arybchik set sender to arybchik@FreeBSD.org using -f From: Andrew Rybchenko Date: Sat, 15 Oct 2016 13:45:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307373 - stable/10/sys/dev/sfxge/common X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 Oct 2016 13:45:13 -0000 Author: arybchik Date: Sat Oct 15 13:45:12 2016 New Revision: 307373 URL: https://svnweb.freebsd.org/changeset/base/307373 Log: MFC r307038 sfxge(4): update external port mapping for Medford Extend the mapping table for external port numbering to support port modes which output to the second external port only. Where supported, map from the current port mode rather than inferring from all the available modes. Updated comments for clarity. Submitted by: Richard Houldsworth Sponsored by: Solarflare Communications, Inc. Modified: stable/10/sys/dev/sfxge/common/ef10_nic.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/sfxge/common/ef10_nic.c ============================================================================== --- stable/10/sys/dev/sfxge/common/ef10_nic.c Sat Oct 15 13:45:09 2016 (r307372) +++ stable/10/sys/dev/sfxge/common/ef10_nic.c Sat Oct 15 13:45:12 2016 (r307373) @@ -1099,41 +1099,50 @@ fail1: /* - * The external port mapping is a one-based numbering of the external - * connectors on the board. It does not distinguish off-board separated - * outputs such as multi-headed cables. - * The number of ports that map to each external port connector - * on the board is determined by the chip family and the port modes to - * which the NIC can be configured. The mapping table lists modes with - * port numbering requirements in increasing order. + * Table of mapping schemes from port number to the number of the external + * connector on the board. The external numbering does not distinguish + * off-board separated outputs such as from multi-headed cables. + * + * The count of adjacent port numbers that map to each external port + * and the offset in the numbering, is determined by the chip family and + * current port mode. + * + * For the Huntington family, the current port mode cannot be discovered, + * so the mapping used is instead the last match in the table to the full + * set of port modes to which the NIC can be configured. Therefore the + * ordering of entries in the the mapping table is significant. */ static struct { efx_family_t family; uint32_t modes_mask; - uint32_t stride; + int32_t count; + int32_t offset; } __ef10_external_port_mappings[] = { - /* Supported modes requiring 1 output per port */ + /* Supported modes with 1 output per external port */ { EFX_FAMILY_HUNTINGTON, (1 << TLV_PORT_MODE_10G) | (1 << TLV_PORT_MODE_10G_10G) | (1 << TLV_PORT_MODE_10G_10G_10G_10G), + 1, 1 }, { EFX_FAMILY_MEDFORD, (1 << TLV_PORT_MODE_10G) | (1 << TLV_PORT_MODE_10G_10G), + 1, 1 }, - /* Supported modes requiring 2 outputs per port */ + /* Supported modes with 2 outputs per external port */ { EFX_FAMILY_HUNTINGTON, (1 << TLV_PORT_MODE_40G) | (1 << TLV_PORT_MODE_40G_40G) | (1 << TLV_PORT_MODE_40G_10G_10G) | (1 << TLV_PORT_MODE_10G_10G_40G), - 2 + 2, + 1 }, { EFX_FAMILY_MEDFORD, @@ -1142,15 +1151,22 @@ static struct { (1 << TLV_PORT_MODE_40G_10G_10G) | (1 << TLV_PORT_MODE_10G_10G_40G) | (1 << TLV_PORT_MODE_10G_10G_10G_10G_Q1_Q2), - 2 + 2, + 1 }, - /* Supported modes requiring 4 outputs per port */ + /* Supported modes with 4 outputs per external port */ { EFX_FAMILY_MEDFORD, (1 << TLV_PORT_MODE_10G_10G_10G_10G_Q) | - (1 << TLV_PORT_MODE_10G_10G_10G_10G_Q1) | + (1 << TLV_PORT_MODE_10G_10G_10G_10G_Q1), + 4, + 1, + }, + { + EFX_FAMILY_MEDFORD, (1 << TLV_PORT_MODE_10G_10G_10G_10G_Q2), - 4 + 4, + 2 }, }; @@ -1164,11 +1180,26 @@ ef10_external_port_mapping( int i; uint32_t port_modes; uint32_t matches; - uint32_t stride = 1; /* default 1-1 mapping */ - - if ((rc = efx_mcdi_get_port_modes(enp, &port_modes, NULL)) != 0) { - /* No port mode information available - use default mapping */ - goto out; + uint32_t current; + int32_t count = 1; /* Default 1-1 mapping */ + int32_t offset = 1; /* Default starting external port number */ + + if ((rc = efx_mcdi_get_port_modes(enp, &port_modes, ¤t)) != 0) { + /* + * No current port mode information + * - infer mapping from available modes + */ + if ((rc = efx_mcdi_get_port_modes(enp, + &port_modes, NULL)) != 0) { + /* + * No port mode information available + * - use default mapping + */ + goto out; + } + } else { + /* Only need to scan the current mode */ + port_modes = 1 << current; } /* @@ -1182,7 +1213,8 @@ ef10_external_port_mapping( matches = (__ef10_external_port_mappings[i].modes_mask & port_modes); if (matches != 0) { - stride = __ef10_external_port_mappings[i].stride; + count = __ef10_external_port_mappings[i].count; + offset = __ef10_external_port_mappings[i].offset; port_modes &= ~matches; } } @@ -1196,9 +1228,9 @@ ef10_external_port_mapping( out: /* * Scale as required by last matched mode and then convert to - * one-based numbering + * correctly offset numbering */ - *external_portp = (uint8_t)(port / stride) + 1; + *external_portp = (uint8_t)((port / count) + offset); return (0); fail1: From owner-svn-src-all@freebsd.org Sat Oct 15 14:40:35 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id F0D98C13186; Sat, 15 Oct 2016 14:40:35 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id A312BA40; Sat, 15 Oct 2016 14:40:35 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9FEeY6G077714; Sat, 15 Oct 2016 14:40:34 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9FEeYZ0077712; Sat, 15 Oct 2016 14:40:34 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201610151440.u9FEeYZ0077712@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Sat, 15 Oct 2016 14:40:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307374 - in head: sys/cam/ctl usr.sbin/ctladm X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 Oct 2016 14:40:36 -0000 Author: mav Date: Sat Oct 15 14:40:34 2016 New Revision: 307374 URL: https://svnweb.freebsd.org/changeset/base/307374 Log: Add LU option to control reported provisioning type. MFC after: 2 weeks Modified: head/sys/cam/ctl/ctl.c head/usr.sbin/ctladm/ctladm.8 Modified: head/sys/cam/ctl/ctl.c ============================================================================== --- head/sys/cam/ctl/ctl.c Sat Oct 15 13:45:12 2016 (r307373) +++ head/sys/cam/ctl/ctl.c Sat Oct 15 14:40:34 2016 (r307374) @@ -10040,6 +10040,7 @@ ctl_inquiry_evpd_lbp(struct ctl_scsiio * { struct scsi_vpd_logical_block_prov *lbp_ptr; struct ctl_lun *lun; + const char *value; lun = (struct ctl_lun *)ctsio->io_hdr.ctl_private[CTL_PRIV_LUN].ptr; @@ -10077,7 +10078,14 @@ ctl_inquiry_evpd_lbp(struct ctl_scsiio * if (lun != NULL && lun->be_lun->flags & CTL_LUN_FLAG_UNMAP) { lbp_ptr->flags = SVPD_LBP_UNMAP | SVPD_LBP_WS16 | SVPD_LBP_WS10 | SVPD_LBP_RZ | SVPD_LBP_ANC_SUP; - lbp_ptr->prov_type = SVPD_LBP_THIN; + value = ctl_get_opt(&lun->be_lun->options, "provisioning_type"); + if (value != NULL) { + if (strcmp(value, "resource") == 0) + lbp_ptr->prov_type = SVPD_LBP_RESOURCE; + else if (strcmp(value, "thin") == 0) + lbp_ptr->prov_type = SVPD_LBP_THIN; + } else + lbp_ptr->prov_type = SVPD_LBP_THIN; } ctl_set_success(ctsio); Modified: head/usr.sbin/ctladm/ctladm.8 ============================================================================== --- head/usr.sbin/ctladm/ctladm.8 Sat Oct 15 13:45:12 2016 (r307373) +++ head/usr.sbin/ctladm/ctladm.8 Sat Oct 15 14:40:34 2016 (r307374) @@ -903,8 +903,14 @@ Specifies medium rotation rate of the de .It Va formfactor Specifies nominal form factor of the device: 0 -- not reported, 1 -- 5.25", 2 -- 3.5", 3 -- 2.5", 4 -- 1.8", 5 -- less then 1.8". +.It Va provisioning_type +When UNMAP support is enabled, this option specifies provisioning type: +"resource", "thin" or "unknown". +Default value is "thin". +Logical units without UNMAP support are reported as fully provisioned. .It Va unmap -Set to "on", enables UNMAP support for the LUN, if supported by the backend. +Setting to "on" or "off" controls UNMAP support for the logical unit. +Default value is "on" if supported by the backend. .It Va unmap_max_lba .It Va unmap_max_descr Specify maximum allowed number of LBAs and block descriptors per UNMAP From owner-svn-src-all@freebsd.org Sat Oct 15 15:10:57 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 17488C136F9; Sat, 15 Oct 2016 15:10:57 +0000 (UTC) (envelope-from vangyzen@FreeBSD.org) Received: from smtp.vangyzen.net (hotblack.vangyzen.net [IPv6:2607:fc50:1000:7400:216:3eff:fe72:314f]) by mx1.freebsd.org (Postfix) with ESMTP id 0236B9D5; Sat, 15 Oct 2016 15:10:57 +0000 (UTC) (envelope-from vangyzen@FreeBSD.org) Received: from ford.home.vangyzen.net (unknown [76.164.15.242]) by smtp.vangyzen.net (Postfix) with ESMTPSA id D346756488; Sat, 15 Oct 2016 10:10:49 -0500 (CDT) Subject: Re: svn commit: r306346 - head/sys/kern To: Gleb Smirnoff References: <201609261530.u8QFUUZd020174@repo.freebsd.org> <20161004205600.GN23123@FreeBSD.org> Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org From: Eric van Gyzen Message-ID: Date: Sat, 15 Oct 2016 10:10:46 -0500 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:45.0) Gecko/20100101 Thunderbird/45.3.0 MIME-Version: 1.0 In-Reply-To: <20161004205600.GN23123@FreeBSD.org> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 Oct 2016 15:10:57 -0000 On 10/04/2016 15:56, Gleb Smirnoff wrote: > Eric, > > E> @@ -924,7 +924,7 @@ __mtx_assert(const volatile uintptr_t *c > E> { > E> const struct mtx *m; > E> > E> - if (panicstr != NULL || dumping) > E> + if (panicstr != NULL || dumping || SCHEDULER_STOPPED()) > E> return; > > I wonder if all this disjunct can be reduced just to SCHEDULER_STOPPED()? > Positive panicstr and dumping imply scheduler stopped. If I read correctly, that's /almost/ true, but the scheduler is only stopped #ifdef SMP and we're panicking, so we need the full expression to cover the !SMP and reboot(RB_DUMP) cases. Eric From owner-svn-src-all@freebsd.org Sat Oct 15 15:55:06 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 2B153C131BA; Sat, 15 Oct 2016 15:55:06 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id F1644FD3; Sat, 15 Oct 2016 15:55:05 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9FFt53H008164; Sat, 15 Oct 2016 15:55:05 GMT (envelope-from bapt@FreeBSD.org) Received: (from bapt@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9FFt5QE008163; Sat, 15 Oct 2016 15:55:05 GMT (envelope-from bapt@FreeBSD.org) Message-Id: <201610151555.u9FFt5QE008163@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bapt set sender to bapt@FreeBSD.org using -f From: Baptiste Daroussin Date: Sat, 15 Oct 2016 15:55:05 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307376 - head X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 Oct 2016 15:55:06 -0000 Author: bapt Date: Sat Oct 15 15:55:04 2016 New Revision: 307376 URL: https://svnweb.freebsd.org/changeset/base/307376 Log: Improve wording Submitted by: lidl Modified: head/UPDATING Modified: head/UPDATING ============================================================================== --- head/UPDATING Sat Oct 15 14:42:41 2016 (r307375) +++ head/UPDATING Sat Oct 15 15:55:04 2016 (r307376) @@ -34,7 +34,8 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 12 20161015: GNU rcs has been removed from base. It is available as packages: - rcs: Latest GPLv3 GNU rcs version. - - rcs57: Copy of the latest version of GNU rcs (GPLv2) from base. + - rcs57: Copy of the latest version of GNU rcs (GPLv2) before it was + removed from base. 20161008: Use of the cc_cdg, cc_chd, cc_hd, or cc_vegas congestion control From owner-svn-src-all@freebsd.org Sat Oct 15 16:29:08 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 00FD4C1383D; Sat, 15 Oct 2016 16:29:08 +0000 (UTC) (envelope-from andrew@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id C70DCEE; Sat, 15 Oct 2016 16:29:07 +0000 (UTC) (envelope-from andrew@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9FGT6IW019395; Sat, 15 Oct 2016 16:29:06 GMT (envelope-from andrew@FreeBSD.org) Received: (from andrew@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9FGT6oR019394; Sat, 15 Oct 2016 16:29:06 GMT (envelope-from andrew@FreeBSD.org) Message-Id: <201610151629.u9FGT6oR019394@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: andrew set sender to andrew@FreeBSD.org using -f From: Andrew Turner Date: Sat, 15 Oct 2016 16:29:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307377 - head/sys/arm64/include X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 Oct 2016 16:29:08 -0000 Author: andrew Date: Sat Oct 15 16:29:06 2016 New Revision: 307377 URL: https://svnweb.freebsd.org/changeset/base/307377 Log: Fix the build, struct vfpstate needs to be visible to userspace as it's part of struct pcb which is in a header used in libutil. Obtained from: ABT Systems Ltd Sponsored by: The FreeBSD Foundation Modified: head/sys/arm64/include/vfp.h Modified: head/sys/arm64/include/vfp.h ============================================================================== --- head/sys/arm64/include/vfp.h Sat Oct 15 15:55:04 2016 (r307376) +++ head/sys/arm64/include/vfp.h Sat Oct 15 16:29:06 2016 (r307377) @@ -32,7 +32,6 @@ #ifndef _MACHINE_VFP_H_ #define _MACHINE_VFP_H_ -#ifdef _KERNEL #ifndef LOCORE struct vfpstate { @@ -41,6 +40,7 @@ struct vfpstate { uint32_t vfp_fpsr; }; +#ifdef _KERNEL void vfp_init(void); void vfp_discard(struct thread *); void vfp_restore_state(void); From owner-svn-src-all@freebsd.org Sat Oct 15 17:39:41 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 90FC3C13566; Sat, 15 Oct 2016 17:39:41 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 6BC59E27; Sat, 15 Oct 2016 17:39:41 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9FHdeV2045375; Sat, 15 Oct 2016 17:39:40 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9FHdeZc045374; Sat, 15 Oct 2016 17:39:40 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201610151739.u9FHdeZc045374@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Sat, 15 Oct 2016 17:39:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r307378 - stable/10/sys/dev/iscsi X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 Oct 2016 17:39:41 -0000 Author: mav Date: Sat Oct 15 17:39:40 2016 New Revision: 307378 URL: https://svnweb.freebsd.org/changeset/base/307378 Log: MFC r282970: Close some potential races around socket start/close. There are some reports about panics on ic->ic_socket NULL derefence. This kind of races is the only way I can imagine it to happen. Modified: stable/10/sys/dev/iscsi/icl.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/iscsi/icl.c ============================================================================== --- stable/10/sys/dev/iscsi/icl.c Sat Oct 15 16:29:06 2016 (r307377) +++ stable/10/sys/dev/iscsi/icl.c Sat Oct 15 17:39:40 2016 (r307378) @@ -746,10 +746,6 @@ icl_receive_thread(void *arg) ic = arg; so = ic->ic_socket; - ICL_CONN_LOCK(ic); - ic->ic_receive_running = true; - ICL_CONN_UNLOCK(ic); - for (;;) { if (ic->ic_disconnecting) { //ICL_DEBUG("terminating"); @@ -971,8 +967,6 @@ icl_send_thread(void *arg) STAILQ_INIT(&queue); ICL_CONN_LOCK(ic); - ic->ic_send_running = true; - for (;;) { for (;;) { /* @@ -1224,35 +1218,45 @@ icl_conn_start(struct icl_conn *ic) } /* + * Register socket upcall, to get notified about incoming PDUs + * and free space to send outgoing ones. + */ + SOCKBUF_LOCK(&ic->ic_socket->so_snd); + soupcall_set(ic->ic_socket, SO_SND, icl_soupcall_send, ic); + SOCKBUF_UNLOCK(&ic->ic_socket->so_snd); + SOCKBUF_LOCK(&ic->ic_socket->so_rcv); + soupcall_set(ic->ic_socket, SO_RCV, icl_soupcall_receive, ic); + SOCKBUF_UNLOCK(&ic->ic_socket->so_rcv); + + /* * Start threads. */ + ICL_CONN_LOCK(ic); + ic->ic_send_running = ic->ic_receive_running = true; + ICL_CONN_UNLOCK(ic); error = kthread_add(icl_send_thread, ic, NULL, NULL, 0, 0, "%stx", ic->ic_name); if (error != 0) { ICL_WARN("kthread_add(9) failed with error %d", error); + ICL_CONN_LOCK(ic); + ic->ic_send_running = ic->ic_receive_running = false; + cv_signal(&ic->ic_send_cv); + ICL_CONN_UNLOCK(ic); icl_conn_close(ic); return (error); } - error = kthread_add(icl_receive_thread, ic, NULL, NULL, 0, 0, "%srx", ic->ic_name); if (error != 0) { ICL_WARN("kthread_add(9) failed with error %d", error); + ICL_CONN_LOCK(ic); + ic->ic_receive_running = false; + cv_signal(&ic->ic_send_cv); + ICL_CONN_UNLOCK(ic); icl_conn_close(ic); return (error); } - /* - * Register socket upcall, to get notified about incoming PDUs - * and free space to send outgoing ones. - */ - SOCKBUF_LOCK(&ic->ic_socket->so_snd); - soupcall_set(ic->ic_socket, SO_SND, icl_soupcall_send, ic); - SOCKBUF_UNLOCK(&ic->ic_socket->so_snd); - SOCKBUF_LOCK(&ic->ic_socket->so_rcv); - soupcall_set(ic->ic_socket, SO_RCV, icl_soupcall_receive, ic); - SOCKBUF_UNLOCK(&ic->ic_socket->so_rcv); - return (0); } @@ -1306,46 +1310,42 @@ void icl_conn_close(struct icl_conn *ic) { struct icl_pdu *pdu; + struct socket *so; - ICL_CONN_LOCK_ASSERT_NOT(ic); - - ICL_CONN_LOCK(ic); - if (ic->ic_socket == NULL) { - ICL_CONN_UNLOCK(ic); - return; - } - - /* - * Deregister socket upcalls. - */ - ICL_CONN_UNLOCK(ic); - SOCKBUF_LOCK(&ic->ic_socket->so_snd); - if (ic->ic_socket->so_snd.sb_upcall != NULL) - soupcall_clear(ic->ic_socket, SO_SND); - SOCKBUF_UNLOCK(&ic->ic_socket->so_snd); - SOCKBUF_LOCK(&ic->ic_socket->so_rcv); - if (ic->ic_socket->so_rcv.sb_upcall != NULL) - soupcall_clear(ic->ic_socket, SO_RCV); - SOCKBUF_UNLOCK(&ic->ic_socket->so_rcv); ICL_CONN_LOCK(ic); - ic->ic_disconnecting = true; - /* * Wake up the threads, so they can properly terminate. */ + ic->ic_disconnecting = true; while (ic->ic_receive_running || ic->ic_send_running) { - //ICL_DEBUG("waiting for send/receive threads to terminate"); cv_signal(&ic->ic_receive_cv); cv_signal(&ic->ic_send_cv); cv_wait(&ic->ic_send_cv, ic->ic_lock); } - //ICL_DEBUG("send/receive threads terminated"); + /* Some other thread could close the connection same time. */ + so = ic->ic_socket; + if (so == NULL) { + ICL_CONN_UNLOCK(ic); + return; + } + ic->ic_socket = NULL; + + /* + * Deregister socket upcalls. + */ ICL_CONN_UNLOCK(ic); - soclose(ic->ic_socket); + SOCKBUF_LOCK(&so->so_snd); + if (so->so_snd.sb_upcall != NULL) + soupcall_clear(so, SO_SND); + SOCKBUF_UNLOCK(&so->so_snd); + SOCKBUF_LOCK(&so->so_rcv); + if (so->so_rcv.sb_upcall != NULL) + soupcall_clear(so, SO_RCV); + SOCKBUF_UNLOCK(&so->so_rcv); + soclose(so); ICL_CONN_LOCK(ic); - ic->ic_socket = NULL; if (ic->ic_receive_pdu != NULL) { //ICL_DEBUG("freeing partially received PDU"); From owner-svn-src-all@freebsd.org Sat Oct 15 17:49:43 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 3EE11C137E6; Sat, 15 Oct 2016 17:49:43 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 18BF0322; Sat, 15 Oct 2016 17:49:43 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9FHngW5049128; Sat, 15 Oct 2016 17:49:42 GMT (envelope-from manu@FreeBSD.org) Received: (from manu@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9FHngP8049126; Sat, 15 Oct 2016 17:49:42 GMT (envelope-from manu@FreeBSD.org) Message-Id: <201610151749.u9FHngP8049126@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: manu set sender to manu@FreeBSD.org using -f From: Emmanuel Vadot Date: Sat, 15 Oct 2016 17:49:42 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307379 - head/sys/arm/allwinner X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 Oct 2016 17:49:43 -0000 Author: manu Date: Sat Oct 15 17:49:41 2016 New Revision: 307379 URL: https://svnweb.freebsd.org/changeset/base/307379 Log: axp209: Add support for regulators Except for LDO4, all regulators are supported. MFC after: 1 week Modified: head/sys/arm/allwinner/axp209.c head/sys/arm/allwinner/axp209reg.h Modified: head/sys/arm/allwinner/axp209.c ============================================================================== --- head/sys/arm/allwinner/axp209.c Sat Oct 15 17:39:40 2016 (r307378) +++ head/sys/arm/allwinner/axp209.c Sat Oct 15 17:49:41 2016 (r307379) @@ -50,14 +50,92 @@ __FBSDID("$FreeBSD$"); #include -#include #include #include +#include + #include #include "iicbus_if.h" #include "gpio_if.h" +#include "regdev_if.h" + +MALLOC_DEFINE(M_AXP209_REG, "Axp209 regulator", "Axp209 power regulator"); + +struct axp209_regdef { + intptr_t id; + char *name; + uint8_t enable_reg; + uint8_t enable_mask; + uint8_t voltage_reg; + uint8_t voltage_mask; + uint8_t voltage_shift; + int voltage_min; + int voltage_max; + int voltage_step; + int voltage_nstep; +}; + +static struct axp209_regdef axp209_regdefs[] = { + { + .id = AXP209_REG_ID_DCDC2, + .name = "dcdc2", + .enable_reg = AXP209_POWERCTL, + .enable_mask = AXP209_POWERCTL_DCDC2, + .voltage_reg = AXP209_REG_DCDC2_VOLTAGE, + .voltage_mask = 0x3f, + .voltage_min = 700, + .voltage_max = 2275, + .voltage_step = 25, + .voltage_nstep = 64, + }, + { + .id = AXP209_REG_ID_DCDC3, + .name = "dcdc3", + .enable_reg = AXP209_POWERCTL, + .enable_mask = AXP209_POWERCTL_DCDC3, + .voltage_reg = AXP209_REG_DCDC3_VOLTAGE, + .voltage_mask = 0x7f, + .voltage_min = 700, + .voltage_max = 3500, + .voltage_step = 25, + .voltage_nstep = 128, + }, + { + .id = AXP209_REG_ID_LDO2, + .name = "ldo2", + .enable_reg = AXP209_POWERCTL, + .enable_mask = AXP209_POWERCTL_LDO2, + .voltage_reg = AXP209_REG_LDO24_VOLTAGE, + .voltage_mask = 0xf0, + .voltage_shift = 4, + .voltage_min = 1800, + .voltage_max = 3300, + .voltage_step = 100, + .voltage_nstep = 16, + }, + { + .id = AXP209_REG_ID_LDO3, + .name = "ldo3", + .enable_reg = AXP209_POWERCTL, + .enable_mask = AXP209_POWERCTL_LDO3, + .voltage_reg = AXP209_REG_LDO3_VOLTAGE, + .voltage_mask = 0x7f, + .voltage_min = 700, + .voltage_max = 2275, + .voltage_step = 25, + .voltage_nstep = 128, + }, +}; + +struct axp209_reg_sc { + struct regnode *regnode; + device_t base_dev; + struct axp209_regdef *def; + phandle_t xref; + struct regnode_std_param *param; +}; struct axp209_softc { device_t dev; @@ -67,6 +145,10 @@ struct axp209_softc { struct intr_config_hook intr_hook; device_t gpiodev; struct mtx mtx; + + /* Regulators */ + struct axp209_reg_sc **regs; + int nregs; }; /* GPIO3 is different, don't expose it for now */ @@ -125,6 +207,115 @@ axp209_write(device_t dev, uint8_t reg, } static int +axp209_regnode_init(struct regnode *regnode) +{ + return (0); +} + +static int +axp209_regnode_enable(struct regnode *regnode, bool enable, int *udelay) +{ + struct axp209_reg_sc *sc; + uint8_t val; + + sc = regnode_get_softc(regnode); + + axp209_read(sc->base_dev, sc->def->enable_reg, &val, 1); + if (enable) + val |= sc->def->enable_mask; + else + val &= ~sc->def->enable_mask; + axp209_write(sc->base_dev, sc->def->enable_reg, val); + + *udelay = 0; + + return (0); +} + +static void +axp209_regnode_reg_to_voltage(struct axp209_reg_sc *sc, uint8_t val, int *uv) +{ + if (val < sc->def->voltage_nstep) + *uv = sc->def->voltage_min + val * sc->def->voltage_step; + else + *uv = sc->def->voltage_min + + (sc->def->voltage_nstep * sc->def->voltage_step); + *uv *= 1000; +} + +static int +axp209_regnode_voltage_to_reg(struct axp209_reg_sc *sc, int min_uvolt, + int max_uvolt, uint8_t *val) +{ + uint8_t nval; + int nstep, uvolt; + + nval = 0; + uvolt = sc->def->voltage_min * 1000; + + for (nstep = 0; nstep < sc->def->voltage_nstep && uvolt < min_uvolt; + nstep++) { + ++nval; + uvolt += (sc->def->voltage_step * 1000); + } + if (uvolt > max_uvolt) + return (EINVAL); + + *val = nval; + return (0); +} + +static int +axp209_regnode_set_voltage(struct regnode *regnode, int min_uvolt, + int max_uvolt, int *udelay) +{ + struct axp209_reg_sc *sc; + uint8_t val; + + sc = regnode_get_softc(regnode); + + if (!sc->def->voltage_step) + return (ENXIO); + + if (axp209_regnode_voltage_to_reg(sc, min_uvolt, max_uvolt, &val) != 0) + return (ERANGE); + + axp209_write(sc->base_dev, sc->def->voltage_reg, val); + + *udelay = 0; + + return (0); +} + +static int +axp209_regnode_get_voltage(struct regnode *regnode, int *uvolt) +{ + struct axp209_reg_sc *sc; + uint8_t val; + + sc = regnode_get_softc(regnode); + + if (!sc->def->voltage_step) + return (ENXIO); + + axp209_read(sc->base_dev, sc->def->voltage_reg, &val, 1); + axp209_regnode_reg_to_voltage(sc, val & sc->def->voltage_mask, uvolt); + + return (0); +} + +static regnode_method_t axp209_regnode_methods[] = { + /* Regulator interface */ + REGNODEMETHOD(regnode_init, axp209_regnode_init), + REGNODEMETHOD(regnode_enable, axp209_regnode_enable), + REGNODEMETHOD(regnode_set_voltage, axp209_regnode_set_voltage), + REGNODEMETHOD(regnode_get_voltage, axp209_regnode_get_voltage), + REGNODEMETHOD_END +}; +DEFINE_CLASS_1(axp209_regnode, axp209_regnode_class, axp209_regnode_methods, + sizeof(struct axp209_reg_sc), regnode_class); + +static int axp209_sysctl(SYSCTL_HANDLER_ARGS) { device_t dev = arg1; @@ -517,6 +708,63 @@ axp209_get_node(device_t dev, device_t b return (ofw_bus_get_node(dev)); } +static struct axp209_reg_sc * +axp209_reg_attach(device_t dev, phandle_t node, + struct axp209_regdef *def) +{ + struct axp209_reg_sc *reg_sc; + struct regnode_init_def initdef; + struct regnode *regnode; + + memset(&initdef, 0, sizeof(initdef)); + if (regulator_parse_ofw_stdparam(dev, node, &initdef) != 0) { + device_printf(dev, "cannot create regulator\n"); + return (NULL); + } + if (initdef.std_param.min_uvolt == 0) + initdef.std_param.min_uvolt = def->voltage_min * 1000; + if (initdef.std_param.max_uvolt == 0) + initdef.std_param.max_uvolt = def->voltage_max * 1000; + initdef.id = def->id; + initdef.ofw_node = node; + regnode = regnode_create(dev, &axp209_regnode_class, &initdef); + if (regnode == NULL) { + device_printf(dev, "cannot create regulator\n"); + return (NULL); + } + + reg_sc = regnode_get_softc(regnode); + reg_sc->regnode = regnode; + reg_sc->base_dev = dev; + reg_sc->def = def; + reg_sc->xref = OF_xref_from_node(node); + reg_sc->param = regnode_get_stdparam(regnode); + + regnode_register(regnode); + + return (reg_sc); +} + +static int +axp209_regdev_map(device_t dev, phandle_t xref, int ncells, pcell_t *cells, + intptr_t *num) +{ + struct axp209_softc *sc; + int i; + + sc = device_get_softc(dev); + for (i = 0; i < sc->nregs; i++) { + if (sc->regs[i] == NULL) + continue; + if (sc->regs[i]->xref == xref) { + *num = sc->regs[i]->def->id; + return (0); + } + } + + return (ENXIO); +} + static void axp209_start(void *pdev) { @@ -654,6 +902,9 @@ static int axp209_attach(device_t dev) { struct axp209_softc *sc; + struct axp209_reg_sc *reg; + phandle_t rnode, child; + int i; sc = device_get_softc(dev); mtx_init(&sc->mtx, device_get_nameunit(dev), NULL, MTX_DEF); @@ -669,6 +920,29 @@ axp209_attach(device_t dev) if (config_intrhook_establish(&sc->intr_hook) != 0) return (ENOMEM); + sc->nregs = nitems(axp209_regdefs); + sc->regs = malloc(sizeof(struct axp209_reg_sc *) * sc->nregs, + M_AXP209_REG, M_WAITOK | M_ZERO); + + /* Attach known regulators that exist in the DT */ + rnode = ofw_bus_find_child(ofw_bus_get_node(dev), "regulators"); + if (rnode > 0) { + for (i = 0; i < sc->nregs; i++) { + child = ofw_bus_find_child(rnode, + axp209_regdefs[i].name); + if (child == 0) + continue; + reg = axp209_reg_attach(dev, child, &axp209_regdefs[i]); + if (reg == NULL) { + device_printf(dev, + "cannot attach regulator %s\n", + axp209_regdefs[i].name); + continue; + } + sc->regs[i] = reg; + } + } + sc->gpiodev = gpiobus_attach_bus(dev); return (0); @@ -690,6 +964,9 @@ static device_method_t axp209_methods[] DEVMETHOD(gpio_pin_toggle, axp209_gpio_pin_toggle), DEVMETHOD(gpio_map_gpios, axp209_gpio_map_gpios), + /* Regdev interface */ + DEVMETHOD(regdev_map, axp209_regdev_map), + /* OFW bus interface */ DEVMETHOD(ofw_bus_get_node, axp209_get_node), Modified: head/sys/arm/allwinner/axp209reg.h ============================================================================== --- head/sys/arm/allwinner/axp209reg.h Sat Oct 15 17:39:40 2016 (r307378) +++ head/sys/arm/allwinner/axp209reg.h Sat Oct 15 17:49:41 2016 (r307379) @@ -146,6 +146,19 @@ #define AXP209_GPIO_DATA(x) (1 << (x + 4)) +/* Regulators registers */ +#define AXP209_POWERCTL 0x12 +#define AXP209_POWERCTL_DCDC3 (1 << 1) +#define AXP209_POWERCTL_LDO2 (1 << 2) +#define AXP209_POWERCTL_LDO4 (1 << 3) +#define AXP209_POWERCTL_DCDC2 (1 << 4) +#define AXP209_POWERCTL_LDO3 (1 << 6) + +#define AXP209_REG_DCDC2_VOLTAGE 0x23 +#define AXP209_REG_DCDC3_VOLTAGE 0x27 +#define AXP209_REG_LDO24_VOLTAGE 0x28 +#define AXP209_REG_LDO3_VOLTAGE 0x29 + enum axp209_sensor { AXP209_TEMP, AXP209_ACVOLT, @@ -157,4 +170,15 @@ enum axp209_sensor { AXP209_BATDISCHARGECURRENT, }; +enum axp209_regulators { + AXP209_REG_ID_DCDC2, + AXP209_REG_ID_DCDC3, + AXP209_REG_ID_LDO1, + AXP209_REG_ID_LDO2, + AXP209_REG_ID_LDO3, + /* LDO4 is weird, need to find a correct way to handle it */ + /* AXP209_REG_ID_LDO4, */ + AXP209_REG_ID_LDO5, +}; + #endif /* _AXP209REG_H_ */ From owner-svn-src-all@freebsd.org Sat Oct 15 18:20:16 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 658C2C13074; Sat, 15 Oct 2016 18:20:16 +0000 (UTC) (envelope-from np@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 3747921B; Sat, 15 Oct 2016 18:20:16 +0000 (UTC) (envelope-from np@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9FIKFDI060341; Sat, 15 Oct 2016 18:20:15 GMT (envelope-from np@FreeBSD.org) Received: (from np@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9FIKF65060340; Sat, 15 Oct 2016 18:20:15 GMT (envelope-from np@FreeBSD.org) Message-Id: <201610151820.u9FIKF65060340@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: np set sender to np@FreeBSD.org using -f From: Navdeep Parhar Date: Sat, 15 Oct 2016 18:20:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307380 - head/sys/sys X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 Oct 2016 18:20:16 -0000 Author: np Date: Sat Oct 15 18:20:15 2016 New Revision: 307380 URL: https://svnweb.freebsd.org/changeset/base/307380 Log: Fix typo in comments. Modified: head/sys/sys/mbuf.h Modified: head/sys/sys/mbuf.h ============================================================================== --- head/sys/sys/mbuf.h Sat Oct 15 17:49:41 2016 (r307379) +++ head/sys/sys/mbuf.h Sat Oct 15 18:20:15 2016 (r307380) @@ -335,7 +335,7 @@ struct mbuf { #define M_HASHTYPE_RSS_TCP_IPV6 M_HASHTYPE_HASH(4) /* TCPv6 4-tuple */ #define M_HASHTYPE_RSS_IPV6_EX M_HASHTYPE_HASH(5) /* IPv6 2-tuple + * ext hdrs */ -#define M_HASHTYPE_RSS_TCP_IPV6_EX M_HASHTYPE_HASH(6) /* TCPv6 4-tiple + +#define M_HASHTYPE_RSS_TCP_IPV6_EX M_HASHTYPE_HASH(6) /* TCPv6 4-tuple + * ext hdrs */ /* Non-standard RSS hash types */ #define M_HASHTYPE_RSS_UDP_IPV4 M_HASHTYPE_HASH(7) /* IPv4 UDP 4-tuple*/ From owner-svn-src-all@freebsd.org Sat Oct 15 19:55:08 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 9557DC1364C; Sat, 15 Oct 2016 19:55:08 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4D13BD7A; Sat, 15 Oct 2016 19:55:08 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9FJt7kT096944; Sat, 15 Oct 2016 19:55:07 GMT (envelope-from bapt@FreeBSD.org) Received: (from bapt@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9FJt7X5096943; Sat, 15 Oct 2016 19:55:07 GMT (envelope-from bapt@FreeBSD.org) Message-Id: <201610151955.u9FJt7X5096943@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bapt set sender to bapt@FreeBSD.org using -f From: Baptiste Daroussin Date: Sat, 15 Oct 2016 19:55:07 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307381 - head/usr.bin/sdiff X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 Oct 2016 19:55:08 -0000 Author: bapt Date: Sat Oct 15 19:55:07 2016 New Revision: 307381 URL: https://svnweb.freebsd.org/changeset/base/307381 Log: Fix typos in sdiff(1) message and improve display Modified: head/usr.bin/sdiff/sdiff.c Modified: head/usr.bin/sdiff/sdiff.c ============================================================================== --- head/usr.bin/sdiff/sdiff.c Sat Oct 15 18:20:15 2016 (r307380) +++ head/usr.bin/sdiff/sdiff.c Sat Oct 15 19:55:07 2016 (r307381) @@ -137,24 +137,25 @@ static struct option longopts[] = { }; static const char *help_msg[] = { - "\nusage: sdiff [-abdilstW] [-I regexp] [-o outfile] [-w width] file1 file2\n", - "\t-l, --left-column, Only print the left column for identical lines.", - "\t-o OUTFILE, --output=OUTFILE, nteractively merge file1 and file2 into outfile.", - "\t-s, --suppress-common-lines, Skip identical lines.", - "\t-w WIDTH, --width=WIDTH, Print a maximum of WIDTH characters on each line.", - "\tOptions passed to diff(1) are:", - "\t\t-a, --text, Treat file1 and file2 as text files.", - "\t\t-b, --ignore-trailing-cr, Ignore trailing blank spaces.", - "\t\t-d, --minimal, Minimize diff size.", - "\t\t-I RE, --ignore-matching-lines=RE, Ignore changes whose line matches RE.", - "\t\t-i, --ignore-case, Do a case-insensitive comparison.", - "\t\t-t, --expand-tabs Expand tabs to spaces.", - "\t\t-W, --ignore-all-spaces, Ignore all spaces.", - "\t\t--speed-large-files, Assume large file with scattered changes.", - "\t\t--strip-trailing-cr, Strip trailing carriage return.", - "\t\t--ignore-file-name-case, Ignore case of file names.", - "\t\t--no-ignore-file-name-case, Do not ignore file name case", - "\t\t--tabsize NUM, Change size of tabs (default 8.)", + "usage: sdiff [-abdilstW] [-I regexp] [-o outfile] [-w width] file1 file2\n", + "-l, --left-column: only print the left column for identical lines.", + "-o OUTFILE, --output=OUTFILE: interactively merge file1 and file2 into outfile.", + "-s, --suppress-common-lines: skip identical lines.", + "-w WIDTH, --width=WIDTH: print a maximum of WIDTH characters on each line.", + "", + "Options passed to diff(1) are:", + "\t-a, --text: treat file1 and file2 as text files.", + "\t-b, --ignore-trailing-cr: ignore trailing blank spaces.", + "\t-d, --minimal: minimize diff size.", + "\t-I RE, --ignore-matching-lines=RE: ignore changes whose line matches RE.", + "\t-i, --ignore-case: do a case-insensitive comparison.", + "\t-t, --expand-tabs: sxpand tabs to spaces.", + "\t-W, --ignore-all-spaces: ignore all spaces.", + "\t--speed-large-files: assume large file with scattered changes.", + "\t--strip-trailing-cr: strip trailing carriage return.", + "\t--ignore-file-name-case: ignore case of file names.", + "\t--no-ignore-file-name-case: do not ignore file name case", + "\t--tabsize NUM: change size of tabs (default 8.)", NULL, }; From owner-svn-src-all@freebsd.org Sat Oct 15 20:04:16 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 0ABD9C1384A; Sat, 15 Oct 2016 20:04:16 +0000 (UTC) (envelope-from jmcneill@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id C0A29236; Sat, 15 Oct 2016 20:04:15 +0000 (UTC) (envelope-from jmcneill@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9FK4Eqt000677; Sat, 15 Oct 2016 20:04:14 GMT (envelope-from jmcneill@FreeBSD.org) Received: (from jmcneill@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9FK4EL7000674; Sat, 15 Oct 2016 20:04:14 GMT (envelope-from jmcneill@FreeBSD.org) Message-Id: <201610152004.u9FK4EL7000674@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jmcneill set sender to jmcneill@FreeBSD.org using -f From: Jared McNeill Date: Sat, 15 Oct 2016 20:04:14 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307382 - in head/sys: arm/conf conf dev/gpio X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 Oct 2016 20:04:16 -0000 Author: jmcneill Date: Sat Oct 15 20:04:14 2016 New Revision: 307382 URL: https://svnweb.freebsd.org/changeset/base/307382 Log: Add driver for GPIO controlled regulator. Reviewed by: gonzo, manu, mmel Differential Revision: https://reviews.freebsd.org/D8257 Added: head/sys/dev/gpio/gpioregulator.c (contents, props changed) Modified: head/sys/arm/conf/GENERIC head/sys/conf/files Modified: head/sys/arm/conf/GENERIC ============================================================================== --- head/sys/arm/conf/GENERIC Sat Oct 15 19:55:07 2016 (r307381) +++ head/sys/arm/conf/GENERIC Sat Oct 15 20:04:14 2016 (r307382) @@ -112,6 +112,7 @@ device icee # GPIO device gpio device gpioled +device gpioregulator # SPI device spibus Modified: head/sys/conf/files ============================================================================== --- head/sys/conf/files Sat Oct 15 19:55:07 2016 (r307381) +++ head/sys/conf/files Sat Oct 15 20:04:14 2016 (r307382) @@ -1573,6 +1573,7 @@ dev/gpio/gpioc.c optional gpio \ dependency "gpio_if.h" dev/gpio/gpioiic.c optional gpioiic dev/gpio/gpioled.c optional gpioled +dev/gpio/gpioregulator.c optional gpioregulator fdt ext_resources dev/gpio/gpiospi.c optional gpiospi dev/gpio/gpio_if.m optional gpio dev/gpio/gpiobus_if.m optional gpio Added: head/sys/dev/gpio/gpioregulator.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/dev/gpio/gpioregulator.c Sat Oct 15 20:04:14 2016 (r307382) @@ -0,0 +1,348 @@ +/*- + * Copyright (c) 2016 Jared McNeill + * 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 ``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 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$ + */ + +/* + * GPIO controlled regulators + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include + +#include + +#include "regdev_if.h" + +struct gpioregulator_state { + int val; + uint32_t mask; +}; + +struct gpioregulator_init_def { + struct regnode_init_def reg_init_def; + struct gpiobus_pin *enable_pin; + int enable_pin_valid; + int startup_delay_us; + int nstates; + struct gpioregulator_state *states; + int npins; + struct gpiobus_pin **pins; +}; + +struct gpioregulator_reg_sc { + struct regnode *regnode; + device_t base_dev; + struct regnode_std_param *param; + struct gpioregulator_init_def *def; +}; + +struct gpioregulator_softc { + device_t dev; + struct gpioregulator_reg_sc *reg_sc; + struct gpioregulator_init_def init_def; +}; + +static int +gpioregulator_regnode_init(struct regnode *regnode) +{ + struct gpioregulator_reg_sc *sc; + int error, n; + + sc = regnode_get_softc(regnode); + + if (sc->def->enable_pin_valid == 1) { + error = gpio_pin_setflags(sc->def->enable_pin, GPIO_PIN_OUTPUT); + if (error != 0) + return (error); + } + + for (n = 0; n < sc->def->npins; n++) { + error = gpio_pin_setflags(sc->def->pins[n], GPIO_PIN_OUTPUT); + if (error != 0) + return (error); + } + + return (0); +} + +static int +gpioregulator_regnode_enable(struct regnode *regnode, bool enable, int *udelay) +{ + struct gpioregulator_reg_sc *sc; + bool active; + int error; + + sc = regnode_get_softc(regnode); + + if (sc->def->enable_pin_valid == 1) { + active = enable; + if (!sc->param->enable_active_high) + active = !active; + error = gpio_pin_set_active(sc->def->enable_pin, active); + if (error != 0) + return (error); + } + + *udelay = sc->def->startup_delay_us; + + return (0); +} + +static int +gpioregulator_regnode_set_voltage(struct regnode *regnode, int min_uvolt, + int max_uvolt, int *udelay) +{ + struct gpioregulator_reg_sc *sc; + const struct gpioregulator_state *state; + int error, n; + + sc = regnode_get_softc(regnode); + state = NULL; + + for (n = 0; n < sc->def->nstates; n++) { + if (sc->def->states[n].val >= min_uvolt && + sc->def->states[n].val <= max_uvolt) { + state = &sc->def->states[n]; + break; + } + } + if (state == NULL) + return (EINVAL); + + for (n = 0; n < sc->def->npins; n++) { + error = gpio_pin_set_active(sc->def->pins[n], + (state->mask >> n) & 1); + if (error != 0) + return (error); + } + + *udelay = sc->def->startup_delay_us; + + return (0); +} + +static int +gpioregulator_regnode_get_voltage(struct regnode *regnode, int *uvolt) +{ + struct gpioregulator_reg_sc *sc; + uint32_t mask; + int error, n; + bool active; + + sc = regnode_get_softc(regnode); + mask = 0; + + for (n = 0; n < sc->def->npins; n++) { + error = gpio_pin_is_active(sc->def->pins[n], &active); + if (error != 0) + return (error); + mask |= (active << n); + } + + for (n = 0; n < sc->def->nstates; n++) { + if (sc->def->states[n].mask == mask) { + *uvolt = sc->def->states[n].val; + return (0); + } + } + + return (EIO); +} + +static regnode_method_t gpioregulator_regnode_methods[] = { + /* Regulator interface */ + REGNODEMETHOD(regnode_init, gpioregulator_regnode_init), + REGNODEMETHOD(regnode_enable, gpioregulator_regnode_enable), + REGNODEMETHOD(regnode_set_voltage, gpioregulator_regnode_set_voltage), + REGNODEMETHOD(regnode_get_voltage, gpioregulator_regnode_get_voltage), + REGNODEMETHOD_END +}; +DEFINE_CLASS_1(gpioregulator_regnode, gpioregulator_regnode_class, + gpioregulator_regnode_methods, sizeof(struct gpioregulator_reg_sc), + regnode_class); + +static int +gpioregulator_parse_fdt(struct gpioregulator_softc *sc) +{ + uint32_t *pstates, mask; + phandle_t node; + ssize_t len; + int error, n; + + node = ofw_bus_get_node(sc->dev); + pstates = NULL; + mask = 0; + + error = regulator_parse_ofw_stdparam(sc->dev, node, + &sc->init_def.reg_init_def); + if (error != 0) + return (error); + + /* "states" property (required) */ + len = OF_getencprop_alloc(node, "states", sizeof(*pstates), + (void **)&pstates); + if (len < 2) { + device_printf(sc->dev, "invalid 'states' property\n"); + error = EINVAL; + goto done; + } + sc->init_def.nstates = len / 2; + sc->init_def.states = malloc(sc->init_def.nstates * + sizeof(*sc->init_def.states), M_DEVBUF, M_WAITOK); + for (n = 0; n < sc->init_def.nstates; n++) { + sc->init_def.states[n].val = pstates[n * 2 + 0]; + sc->init_def.states[n].mask = pstates[n * 2 + 1]; + mask |= sc->init_def.states[n].mask; + } + + /* "startup-delay-us" property (optional) */ + len = OF_getencprop(node, "startup-delay-us", + &sc->init_def.startup_delay_us, + sizeof(sc->init_def.startup_delay_us)); + if (len <= 0) + sc->init_def.startup_delay_us = 0; + + /* "enable-gpio" property (optional) */ + error = gpio_pin_get_by_ofw_property(sc->dev, node, "enable-gpio", + &sc->init_def.enable_pin); + if (error == 0) + sc->init_def.enable_pin_valid = 1; + + /* "gpios" property */ + sc->init_def.npins = 32 - __builtin_clz(mask); + sc->init_def.pins = malloc(sc->init_def.npins * + sizeof(sc->init_def.pins), M_DEVBUF, M_WAITOK); + for (n = 0; n < sc->init_def.npins; n++) { + error = gpio_pin_get_by_ofw_idx(sc->dev, node, n, + &sc->init_def.pins[n]); + if (error != 0) { + device_printf(sc->dev, "cannot get pin %d\n", n); + goto done; + } + } + +done: + if (error != 0) { + for (n = 0; n < sc->init_def.npins; n++) { + if (sc->init_def.pins[n] != NULL) + gpio_pin_release(sc->init_def.pins[n]); + } + + free(sc->init_def.states, M_DEVBUF); + free(sc->init_def.pins, M_DEVBUF); + + } + OF_prop_free(pstates); + + return (error); +} + +static int +gpioregulator_probe(device_t dev) +{ + + if (!ofw_bus_is_compatible(dev, "regulator-gpio")) + return (ENXIO); + + device_set_desc(dev, "GPIO controlled regulator"); + return (BUS_PROBE_GENERIC); +} + +static int +gpioregulator_attach(device_t dev) +{ + struct gpioregulator_softc *sc; + struct regnode *regnode; + phandle_t node; + int error; + + sc = device_get_softc(dev); + sc->dev = dev; + node = ofw_bus_get_node(dev); + + error = gpioregulator_parse_fdt(sc); + if (error != 0) { + device_printf(dev, "cannot parse parameters\n"); + return (ENXIO); + } + sc->init_def.reg_init_def.id = 1; + sc->init_def.reg_init_def.ofw_node = node; + + regnode = regnode_create(dev, &gpioregulator_regnode_class, + &sc->init_def.reg_init_def); + if (regnode == NULL) { + device_printf(dev, "cannot create regulator\n"); + return (ENXIO); + } + + sc->reg_sc = regnode_get_softc(regnode); + sc->reg_sc->regnode = regnode; + sc->reg_sc->base_dev = dev; + sc->reg_sc->param = regnode_get_stdparam(regnode); + sc->reg_sc->def = &sc->init_def; + + regnode_register(regnode); + + return (0); +} + + +static device_method_t gpioregulator_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, gpioregulator_probe), + DEVMETHOD(device_attach, gpioregulator_attach), + + /* Regdev interface */ + DEVMETHOD(regdev_map, regdev_default_ofw_map), + + DEVMETHOD_END +}; + +static driver_t gpioregulator_driver = { + "gpioregulator", + gpioregulator_methods, + sizeof(struct gpioregulator_softc), +}; + +static devclass_t gpioregulator_devclass; + +EARLY_DRIVER_MODULE(gpioregulator, simplebus, gpioregulator_driver, + gpioregulator_devclass, 0, 0, BUS_PASS_INTERRUPT + BUS_PASS_ORDER_LAST); +MODULE_VERSION(gpioregulator, 1); From owner-svn-src-all@freebsd.org Sat Oct 15 23:46:57 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 250D1C135AE; Sat, 15 Oct 2016 23:46:57 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id DD3EC21C; Sat, 15 Oct 2016 23:46:56 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9FNkuZv083026; Sat, 15 Oct 2016 23:46:56 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9FNku8F083025; Sat, 15 Oct 2016 23:46:56 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201610152346.u9FNku8F083025@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Sat, 15 Oct 2016 23:46:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307384 - head/usr.sbin/pmcstat X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 Oct 2016 23:46:57 -0000 Author: markj Date: Sat Oct 15 23:46:55 2016 New Revision: 307384 URL: https://svnweb.freebsd.org/changeset/base/307384 Log: Remove an unused field from struct pmcstat_image. MFC after: 3 days Modified: head/usr.sbin/pmcstat/pmcstat_log.h Modified: head/usr.sbin/pmcstat/pmcstat_log.h ============================================================================== --- head/usr.sbin/pmcstat/pmcstat_log.h Sat Oct 15 22:49:04 2016 (r307383) +++ head/usr.sbin/pmcstat/pmcstat_log.h Sat Oct 15 23:46:55 2016 (r307384) @@ -76,7 +76,6 @@ enum pmcstat_image_type { struct pmcstat_image { LIST_ENTRY(pmcstat_image) pi_next; /* hash link */ - TAILQ_ENTRY(pmcstat_image) pi_lru; /* LRU list */ pmcstat_interned_string pi_execpath; /* cookie */ pmcstat_interned_string pi_samplename; /* sample path name */ pmcstat_interned_string pi_fullpath; /* path to FS object */