From owner-svn-src-stable@FreeBSD.ORG Sun Feb 8 19:53:37 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 70F191065674; Sun, 8 Feb 2009 19:53:37 +0000 (UTC) (envelope-from rpaulo@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 5CDD78FC17; Sun, 8 Feb 2009 19:53:37 +0000 (UTC) (envelope-from rpaulo@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n18JrbE4032438; Sun, 8 Feb 2009 19:53:37 GMT (envelope-from rpaulo@svn.freebsd.org) Received: (from rpaulo@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n18JrbXk032437; Sun, 8 Feb 2009 19:53:37 GMT (envelope-from rpaulo@svn.freebsd.org) Message-Id: <200902081953.n18JrbXk032437@svn.freebsd.org> From: Rui Paulo Date: Sun, 8 Feb 2009 19:53:37 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r188322 - in stable/7/sys: . contrib/pf dev/acpi_support dev/ath/ath_hal dev/cxgb X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 08 Feb 2009 19:53:38 -0000 Author: rpaulo Date: Sun Feb 8 19:53:37 2009 New Revision: 188322 URL: http://svn.freebsd.org/changeset/base/188322 Log: MFC r181885: Fix typo in comment. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/acpi_support/acpi_asus.c stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) Modified: stable/7/sys/dev/acpi_support/acpi_asus.c ============================================================================== --- stable/7/sys/dev/acpi_support/acpi_asus.c Sun Feb 8 19:44:50 2009 (r188321) +++ stable/7/sys/dev/acpi_support/acpi_asus.c Sun Feb 8 19:53:37 2009 (r188322) @@ -286,7 +286,7 @@ static struct acpi_asus_model acpi_asus_ }, { .name = "L8L" - /* Only has hotkeys, apparantly */ + /* Only has hotkeys, apparently */ }, { .name = "M1A", From owner-svn-src-stable@FreeBSD.ORG Sun Feb 8 19:55:13 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id CA5FA1065676; Sun, 8 Feb 2009 19:55:13 +0000 (UTC) (envelope-from rpaulo@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id B69208FC22; Sun, 8 Feb 2009 19:55:13 +0000 (UTC) (envelope-from rpaulo@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n18JtD7J032569; Sun, 8 Feb 2009 19:55:13 GMT (envelope-from rpaulo@svn.freebsd.org) Received: (from rpaulo@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n18JtDhM032568; Sun, 8 Feb 2009 19:55:13 GMT (envelope-from rpaulo@svn.freebsd.org) Message-Id: <200902081955.n18JtDhM032568@svn.freebsd.org> From: Rui Paulo Date: Sun, 8 Feb 2009 19:55:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r188324 - in stable/7/sys: . contrib/pf dev/acpi_support dev/ath/ath_hal dev/cxgb X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 08 Feb 2009 19:55:14 -0000 Author: rpaulo Date: Sun Feb 8 19:55:13 2009 New Revision: 188324 URL: http://svn.freebsd.org/changeset/base/188324 Log: MFC r184625: Add support for Asus A8Sr notebooks. PR: 128553 Submitted by: Eygene Ryabinkin Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/acpi_support/acpi_asus.c stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) Modified: stable/7/sys/dev/acpi_support/acpi_asus.c ============================================================================== --- stable/7/sys/dev/acpi_support/acpi_asus.c Sun Feb 8 19:55:03 2009 (r188323) +++ stable/7/sys/dev/acpi_support/acpi_asus.c Sun Feb 8 19:55:13 2009 (r188324) @@ -89,6 +89,9 @@ struct acpi_asus_model { char *crd_set; void (*n_func)(ACPI_HANDLE, UINT32, void *); + + char *lcdd; + void (*lcdd_n_func)(ACPI_HANDLE, UINT32, void *); }; struct acpi_asus_led { @@ -109,6 +112,7 @@ struct acpi_asus_led { struct acpi_asus_softc { device_t dev; ACPI_HANDLE handle; + ACPI_HANDLE lcdd_handle; struct acpi_asus_model *model; struct sysctl_ctx_list sysctl_ctx; @@ -128,6 +132,9 @@ struct acpi_asus_softc { int s_crd; }; +static void acpi_asus_lcdd_notify(ACPI_HANDLE h, UINT32 notify, + void *context); + /* * We can identify Asus laptops from the string they return * as a result of calling the ATK0100 'INIT' method. @@ -200,6 +207,20 @@ static struct acpi_asus_model acpi_asus_ .disp_set = "SDSP" }, { + .name = "A8SR", + .bled_set = "BLED", + .mled_set = "MLED", + .wled_set = "WLED", + .lcd_get = NULL, + .lcd_set = "\\_SB.PCI0.SBRG.EC0._Q10", + .brn_get = "GPLV", + .brn_set = "SPLV", + .disp_get = "\\_SB.PCI0.P0P1.VGA.GETD", + .disp_set = "SDSP", + .lcdd = "\\_SB.PCI0.P0P1.VGA.LCDD", + .lcdd_n_func = acpi_asus_lcdd_notify + }, + { .name = "D1x", .mled_set = "MLED", .lcd_get = "\\GP11", @@ -749,6 +770,22 @@ acpi_asus_attach(device_t dev) AcpiInstallNotifyHandler(sc->handle, ACPI_SYSTEM_NOTIFY, sc->model->n_func, dev); + /* Find and hook the 'LCDD' object */ + if (sc->model->lcdd != NULL && sc->model->lcdd_n_func != NULL) { + ACPI_STATUS res; + + sc->lcdd_handle = NULL; + res = AcpiGetHandle((sc->model->lcdd[0] == '\\' ? + NULL : sc->handle), sc->model->lcdd, &(sc->lcdd_handle)); + if (ACPI_SUCCESS(res)) { + AcpiInstallNotifyHandler((sc->lcdd_handle), + ACPI_DEVICE_NOTIFY, sc->model->lcdd_n_func, dev); + } else { + printf("%s: unable to find LCD device '%s'\n", + __func__, sc->model->lcdd); + } + } + return (0); } @@ -783,6 +820,13 @@ acpi_asus_detach(device_t dev) /* Remove notify handler */ AcpiRemoveNotifyHandler(sc->handle, ACPI_SYSTEM_NOTIFY, acpi_asus_notify); + + if (sc->lcdd_handle) { + KASSERT(sc->model->lcdd_n_func != NULL, + ("model->lcdd_n_func is NULL, but lcdd_handle is non-zero")); + AcpiRemoveNotifyHandler((sc->lcdd_handle), + ACPI_DEVICE_NOTIFY, sc->model->lcdd_n_func); + } /* Free sysctl tree */ sysctl_ctx_free(&sc->sysctl_ctx); @@ -1124,6 +1168,12 @@ acpi_asus_notify(ACPI_HANDLE h, UINT32 n } else if (notify == 0x34) { sc->s_lcd = 0; ACPI_VPRINT(sc->dev, acpi_sc, "LCD turned off\n"); + } else if (notify == 0x86) { + acpi_asus_sysctl_set(sc, ACPI_ASUS_METHOD_BRN, sc->s_brn-1); + ACPI_VPRINT(sc->dev, acpi_sc, "Brightness decreased\n"); + } else if (notify == 0x87) { + acpi_asus_sysctl_set(sc, ACPI_ASUS_METHOD_BRN, sc->s_brn+1); + ACPI_VPRINT(sc->dev, acpi_sc, "Brightness increased\n"); } else { /* Notify devd(8) */ acpi_UserNotify("ASUS", h, notify); @@ -1132,6 +1182,31 @@ acpi_asus_notify(ACPI_HANDLE h, UINT32 n } static void +acpi_asus_lcdd_notify(ACPI_HANDLE h, UINT32 notify, void *context) +{ + struct acpi_asus_softc *sc; + struct acpi_softc *acpi_sc; + + ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__); + + sc = device_get_softc((device_t)context); + acpi_sc = acpi_device_get_parent_softc(sc->dev); + + ACPI_SERIAL_BEGIN(asus); + switch (notify) { + case 0x87: + acpi_asus_sysctl_set(sc, ACPI_ASUS_METHOD_BRN, sc->s_brn-1); + ACPI_VPRINT(sc->dev, acpi_sc, "Brightness decreased\n"); + break; + case 0x86: + acpi_asus_sysctl_set(sc, ACPI_ASUS_METHOD_BRN, sc->s_brn+1); + ACPI_VPRINT(sc->dev, acpi_sc, "Brightness increased\n"); + break; + } + ACPI_SERIAL_END(asus); +} + +static void acpi_asus_eeepc_notify(ACPI_HANDLE h, UINT32 notify, void *context) { struct acpi_asus_softc *sc; From owner-svn-src-stable@FreeBSD.ORG Sun Feb 8 20:00:37 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1B4D91065675; Sun, 8 Feb 2009 20:00:37 +0000 (UTC) (envelope-from rpaulo@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 083668FC21; Sun, 8 Feb 2009 20:00:37 +0000 (UTC) (envelope-from rpaulo@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n18K0aDj032798; Sun, 8 Feb 2009 20:00:36 GMT (envelope-from rpaulo@svn.freebsd.org) Received: (from rpaulo@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n18K0aBr032797; Sun, 8 Feb 2009 20:00:36 GMT (envelope-from rpaulo@svn.freebsd.org) Message-Id: <200902082000.n18K0aBr032797@svn.freebsd.org> From: Rui Paulo Date: Sun, 8 Feb 2009 20:00:36 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r188326 - in stable/7/sys: . contrib/pf dev/acpi_support dev/cxgb X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 08 Feb 2009 20:00:38 -0000 Author: rpaulo Date: Sun Feb 8 20:00:36 2009 New Revision: 188326 URL: http://svn.freebsd.org/changeset/base/188326 Log: MFC r186529 (stas): - Fix incorrect array declaration that was causing the stack overflow on some (most?) Asus laptops. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/acpi_support/acpi_asus.c stable/7/sys/dev/cxgb/ (props changed) Modified: stable/7/sys/dev/acpi_support/acpi_asus.c ============================================================================== --- stable/7/sys/dev/acpi_support/acpi_asus.c Sun Feb 8 20:00:33 2009 (r188325) +++ stable/7/sys/dev/acpi_support/acpi_asus.c Sun Feb 8 20:00:36 2009 (r188326) @@ -958,7 +958,9 @@ acpi_asus_sysctl_get(struct acpi_asus_so static int acpi_asus_sysctl_set(struct acpi_asus_softc *sc, int method, int arg) { - ACPI_STATUS status = AE_OK; + ACPI_STATUS status = AE_OK; + ACPI_OBJECT_LIST acpiargs; + ACPI_OBJECT acpiarg[1]; ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__); ACPI_SERIAL_ASSERT(asus); From owner-svn-src-stable@FreeBSD.ORG Sun Feb 8 20:47:38 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2E2B8106566C for ; Sun, 8 Feb 2009 20:47:38 +0000 (UTC) (envelope-from christoph.mallon@gmx.de) Received: from mail.gmx.net (mail.gmx.net [213.165.64.20]) by mx1.freebsd.org (Postfix) with SMTP id 6F4228FC19 for ; Sun, 8 Feb 2009 20:47:37 +0000 (UTC) (envelope-from christoph.mallon@gmx.de) Received: (qmail invoked by alias); 08 Feb 2009 20:20:56 -0000 Received: from p54A3DED5.dip.t-dialin.net (EHLO tron.homeunix.org) [84.163.222.213] by mail.gmx.net (mp016) with SMTP; 08 Feb 2009 21:20:56 +0100 X-Authenticated: #1673122 X-Provags-ID: V01U2FsdGVkX19Wd1ZQp9RWc/blR14k12S7ktJkmwyKMfXPELZkf1 CrUtxFzT67hlon Message-ID: <498F3EA7.4050900@gmx.de> Date: Sun, 08 Feb 2009 21:20:55 +0100 From: Christoph Mallon User-Agent: Thunderbird 2.0.0.19 (X11/20090103) MIME-Version: 1.0 To: Rui Paulo References: <200902082000.n18K0aBr032797@svn.freebsd.org> In-Reply-To: <200902082000.n18K0aBr032797@svn.freebsd.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Y-GMX-Trusted: 0 X-FuHaFi: 0.53 Cc: svn-src-stable@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, svn-src-stable-7@freebsd.org Subject: Re: svn commit: r188326 - in stable/7/sys: . contrib/pf dev/acpi_support dev/cxgb X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 08 Feb 2009 20:47:38 -0000 Rui Paulo schrieb: > Author: rpaulo > Date: Sun Feb 8 20:00:36 2009 > New Revision: 188326 > URL: http://svn.freebsd.org/changeset/base/188326 > > Log: > MFC r186529 (stas): > - Fix incorrect array declaration that was causing the stack overflow > on some (most?) Asus laptops. > > Modified: > stable/7/sys/ (props changed) > stable/7/sys/contrib/pf/ (props changed) > stable/7/sys/dev/acpi_support/acpi_asus.c > stable/7/sys/dev/cxgb/ (props changed) > > Modified: stable/7/sys/dev/acpi_support/acpi_asus.c > ============================================================================== > --- stable/7/sys/dev/acpi_support/acpi_asus.c Sun Feb 8 20:00:33 2009 (r188325) > +++ stable/7/sys/dev/acpi_support/acpi_asus.c Sun Feb 8 20:00:36 2009 (r188326) > @@ -958,7 +958,9 @@ acpi_asus_sysctl_get(struct acpi_asus_so > static int > acpi_asus_sysctl_set(struct acpi_asus_softc *sc, int method, int arg) > { > - ACPI_STATUS status = AE_OK; > + ACPI_STATUS status = AE_OK; > + ACPI_OBJECT_LIST acpiargs; > + ACPI_OBJECT acpiarg[1]; > > ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__); > ACPI_SERIAL_ASSERT(asus); r186529 does not seem to apply to 7.x, because you just added two unused variables. Maybe you forgot to MFC something else (r180268?) first. From owner-svn-src-stable@FreeBSD.ORG Sun Feb 8 20:53:52 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4C1AB1065698 for ; Sun, 8 Feb 2009 20:53:52 +0000 (UTC) (envelope-from rpaulo@gmail.com) Received: from mail-fx0-f14.google.com (mail-fx0-f14.google.com [209.85.220.14]) by mx1.freebsd.org (Postfix) with ESMTP id 92B378FC0A for ; Sun, 8 Feb 2009 20:53:51 +0000 (UTC) (envelope-from rpaulo@gmail.com) Received: by fxm7 with SMTP id 7so629501fxm.19 for ; Sun, 08 Feb 2009 12:53:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:sender:cc:message-id:from:to :in-reply-to:content-type:content-transfer-encoding:mime-version :subject:date:references:x-pgp-agent:x-mailer; bh=e//Ehp7HHRdETTg63a8m7McNpAm+c/hd7Q9zYBKF3zw=; b=Ui2T0icSYSOECUcsdTjSUAQiPTPYXtfWdjQQCNe4ldbwQvO9NwAWSn7PlxuU+kY9h7 zpcOc33b46qt8OAgi2h9nRxlrw4MM11i52QD4jZ8r6aSeWriQjx3AMOCYeZtIMZY3Xvt ZKfW5LnR4gpdwXiSpaOYhkksn9f2oFJO1Ibsc= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=sender:cc:message-id:from:to:in-reply-to:content-type :content-transfer-encoding:mime-version:subject:date:references :x-pgp-agent:x-mailer; b=LunGx8gxPL21aXL0cKGZsw8tCvumRGmNNkD7tKJUWuyFH5oR9mJDnZVrvbYCNGW+qn Mm9r/WP2vyyh+sdhaSG7tFgOikthjBzCzTTmCCMQuob6CFBixtV3fi9U/7sQNVBd0kDd SGz0JVISiwCzHJq0f5ZmHbws3omM1wt7lwBiU= Received: by 10.223.110.3 with SMTP id l3mr1543475fap.48.1234125144092; Sun, 08 Feb 2009 12:32:24 -0800 (PST) Received: from epsilon.lan (bl9-153-17.dsl.telepac.pt [85.242.153.17]) by mx.google.com with ESMTPS id k9sm8846810nfh.17.2009.02.08.12.32.21 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sun, 08 Feb 2009 12:32:23 -0800 (PST) Sender: Rui Paulo Message-Id: <1F7BDEA8-EFB8-42D9-A32D-1D3F49F9C9EC@FreeBSD.org> From: Rui Paulo To: Christoph Mallon In-Reply-To: <498F3EA7.4050900@gmx.de> Content-Type: multipart/signed; protocol="application/pgp-signature"; micalg=pgp-sha1; boundary="Apple-Mail-3-267380729" Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Apple Message framework v930.3) Date: Sun, 8 Feb 2009 20:32:14 +0000 References: <200902082000.n18K0aBr032797@svn.freebsd.org> <498F3EA7.4050900@gmx.de> X-Pgp-Agent: GPGMail 1.2.0 (v56) X-Mailer: Apple Mail (2.930.3) Cc: svn-src-stable@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, svn-src-stable-7@freebsd.org Subject: Re: svn commit: r188326 - in stable/7/sys: . contrib/pf dev/acpi_support dev/cxgb X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 08 Feb 2009 20:53:52 -0000 This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --Apple-Mail-3-267380729 Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit On 8 Feb 2009, at 20:20, Christoph Mallon wrote: > Rui Paulo schrieb: >> Author: rpaulo >> Date: Sun Feb 8 20:00:36 2009 >> New Revision: 188326 >> URL: http://svn.freebsd.org/changeset/base/188326 >> Log: >> MFC r186529 (stas): >> - Fix incorrect array declaration that was causing the stack >> overflow >> on some (most?) Asus laptops. >> Modified: >> stable/7/sys/ (props changed) >> stable/7/sys/contrib/pf/ (props changed) >> stable/7/sys/dev/acpi_support/acpi_asus.c >> stable/7/sys/dev/cxgb/ (props changed) >> Modified: stable/7/sys/dev/acpi_support/acpi_asus.c >> = >> = >> = >> = >> = >> = >> = >> = >> = >> ===================================================================== >> --- stable/7/sys/dev/acpi_support/acpi_asus.c Sun Feb 8 20:00:33 >> 2009 (r188325) >> +++ stable/7/sys/dev/acpi_support/acpi_asus.c Sun Feb 8 20:00:36 >> 2009 (r188326) >> @@ -958,7 +958,9 @@ acpi_asus_sysctl_get(struct acpi_asus_so >> static int >> acpi_asus_sysctl_set(struct acpi_asus_softc *sc, int method, int arg) >> { >> - ACPI_STATUS status = AE_OK; >> + ACPI_STATUS status = AE_OK; >> + ACPI_OBJECT_LIST acpiargs; >> + ACPI_OBJECT acpiarg[1]; >> ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__); >> ACPI_SERIAL_ASSERT(asus); > > r186529 does not seem to apply to 7.x, because you just added two > unused variables. Maybe you forgot to MFC something else (r180268?) > first. This is a merge botch... Sorry. -- Rui Paulo --Apple-Mail-3-267380729 content-type: application/pgp-signature; x-mac-type=70674453; name=PGP.sig content-description: This is a digitally signed message part content-disposition: inline; filename=PGP.sig content-transfer-encoding: 7bit -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (Darwin) iEYEARECAAYFAkmPQU4ACgkQfD8M/ASTygJxegCgqgPS9pu3OEOKkRFPCyY1ouZh eTcAmQFilkgGhjltEF7l4Rz6lONzJUb1 =tTxR -----END PGP SIGNATURE----- --Apple-Mail-3-267380729-- From owner-svn-src-stable@FreeBSD.ORG Sun Feb 8 22:01:20 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 70A88106566C; Sun, 8 Feb 2009 22:01:20 +0000 (UTC) (envelope-from rpaulo@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 5DD358FC0A; Sun, 8 Feb 2009 22:01:20 +0000 (UTC) (envelope-from rpaulo@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n18M1K71035737; Sun, 8 Feb 2009 22:01:20 GMT (envelope-from rpaulo@svn.freebsd.org) Received: (from rpaulo@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n18M1KM3035736; Sun, 8 Feb 2009 22:01:20 GMT (envelope-from rpaulo@svn.freebsd.org) Message-Id: <200902082201.n18M1KM3035736@svn.freebsd.org> From: Rui Paulo Date: Sun, 8 Feb 2009 22:01:20 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r188342 - in stable/7/sys: . contrib/pf dev/acpi_support dev/cxgb X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 08 Feb 2009 22:01:21 -0000 Author: rpaulo Date: Sun Feb 8 22:01:20 2009 New Revision: 188342 URL: http://svn.freebsd.org/changeset/base/188342 Log: Reverse botched r188326. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/acpi_support/acpi_asus.c stable/7/sys/dev/cxgb/ (props changed) Modified: stable/7/sys/dev/acpi_support/acpi_asus.c ============================================================================== --- stable/7/sys/dev/acpi_support/acpi_asus.c Sun Feb 8 21:54:51 2009 (r188341) +++ stable/7/sys/dev/acpi_support/acpi_asus.c Sun Feb 8 22:01:20 2009 (r188342) @@ -958,9 +958,7 @@ acpi_asus_sysctl_get(struct acpi_asus_so static int acpi_asus_sysctl_set(struct acpi_asus_softc *sc, int method, int arg) { - ACPI_STATUS status = AE_OK; - ACPI_OBJECT_LIST acpiargs; - ACPI_OBJECT acpiarg[1]; + ACPI_STATUS status = AE_OK; ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__); ACPI_SERIAL_ASSERT(asus); From owner-svn-src-stable@FreeBSD.ORG Sun Feb 8 22:09:49 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C2ACA106564A; Sun, 8 Feb 2009 22:09:49 +0000 (UTC) (envelope-from rpaulo@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id AEC838FC18; Sun, 8 Feb 2009 22:09:49 +0000 (UTC) (envelope-from rpaulo@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n18M9nQ0036274; Sun, 8 Feb 2009 22:09:49 GMT (envelope-from rpaulo@svn.freebsd.org) Received: (from rpaulo@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n18M9nIo036273; Sun, 8 Feb 2009 22:09:49 GMT (envelope-from rpaulo@svn.freebsd.org) Message-Id: <200902082209.n18M9nIo036273@svn.freebsd.org> From: Rui Paulo Date: Sun, 8 Feb 2009 22:09:49 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r188346 - in stable/7/sys: . contrib/pf dev/acpi_support dev/ath/ath_hal dev/cxgb X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 08 Feb 2009 22:09:50 -0000 Author: rpaulo Date: Sun Feb 8 22:09:49 2009 New Revision: 188346 URL: http://svn.freebsd.org/changeset/base/188346 Log: MFC r180268: Fix my previous commit. We actually should pass evaluation args in AcpiEvaluateObject() calls, otherwise, we are not able to bring devices back up (NULL means 0, hence always off). While there add missing WLAN on/off support. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/acpi_support/acpi_asus.c stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) Modified: stable/7/sys/dev/acpi_support/acpi_asus.c ============================================================================== --- stable/7/sys/dev/acpi_support/acpi_asus.c Sun Feb 8 22:08:48 2009 (r188345) +++ stable/7/sys/dev/acpi_support/acpi_asus.c Sun Feb 8 22:09:49 2009 (r188346) @@ -57,6 +57,7 @@ __FBSDID("$FreeBSD$"); #define ACPI_ASUS_METHOD_LCD 3 #define ACPI_ASUS_METHOD_CAMERA 4 #define ACPI_ASUS_METHOD_CARDRD 5 +#define ACPI_ASUS_METHOD_WLAN 6 #define _COMPONENT ACPI_OEM ACPI_MODULE_NAME("ASUS") @@ -88,6 +89,9 @@ struct acpi_asus_model { char *crd_get; char *crd_set; + char *wlan_get; + char *wlan_set; + void (*n_func)(ACPI_HANDLE, UINT32, void *); char *lcdd; @@ -130,6 +134,7 @@ struct acpi_asus_softc { int s_lcd; int s_cam; int s_crd; + int s_wlan; }; static void acpi_asus_lcdd_notify(ACPI_HANDLE h, UINT32 notify, @@ -423,6 +428,8 @@ static struct acpi_asus_model acpi_eeepc .cam_set = "\\_SB.ATKD.CAMS", .crd_set = "\\_SB.ATKD.CRDS", .crd_get = "\\_SB.ATKD.CRDG", + .wlan_get = "\\_SB.ATKD.WLDG", + .wlan_set = "\\_SB.ATKD.WLDS", .n_func = acpi_asus_eeepc_notify }, @@ -465,6 +472,12 @@ static struct { .description = "internal card reader state", .flags = CTLTYPE_INT | CTLFLAG_RW }, + { + .name = "wlan", + .method = ACPI_ASUS_METHOD_WLAN, + .description = "wireless lan state", + .flags = CTLTYPE_INT | CTLFLAG_RW + }, { .name = NULL } }; @@ -950,6 +963,9 @@ acpi_asus_sysctl_get(struct acpi_asus_so case ACPI_ASUS_METHOD_CARDRD: val = sc->s_crd; break; + case ACPI_ASUS_METHOD_WLAN: + val = sc->s_wlan; + break; } return (val); @@ -958,11 +974,18 @@ acpi_asus_sysctl_get(struct acpi_asus_so static int acpi_asus_sysctl_set(struct acpi_asus_softc *sc, int method, int arg) { - ACPI_STATUS status = AE_OK; + ACPI_STATUS status = AE_OK; + ACPI_OBJECT_LIST acpiargs; + ACPI_OBJECT acpiarg[0]; ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__); ACPI_SERIAL_ASSERT(asus); + acpiargs.Count = 1; + acpiargs.Pointer = acpiarg; + acpiarg[0].Type = ACPI_TYPE_INTEGER; + acpiarg[0].Integer.Value = arg; + switch (method) { case ACPI_ASUS_METHOD_BRN: if (arg < 0 || arg > 15) @@ -1015,7 +1038,7 @@ acpi_asus_sysctl_set(struct acpi_asus_so return (EINVAL); status = AcpiEvaluateObject(sc->handle, - sc->model->cam_set, NULL, NULL); + sc->model->cam_set, &acpiargs, NULL); if (ACPI_SUCCESS(status)) sc->s_cam = arg; @@ -1025,11 +1048,21 @@ acpi_asus_sysctl_set(struct acpi_asus_so return (EINVAL); status = AcpiEvaluateObject(sc->handle, - sc->model->crd_set, NULL, NULL); + sc->model->crd_set, &acpiargs, NULL); if (ACPI_SUCCESS(status)) sc->s_crd = arg; break; + case ACPI_ASUS_METHOD_WLAN: + if (arg < 0 || arg > 1) + return (EINVAL); + + status = AcpiEvaluateObject(sc->handle, + sc->model->wlan_set, &acpiargs, NULL); + + if (ACPI_SUCCESS(status)) + sc->s_wlan = arg; + break; } return (0); @@ -1140,6 +1173,14 @@ acpi_asus_sysctl_init(struct acpi_asus_s return (TRUE); } return (FALSE); + case ACPI_ASUS_METHOD_WLAN: + if (sc->model->wlan_get) { + status = acpi_GetInteger(sc->handle, + sc->model->wlan_get, &sc->s_wlan); + if (ACPI_SUCCESS(status)) + return (TRUE); + } + return (FALSE); } return (FALSE); } From owner-svn-src-stable@FreeBSD.ORG Sun Feb 8 22:13:55 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B8C321065675; Sun, 8 Feb 2009 22:13:55 +0000 (UTC) (envelope-from rpaulo@gmail.com) Received: from ey-out-2122.google.com (ey-out-2122.google.com [74.125.78.26]) by mx1.freebsd.org (Postfix) with ESMTP id 88F118FC20; Sun, 8 Feb 2009 22:13:54 +0000 (UTC) (envelope-from rpaulo@gmail.com) Received: by ey-out-2122.google.com with SMTP id d26so198732eyd.7 for ; Sun, 08 Feb 2009 14:13:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:cc:message-id:from:to :in-reply-to:content-type:content-transfer-encoding:mime-version :subject:date:references:x-pgp-agent:x-mailer; bh=ylUBhBoUvp+dwbtYyiv+MpgKZHN2Syd8kuTSpwPCRbY=; b=f2HAfSM1OvCpW6JliGGjVMb0Atvb0RgcQYl9CHqt1J38J2EQSdUTD4/EnH4PivtWYv 9tXUHjgY+v23W29UpVR4P1iVvsqHGMrziNMWiBKGDwMClIAgGpcZXhNtVUHVHSA7QrDX XXExMmVRcE5Tm+ATN+pLAKbxj0noxL1qLV9/g= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=cc:message-id:from:to:in-reply-to:content-type :content-transfer-encoding:mime-version:subject:date:references :x-pgp-agent:x-mailer; b=vZoF8ddkwaEmlV52xl0m88tzhPfAAXUDQVL8pKZF9eECSlBW9OyASCmsIyZ+hwcV2e UzU8MWPbrNnIOnHQACrziH6PXJ1u8vQ8tsYhcu0I4IjH56c8gGrZjPhDaxGZquDyoodx cPuitvFP5ua3eOz40SUJ9/0s8tIbRcGiPALKg= Received: by 10.210.119.16 with SMTP id r16mr849680ebc.91.1234131233532; Sun, 08 Feb 2009 14:13:53 -0800 (PST) Received: from epsilon.lan (bl9-153-17.dsl.telepac.pt [85.242.153.17]) by mx.google.com with ESMTPS id h7sm9379173nfh.27.2009.02.08.14.13.51 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sun, 08 Feb 2009 14:13:52 -0800 (PST) Message-Id: <8F7136F6-15CC-4ACC-83AC-867900012717@gmail.com> From: Rui Paulo To: Rui Paulo In-Reply-To: <1F7BDEA8-EFB8-42D9-A32D-1D3F49F9C9EC@FreeBSD.org> Content-Type: multipart/signed; protocol="application/pgp-signature"; micalg=pgp-sha1; boundary="Apple-Mail-4-273472754" Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Apple Message framework v930.3) Date: Sun, 8 Feb 2009 22:13:46 +0000 References: <200902082000.n18K0aBr032797@svn.freebsd.org> <498F3EA7.4050900@gmx.de> <1F7BDEA8-EFB8-42D9-A32D-1D3F49F9C9EC@FreeBSD.org> X-Pgp-Agent: GPGMail 1.2.0 (v56) X-Mailer: Apple Mail (2.930.3) Cc: svn-src-stable-7@freebsd.org, svn-src-stable@freebsd.org, svn-src-all@freebsd.org, Christoph Mallon , src-committers@freebsd.org Subject: Re: svn commit: r188326 - in stable/7/sys: . contrib/pf dev/acpi_support dev/cxgb X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 08 Feb 2009 22:13:56 -0000 This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --Apple-Mail-4-273472754 Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit On 8 Feb 2009, at 20:32, Rui Paulo wrote: > > On 8 Feb 2009, at 20:20, Christoph Mallon wrote: > >> Rui Paulo schrieb: >>> Author: rpaulo >>> Date: Sun Feb 8 20:00:36 2009 >>> New Revision: 188326 >>> URL: http://svn.freebsd.org/changeset/base/188326 >>> Log: >>> MFC r186529 (stas): >>> - Fix incorrect array declaration that was causing the stack >>> overflow >>> on some (most?) Asus laptops. >>> Modified: >>> stable/7/sys/ (props changed) >>> stable/7/sys/contrib/pf/ (props changed) >>> stable/7/sys/dev/acpi_support/acpi_asus.c >>> stable/7/sys/dev/cxgb/ (props changed) >>> Modified: stable/7/sys/dev/acpi_support/acpi_asus.c >>> = >>> = >>> = >>> = >>> = >>> = >>> = >>> = >>> = >>> = >>> ==================================================================== >>> --- stable/7/sys/dev/acpi_support/acpi_asus.c Sun Feb 8 20:00:33 >>> 2009 (r188325) >>> +++ stable/7/sys/dev/acpi_support/acpi_asus.c Sun Feb 8 20:00:36 >>> 2009 (r188326) >>> @@ -958,7 +958,9 @@ acpi_asus_sysctl_get(struct acpi_asus_so >>> static int >>> acpi_asus_sysctl_set(struct acpi_asus_softc *sc, int method, int >>> arg) >>> { >>> - ACPI_STATUS status = AE_OK; >>> + ACPI_STATUS status = AE_OK; >>> + ACPI_OBJECT_LIST acpiargs; >>> + ACPI_OBJECT acpiarg[1]; >>> ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__); >>> ACPI_SERIAL_ASSERT(asus); >> >> r186529 does not seem to apply to 7.x, because you just added two >> unused variables. Maybe you forgot to MFC something else (r180268?) >> first. > > > This is a merge botch... Sorry. Should be fixed now. Thanks, -- Rui Paulo --Apple-Mail-4-273472754 content-type: application/pgp-signature; x-mac-type=70674453; name=PGP.sig content-description: This is a digitally signed message part content-disposition: inline; filename=PGP.sig content-transfer-encoding: 7bit -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (Darwin) iEYEARECAAYFAkmPWRoACgkQfD8M/ASTygL2zgCfQxT2wmclxtXGnW4ZHHY2dnmh 3NgAn3UzAwwex6KcGxhaBbVe+W62yG29 =gwqd -----END PGP SIGNATURE----- --Apple-Mail-4-273472754-- From owner-svn-src-stable@FreeBSD.ORG Sun Feb 8 22:13:57 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id BECB1106564A; Sun, 8 Feb 2009 22:13:57 +0000 (UTC) (envelope-from rpaulo@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id AC2A28FC08; Sun, 8 Feb 2009 22:13:57 +0000 (UTC) (envelope-from rpaulo@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n18MDvW4036426; Sun, 8 Feb 2009 22:13:57 GMT (envelope-from rpaulo@svn.freebsd.org) Received: (from rpaulo@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n18MDvrx036425; Sun, 8 Feb 2009 22:13:57 GMT (envelope-from rpaulo@svn.freebsd.org) Message-Id: <200902082213.n18MDvrx036425@svn.freebsd.org> From: Rui Paulo Date: Sun, 8 Feb 2009 22:13:57 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r188347 - in stable/7/sys: . contrib/pf dev/acpi_support dev/cxgb X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 08 Feb 2009 22:13:58 -0000 Author: rpaulo Date: Sun Feb 8 22:13:57 2009 New Revision: 188347 URL: http://svn.freebsd.org/changeset/base/188347 Log: MFC 186529 (stas): - Fix incorrect array declaration that was causing the stack overflow on some (most?) Asus laptops. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/acpi_support/acpi_asus.c stable/7/sys/dev/cxgb/ (props changed) Modified: stable/7/sys/dev/acpi_support/acpi_asus.c ============================================================================== --- stable/7/sys/dev/acpi_support/acpi_asus.c Sun Feb 8 22:09:49 2009 (r188346) +++ stable/7/sys/dev/acpi_support/acpi_asus.c Sun Feb 8 22:13:57 2009 (r188347) @@ -976,7 +976,7 @@ acpi_asus_sysctl_set(struct acpi_asus_so { ACPI_STATUS status = AE_OK; ACPI_OBJECT_LIST acpiargs; - ACPI_OBJECT acpiarg[0]; + ACPI_OBJECT acpiarg[1]; ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__); ACPI_SERIAL_ASSERT(asus); From owner-svn-src-stable@FreeBSD.ORG Mon Feb 9 01:16:37 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 44A0F1065670; Mon, 9 Feb 2009 01:16:37 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 31A338FC21; Mon, 9 Feb 2009 01:16:37 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n191GbYO040281; Mon, 9 Feb 2009 01:16:37 GMT (envelope-from yongari@svn.freebsd.org) Received: (from yongari@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n191GbaZ040279; Mon, 9 Feb 2009 01:16:37 GMT (envelope-from yongari@svn.freebsd.org) Message-Id: <200902090116.n191GbaZ040279@svn.freebsd.org> From: Pyun YongHyeon Date: Mon, 9 Feb 2009 01:16:37 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r188356 - in stable/7/sys: . contrib/pf dev/cxgb dev/re pci X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Feb 2009 01:16:38 -0000 Author: yongari Date: Mon Feb 9 01:16:36 2009 New Revision: 188356 URL: http://svn.freebsd.org/changeset/base/188356 Log: MFC: r185752-185753,185756,185896 r185752: Make sure to return the result of meida change request. Previously it used to return success regardless of the result. r185753: o Implemented miibus_statchg handler. It detects whether re(4) established a valid link or not. In miibus_statchg handler add a check for established link is valid one for the controller(e.g. 1000baseT is not a valid link for fastethernet controllers.) o Added a flag RE_FLAG_FASTETHER to mark fastethernet controllers. o Added additional check to know whether we've really encountered watchdog timeouts or missed Tx completion interrupts. This change may help to track down the cause of watchdog timeouts. o In interrupt handler, removed a check for link state change interrupt. Not all controllers have the bit and re(4) did not rely on the event for a long time. In addition, re(4) didn't request the interrupt in RL_IMR register. r185756: Reduce spin wait time consumed in GMII register access routines. Waiting for 1ms for each GMII register access looks overkill and it may also decrease overall performance of driver because re(4) invokes mii_tick for every hz. r185896: Partly revert r185756. RTL8169SC doesn't like reduced delays in GMII access while Tx/Rx is in progress. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/dev/re/if_re.c stable/7/sys/pci/if_rlreg.h Modified: stable/7/sys/dev/re/if_re.c ============================================================================== --- stable/7/sys/dev/re/if_re.c Mon Feb 9 00:58:16 2009 (r188355) +++ stable/7/sys/dev/re/if_re.c Mon Feb 9 01:16:36 2009 (r188356) @@ -417,7 +417,6 @@ re_gmii_readreg(device_t dev, int phy, i } CSR_WRITE_4(sc, RL_PHYAR, reg << 16); - DELAY(1000); for (i = 0; i < RL_TIMEOUT; i++) { rval = CSR_READ_4(sc, RL_PHYAR); @@ -445,7 +444,6 @@ re_gmii_writereg(device_t dev, int phy, CSR_WRITE_4(sc, RL_PHYAR, (reg << 16) | (data & RL_PHYAR_PHYDATA) | RL_PHYAR_BUSY); - DELAY(1000); for (i = 0; i < RL_TIMEOUT; i++) { rval = CSR_READ_4(sc, RL_PHYAR); @@ -573,7 +571,39 @@ re_miibus_writereg(device_t dev, int phy static void re_miibus_statchg(device_t dev) { + struct rl_softc *sc; + struct ifnet *ifp; + struct mii_data *mii; + + sc = device_get_softc(dev); + mii = device_get_softc(sc->rl_miibus); + ifp = sc->rl_ifp; + if (mii == NULL || ifp == NULL || + (ifp->if_drv_flags & IFF_DRV_RUNNING) == 0) + return; + sc->rl_flags &= ~RL_FLAG_LINK; + if ((mii->mii_media_status & (IFM_ACTIVE | IFM_AVALID)) == + (IFM_ACTIVE | IFM_AVALID)) { + switch (IFM_SUBTYPE(mii->mii_media_active)) { + case IFM_10_T: + case IFM_100_TX: + sc->rl_flags |= RL_FLAG_LINK; + break; + case IFM_1000_T: + if ((sc->rl_flags & RL_FLAG_FASTETHER) != 0) + break; + sc->rl_flags |= RL_FLAG_LINK; + break; + default: + break; + } + } + /* + * RealTek controllers does not provide any interface to + * Tx/Rx MACs for resolved speed, duplex and flow-control + * parameters. + */ } /* @@ -1204,18 +1234,18 @@ re_attach(device_t dev) switch (hw_rev->rl_rev) { case RL_HWREV_8139CPLUS: - sc->rl_flags |= RL_FLAG_NOJUMBO; + sc->rl_flags |= RL_FLAG_NOJUMBO | RL_FLAG_FASTETHER; break; case RL_HWREV_8100E: case RL_HWREV_8101E: sc->rl_flags |= RL_FLAG_NOJUMBO | RL_FLAG_INVMAR | - RL_FLAG_PHYWAKE; + RL_FLAG_PHYWAKE | RL_FLAG_FASTETHER; break; case RL_HWREV_8102E: case RL_HWREV_8102EL: sc->rl_flags |= RL_FLAG_NOJUMBO | RL_FLAG_INVMAR | RL_FLAG_PHYWAKE | RL_FLAG_PAR | RL_FLAG_DESCV2 | - RL_FLAG_MACSTAT; + RL_FLAG_MACSTAT | RL_FLAG_FASTETHER; break; case RL_HWREV_8168_SPIN1: case RL_HWREV_8168_SPIN2: @@ -2011,30 +2041,14 @@ re_tick(void *xsc) { struct rl_softc *sc; struct mii_data *mii; - struct ifnet *ifp; sc = xsc; - ifp = sc->rl_ifp; RL_LOCK_ASSERT(sc); - re_watchdog(sc); - mii = device_get_softc(sc->rl_miibus); mii_tick(mii); - if ((sc->rl_flags & RL_FLAG_LINK) != 0) { - if (!(mii->mii_media_status & IFM_ACTIVE)) - sc->rl_flags &= ~RL_FLAG_LINK; - } else { - if (mii->mii_media_status & IFM_ACTIVE && - IFM_SUBTYPE(mii->mii_media_active) != IFM_NONE) { - sc->rl_flags |= RL_FLAG_LINK; - if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd)) - taskqueue_enqueue_fast(taskqueue_fast, - &sc->rl_txtask); - } - } - + re_watchdog(sc); callout_reset(&sc->rl_stat_callout, hz, re_tick, sc); } @@ -2149,11 +2163,6 @@ re_int_task(void *arg, int npending) re_init_locked(sc); } - if (status & RL_ISR_LINKCHG) { - callout_stop(&sc->rl_stat_callout); - re_tick(sc); - } - if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd)) taskqueue_enqueue_fast(taskqueue_fast, &sc->rl_txtask); @@ -2652,14 +2661,15 @@ re_ifmedia_upd(struct ifnet *ifp) { struct rl_softc *sc; struct mii_data *mii; + int error; sc = ifp->if_softc; mii = device_get_softc(sc->rl_miibus); RL_LOCK(sc); - mii_mediachg(mii); + error = mii_mediachg(mii); RL_UNLOCK(sc); - return (0); + return (error); } /* @@ -2814,18 +2824,30 @@ re_ioctl(struct ifnet *ifp, u_long comma static void re_watchdog(struct rl_softc *sc) { + struct ifnet *ifp; RL_LOCK_ASSERT(sc); if (sc->rl_watchdog_timer == 0 || --sc->rl_watchdog_timer != 0) return; - device_printf(sc->rl_dev, "watchdog timeout\n"); - sc->rl_ifp->if_oerrors++; - + ifp = sc->rl_ifp; re_txeof(sc); + if (sc->rl_ldata.rl_tx_free == sc->rl_ldata.rl_tx_desc_cnt) { + if_printf(ifp, "watchdog timeout (missed Tx interrupts) " + "-- recovering\n"); + if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd)) + taskqueue_enqueue_fast(taskqueue_fast, &sc->rl_txtask); + return; + } + + if_printf(ifp, "watchdog timeout\n"); + ifp->if_oerrors++; + re_rxeof(sc); re_init_locked(sc); + if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd)) + taskqueue_enqueue_fast(taskqueue_fast, &sc->rl_txtask); } /* Modified: stable/7/sys/pci/if_rlreg.h ============================================================================== --- stable/7/sys/pci/if_rlreg.h Mon Feb 9 00:58:16 2009 (r188355) +++ stable/7/sys/pci/if_rlreg.h Mon Feb 9 01:16:36 2009 (r188356) @@ -855,6 +855,7 @@ struct rl_softc { #define RL_FLAG_PAR 0x0020 #define RL_FLAG_DESCV2 0x0040 #define RL_FLAG_MACSTAT 0x0080 +#define RL_FLAG_FASTETHER 0x0100 #define RL_FLAG_LINK 0x8000 }; From owner-svn-src-stable@FreeBSD.ORG Mon Feb 9 01:26:32 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 025F31065670; Mon, 9 Feb 2009 01:26:32 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id DACF98FC14; Mon, 9 Feb 2009 01:26:31 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n191QVuW040545; Mon, 9 Feb 2009 01:26:31 GMT (envelope-from yongari@svn.freebsd.org) Received: (from yongari@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n191QVjF040543; Mon, 9 Feb 2009 01:26:31 GMT (envelope-from yongari@svn.freebsd.org) Message-Id: <200902090126.n191QVjF040543@svn.freebsd.org> From: Pyun YongHyeon Date: Mon, 9 Feb 2009 01:26:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r188357 - in stable/7/sys: . contrib/pf dev/cxgb dev/re pci X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Feb 2009 01:26:32 -0000 Author: yongari Date: Mon Feb 9 01:26:31 2009 New Revision: 188357 URL: http://svn.freebsd.org/changeset/base/188357 Log: MFC: r185897,185900-185901,185903 r185897: Always put controller into known state before device intialization. While here remove re_reset calls invoked in system error case as controller reset is always done in device initialization. r185900: Newer RealTek controllers requires setting stop request bit to terminate active Tx/Rx operation. r185901: Don't access undocumented register 0x82 on controllers that have no such register. While here clear undocumented PHY register 0x0B for RTL8110S. r185903: Make WOL work on RTL8168B. This controller seems to require explicit command to enable Rx MAC prior to entering D3. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/dev/re/if_re.c stable/7/sys/pci/if_rlreg.h Modified: stable/7/sys/dev/re/if_re.c ============================================================================== --- stable/7/sys/dev/re/if_re.c Mon Feb 9 01:16:36 2009 (r188356) +++ stable/7/sys/dev/re/if_re.c Mon Feb 9 01:26:31 2009 (r188357) @@ -700,7 +700,12 @@ re_reset(struct rl_softc *sc) if (i == RL_TIMEOUT) device_printf(sc->rl_dev, "reset never completed!\n"); - CSR_WRITE_1(sc, 0x82, 1); + if ((sc->rl_flags & RL_FLAG_PHY8169) != 0) + CSR_WRITE_1(sc, 0x82, 1); + if ((sc->rl_flags & RL_FLAG_PHY8110S) != 0) { + CSR_WRITE_1(sc, 0x82, 1); + re_gmii_writereg(sc->rl_dev, 1, 0x0B, 0); + } } #ifdef RE_DIAG @@ -756,7 +761,6 @@ re_diag(struct rl_softc *sc) ifp->if_flags |= IFF_PROMISC; sc->rl_testmode = 1; - re_reset(sc); re_init_locked(sc); sc->rl_flags |= RL_FLAG_LINK; if (sc->rl_type == RL_8169) @@ -1236,6 +1240,9 @@ re_attach(device_t dev) case RL_HWREV_8139CPLUS: sc->rl_flags |= RL_FLAG_NOJUMBO | RL_FLAG_FASTETHER; break; + case RL_HWREV_8110S: + sc->rl_flags |= RL_FLAG_PHY8110S; + break; case RL_HWREV_8100E: case RL_HWREV_8101E: sc->rl_flags |= RL_FLAG_NOJUMBO | RL_FLAG_INVMAR | @@ -1245,10 +1252,12 @@ re_attach(device_t dev) case RL_HWREV_8102EL: sc->rl_flags |= RL_FLAG_NOJUMBO | RL_FLAG_INVMAR | RL_FLAG_PHYWAKE | RL_FLAG_PAR | RL_FLAG_DESCV2 | - RL_FLAG_MACSTAT | RL_FLAG_FASTETHER; + RL_FLAG_MACSTAT | RL_FLAG_FASTETHER | RL_FLAG_CMDSTOP; break; case RL_HWREV_8168_SPIN1: case RL_HWREV_8168_SPIN2: + sc->rl_flags |= RL_FLAG_WOLRXENB; + /* FALLTHROUGH */ case RL_HWREV_8168_SPIN3: sc->rl_flags |= RL_FLAG_INVMAR | RL_FLAG_PHYWAKE | RL_FLAG_MACSTAT; @@ -1258,7 +1267,8 @@ re_attach(device_t dev) case RL_HWREV_8168CP: case RL_HWREV_8168D: sc->rl_flags |= RL_FLAG_INVMAR | RL_FLAG_PHYWAKE | - RL_FLAG_PAR | RL_FLAG_DESCV2 | RL_FLAG_MACSTAT; + RL_FLAG_PAR | RL_FLAG_DESCV2 | RL_FLAG_MACSTAT | + RL_FLAG_CMDSTOP; /* * These controllers support jumbo frame but it seems * that enabling it requires touching additional magic @@ -1271,10 +1281,14 @@ re_attach(device_t dev) */ sc->rl_flags |= RL_FLAG_NOJUMBO; break; + case RL_HWREV_8169: + case RL_HWREV_8169S: + sc->rl_flags |= RL_FLAG_PHY8169; + break; case RL_HWREV_8169_8110SB: case RL_HWREV_8169_8110SC: case RL_HWREV_8169_8110SBL: - sc->rl_flags |= RL_FLAG_PHYWAKE; + sc->rl_flags |= RL_FLAG_PHYWAKE | RL_FLAG_PHY8169; break; default: break; @@ -2091,10 +2105,8 @@ re_poll_locked(struct ifnet *ifp, enum p * XXX check behaviour on receiver stalls. */ - if (status & RL_ISR_SYSTEM_ERR) { - re_reset(sc); + if (status & RL_ISR_SYSTEM_ERR) re_init_locked(sc); - } } } #endif /* DEVICE_POLLING */ @@ -2158,10 +2170,8 @@ re_int_task(void *arg, int npending) RL_ISR_TX_ERR|RL_ISR_TX_DESC_UNAVAIL)) re_txeof(sc); - if (status & RL_ISR_SYSTEM_ERR) { - re_reset(sc); + if (status & RL_ISR_SYSTEM_ERR) re_init_locked(sc); - } if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd)) taskqueue_enqueue_fast(taskqueue_fast, &sc->rl_txtask); @@ -2482,6 +2492,9 @@ re_init_locked(struct rl_softc *sc) */ re_stop(sc); + /* Put controller into known state. */ + re_reset(sc); + /* * Enable C+ RX and TX mode, as well as VLAN stripping and * RX checksum offload. We must configure the C+ register @@ -2870,7 +2883,12 @@ re_stop(struct rl_softc *sc) callout_stop(&sc->rl_stat_callout); ifp->if_drv_flags &= ~(IFF_DRV_RUNNING | IFF_DRV_OACTIVE); - CSR_WRITE_1(sc, RL_COMMAND, 0x00); + if ((sc->rl_flags & RL_FLAG_CMDSTOP) != 0) + CSR_WRITE_1(sc, RL_COMMAND, RL_CMD_STOPREQ | RL_CMD_TX_ENB | + RL_CMD_RX_ENB); + else + CSR_WRITE_1(sc, RL_COMMAND, 0x00); + DELAY(1000); CSR_WRITE_2(sc, RL_IMR, 0x0000); CSR_WRITE_2(sc, RL_ISR, 0xFFFF); @@ -3000,6 +3018,9 @@ re_setwol(struct rl_softc *sc) return; ifp = sc->rl_ifp; + if ((ifp->if_capenable & IFCAP_WOL) != 0 && + (sc->rl_flags & RL_FLAG_WOLRXENB) != 0) + CSR_WRITE_1(sc, RL_COMMAND, RL_CMD_RX_ENB); /* Enable config register write. */ CSR_WRITE_1(sc, RL_EECMD, RL_EE_MODE); Modified: stable/7/sys/pci/if_rlreg.h ============================================================================== --- stable/7/sys/pci/if_rlreg.h Mon Feb 9 01:16:36 2009 (r188356) +++ stable/7/sys/pci/if_rlreg.h Mon Feb 9 01:26:31 2009 (r188357) @@ -308,6 +308,7 @@ #define RL_CMD_TX_ENB 0x0004 #define RL_CMD_RX_ENB 0x0008 #define RL_CMD_RESET 0x0010 +#define RL_CMD_STOPREQ 0x0080 /* * EEPROM control register @@ -856,6 +857,10 @@ struct rl_softc { #define RL_FLAG_DESCV2 0x0040 #define RL_FLAG_MACSTAT 0x0080 #define RL_FLAG_FASTETHER 0x0100 +#define RL_FLAG_CMDSTOP 0x0200 +#define RL_FLAG_PHY8169 0x0400 +#define RL_FLAG_PHY8110S 0x0800 +#define RL_FLAG_WOLRXENB 0x1000 #define RL_FLAG_LINK 0x8000 }; From owner-svn-src-stable@FreeBSD.ORG Mon Feb 9 01:30:15 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0C0DF106566B; Mon, 9 Feb 2009 01:30:15 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id EDDE88FC17; Mon, 9 Feb 2009 01:30:14 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n191UE3i040658; Mon, 9 Feb 2009 01:30:14 GMT (envelope-from yongari@svn.freebsd.org) Received: (from yongari@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n191UEnV040656; Mon, 9 Feb 2009 01:30:14 GMT (envelope-from yongari@svn.freebsd.org) Message-Id: <200902090130.n191UEnV040656@svn.freebsd.org> From: Pyun YongHyeon Date: Mon, 9 Feb 2009 01:30:14 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r188358 - in stable/7/sys: . contrib/pf dev/cxgb dev/re pci X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Feb 2009 01:30:15 -0000 Author: yongari Date: Mon Feb 9 01:30:14 2009 New Revision: 188358 URL: http://svn.freebsd.org/changeset/base/188358 Log: MFC r186210: For RTL8168C SPIN2 controllers, make sure to take the controller out of sleep mode prior to accessing to PHY. This should fix device attach failure seen on these controllers. Also enable the sleep mode when device is put into sleep state. PR: kern/123123, kern/123053 Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/dev/re/if_re.c stable/7/sys/pci/if_rlreg.h Modified: stable/7/sys/dev/re/if_re.c ============================================================================== --- stable/7/sys/dev/re/if_re.c Mon Feb 9 01:26:31 2009 (r188357) +++ stable/7/sys/dev/re/if_re.c Mon Feb 9 01:30:14 2009 (r188358) @@ -1262,8 +1262,13 @@ re_attach(device_t dev) sc->rl_flags |= RL_FLAG_INVMAR | RL_FLAG_PHYWAKE | RL_FLAG_MACSTAT; break; - case RL_HWREV_8168C: case RL_HWREV_8168C_SPIN2: + sc->rl_flags |= RL_FLAG_MACSLEEP; + /* FALLTHROUGH */ + case RL_HWREV_8168C: + if ((hwrev & 0x00700000) == 0x00200000) + sc->rl_flags |= RL_FLAG_MACSLEEP; + /* FALLTHROUGH */ case RL_HWREV_8168CP: case RL_HWREV_8168D: sc->rl_flags |= RL_FLAG_INVMAR | RL_FLAG_PHYWAKE | @@ -1351,6 +1356,16 @@ re_attach(device_t dev) goto fail; } + /* Take controller out of deep sleep mode. */ + if ((sc->rl_flags & RL_FLAG_MACSLEEP) != 0) { + if ((CSR_READ_1(sc, RL_MACDBG) & 0x80) == 0x80) + CSR_WRITE_1(sc, RL_GPIO, + CSR_READ_1(sc, RL_GPIO) | 0x01); + else + CSR_WRITE_1(sc, RL_GPIO, + CSR_READ_1(sc, RL_GPIO) & ~0x01); + } + /* Take PHY out of power down mode. */ if ((sc->rl_flags & RL_FLAG_PHYWAKE) != 0) { re_gmii_writereg(dev, 1, 0x1f, 0); @@ -2963,6 +2978,12 @@ re_resume(device_t dev) RL_LOCK(sc); ifp = sc->rl_ifp; + /* Take controller out of sleep mode. */ + if ((sc->rl_flags & RL_FLAG_MACSLEEP) != 0) { + if ((CSR_READ_1(sc, RL_MACDBG) & 0x80) == 0x80) + CSR_WRITE_1(sc, RL_GPIO, + CSR_READ_1(sc, RL_GPIO) | 0x01); + } /* reinitialize interface if necessary */ if (ifp->if_flags & IFF_UP) @@ -3018,6 +3039,12 @@ re_setwol(struct rl_softc *sc) return; ifp = sc->rl_ifp; + /* Put controller into sleep mode. */ + if ((sc->rl_flags & RL_FLAG_MACSLEEP) != 0) { + if ((CSR_READ_1(sc, RL_MACDBG) & 0x80) == 0x80) + CSR_WRITE_1(sc, RL_GPIO, + CSR_READ_1(sc, RL_GPIO) & ~0x01); + } if ((ifp->if_capenable & IFCAP_WOL) != 0 && (sc->rl_flags & RL_FLAG_WOLRXENB) != 0) CSR_WRITE_1(sc, RL_COMMAND, RL_CMD_RX_ENB); Modified: stable/7/sys/pci/if_rlreg.h ============================================================================== --- stable/7/sys/pci/if_rlreg.h Mon Feb 9 01:26:31 2009 (r188357) +++ stable/7/sys/pci/if_rlreg.h Mon Feb 9 01:30:14 2009 (r188358) @@ -131,6 +131,8 @@ #define RL_TBI_ANAR 0x0068 #define RL_TBI_LPAR 0x006A #define RL_GMEDIASTAT 0x006C /* 8 bits */ +#define RL_MACDBG 0x006D /* 8 bits, 8168C SPIN2 only */ +#define RL_GPIO 0x006E /* 8 bits, 8168C SPIN2 only */ #define RL_MAXRXPKTLEN 0x00DA /* 16 bits, chip multiplies by 8 */ #define RL_GTXSTART 0x0038 /* 8 bits */ @@ -861,6 +863,7 @@ struct rl_softc { #define RL_FLAG_PHY8169 0x0400 #define RL_FLAG_PHY8110S 0x0800 #define RL_FLAG_WOLRXENB 0x1000 +#define RL_FLAG_MACSLEEP 0x2000 #define RL_FLAG_LINK 0x8000 }; From owner-svn-src-stable@FreeBSD.ORG Mon Feb 9 01:38:02 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6680F1065670; Mon, 9 Feb 2009 01:38:02 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 52E3D8FC08; Mon, 9 Feb 2009 01:38:02 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n191c2do040861; Mon, 9 Feb 2009 01:38:02 GMT (envelope-from yongari@svn.freebsd.org) Received: (from yongari@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n191c2R3040859; Mon, 9 Feb 2009 01:38:02 GMT (envelope-from yongari@svn.freebsd.org) Message-Id: <200902090138.n191c2R3040859@svn.freebsd.org> From: Pyun YongHyeon Date: Mon, 9 Feb 2009 01:38:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r188359 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb dev/re pci X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Feb 2009 01:38:03 -0000 Author: yongari Date: Mon Feb 9 01:38:01 2009 New Revision: 188359 URL: http://svn.freebsd.org/changeset/base/188359 Log: MFC r186214,186389,187417 r186214: It seems that RealTek PCIe controllers require an explicit Tx poll command whenever Tx completion interrupt is raised. The Tx poll bit is cleared when all packets waiting to be transferred have been processed. This means the second Tx poll command can be silently ignored as the Tx poll bit could be still active while processing of previous Tx poll command is in progress. To address the issue re(4) used to invoke the Tx poll command in Tx completion handler whenever it detects there are pending packets in TxQ. However that still does not seem to completely eliminate watchdog timeouts seen on RealTek PCIe controllers. To fix the issue kick Tx poll command only after Tx completion interrupt is raised as this would indicate Tx is now idle state such that it can accept new Tx poll command again. While here apply this workaround for PCIe based controllers as other controllers does not seem to have this limitation. r186389: Since we don't request reset for rlphy(4), the link state 'UP' event from mii(4) may not be delivered if valid link was already established. To address the issue, check current link state after driving MII_TICK. This should fix a regression introduced in r185753 on fast ethernet controllers. r187417: Sometimes RTL8168B seems to take long time to access GMII registers in device attach phase. Double GMII register access timeout value to fix the issue. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/dev/re/if_re.c stable/7/sys/pci/if_rlreg.h Modified: stable/7/sys/dev/re/if_re.c ============================================================================== --- stable/7/sys/dev/re/if_re.c Mon Feb 9 01:30:14 2009 (r188358) +++ stable/7/sys/dev/re/if_re.c Mon Feb 9 01:38:01 2009 (r188359) @@ -418,14 +418,14 @@ re_gmii_readreg(device_t dev, int phy, i CSR_WRITE_4(sc, RL_PHYAR, reg << 16); - for (i = 0; i < RL_TIMEOUT; i++) { + for (i = 0; i < RL_PHY_TIMEOUT; i++) { rval = CSR_READ_4(sc, RL_PHYAR); if (rval & RL_PHYAR_BUSY) break; DELAY(100); } - if (i == RL_TIMEOUT) { + if (i == RL_PHY_TIMEOUT) { device_printf(sc->rl_dev, "PHY read failed\n"); return (0); } @@ -445,14 +445,14 @@ re_gmii_writereg(device_t dev, int phy, CSR_WRITE_4(sc, RL_PHYAR, (reg << 16) | (data & RL_PHYAR_PHYDATA) | RL_PHYAR_BUSY); - for (i = 0; i < RL_TIMEOUT; i++) { + for (i = 0; i < RL_PHY_TIMEOUT; i++) { rval = CSR_READ_4(sc, RL_PHYAR); if (!(rval & RL_PHYAR_BUSY)) break; DELAY(100); } - if (i == RL_TIMEOUT) { + if (i == RL_PHY_TIMEOUT) { device_printf(sc->rl_dev, "PHY write failed\n"); return (0); } @@ -1157,6 +1157,7 @@ re_attach(device_t dev) msic = 0; if (pci_find_extcap(dev, PCIY_EXPRESS, ®) == 0) { + sc->rl_flags |= RL_FLAG_PCIE; msic = pci_msi_count(dev); if (bootverbose) device_printf(dev, "MSI count : %d\n", msic); @@ -2042,16 +2043,6 @@ re_txeof(struct rl_softc *sc) /* No changes made to the TX ring, so no flush needed */ if (sc->rl_ldata.rl_tx_free != sc->rl_ldata.rl_tx_desc_cnt) { - /* - * Some chips will ignore a second TX request issued - * while an existing transmission is in progress. If - * the transmitter goes idle but there are still - * packets waiting to be sent, we need to restart the - * channel here to flush them out. This only seems to - * be required with the PCIe devices. - */ - CSR_WRITE_1(sc, sc->rl_txstart, RL_TXSTART_START); - #ifdef RE_TX_MODERATION /* * If not all descriptors have been reaped yet, reload @@ -2077,6 +2068,8 @@ re_tick(void *xsc) mii = device_get_softc(sc->rl_miibus); mii_tick(mii); + if ((sc->rl_flags & RL_FLAG_LINK) == 0) + re_miibus_statchg(sc->rl_dev); re_watchdog(sc); callout_reset(&sc->rl_stat_callout, hz, re_tick, sc); } @@ -2115,6 +2108,9 @@ re_poll_locked(struct ifnet *ifp, enum p return; if (status) CSR_WRITE_2(sc, RL_ISR, status); + if ((status & (RL_ISR_TX_OK | RL_ISR_TX_DESC_UNAVAIL)) && + (sc->rl_flags & RL_FLAG_PCIE)) + CSR_WRITE_1(sc, sc->rl_txstart, RL_TXSTART_START); /* * XXX check behaviour on receiver stalls. @@ -2176,6 +2172,17 @@ re_int_task(void *arg, int npending) if (status & (RL_ISR_RX_OK|RL_ISR_RX_ERR|RL_ISR_FIFO_OFLOW)) rval = re_rxeof(sc); + /* + * Some chips will ignore a second TX request issued + * while an existing transmission is in progress. If + * the transmitter goes idle but there are still + * packets waiting to be sent, we need to restart the + * channel here to flush them out. This only seems to + * be required with the PCIe devices. + */ + if ((status & (RL_ISR_TX_OK | RL_ISR_TX_DESC_UNAVAIL)) && + (sc->rl_flags & RL_FLAG_PCIE)) + CSR_WRITE_1(sc, sc->rl_txstart, RL_TXSTART_START); if (status & ( #ifdef RE_TX_MODERATION RL_ISR_TIMEOUT_EXPIRED| Modified: stable/7/sys/pci/if_rlreg.h ============================================================================== --- stable/7/sys/pci/if_rlreg.h Mon Feb 9 01:30:14 2009 (r188358) +++ stable/7/sys/pci/if_rlreg.h Mon Feb 9 01:38:01 2009 (r188359) @@ -864,6 +864,7 @@ struct rl_softc { #define RL_FLAG_PHY8110S 0x0800 #define RL_FLAG_WOLRXENB 0x1000 #define RL_FLAG_MACSLEEP 0x2000 +#define RL_FLAG_PCIE 0x4000 #define RL_FLAG_LINK 0x8000 }; @@ -909,6 +910,7 @@ struct rl_softc { CSR_WRITE_4(sc, offset, CSR_READ_4(sc, offset) & ~(val)) #define RL_TIMEOUT 1000 +#define RL_PHY_TIMEOUT 2000 /* * General constants that are fun to know. From owner-svn-src-stable@FreeBSD.ORG Mon Feb 9 01:55:30 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C0F7C106566C; Mon, 9 Feb 2009 01:55:30 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id AD15C8FC18; Mon, 9 Feb 2009 01:55:30 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n191tUax041236; Mon, 9 Feb 2009 01:55:30 GMT (envelope-from yongari@svn.freebsd.org) Received: (from yongari@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n191tUuU041233; Mon, 9 Feb 2009 01:55:30 GMT (envelope-from yongari@svn.freebsd.org) Message-Id: <200902090155.n191tUuU041233@svn.freebsd.org> From: Pyun YongHyeon Date: Mon, 9 Feb 2009 01:55:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r188360 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb dev/msk X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Feb 2009 01:55:31 -0000 Author: yongari Date: Mon Feb 9 01:55:30 2009 New Revision: 188360 URL: http://svn.freebsd.org/changeset/base/188360 Log: MFC r183346 Add another hardware bug workaround for Yukon II controllers that have hardware ram buffer. The silicon bug seem to be triggered by pause frames if receive buffer is not aligned on FIFO word(8 bytes). To workaround the issue, make sure to align Rx buffers on 8 bytes. Unfortunately this workaround requires yet another Rx fixup for strict alignment architecture machines to align IP header. For newer hardwares that lacks ram buffer may not have this bug so check number of available ram buffer size to see the existence of ram buffer. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/dev/msk/if_msk.c stable/7/sys/dev/msk/if_mskreg.h Modified: stable/7/sys/dev/msk/if_msk.c ============================================================================== --- stable/7/sys/dev/msk/if_msk.c Mon Feb 9 01:38:01 2009 (r188359) +++ stable/7/sys/dev/msk/if_msk.c Mon Feb 9 01:55:30 2009 (r188360) @@ -244,6 +244,9 @@ static __inline void msk_rxput(struct ms static int msk_handle_events(struct msk_softc *); static void msk_handle_hwerr(struct msk_if_softc *, uint32_t); static void msk_intr_hwerr(struct msk_softc *); +#ifndef __NO_STRICT_ALIGNMENT +static __inline void msk_fixup_rx(struct mbuf *); +#endif static void msk_rxeof(struct msk_if_softc *, uint32_t, int); static void msk_jumbo_rxeof(struct msk_if_softc *, uint32_t, int); static void msk_txeof(struct msk_if_softc *, int); @@ -783,7 +786,12 @@ msk_newbuf(struct msk_if_softc *sc_if, i return (ENOBUFS); m->m_len = m->m_pkthdr.len = MCLBYTES; - m_adj(m, ETHER_ALIGN); + if ((sc_if->msk_flags & MSK_FLAG_RAMBUF) == 0) + m_adj(m, ETHER_ALIGN); +#ifndef __NO_STRICT_ALIGNMENT + else + m_adj(m, MSK_RX_BUF_ALIGN); +#endif if (bus_dmamap_load_mbuf_sg(sc_if->msk_cdata.msk_rx_tag, sc_if->msk_cdata.msk_rx_sparemap, m, segs, &nsegs, @@ -840,7 +848,12 @@ msk_jumbo_newbuf(struct msk_if_softc *sc return (ENOBUFS); } m->m_pkthdr.len = m->m_len = MSK_JLEN; - m_adj(m, ETHER_ALIGN); + if ((sc_if->msk_flags & MSK_FLAG_RAMBUF) == 0) + m_adj(m, ETHER_ALIGN); +#ifndef __NO_STRICT_ALIGNMENT + else + m_adj(m, MSK_RX_BUF_ALIGN); +#endif if (bus_dmamap_load_mbuf_sg(sc_if->msk_cdata.msk_jumbo_rx_tag, sc_if->msk_cdata.msk_jumbo_rx_sparemap, m, segs, &nsegs, @@ -1041,14 +1054,16 @@ mskc_setup_rambuffer(struct msk_softc *s { int next; int i; - uint8_t val; /* Get adapter SRAM size. */ - val = CSR_READ_1(sc, B2_E_0); - sc->msk_ramsize = (val == 0) ? 128 : val * 4; + sc->msk_ramsize = CSR_READ_1(sc, B2_E_0) * 4; if (bootverbose) device_printf(sc->msk_dev, "RAM buffer size : %dKB\n", sc->msk_ramsize); + if (sc->msk_ramsize == 0) + return (0); + + sc->msk_pflags |= MSK_FLAG_RAMBUF; /* * Give receiver 2/3 of memory and round down to the multiple * of 1024. Tx/Rx RAM buffer size of Yukon II shoud be multiple @@ -1412,6 +1427,7 @@ msk_attach(device_t dev) sc_if->msk_if_dev = dev; sc_if->msk_port = port; sc_if->msk_softc = sc; + sc_if->msk_flags = sc->msk_pflags; sc->msk_if[port] = sc_if; /* Setup Tx/Rx queue register offsets. */ if (port == MSK_PORT_A) { @@ -1976,6 +1992,7 @@ msk_txrx_dma_alloc(struct msk_if_softc * struct msk_rxdesc *jrxd; struct msk_jpool_entry *entry; uint8_t *ptr; + bus_size_t rxalign; int error, i; mtx_init(&sc_if->msk_jlist_mtx, "msk_jlist_mtx", NULL, MTX_DEF); @@ -2107,9 +2124,16 @@ msk_txrx_dma_alloc(struct msk_if_softc * goto fail; } + rxalign = 1; + /* + * Workaround hardware hang which seems to happen when Rx buffer + * is not aligned on multiple of FIFO word(8 bytes). + */ + if ((sc_if->msk_flags & MSK_FLAG_RAMBUF) != 0) + rxalign = MSK_RX_BUF_ALIGN; /* Create tag for Rx buffers. */ error = bus_dma_tag_create(sc_if->msk_cdata.msk_parent_tag,/* parent */ - 1, 0, /* alignment, boundary */ + rxalign, 0, /* alignment, boundary */ BUS_SPACE_MAXADDR, /* lowaddr */ BUS_SPACE_MAXADDR, /* highaddr */ NULL, NULL, /* filter, filterarg */ @@ -2918,6 +2942,23 @@ mskc_resume(device_t dev) return (0); } +#ifndef __NO_STRICT_ALIGNMENT +static __inline void +msk_fixup_rx(struct mbuf *m) +{ + int i; + uint16_t *src, *dst; + + src = mtod(m, uint16_t *); + dst = src - 3; + + for (i = 0; i < (m->m_len / sizeof(uint16_t) + 1); i++) + *dst++ = *src++; + + m->m_data -= (MSK_RX_BUF_ALIGN - ETHER_ALIGN); +} +#endif + static void msk_rxeof(struct msk_if_softc *sc_if, uint32_t status, int len) { @@ -2955,6 +2996,10 @@ msk_rxeof(struct msk_if_softc *sc_if, ui } m->m_pkthdr.rcvif = ifp; m->m_pkthdr.len = m->m_len = len; +#ifndef __NO_STRICT_ALIGNMENT + if ((sc_if->msk_flags & MSK_FLAG_RAMBUF) != 0) + msk_fixup_rx(m); +#endif ifp->if_ipackets++; /* Check for VLAN tagged packets. */ if ((status & GMR_FS_VLAN) != 0 && @@ -3008,6 +3053,10 @@ msk_jumbo_rxeof(struct msk_if_softc *sc_ } m->m_pkthdr.rcvif = ifp; m->m_pkthdr.len = m->m_len = len; +#ifndef __NO_STRICT_ALIGNMENT + if ((sc_if->msk_flags & MSK_FLAG_RAMBUF) != 0) + msk_fixup_rx(m); +#endif ifp->if_ipackets++; /* Check for VLAN tagged packets. */ if ((status & GMR_FS_VLAN) != 0 && @@ -3677,7 +3726,7 @@ msk_init_locked(struct msk_if_softc *sc_ /* Configure hardware VLAN tag insertion/stripping. */ msk_setvlan(sc_if, ifp); - if (sc->msk_hw_id == CHIP_ID_YUKON_EC_U) { + if ((sc_if->msk_flags & MSK_FLAG_RAMBUF) == 0) { /* Set Rx Pause threshould. */ CSR_WRITE_1(sc, MR_ADDR(sc_if->msk_port, RX_GMF_LP_THR), MSK_ECU_LLPP); @@ -3790,6 +3839,8 @@ msk_set_rambuffer(struct msk_if_softc *s int ltpp, utpp; sc = sc_if->msk_softc; + if ((sc_if->msk_flags & MSK_FLAG_RAMBUF) == 0) + return; /* Setup Rx Queue. */ CSR_WRITE_1(sc, RB_ADDR(sc_if->msk_rxq, RB_CTRL), RB_RST_CLR); Modified: stable/7/sys/dev/msk/if_mskreg.h ============================================================================== --- stable/7/sys/dev/msk/if_mskreg.h Mon Feb 9 01:38:01 2009 (r188359) +++ stable/7/sys/dev/msk/if_mskreg.h Mon Feb 9 01:55:30 2009 (r188360) @@ -2158,6 +2158,7 @@ struct msk_stat_desc { #define MSK_TX_RING_CNT 256 #define MSK_RX_RING_CNT 256 +#define MSK_RX_BUF_ALIGN 8 #define MSK_JUMBO_RX_RING_CNT MSK_RX_RING_CNT #define MSK_STAT_RING_CNT ((1 + 3) * (MSK_TX_RING_CNT + MSK_RX_RING_CNT)) #define MSK_MAXTXSEGS 32 @@ -2307,6 +2308,7 @@ struct msk_softc { uint32_t msk_coppertype; uint32_t msk_intrmask; uint32_t msk_intrhwemask; + uint32_t msk_pflags; int msk_suspended; int msk_clock; int msk_msi; @@ -2348,6 +2350,8 @@ struct msk_if_softc { int msk_phytype; int msk_phyaddr; int msk_link; + uint32_t msk_flags; +#define MSK_FLAG_RAMBUF 0x0010 struct callout msk_tick_ch; int msk_watchdog_timer; uint32_t msk_txq; /* Tx. Async Queue offset */ From owner-svn-src-stable@FreeBSD.ORG Mon Feb 9 02:00:43 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E6E7D106566C; Mon, 9 Feb 2009 02:00:43 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id D3D618FC27; Mon, 9 Feb 2009 02:00:43 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n1920hCd041405; Mon, 9 Feb 2009 02:00:43 GMT (envelope-from yongari@svn.freebsd.org) Received: (from yongari@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n1920h4o041404; Mon, 9 Feb 2009 02:00:43 GMT (envelope-from yongari@svn.freebsd.org) Message-Id: <200902090200.n1920h4o041404@svn.freebsd.org> From: Pyun YongHyeon Date: Mon, 9 Feb 2009 02:00:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r188361 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb dev/msk X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Feb 2009 02:00:44 -0000 Author: yongari Date: Mon Feb 9 02:00:43 2009 New Revision: 188361 URL: http://svn.freebsd.org/changeset/base/188361 Log: MFC r183485-183486 r183485: Always pullup mbuf prior to accessing TCP header. This should fix occasional Tx checksum corruption issue. r183486: If mbuf is not writable get a writable copy before invoking m_pullup(9). Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/dev/msk/if_msk.c Modified: stable/7/sys/dev/msk/if_msk.c ============================================================================== --- stable/7/sys/dev/msk/if_msk.c Mon Feb 9 01:55:30 2009 (r188360) +++ stable/7/sys/dev/msk/if_msk.c Mon Feb 9 02:00:43 2009 (r188361) @@ -2559,7 +2559,16 @@ msk_encap(struct msk_if_softc *sc_if, st struct ip *ip; struct tcphdr *tcp; - /* TODO check for M_WRITABLE(m) */ + if (M_WRITABLE(m) == 0) { + /* Get a writable copy. */ + m = m_dup(*m_head, M_DONTWAIT); + m_freem(*m_head); + if (m == NULL) { + *m_head = NULL; + return (ENOBUFS); + } + *m_head = m; + } offset = sizeof(struct ether_header); m = m_pullup(m, offset); @@ -2601,6 +2610,11 @@ msk_encap(struct msk_if_softc *sc_if, st (m->m_pkthdr.csum_flags & CSUM_TCP) != 0) { uint16_t csum; + m = m_pullup(m, offset + sizeof(struct tcphdr)); + if (m == NULL) { + *m_head = NULL; + return (ENOBUFS); + } csum = in_cksum_skip(m, ntohs(ip->ip_len) + offset - (ip->ip_hl << 2), offset); *(uint16_t *)(m->m_data + offset + From owner-svn-src-stable@FreeBSD.ORG Mon Feb 9 02:03:49 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id CBF5B1065675; Mon, 9 Feb 2009 02:03:49 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id B74568FC1B; Mon, 9 Feb 2009 02:03:49 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n1923nsf041509; Mon, 9 Feb 2009 02:03:49 GMT (envelope-from yongari@svn.freebsd.org) Received: (from yongari@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n1923nXe041508; Mon, 9 Feb 2009 02:03:49 GMT (envelope-from yongari@svn.freebsd.org) Message-Id: <200902090203.n1923nXe041508@svn.freebsd.org> From: Pyun YongHyeon Date: Mon, 9 Feb 2009 02:03:49 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r188362 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb dev/msk X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Feb 2009 02:03:51 -0000 Author: yongari Date: Mon Feb 9 02:03:49 2009 New Revision: 188362 URL: http://svn.freebsd.org/changeset/base/188362 Log: MFC r185244 Save the value read from TX queue CSR, so we don't test against a stale one. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/dev/msk/if_msk.c Modified: stable/7/sys/dev/msk/if_msk.c ============================================================================== --- stable/7/sys/dev/msk/if_msk.c Mon Feb 9 02:00:43 2009 (r188361) +++ stable/7/sys/dev/msk/if_msk.c Mon Feb 9 02:03:49 2009 (r188362) @@ -3966,7 +3966,7 @@ msk_stop(struct msk_if_softc *sc_if) if ((val & (BMU_STOP | BMU_IDLE)) == 0) { CSR_WRITE_4(sc, Q_ADDR(sc_if->msk_txq, Q_CSR), BMU_STOP); - CSR_READ_4(sc, Q_ADDR(sc_if->msk_txq, Q_CSR)); + val = CSR_READ_4(sc, Q_ADDR(sc_if->msk_txq, Q_CSR)); } else break; DELAY(1); From owner-svn-src-stable@FreeBSD.ORG Mon Feb 9 02:06:15 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 94A9C1065672; Mon, 9 Feb 2009 02:06:15 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 814818FC18; Mon, 9 Feb 2009 02:06:15 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n1926Foh041602; Mon, 9 Feb 2009 02:06:15 GMT (envelope-from yongari@svn.freebsd.org) Received: (from yongari@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n1926Fgg041601; Mon, 9 Feb 2009 02:06:15 GMT (envelope-from yongari@svn.freebsd.org) Message-Id: <200902090206.n1926Fgg041601@svn.freebsd.org> From: Pyun YongHyeon Date: Mon, 9 Feb 2009 02:06:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r188363 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb dev/msk X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Feb 2009 02:06:16 -0000 Author: yongari Date: Mon Feb 9 02:06:15 2009 New Revision: 188363 URL: http://svn.freebsd.org/changeset/base/188363 Log: MFC r187207: Correct frame length argument of in_cksum_skip. While I'm here remove intermediate variable csum. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/dev/msk/if_msk.c Modified: stable/7/sys/dev/msk/if_msk.c ============================================================================== --- stable/7/sys/dev/msk/if_msk.c Mon Feb 9 02:03:49 2009 (r188362) +++ stable/7/sys/dev/msk/if_msk.c Mon Feb 9 02:06:15 2009 (r188363) @@ -2608,17 +2608,14 @@ msk_encap(struct msk_if_softc *sc_if, st */ if (m->m_pkthdr.len < MSK_MIN_FRAMELEN && (m->m_pkthdr.csum_flags & CSUM_TCP) != 0) { - uint16_t csum; - m = m_pullup(m, offset + sizeof(struct tcphdr)); if (m == NULL) { *m_head = NULL; return (ENOBUFS); } - csum = in_cksum_skip(m, ntohs(ip->ip_len) + offset - - (ip->ip_hl << 2), offset); *(uint16_t *)(m->m_data + offset + - m->m_pkthdr.csum_data) = csum; + m->m_pkthdr.csum_data) = in_cksum_skip(m, + m->m_pkthdr.len, offset); m->m_pkthdr.csum_flags &= ~CSUM_TCP; } if ((m->m_pkthdr.csum_flags & CSUM_TSO) != 0) { From owner-svn-src-stable@FreeBSD.ORG Mon Feb 9 02:15:25 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9D296106566B; Mon, 9 Feb 2009 02:15:25 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 88D388FC12; Mon, 9 Feb 2009 02:15:25 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n192FPuQ041830; Mon, 9 Feb 2009 02:15:25 GMT (envelope-from yongari@svn.freebsd.org) Received: (from yongari@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n192FPXr041828; Mon, 9 Feb 2009 02:15:25 GMT (envelope-from yongari@svn.freebsd.org) Message-Id: <200902090215.n192FPXr041828@svn.freebsd.org> From: Pyun YongHyeon Date: Mon, 9 Feb 2009 02:15:25 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r188364 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb dev/msk X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Feb 2009 02:15:26 -0000 Author: yongari Date: Mon Feb 9 02:15:25 2009 New Revision: 188364 URL: http://svn.freebsd.org/changeset/base/188364 Log: MFC r187208: Remove local jumbo locator and switch to UMA backed page allocator for jumbo frame. o Nuke unneeded jlist lock which was used to protect jumbo buffer management in local allocator. o Added a new tunable hw.mskc.jumbo_disable to disable jumbo frame support for the driver. The tunable could be set for systems that do not need to use jumbo frames and it would save (9K * number of Rx descriptors) bytes kernel memory. o Jumbo buffer allocation failure is no longer critical error for the operation of msk(4). If msk(4) encounter the allocation failure it just disables jumbo frame support and continues to work without your intervention. Using local allocator had several drawbacks such as requirement of large amount of continuous kernel memory and fixed (small) number of available buffers. The need for large continuous memory resulted in failure of loading driver with kldload on running systems. Also small number of buffer used in local allocator showed poor performance for some applications. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/dev/msk/if_msk.c stable/7/sys/dev/msk/if_mskreg.h Modified: stable/7/sys/dev/msk/if_msk.c ============================================================================== --- stable/7/sys/dev/msk/if_msk.c Mon Feb 9 02:06:15 2009 (r188363) +++ stable/7/sys/dev/msk/if_msk.c Mon Feb 9 02:15:25 2009 (r188364) @@ -156,6 +156,8 @@ static int msi_disable = 0; TUNABLE_INT("hw.msk.msi_disable", &msi_disable); static int legacy_intr = 0; TUNABLE_INT("hw.msk.legacy_intr", &legacy_intr); +static int jumbo_disable = 0; +TUNABLE_INT("hw.msk.jumbo_disable", &jumbo_disable); #define MSK_CSUM_FEATURES (CSUM_TCP | CSUM_UDP) @@ -267,9 +269,9 @@ static void msk_dmamap_cb(void *, bus_dm static int msk_status_dma_alloc(struct msk_softc *); static void msk_status_dma_free(struct msk_softc *); static int msk_txrx_dma_alloc(struct msk_if_softc *); +static int msk_rx_dma_jalloc(struct msk_if_softc *); static void msk_txrx_dma_free(struct msk_if_softc *); -static void *msk_jalloc(struct msk_if_softc *); -static void msk_jfree(void *, void *); +static void msk_rx_dma_jfree(struct msk_if_softc *); static int msk_init_rx_ring(struct msk_if_softc *); static int msk_init_jumbo_rx_ring(struct msk_if_softc *); static void msk_init_tx_ring(struct msk_if_softc *); @@ -830,24 +832,15 @@ msk_jumbo_newbuf(struct msk_if_softc *sc bus_dma_segment_t segs[1]; bus_dmamap_t map; int nsegs; - void *buf; - MGETHDR(m, M_DONTWAIT, MT_DATA); + m = m_getjcl(M_DONTWAIT, MT_DATA, M_PKTHDR, MJUM9BYTES); if (m == NULL) return (ENOBUFS); - buf = msk_jalloc(sc_if); - if (buf == NULL) { - m_freem(m); - return (ENOBUFS); - } - /* Attach the buffer to the mbuf. */ - MEXTADD(m, buf, MSK_JLEN, msk_jfree, (struct msk_if_softc *)sc_if, 0, - EXT_NET_DRV); if ((m->m_flags & M_EXT) == 0) { m_freem(m); return (ENOBUFS); } - m->m_pkthdr.len = m->m_len = MSK_JLEN; + m->m_len = m->m_pkthdr.len = MJUM9BYTES; if ((sc_if->msk_flags & MSK_FLAG_RAMBUF) == 0) m_adj(m, ETHER_ALIGN); #ifndef __NO_STRICT_ALIGNMENT @@ -936,20 +929,20 @@ msk_ioctl(struct ifnet *ifp, u_long comm switch(command) { case SIOCSIFMTU: - if (ifr->ifr_mtu > MSK_JUMBO_MTU || ifr->ifr_mtu < ETHERMIN) { - error = EINVAL; - break; - } - if (sc_if->msk_softc->msk_hw_id == CHIP_ID_YUKON_FE && - ifr->ifr_mtu > MSK_MAX_FRAMELEN) { + if (ifr->ifr_mtu > MSK_JUMBO_MTU || ifr->ifr_mtu < ETHERMIN) error = EINVAL; - break; + else if (ifp->if_mtu != ifr->ifr_mtu) { + if ((sc_if->msk_flags & MSK_FLAG_NOJUMBO) != 0 && + ifr->ifr_mtu > ETHERMTU) + error = EINVAL; + else { + MSK_IF_LOCK(sc_if); + ifp->if_mtu = ifr->ifr_mtu; + if ((ifp->if_drv_flags & IFF_DRV_RUNNING) != 0) + msk_init_locked(sc_if); + MSK_IF_UNLOCK(sc_if); + } } - MSK_IF_LOCK(sc_if); - ifp->if_mtu = ifr->ifr_mtu; - if ((ifp->if_drv_flags & IFF_DRV_RUNNING) != 0) - msk_init_locked(sc_if); - MSK_IF_UNLOCK(sc_if); break; case SIOCSIFFLAGS: MSK_IF_LOCK(sc_if); @@ -1007,7 +1000,7 @@ msk_ioctl(struct ifnet *ifp, u_long comm else ifp->if_hwassist &= ~CSUM_TSO; } - if (sc_if->msk_framesize > MSK_MAX_FRAMELEN && + if (ifp->if_mtu > ETHERMTU && sc_if->msk_softc->msk_hw_id == CHIP_ID_YUKON_EC_U) { /* * In Yukon EC Ultra, TSO & checksum offload is not @@ -1443,8 +1436,13 @@ msk_attach(device_t dev) callout_init_mtx(&sc_if->msk_tick_ch, &sc_if->msk_softc->msk_mtx, 0); TASK_INIT(&sc_if->msk_link_task, 0, msk_link_task, sc_if); + /* Disable jumbo frame for Yukon FE. */ + if (sc_if->msk_softc->msk_hw_id == CHIP_ID_YUKON_FE) + sc_if->msk_flags |= MSK_FLAG_NOJUMBO; + if ((error = msk_txrx_dma_alloc(sc_if) != 0)) goto fail; + msk_rx_dma_jalloc(sc_if); ifp = sc_if->msk_ifp = if_alloc(IFT_ETHER); if (ifp == NULL) { @@ -1519,9 +1517,6 @@ msk_attach(device_t dev) */ ifp->if_data.ifi_hdrlen = sizeof(struct ether_vlan_header); - sc_if->msk_framesize = ifp->if_mtu + ETHER_HDR_LEN + - ETHER_VLAN_ENCAP_LEN; - /* * Do miibus setup. */ @@ -1829,6 +1824,7 @@ msk_detach(device_t dev) * } */ + msk_rx_dma_jfree(sc_if); msk_txrx_dma_free(sc_if); bus_generic_detach(dev); @@ -1989,16 +1985,9 @@ msk_txrx_dma_alloc(struct msk_if_softc * struct msk_dmamap_arg ctx; struct msk_txdesc *txd; struct msk_rxdesc *rxd; - struct msk_rxdesc *jrxd; - struct msk_jpool_entry *entry; - uint8_t *ptr; bus_size_t rxalign; int error, i; - mtx_init(&sc_if->msk_jlist_mtx, "msk_jlist_mtx", NULL, MTX_DEF); - SLIST_INIT(&sc_if->msk_jfree_listhead); - SLIST_INIT(&sc_if->msk_jinuse_listhead); - /* Create parent DMA tag. */ /* * XXX @@ -2070,42 +2059,6 @@ msk_txrx_dma_alloc(struct msk_if_softc * goto fail; } - /* Create tag for jumbo Rx ring. */ - error = bus_dma_tag_create(sc_if->msk_cdata.msk_parent_tag,/* parent */ - MSK_RING_ALIGN, 0, /* alignment, boundary */ - BUS_SPACE_MAXADDR, /* lowaddr */ - BUS_SPACE_MAXADDR, /* highaddr */ - NULL, NULL, /* filter, filterarg */ - MSK_JUMBO_RX_RING_SZ, /* maxsize */ - 1, /* nsegments */ - MSK_JUMBO_RX_RING_SZ, /* maxsegsize */ - 0, /* flags */ - NULL, NULL, /* lockfunc, lockarg */ - &sc_if->msk_cdata.msk_jumbo_rx_ring_tag); - if (error != 0) { - device_printf(sc_if->msk_if_dev, - "failed to create jumbo Rx ring DMA tag\n"); - goto fail; - } - - /* Create tag for jumbo buffer blocks. */ - error = bus_dma_tag_create(sc_if->msk_cdata.msk_parent_tag,/* parent */ - PAGE_SIZE, 0, /* alignment, boundary */ - BUS_SPACE_MAXADDR, /* lowaddr */ - BUS_SPACE_MAXADDR, /* highaddr */ - NULL, NULL, /* filter, filterarg */ - MSK_JMEM, /* maxsize */ - 1, /* nsegments */ - MSK_JMEM, /* maxsegsize */ - 0, /* flags */ - NULL, NULL, /* lockfunc, lockarg */ - &sc_if->msk_cdata.msk_jumbo_tag); - if (error != 0) { - device_printf(sc_if->msk_if_dev, - "failed to create jumbo Rx buffer block DMA tag\n"); - goto fail; - } - /* Create tag for Tx buffers. */ error = bus_dma_tag_create(sc_if->msk_cdata.msk_parent_tag,/* parent */ 1, 0, /* alignment, boundary */ @@ -2149,24 +2102,6 @@ msk_txrx_dma_alloc(struct msk_if_softc * goto fail; } - /* Create tag for jumbo Rx buffers. */ - error = bus_dma_tag_create(sc_if->msk_cdata.msk_parent_tag,/* parent */ - PAGE_SIZE, 0, /* alignment, boundary */ - BUS_SPACE_MAXADDR, /* lowaddr */ - BUS_SPACE_MAXADDR, /* highaddr */ - NULL, NULL, /* filter, filterarg */ - MCLBYTES * MSK_MAXRXSEGS, /* maxsize */ - MSK_MAXRXSEGS, /* nsegments */ - MSK_JLEN, /* maxsegsize */ - 0, /* flags */ - NULL, NULL, /* lockfunc, lockarg */ - &sc_if->msk_cdata.msk_jumbo_rx_tag); - if (error != 0) { - device_printf(sc_if->msk_if_dev, - "failed to create jumbo Rx DMA tag\n"); - goto fail; - } - /* Allocate DMA'able memory and load the DMA map for Tx ring. */ error = bus_dmamem_alloc(sc_if->msk_cdata.msk_tx_ring_tag, (void **)&sc_if->msk_rdata.msk_tx_ring, BUS_DMA_WAITOK | @@ -2209,29 +2144,6 @@ msk_txrx_dma_alloc(struct msk_if_softc * } sc_if->msk_rdata.msk_rx_ring_paddr = ctx.msk_busaddr; - /* Allocate DMA'able memory and load the DMA map for jumbo Rx ring. */ - error = bus_dmamem_alloc(sc_if->msk_cdata.msk_jumbo_rx_ring_tag, - (void **)&sc_if->msk_rdata.msk_jumbo_rx_ring, - BUS_DMA_WAITOK | BUS_DMA_COHERENT | BUS_DMA_ZERO, - &sc_if->msk_cdata.msk_jumbo_rx_ring_map); - if (error != 0) { - device_printf(sc_if->msk_if_dev, - "failed to allocate DMA'able memory for jumbo Rx ring\n"); - goto fail; - } - - ctx.msk_busaddr = 0; - error = bus_dmamap_load(sc_if->msk_cdata.msk_jumbo_rx_ring_tag, - sc_if->msk_cdata.msk_jumbo_rx_ring_map, - sc_if->msk_rdata.msk_jumbo_rx_ring, MSK_JUMBO_RX_RING_SZ, - msk_dmamap_cb, &ctx, 0); - if (error != 0) { - device_printf(sc_if->msk_if_dev, - "failed to load DMA'able memory for jumbo Rx ring\n"); - goto fail; - } - sc_if->msk_rdata.msk_jumbo_rx_ring_paddr = ctx.msk_busaddr; - /* Create DMA maps for Tx buffers. */ for (i = 0; i < MSK_TX_RING_CNT; i++) { txd = &sc_if->msk_cdata.msk_txdesc[i]; @@ -2264,12 +2176,98 @@ msk_txrx_dma_alloc(struct msk_if_softc * goto fail; } } + +fail: + return (error); +} + +static int +msk_rx_dma_jalloc(struct msk_if_softc *sc_if) +{ + struct msk_dmamap_arg ctx; + struct msk_rxdesc *jrxd; + bus_size_t rxalign; + int error, i; + + if (jumbo_disable != 0 || (sc_if->msk_flags & MSK_FLAG_NOJUMBO) != 0) { + sc_if->msk_flags |= MSK_FLAG_NOJUMBO; + device_printf(sc_if->msk_if_dev, + "disabling jumbo frame support\n"); + sc_if->msk_flags |= MSK_FLAG_NOJUMBO; + return (0); + } + /* Create tag for jumbo Rx ring. */ + error = bus_dma_tag_create(sc_if->msk_cdata.msk_parent_tag,/* parent */ + MSK_RING_ALIGN, 0, /* alignment, boundary */ + BUS_SPACE_MAXADDR, /* lowaddr */ + BUS_SPACE_MAXADDR, /* highaddr */ + NULL, NULL, /* filter, filterarg */ + MSK_JUMBO_RX_RING_SZ, /* maxsize */ + 1, /* nsegments */ + MSK_JUMBO_RX_RING_SZ, /* maxsegsize */ + 0, /* flags */ + NULL, NULL, /* lockfunc, lockarg */ + &sc_if->msk_cdata.msk_jumbo_rx_ring_tag); + if (error != 0) { + device_printf(sc_if->msk_if_dev, + "failed to create jumbo Rx ring DMA tag\n"); + goto jumbo_fail; + } + + rxalign = 1; + /* + * Workaround hardware hang which seems to happen when Rx buffer + * is not aligned on multiple of FIFO word(8 bytes). + */ + if ((sc_if->msk_flags & MSK_FLAG_RAMBUF) != 0) + rxalign = MSK_RX_BUF_ALIGN; + /* Create tag for jumbo Rx buffers. */ + error = bus_dma_tag_create(sc_if->msk_cdata.msk_parent_tag,/* parent */ + rxalign, 0, /* alignment, boundary */ + BUS_SPACE_MAXADDR, /* lowaddr */ + BUS_SPACE_MAXADDR, /* highaddr */ + NULL, NULL, /* filter, filterarg */ + MJUM9BYTES, /* maxsize */ + 1, /* nsegments */ + MJUM9BYTES, /* maxsegsize */ + 0, /* flags */ + NULL, NULL, /* lockfunc, lockarg */ + &sc_if->msk_cdata.msk_jumbo_rx_tag); + if (error != 0) { + device_printf(sc_if->msk_if_dev, + "failed to create jumbo Rx DMA tag\n"); + goto jumbo_fail; + } + + /* Allocate DMA'able memory and load the DMA map for jumbo Rx ring. */ + error = bus_dmamem_alloc(sc_if->msk_cdata.msk_jumbo_rx_ring_tag, + (void **)&sc_if->msk_rdata.msk_jumbo_rx_ring, + BUS_DMA_WAITOK | BUS_DMA_COHERENT | BUS_DMA_ZERO, + &sc_if->msk_cdata.msk_jumbo_rx_ring_map); + if (error != 0) { + device_printf(sc_if->msk_if_dev, + "failed to allocate DMA'able memory for jumbo Rx ring\n"); + goto jumbo_fail; + } + + ctx.msk_busaddr = 0; + error = bus_dmamap_load(sc_if->msk_cdata.msk_jumbo_rx_ring_tag, + sc_if->msk_cdata.msk_jumbo_rx_ring_map, + sc_if->msk_rdata.msk_jumbo_rx_ring, MSK_JUMBO_RX_RING_SZ, + msk_dmamap_cb, &ctx, 0); + if (error != 0) { + device_printf(sc_if->msk_if_dev, + "failed to load DMA'able memory for jumbo Rx ring\n"); + goto jumbo_fail; + } + sc_if->msk_rdata.msk_jumbo_rx_ring_paddr = ctx.msk_busaddr; + /* Create DMA maps for jumbo Rx buffers. */ if ((error = bus_dmamap_create(sc_if->msk_cdata.msk_jumbo_rx_tag, 0, &sc_if->msk_cdata.msk_jumbo_rx_sparemap)) != 0) { device_printf(sc_if->msk_if_dev, "failed to create spare jumbo Rx dmamap\n"); - goto fail; + goto jumbo_fail; } for (i = 0; i < MSK_JUMBO_RX_RING_CNT; i++) { jrxd = &sc_if->msk_cdata.msk_jumbo_rxdesc[i]; @@ -2280,54 +2278,17 @@ msk_txrx_dma_alloc(struct msk_if_softc * if (error != 0) { device_printf(sc_if->msk_if_dev, "failed to create jumbo Rx dmamap\n"); - goto fail; + goto jumbo_fail; } } - /* Allocate DMA'able memory and load the DMA map for jumbo buf. */ - error = bus_dmamem_alloc(sc_if->msk_cdata.msk_jumbo_tag, - (void **)&sc_if->msk_rdata.msk_jumbo_buf, - BUS_DMA_WAITOK | BUS_DMA_COHERENT | BUS_DMA_ZERO, - &sc_if->msk_cdata.msk_jumbo_map); - if (error != 0) { - device_printf(sc_if->msk_if_dev, - "failed to allocate DMA'able memory for jumbo buf\n"); - goto fail; - } - - ctx.msk_busaddr = 0; - error = bus_dmamap_load(sc_if->msk_cdata.msk_jumbo_tag, - sc_if->msk_cdata.msk_jumbo_map, sc_if->msk_rdata.msk_jumbo_buf, - MSK_JMEM, msk_dmamap_cb, &ctx, 0); - if (error != 0) { - device_printf(sc_if->msk_if_dev, - "failed to load DMA'able memory for jumbobuf\n"); - goto fail; - } - sc_if->msk_rdata.msk_jumbo_buf_paddr = ctx.msk_busaddr; - - /* - * Now divide it up into 9K pieces and save the addresses - * in an array. - */ - ptr = sc_if->msk_rdata.msk_jumbo_buf; - for (i = 0; i < MSK_JSLOTS; i++) { - sc_if->msk_cdata.msk_jslots[i] = ptr; - ptr += MSK_JLEN; - entry = malloc(sizeof(struct msk_jpool_entry), - M_DEVBUF, M_WAITOK); - if (entry == NULL) { - device_printf(sc_if->msk_if_dev, - "no memory for jumbo buffers!\n"); - error = ENOMEM; - goto fail; - } - entry->slot = i; - SLIST_INSERT_HEAD(&sc_if->msk_jfree_listhead, entry, - jpool_entries); - } + return (0); -fail: +jumbo_fail: + msk_rx_dma_jfree(sc_if); + device_printf(sc_if->msk_if_dev, "disabling jumbo frame support " + "due to resource shortage\n"); + sc_if->msk_flags |= MSK_FLAG_NOJUMBO; return (error); } @@ -2336,39 +2297,8 @@ msk_txrx_dma_free(struct msk_if_softc *s { struct msk_txdesc *txd; struct msk_rxdesc *rxd; - struct msk_rxdesc *jrxd; - struct msk_jpool_entry *entry; int i; - MSK_JLIST_LOCK(sc_if); - while ((entry = SLIST_FIRST(&sc_if->msk_jinuse_listhead))) { - device_printf(sc_if->msk_if_dev, - "asked to free buffer that is in use!\n"); - SLIST_REMOVE_HEAD(&sc_if->msk_jinuse_listhead, jpool_entries); - SLIST_INSERT_HEAD(&sc_if->msk_jfree_listhead, entry, - jpool_entries); - } - - while (!SLIST_EMPTY(&sc_if->msk_jfree_listhead)) { - entry = SLIST_FIRST(&sc_if->msk_jfree_listhead); - SLIST_REMOVE_HEAD(&sc_if->msk_jfree_listhead, jpool_entries); - free(entry, M_DEVBUF); - } - MSK_JLIST_UNLOCK(sc_if); - - /* Destroy jumbo buffer block. */ - if (sc_if->msk_cdata.msk_jumbo_map) - bus_dmamap_unload(sc_if->msk_cdata.msk_jumbo_tag, - sc_if->msk_cdata.msk_jumbo_map); - - if (sc_if->msk_rdata.msk_jumbo_buf) { - bus_dmamem_free(sc_if->msk_cdata.msk_jumbo_tag, - sc_if->msk_rdata.msk_jumbo_buf, - sc_if->msk_cdata.msk_jumbo_map); - sc_if->msk_rdata.msk_jumbo_buf = NULL; - sc_if->msk_cdata.msk_jumbo_map = NULL; - } - /* Tx ring. */ if (sc_if->msk_cdata.msk_tx_ring_tag) { if (sc_if->msk_cdata.msk_tx_ring_map) @@ -2399,21 +2329,6 @@ msk_txrx_dma_free(struct msk_if_softc *s bus_dma_tag_destroy(sc_if->msk_cdata.msk_rx_ring_tag); sc_if->msk_cdata.msk_rx_ring_tag = NULL; } - /* Jumbo Rx ring. */ - if (sc_if->msk_cdata.msk_jumbo_rx_ring_tag) { - if (sc_if->msk_cdata.msk_jumbo_rx_ring_map) - bus_dmamap_unload(sc_if->msk_cdata.msk_jumbo_rx_ring_tag, - sc_if->msk_cdata.msk_jumbo_rx_ring_map); - if (sc_if->msk_cdata.msk_jumbo_rx_ring_map && - sc_if->msk_rdata.msk_jumbo_rx_ring) - bus_dmamem_free(sc_if->msk_cdata.msk_jumbo_rx_ring_tag, - sc_if->msk_rdata.msk_jumbo_rx_ring, - sc_if->msk_cdata.msk_jumbo_rx_ring_map); - sc_if->msk_rdata.msk_jumbo_rx_ring = NULL; - sc_if->msk_cdata.msk_jumbo_rx_ring_map = NULL; - bus_dma_tag_destroy(sc_if->msk_cdata.msk_jumbo_rx_ring_tag); - sc_if->msk_cdata.msk_jumbo_rx_ring_tag = NULL; - } /* Tx buffers. */ if (sc_if->msk_cdata.msk_tx_tag) { for (i = 0; i < MSK_TX_RING_CNT; i++) { @@ -2445,6 +2360,33 @@ msk_txrx_dma_free(struct msk_if_softc *s bus_dma_tag_destroy(sc_if->msk_cdata.msk_rx_tag); sc_if->msk_cdata.msk_rx_tag = NULL; } + if (sc_if->msk_cdata.msk_parent_tag) { + bus_dma_tag_destroy(sc_if->msk_cdata.msk_parent_tag); + sc_if->msk_cdata.msk_parent_tag = NULL; + } +} + +static void +msk_rx_dma_jfree(struct msk_if_softc *sc_if) +{ + struct msk_rxdesc *jrxd; + int i; + + /* Jumbo Rx ring. */ + if (sc_if->msk_cdata.msk_jumbo_rx_ring_tag) { + if (sc_if->msk_cdata.msk_jumbo_rx_ring_map) + bus_dmamap_unload(sc_if->msk_cdata.msk_jumbo_rx_ring_tag, + sc_if->msk_cdata.msk_jumbo_rx_ring_map); + if (sc_if->msk_cdata.msk_jumbo_rx_ring_map && + sc_if->msk_rdata.msk_jumbo_rx_ring) + bus_dmamem_free(sc_if->msk_cdata.msk_jumbo_rx_ring_tag, + sc_if->msk_rdata.msk_jumbo_rx_ring, + sc_if->msk_cdata.msk_jumbo_rx_ring_map); + sc_if->msk_rdata.msk_jumbo_rx_ring = NULL; + sc_if->msk_cdata.msk_jumbo_rx_ring_map = NULL; + bus_dma_tag_destroy(sc_if->msk_cdata.msk_jumbo_rx_ring_tag); + sc_if->msk_cdata.msk_jumbo_rx_ring_tag = NULL; + } /* Jumbo Rx buffers. */ if (sc_if->msk_cdata.msk_jumbo_rx_tag) { for (i = 0; i < MSK_JUMBO_RX_RING_CNT; i++) { @@ -2464,69 +2406,6 @@ msk_txrx_dma_free(struct msk_if_softc *s bus_dma_tag_destroy(sc_if->msk_cdata.msk_jumbo_rx_tag); sc_if->msk_cdata.msk_jumbo_rx_tag = NULL; } - - if (sc_if->msk_cdata.msk_parent_tag) { - bus_dma_tag_destroy(sc_if->msk_cdata.msk_parent_tag); - sc_if->msk_cdata.msk_parent_tag = NULL; - } - mtx_destroy(&sc_if->msk_jlist_mtx); -} - -/* - * Allocate a jumbo buffer. - */ -static void * -msk_jalloc(struct msk_if_softc *sc_if) -{ - struct msk_jpool_entry *entry; - - MSK_JLIST_LOCK(sc_if); - - entry = SLIST_FIRST(&sc_if->msk_jfree_listhead); - - if (entry == NULL) { - MSK_JLIST_UNLOCK(sc_if); - return (NULL); - } - - SLIST_REMOVE_HEAD(&sc_if->msk_jfree_listhead, jpool_entries); - SLIST_INSERT_HEAD(&sc_if->msk_jinuse_listhead, entry, jpool_entries); - - MSK_JLIST_UNLOCK(sc_if); - - return (sc_if->msk_cdata.msk_jslots[entry->slot]); -} - -/* - * Release a jumbo buffer. - */ -static void -msk_jfree(void *buf, void *args) -{ - struct msk_if_softc *sc_if; - struct msk_jpool_entry *entry; - int i; - - /* Extract the softc struct pointer. */ - sc_if = (struct msk_if_softc *)args; - KASSERT(sc_if != NULL, ("%s: can't find softc pointer!", __func__)); - - MSK_JLIST_LOCK(sc_if); - /* Calculate the slot this buffer belongs to. */ - i = ((vm_offset_t)buf - - (vm_offset_t)sc_if->msk_rdata.msk_jumbo_buf) / MSK_JLEN; - KASSERT(i >= 0 && i < MSK_JSLOTS, - ("%s: asked to free buffer that we don't manage!", __func__)); - - entry = SLIST_FIRST(&sc_if->msk_jinuse_listhead); - KASSERT(entry != NULL, ("%s: buffer not in use!", __func__)); - entry->slot = i; - SLIST_REMOVE_HEAD(&sc_if->msk_jinuse_listhead, jpool_entries); - SLIST_INSERT_HEAD(&sc_if->msk_jfree_listhead, entry, jpool_entries); - if (SLIST_EMPTY(&sc_if->msk_jinuse_listhead)) - wakeup(sc_if); - - MSK_JLIST_UNLOCK(sc_if); } static int @@ -3328,7 +3207,7 @@ msk_rxput(struct msk_if_softc *sc_if) struct msk_softc *sc; sc = sc_if->msk_softc; - if (sc_if->msk_framesize >(MCLBYTES - ETHER_HDR_LEN)) + if (sc_if->msk_framesize > (MCLBYTES - MSK_RX_BUF_ALIGN)) bus_dmamap_sync( sc_if->msk_cdata.msk_jumbo_rx_ring_tag, sc_if->msk_cdata.msk_jumbo_rx_ring_map, @@ -3395,7 +3274,8 @@ msk_handle_events(struct msk_softc *sc) sc_if->msk_vtag = ntohs(len); break; case OP_RXSTAT: - if (sc_if->msk_framesize > (MCLBYTES - ETHER_HDR_LEN)) + if (sc_if->msk_framesize > + (MCLBYTES - MSK_RX_BUF_ALIGN)) msk_jumbo_rxeof(sc_if, status, len); else msk_rxeof(sc_if, status, len); @@ -3633,9 +3513,12 @@ msk_init_locked(struct msk_if_softc *sc_ /* Cancel pending I/O and free all Rx/Tx buffers. */ msk_stop(sc_if); - sc_if->msk_framesize = ifp->if_mtu + ETHER_HDR_LEN + - ETHER_VLAN_ENCAP_LEN; - if (sc_if->msk_framesize > MSK_MAX_FRAMELEN && + if (ifp->if_mtu < ETHERMTU) + sc_if->msk_framesize = ETHERMTU; + else + sc_if->msk_framesize = ifp->if_mtu; + sc_if->msk_framesize += ETHER_HDR_LEN + ETHER_VLAN_ENCAP_LEN; + if (ifp->if_mtu > ETHERMTU && sc_if->msk_softc->msk_hw_id == CHIP_ID_YUKON_EC_U) { /* * In Yukon EC Ultra, TSO & checksum offload is not @@ -3688,7 +3571,7 @@ msk_init_locked(struct msk_if_softc *sc_ gmac = DATA_BLIND_VAL(DATA_BLIND_DEF) | GM_SMOD_VLAN_ENA | IPG_DATA_VAL(IPG_DATA_DEF); - if (sc_if->msk_framesize > MSK_MAX_FRAMELEN) + if (ifp->if_mtu > ETHERMTU) gmac |= GM_SMOD_JUMBO_ENA; GMAC_WRITE_2(sc, sc_if->msk_port, GM_SERIAL_MODE, gmac); @@ -3743,7 +3626,7 @@ msk_init_locked(struct msk_if_softc *sc_ MSK_ECU_LLPP); CSR_WRITE_1(sc, MR_ADDR(sc_if->msk_port, RX_GMF_UP_THR), MSK_ECU_ULPP); - if (sc_if->msk_framesize > MSK_MAX_FRAMELEN) { + if (ifp->if_mtu > ETHERMTU) { /* * Set Tx GMAC FIFO Almost Empty Threshold. */ @@ -3803,7 +3686,7 @@ msk_init_locked(struct msk_if_softc *sc_ /* Disable Rx checksum offload and RSS hash. */ CSR_WRITE_4(sc, Q_ADDR(sc_if->msk_rxq, Q_CSR), BMU_DIS_RX_CHKSUM | BMU_DIS_RX_RSS_HASH); - if (sc_if->msk_framesize > (MCLBYTES - ETHER_HDR_LEN)) { + if (sc_if->msk_framesize > (MCLBYTES - MSK_RX_BUF_ALIGN)) { msk_set_prefetch(sc, sc_if->msk_rxq, sc_if->msk_rdata.msk_jumbo_rx_ring_paddr, MSK_JUMBO_RX_RING_CNT - 1); Modified: stable/7/sys/dev/msk/if_mskreg.h ============================================================================== --- stable/7/sys/dev/msk/if_mskreg.h Mon Feb 9 02:06:15 2009 (r188363) +++ stable/7/sys/dev/msk/if_mskreg.h Mon Feb 9 02:15:25 2009 (r188364) @@ -2164,7 +2164,6 @@ struct msk_stat_desc { #define MSK_MAXTXSEGS 32 #define MSK_TSO_MAXSGSIZE 4096 #define MSK_TSO_MAXSIZE (65535 + sizeof(struct ether_vlan_header)) -#define MSK_MAXRXSEGS 32 /* * It seems that the hardware requires extra decriptors(LEs) to offload @@ -2191,20 +2190,6 @@ struct msk_stat_desc { #define MSK_MAX_FRAMELEN \ (ETHER_MAX_LEN + ETHER_VLAN_ENCAP_LEN - ETHER_CRC_LEN) #define MSK_MIN_FRAMELEN (ETHER_MIN_LEN - ETHER_CRC_LEN) -#define MSK_JSLOTS ((MSK_RX_RING_CNT * 3) / 2) - -#define MSK_JRAWLEN (MSK_JUMBO_FRAMELEN + ETHER_ALIGN) -#define MSK_JLEN (MSK_JRAWLEN + (sizeof(uint64_t) - \ - (MSK_JRAWLEN % sizeof(uint64_t)))) -#define MSK_JPAGESZ PAGE_SIZE -#define MSK_RESID \ - (MSK_JPAGESZ - (MSK_JLEN * MSK_JSLOTS) % MSK_JPAGESZ) -#define MSK_JMEM ((MSK_JLEN * MSK_JSLOTS) + MSK_RESID) - -struct msk_jpool_entry { - int slot; - SLIST_ENTRY(msk_jpool_entry) jpool_entries; -}; struct msk_txdesc { struct mbuf *tx_m; @@ -2230,10 +2215,6 @@ struct msk_chain_data { bus_dmamap_t msk_rx_ring_map; bus_dmamap_t msk_rx_sparemap; bus_dma_tag_t msk_jumbo_rx_tag; - bus_dma_tag_t msk_jumbo_tag; - bus_dmamap_t msk_jumbo_map; - bus_dma_tag_t msk_jumbo_mtag; - caddr_t msk_jslots[MSK_JSLOTS]; struct msk_rxdesc msk_jumbo_rxdesc[MSK_JUMBO_RX_RING_CNT]; bus_dma_tag_t msk_jumbo_rx_ring_tag; bus_dmamap_t msk_jumbo_rx_ring_map; @@ -2255,8 +2236,6 @@ struct msk_ring_data { bus_addr_t msk_rx_ring_paddr; struct msk_rx_desc *msk_jumbo_rx_ring; bus_addr_t msk_jumbo_rx_ring_paddr; - void *msk_jumbo_buf; - bus_addr_t msk_jumbo_buf_paddr; }; #define MSK_TX_RING_ADDR(sc, i) \ @@ -2352,6 +2331,7 @@ struct msk_if_softc { int msk_link; uint32_t msk_flags; #define MSK_FLAG_RAMBUF 0x0010 +#define MSK_FLAG_NOJUMBO 0x0020 struct callout msk_tick_ch; int msk_watchdog_timer; uint32_t msk_txq; /* Tx. Async Queue offset */ @@ -2365,14 +2345,8 @@ struct msk_if_softc { int msk_if_flags; int msk_detach; uint16_t msk_vtag; /* VLAN tag id. */ - SLIST_HEAD(__msk_jfreehead, msk_jpool_entry) msk_jfree_listhead; - SLIST_HEAD(__msk_jinusehead, msk_jpool_entry) msk_jinuse_listhead; - struct mtx msk_jlist_mtx; }; -#define MSK_JLIST_LOCK(_sc) mtx_lock(&(_sc)->msk_jlist_mtx) -#define MSK_JLIST_UNLOCK(_sc) mtx_unlock(&(_sc)->msk_jlist_mtx) - #define MSK_TIMEOUT 1000 #define MSK_PHY_POWERUP 1 #define MSK_PHY_POWERDOWN 0 From owner-svn-src-stable@FreeBSD.ORG Mon Feb 9 03:23:00 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 79DEF1065670; Mon, 9 Feb 2009 03:23:00 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 5D37A8FC16; Mon, 9 Feb 2009 03:23:00 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n193N0AV043387; Mon, 9 Feb 2009 03:23:00 GMT (envelope-from yongari@svn.freebsd.org) Received: (from yongari@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n193N0nL043386; Mon, 9 Feb 2009 03:23:00 GMT (envelope-from yongari@svn.freebsd.org) Message-Id: <200902090323.n193N0nL043386@svn.freebsd.org> From: Pyun YongHyeon Date: Mon, 9 Feb 2009 03:23:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r188365 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb dev/fxp X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Feb 2009 03:23:01 -0000 Author: yongari Date: Mon Feb 9 03:23:00 2009 New Revision: 188365 URL: http://svn.freebsd.org/changeset/base/188365 Log: MFC r177507(cvs if_fxp.c, 1.267): Reuse the mbuf that was just retrieved from the receive ring if mbuf exhaustion is encountered. There was a fix made previously for this problem but the solution (breaking out of the receive loop) does not seem to work. mbuf reuse strategy is already adopted by other drivers such as if_bge. The problem was recreated and the patch is also verified in the same test environment. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/dev/fxp/if_fxp.c Modified: stable/7/sys/dev/fxp/if_fxp.c ============================================================================== --- stable/7/sys/dev/fxp/if_fxp.c Mon Feb 9 02:15:25 2009 (r188364) +++ stable/7/sys/dev/fxp/if_fxp.c Mon Feb 9 03:23:00 2009 (r188365) @@ -231,7 +231,7 @@ static int fxp_ioctl(struct ifnet *ifp, caddr_t data); static void fxp_watchdog(struct fxp_softc *sc); static int fxp_add_rfabuf(struct fxp_softc *sc, - struct fxp_rx *rxp); + struct fxp_rx *rxp, struct mbuf *oldm); static int fxp_mc_addrs(struct fxp_softc *sc); static void fxp_mc_setup(struct fxp_softc *sc); static uint16_t fxp_eeprom_getword(struct fxp_softc *sc, int offset, @@ -715,7 +715,7 @@ fxp_attach(device_t dev) device_printf(dev, "can't create DMA map for RX\n"); goto fail; } - if (fxp_add_rfabuf(sc, rxp) != 0) { + if (fxp_add_rfabuf(sc, rxp, NULL) != 0) { error = ENOMEM; goto fail; } @@ -1652,7 +1652,7 @@ fxp_intr_body(struct fxp_softc *sc, stru * If this fails, the old buffer is recycled * instead. */ - fxp_rc = fxp_add_rfabuf(sc, rxp); + fxp_rc = fxp_add_rfabuf(sc, rxp, m); if (fxp_rc == 0) { int total_len; @@ -2245,17 +2245,26 @@ fxp_ifmedia_sts(struct ifnet *ifp, struc * data pointer is fixed up to point just past it. */ static int -fxp_add_rfabuf(struct fxp_softc *sc, struct fxp_rx *rxp) +fxp_add_rfabuf(struct fxp_softc *sc, struct fxp_rx *rxp, struct mbuf *oldm) { struct mbuf *m; struct fxp_rfa *rfa, *p_rfa; struct fxp_rx *p_rx; bus_dmamap_t tmp_map; - int error; + int error, reused_mbuf=0; m = m_getcl(M_DONTWAIT, MT_DATA, M_PKTHDR); - if (m == NULL) - return (ENOBUFS); + if (m == NULL) { + if (oldm == NULL) + return ENOBUFS; + m = oldm; + m->m_data = m->m_ext.ext_buf; + /* + * return error so the receive loop will + * not pass the packet to upper layer + */ + reused_mbuf = EAGAIN; + } /* * Move the data pointer up so that the incoming data packet @@ -2320,7 +2329,7 @@ fxp_add_rfabuf(struct fxp_softc *sc, str sc->fxp_desc.rx_head = rxp; } sc->fxp_desc.rx_tail = rxp; - return (0); + return (reused_mbuf); } static int From owner-svn-src-stable@FreeBSD.ORG Mon Feb 9 03:28:58 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0F0C2106564A; Mon, 9 Feb 2009 03:28:58 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id EEF598FC12; Mon, 9 Feb 2009 03:28:57 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n193SvB8043555; Mon, 9 Feb 2009 03:28:57 GMT (envelope-from yongari@svn.freebsd.org) Received: (from yongari@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n193SvUE043552; Mon, 9 Feb 2009 03:28:57 GMT (envelope-from yongari@svn.freebsd.org) Message-Id: <200902090328.n193SvUE043552@svn.freebsd.org> From: Pyun YongHyeon Date: Mon, 9 Feb 2009 03:28:57 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r188366 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb dev/fxp X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Feb 2009 03:28:58 -0000 Author: yongari Date: Mon Feb 9 03:28:57 2009 New Revision: 188366 URL: http://svn.freebsd.org/changeset/base/188366 Log: MFC r185269,185271-185272 r185269: Whitespace fix. r185271: Sort head files and removed ununsed header file. r185272: Make fxp(4) build with FXP_IP_CSUM_WAR. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/dev/fxp/if_fxp.c stable/7/sys/dev/fxp/if_fxpreg.h stable/7/sys/dev/fxp/if_fxpvar.h Modified: stable/7/sys/dev/fxp/if_fxp.c ============================================================================== --- stable/7/sys/dev/fxp/if_fxp.c Mon Feb 9 03:23:00 2009 (r188365) +++ stable/7/sys/dev/fxp/if_fxp.c Mon Feb 9 03:28:57 2009 (r188366) @@ -40,32 +40,28 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include -#include - /* #include */ #include +#include #include +#include #include +#include #include +#include +#include #include +#include #include #include +#include +#include -#include -#include -#include #include -#include #include -#include -#include - - -#include -#include - #ifdef FXP_IP_CSUM_WAR #include #include @@ -526,7 +522,7 @@ fxp_attach(device_t dev) * Systems based on the ICH2/ICH2-M chip from Intel, and possibly * some systems based a normal 82559 design, have a defect where * the chip can cause a PCI protocol violation if it receives - * a CU_RESUME command when it is entering the IDLE state. The + * a CU_RESUME command when it is entering the IDLE state. The * workaround is to disable Dynamic Standby Mode, so the chip never * deasserts CLKRUN#, and always remains in an active state. * @@ -805,7 +801,7 @@ fxp_attach(device_t dev) ifp->if_snd.ifq_drv_maxlen = FXP_NTXCB - 1; IFQ_SET_READY(&ifp->if_snd); - /* + /* * Hook our interrupt after all initialization is complete. */ error = bus_setup_intr(dev, sc->fxp_res[1], INTR_TYPE_NET | INTR_MPSAFE, @@ -899,7 +895,7 @@ fxp_detach(device_t dev) struct fxp_softc *sc = device_get_softc(dev); #ifdef DEVICE_POLLING - if (sc->ifp->if_capenable & IFCAP_POLLING) + if (sc->ifp->if_capenable & IFCAP_POLLING) ether_poll_deregister(sc->ifp); #endif @@ -964,7 +960,7 @@ fxp_suspend(device_t dev) FXP_LOCK(sc); fxp_stop(sc); - + sc->suspended = 1; FXP_UNLOCK(sc); @@ -996,7 +992,7 @@ fxp_resume(device_t dev) return (0); } -static void +static void fxp_eeprom_shiftin(struct fxp_softc *sc, int data, int length) { uint16_t reg; @@ -1185,7 +1181,7 @@ fxp_start(struct ifnet *ifp) } /* - * Start packet transmission on the interface. + * Start packet transmission on the interface. * This routine must be called with the softc lock held, and is an * internal entry point only. */ @@ -1319,8 +1315,8 @@ fxp_encap(struct fxp_softc *sc, struct m if (m_head->m_pkthdr.len < 38) { struct ip *ip; m_head->m_data += ETHER_HDR_LEN; - ip = mtod(mb_head, struct ip *); - ip->ip_sum = in_cksum(mb_head, ip->ip_hl << 2); + ip = mtod(m_head, struct ip *); + ip->ip_sum = in_cksum(m_head, ip->ip_hl << 2); m_head->m_data -= ETHER_HDR_LEN; } else { txp->tx_cb->ipcb_ip_activation_high = @@ -1511,10 +1507,10 @@ fxp_intr(void *xsc) while ((statack = CSR_READ_1(sc, FXP_CSR_SCB_STATACK)) != 0) { /* * It should not be possible to have all bits set; the - * FXP_SCB_INTR_SWI bit always returns 0 on a read. If + * FXP_SCB_INTR_SWI bit always returns 0 on a read. If * all bits are set, this may indicate that the card has * been physically ejected, so ignore it. - */ + */ if (statack == 0xff) { FXP_UNLOCK(sc); return; @@ -1770,7 +1766,7 @@ fxp_tick(void *xsc) * with external storage to be released in a timely manner rather * than being defered for a potentially long time. This limits * the delay to a maximum of one second. - */ + */ fxp_txeof(sc); /* @@ -2203,11 +2199,11 @@ fxp_ifmedia_upd(struct ifnet *ifp) mii = device_get_softc(sc->miibus); FXP_LOCK(sc); - if (mii->mii_instance) { - struct mii_softc *miisc; - LIST_FOREACH(miisc, &mii->mii_phys, mii_list) - mii_phy_reset(miisc); - } + if (mii->mii_instance) { + struct mii_softc *miisc; + LIST_FOREACH(miisc, &mii->mii_phys, mii_list) + mii_phy_reset(miisc); + } mii_mediachg(mii); FXP_UNLOCK(sc); return (0); @@ -2260,7 +2256,7 @@ fxp_add_rfabuf(struct fxp_softc *sc, str m = oldm; m->m_data = m->m_ext.ext_buf; /* - * return error so the receive loop will + * return error so the receive loop will * not pass the packet to upper layer */ reused_mbuf = EAGAIN; @@ -2688,7 +2684,7 @@ fxp_load_ucode(struct fxp_softc *sc) bus_dmamap_sync(sc->cbl_tag, sc->cbl_map, BUS_DMASYNC_POSTWRITE); device_printf(sc->dev, "Microcode loaded, int_delay: %d usec bundle_max: %d\n", - sc->tunable_int_delay, + sc->tunable_int_delay, uc->bundle_max_offset == 0 ? 0 : sc->tunable_bundle_max); sc->flags |= FXP_FLAG_UCODE; } @@ -2710,7 +2706,7 @@ sysctl_int_range(SYSCTL_HANDLER_ARGS, in /* * Interrupt delay is expressed in microseconds, a multiplier is used - * to convert this to the appropriate clock ticks before using. + * to convert this to the appropriate clock ticks before using. */ static int sysctl_hw_fxp_int_delay(SYSCTL_HANDLER_ARGS) Modified: stable/7/sys/dev/fxp/if_fxpreg.h ============================================================================== --- stable/7/sys/dev/fxp/if_fxpreg.h Mon Feb 9 03:23:00 2009 (r188365) +++ stable/7/sys/dev/fxp/if_fxpreg.h Mon Feb 9 03:28:57 2009 (r188366) @@ -287,7 +287,7 @@ struct fxp_cb_tx { /* * The following structure isn't actually part of the TxCB, * unless the extended TxCB feature is being used. In this - * case, the first two elements of the structure below are + * case, the first two elements of the structure below are * fetched along with the TxCB. */ union { @@ -420,7 +420,7 @@ struct fxp_stats { }; #define FXP_STATS_DUMP_COMPLETE 0xa005 #define FXP_STATS_DR_COMPLETE 0xa007 - + /* * Serial EEPROM control register bits */ Modified: stable/7/sys/dev/fxp/if_fxpvar.h ============================================================================== --- stable/7/sys/dev/fxp/if_fxpvar.h Mon Feb 9 03:23:00 2009 (r188365) +++ stable/7/sys/dev/fxp/if_fxpvar.h Mon Feb 9 03:28:57 2009 (r188366) @@ -1,13 +1,13 @@ /*- * Copyright (c) 1995, David Greenman * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions - * are met: + * are met: * 1. Redistributions of source code must retain the above copyright * notice unmodified, this list of conditions, and the following - * disclaimer. + * 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. @@ -86,16 +86,16 @@ /* * Default maximum time, in microseconds, that an interrupt may be delayed - * in an attempt to coalesce interrupts. This is only effective if the Intel + * in an attempt to coalesce interrupts. This is only effective if the Intel * microcode is loaded, and may be changed via either loader tunables or * sysctl. See also the CPUSAVER_DWORD entry in rcvbundl.h. */ #define TUNABLE_INT_DELAY 1000 /* - * Default number of packets that will be bundled, before an interrupt is + * Default number of packets that will be bundled, before an interrupt is * generated. This is only effective if the Intel microcode is loaded, and - * may be changed via either loader tunables or sysctl. This may not be + * may be changed via either loader tunables or sysctl. This may not be * present in all microcode revisions, see also the CPUSAVER_BUNDLE_MAX_DWORD * entry in rcvbundl.h. */ From owner-svn-src-stable@FreeBSD.ORG Mon Feb 9 03:31:53 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 8E801106566B; Mon, 9 Feb 2009 03:31:53 +0000 (UTC) (envelope-from kientzle@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 7A1D38FC0A; Mon, 9 Feb 2009 03:31:53 +0000 (UTC) (envelope-from kientzle@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n193Vrr0043659; Mon, 9 Feb 2009 03:31:53 GMT (envelope-from kientzle@svn.freebsd.org) Received: (from kientzle@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n193VrEu043656; Mon, 9 Feb 2009 03:31:53 GMT (envelope-from kientzle@svn.freebsd.org) Message-Id: <200902090331.n193VrEu043656@svn.freebsd.org> From: Tim Kientzle Date: Mon, 9 Feb 2009 03:31:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r188367 - in stable/7/lib/libarchive: . test X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Feb 2009 03:31:54 -0000 Author: kientzle Date: Mon Feb 9 03:31:53 2009 New Revision: 188367 URL: http://svn.freebsd.org/changeset/base/188367 Log: MFC r187704: Fix ARCHIVE_EXTRACT_SPARSE handling in libarchive. Add a test to exercise this feature. This should fix --sparse/-S support in tar. Thanks to: Daichi GOTO Added: stable/7/lib/libarchive/test/test_write_disk_sparse.c - copied unchanged from r187704, head/lib/libarchive/test/test_write_disk_sparse.c Modified: stable/7/lib/libarchive/ (props changed) stable/7/lib/libarchive/archive_write_disk.c stable/7/lib/libarchive/test/Makefile Modified: stable/7/lib/libarchive/archive_write_disk.c ============================================================================== --- stable/7/lib/libarchive/archive_write_disk.c Mon Feb 9 03:28:57 2009 (r188366) +++ stable/7/lib/libarchive/archive_write_disk.c Mon Feb 9 03:31:53 2009 (r188367) @@ -176,6 +176,8 @@ struct archive_write_disk { int fd; /* Current offset for writing data to the file. */ off_t offset; + /* Last offset actually written to disk. */ + off_t fd_offset; /* Maximum size of file, -1 if unknown. */ off_t filesize; /* Dir we were in before this restore; only for deep paths. */ @@ -185,8 +187,6 @@ struct archive_write_disk { /* UID/GID to use in restoring this entry. */ uid_t uid; gid_t gid; - /* Last offset written to disk. */ - off_t last_offset; }; /* @@ -232,7 +232,7 @@ static struct fixup_entry *sort_dir_list static gid_t trivial_lookup_gid(void *, const char *, gid_t); static uid_t trivial_lookup_uid(void *, const char *, uid_t); static ssize_t write_data_block(struct archive_write_disk *, - const char *, size_t, off_t); + const char *, size_t); static struct archive_vtable *archive_write_disk_vtable(void); @@ -334,7 +334,7 @@ _archive_write_header(struct archive *_a } a->entry = archive_entry_clone(entry); a->fd = -1; - a->last_offset = 0; + a->fd_offset = 0; a->offset = 0; a->uid = a->user_uid; a->mode = archive_entry_mode(a->entry); @@ -500,9 +500,9 @@ archive_write_disk_set_skip_file(struct } static ssize_t -write_data_block(struct archive_write_disk *a, - const char *buff, size_t size, off_t offset) +write_data_block(struct archive_write_disk *a, const char *buff, size_t size) { + uint64_t start_size = size; ssize_t bytes_written = 0; ssize_t block_size = 0, bytes_to_write; int r; @@ -519,8 +519,9 @@ write_data_block(struct archive_write_di block_size = a->pst->st_blksize; } - if (a->filesize >= 0 && (off_t)(offset + size) > a->filesize) - size = (size_t)(a->filesize - offset); + /* If this write would run beyond the file size, truncate it. */ + if (a->filesize >= 0 && (off_t)(a->offset + size) > a->filesize) + start_size = size = (size_t)(a->filesize - a->offset); /* Write the data. */ while (size > 0) { @@ -536,7 +537,7 @@ write_data_block(struct archive_write_di if (*p != '\0') break; } - offset += p - buff; + a->offset += p - buff; size -= p - buff; buff = p; if (size == 0) @@ -544,22 +545,25 @@ write_data_block(struct archive_write_di /* Calculate next block boundary after offset. */ block_end - = (offset / block_size) * block_size + block_size; + = (a->offset / block_size + 1) * block_size; /* If the adjusted write would cross block boundary, * truncate it to the block boundary. */ bytes_to_write = size; - if (offset + bytes_to_write > block_end) - bytes_to_write = block_end - offset; + if (a->offset + bytes_to_write > block_end) + bytes_to_write = block_end - a->offset; } /* Seek if necessary to the specified offset. */ - if (offset != a->last_offset) { - if (lseek(a->fd, offset, SEEK_SET) < 0) { + if (a->offset != a->fd_offset) { + if (lseek(a->fd, a->offset, SEEK_SET) < 0) { archive_set_error(&a->archive, errno, "Seek failed"); return (ARCHIVE_FATAL); } + a->fd_offset = a->offset; + a->archive.file_position = a->offset; + a->archive.raw_position = a->offset; } bytes_written = write(a->fd, buff, bytes_to_write); if (bytes_written < 0) { @@ -568,12 +572,12 @@ write_data_block(struct archive_write_di } buff += bytes_written; size -= bytes_written; - offset += bytes_written; + a->offset += bytes_written; a->archive.file_position += bytes_written; a->archive.raw_position += bytes_written; - a->last_offset = a->offset = offset; + a->fd_offset = a->offset; } - return (bytes_written); + return (start_size - size); } static ssize_t @@ -586,9 +590,9 @@ _archive_write_data_block(struct archive __archive_check_magic(&a->archive, ARCHIVE_WRITE_DISK_MAGIC, ARCHIVE_STATE_DATA, "archive_write_disk_block"); - r = write_data_block(a, buff, size, offset); - - if (r < 0) + a->offset = offset; + r = write_data_block(a, buff, size); + if (r < ARCHIVE_OK) return (r); if ((size_t)r < size) { archive_set_error(&a->archive, 0, @@ -606,7 +610,7 @@ _archive_write_data(struct archive *_a, __archive_check_magic(&a->archive, ARCHIVE_WRITE_DISK_MAGIC, ARCHIVE_STATE_DATA, "archive_write_data"); - return (write_data_block(a, buff, size, a->offset)); + return (write_data_block(a, buff, size)); } static int @@ -627,7 +631,7 @@ _archive_write_finish_entry(struct archi /* There's no file. */ } else if (a->filesize < 0) { /* File size is unknown, so we can't set the size. */ - } else if (a->last_offset == a->filesize) { + } else if (a->fd_offset == a->filesize) { /* Last write ended at exactly the filesize; we're done. */ /* Hopefully, this is the common case. */ } else { Modified: stable/7/lib/libarchive/test/Makefile ============================================================================== --- stable/7/lib/libarchive/test/Makefile Mon Feb 9 03:28:57 2009 (r188366) +++ stable/7/lib/libarchive/test/Makefile Mon Feb 9 03:31:53 2009 (r188367) @@ -58,6 +58,7 @@ TESTS= \ test_write_disk_hardlink.c \ test_write_disk_perms.c \ test_write_disk_secure.c \ + test_write_disk_sparse.c \ test_write_format_ar.c \ test_write_format_cpio.c \ test_write_format_cpio_empty.c \ Copied: stable/7/lib/libarchive/test/test_write_disk_sparse.c (from r187704, head/lib/libarchive/test/test_write_disk_sparse.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/7/lib/libarchive/test/test_write_disk_sparse.c Mon Feb 9 03:31:53 2009 (r188367, copy of r187704, head/lib/libarchive/test/test_write_disk_sparse.c) @@ -0,0 +1,278 @@ +/*- + * Copyright (c) 2003-2007 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$"); + +/* + * Write a file using archive_write_data call, read the file + * back and verify the contents. The data written includes large + * blocks of nulls, so it should exercise the sparsification logic + * if ARCHIVE_EXTRACT_SPARSE is enabled. + */ +static void +verify_write_data(struct archive *a, int sparse) +{ + static const char data[]="abcdefghijklmnopqrstuvwxyz"; + struct stat st; + struct archive_entry *ae; + size_t buff_size = 64 * 1024; + char *buff, *p; + const char *msg = sparse ? "sparse" : "non-sparse"; + int fd; + + buff = malloc(buff_size); + assert(buff != NULL); + + ae = archive_entry_new(); + assert(ae != NULL); + archive_entry_set_size(ae, 8 * buff_size); + archive_entry_set_pathname(ae, "test_write_data"); + archive_entry_set_mode(ae, AE_IFREG | 0755); + assertEqualIntA(a, 0, archive_write_header(a, ae)); + + /* Use archive_write_data() to write three relatively sparse blocks. */ + + /* First has non-null data at beginning. */ + memset(buff, 0, buff_size); + memcpy(buff, data, sizeof(data)); + failure("%s", msg); + assertEqualInt(buff_size, archive_write_data(a, buff, buff_size)); + + /* Second has non-null data in the middle. */ + memset(buff, 0, buff_size); + memcpy(buff + buff_size / 2 - 3, data, sizeof(data)); + failure("%s", msg); + assertEqualInt(buff_size, archive_write_data(a, buff, buff_size)); + + /* Third has non-null data at the end. */ + memset(buff, 0, buff_size); + memcpy(buff + buff_size - sizeof(data), data, sizeof(data)); + failure("%s", msg); + assertEqualInt(buff_size, archive_write_data(a, buff, buff_size)); + + failure("%s", msg); + assertEqualIntA(a, 0, archive_write_finish_entry(a)); + + /* Test the entry on disk. */ + assert(0 == stat(archive_entry_pathname(ae), &st)); + assertEqualInt(st.st_size, 8 * buff_size); + fd = open(archive_entry_pathname(ae), O_RDONLY); + if (!assert(fd >= 0)) + return; + + /* Check first block. */ + assertEqualInt(buff_size, read(fd, buff, buff_size)); + failure("%s", msg); + assertEqualMem(buff, data, sizeof(data)); + for (p = buff + sizeof(data); p < buff + buff_size; ++p) { + failure("offset: %d, %s", (int)(p - buff), msg); + if (!assertEqualInt(0, *p)) + break; + } + + /* Check second block. */ + assertEqualInt(buff_size, read(fd, buff, buff_size)); + for (p = buff; p < buff + buff_size; ++p) { + failure("offset: %d, %s", (int)(p - buff), msg); + if (p == buff + buff_size / 2 - 3) { + assertEqualMem(p, data, sizeof(data)); + p += sizeof(data); + } else if (!assertEqualInt(0, *p)) + break; + } + + /* Check third block. */ + assertEqualInt(buff_size, read(fd, buff, buff_size)); + for (p = buff; p < buff + buff_size - sizeof(data); ++p) { + failure("offset: %d, %s", (int)(p - buff), msg); + if (!assertEqualInt(0, *p)) + break; + } + failure("%s", msg); + assertEqualMem(buff + buff_size - sizeof(data), data, sizeof(data)); + + /* XXX more XXX */ + + assertEqualInt(0, close(fd)); + free(buff); +} + +/* + * As above, but using the archive_write_data_block() call. + */ +static void +verify_write_data_block(struct archive *a, int sparse) +{ + static const char data[]="abcdefghijklmnopqrstuvwxyz"; + struct stat st; + struct archive_entry *ae; + size_t buff_size = 64 * 1024; + char *buff, *p; + const char *msg = sparse ? "sparse" : "non-sparse"; + int fd; + + buff = malloc(buff_size); + assert(buff != NULL); + + ae = archive_entry_new(); + assert(ae != NULL); + archive_entry_set_size(ae, 8 * buff_size); + archive_entry_set_pathname(ae, "test_write_data_block"); + archive_entry_set_mode(ae, AE_IFREG | 0755); + assertEqualIntA(a, 0, archive_write_header(a, ae)); + + /* Use archive_write_data_block() to write three + relatively sparse blocks. */ + + /* First has non-null data at beginning. */ + memset(buff, 0, buff_size); + memcpy(buff, data, sizeof(data)); + failure("%s", msg); + assertEqualInt(ARCHIVE_OK, + archive_write_data_block(a, buff, buff_size, 100)); + + /* Second has non-null data in the middle. */ + memset(buff, 0, buff_size); + memcpy(buff + buff_size / 2 - 3, data, sizeof(data)); + failure("%s", msg); + assertEqualInt(ARCHIVE_OK, + archive_write_data_block(a, buff, buff_size, buff_size + 200)); + + /* Third has non-null data at the end. */ + memset(buff, 0, buff_size); + memcpy(buff + buff_size - sizeof(data), data, sizeof(data)); + failure("%s", msg); + assertEqualInt(ARCHIVE_OK, + archive_write_data_block(a, buff, buff_size, buff_size * 2 + 300)); + + failure("%s", msg); + assertEqualIntA(a, 0, archive_write_finish_entry(a)); + + /* Test the entry on disk. */ + assert(0 == stat(archive_entry_pathname(ae), &st)); + assertEqualInt(st.st_size, 8 * buff_size); + fd = open(archive_entry_pathname(ae), O_RDONLY); + if (!assert(fd >= 0)) + return; + + /* Check 100-byte gap at beginning */ + assertEqualInt(100, read(fd, buff, 100)); + failure("%s", msg); + for (p = buff; p < buff + 100; ++p) { + failure("offset: %d, %s", (int)(p - buff), msg); + if (!assertEqualInt(0, *p)) + break; + } + + /* Check first block. */ + assertEqualInt(buff_size, read(fd, buff, buff_size)); + failure("%s", msg); + assertEqualMem(buff, data, sizeof(data)); + for (p = buff + sizeof(data); p < buff + buff_size; ++p) { + failure("offset: %d, %s", (int)(p - buff), msg); + if (!assertEqualInt(0, *p)) + break; + } + + /* Check 100-byte gap */ + assertEqualInt(100, read(fd, buff, 100)); + failure("%s", msg); + for (p = buff; p < buff + 100; ++p) { + failure("offset: %d, %s", (int)(p - buff), msg); + if (!assertEqualInt(0, *p)) + break; + } + + /* Check second block. */ + assertEqualInt(buff_size, read(fd, buff, buff_size)); + for (p = buff; p < buff + buff_size; ++p) { + failure("offset: %d, %s", (int)(p - buff), msg); + if (p == buff + buff_size / 2 - 3) { + assertEqualMem(p, data, sizeof(data)); + p += sizeof(data); + } else if (!assertEqualInt(0, *p)) + break; + } + + /* Check 100-byte gap */ + assertEqualInt(100, read(fd, buff, 100)); + failure("%s", msg); + for (p = buff; p < buff + 100; ++p) { + failure("offset: %d, %s", (int)(p - buff), msg); + if (!assertEqualInt(0, *p)) + break; + } + + /* Check third block. */ + assertEqualInt(buff_size, read(fd, buff, buff_size)); + for (p = buff; p < buff + buff_size - sizeof(data); ++p) { + failure("offset: %d, %s", (int)(p - buff), msg); + if (!assertEqualInt(0, *p)) + break; + } + failure("%s", msg); + assertEqualMem(buff + buff_size - sizeof(data), data, sizeof(data)); + + /* Check another block size beyond last we wrote. */ + assertEqualInt(buff_size, read(fd, buff, buff_size)); + failure("%s", msg); + for (p = buff; p < buff + buff_size; ++p) { + failure("offset: %d, %s", (int)(p - buff), msg); + if (!assertEqualInt(0, *p)) + break; + } + + + /* XXX more XXX */ + + assertEqualInt(0, close(fd)); + free(buff); +} + +DEFINE_TEST(test_write_disk_sparse) +{ + struct archive *ad; + + + /* + * The return values, etc, of the write data functions + * shouldn't change regardless of whether we've requested + * sparsification. (The performance and pattern of actual + * write calls to the disk should vary, of course, but the + * client program shouldn't see any difference.) + */ + assert((ad = archive_write_disk_new()) != NULL); + archive_write_disk_set_options(ad, 0); + verify_write_data(ad, 0); + verify_write_data_block(ad, 0); + assertEqualInt(0, archive_write_finish(ad)); + + assert((ad = archive_write_disk_new()) != NULL); + archive_write_disk_set_options(ad, ARCHIVE_EXTRACT_SPARSE); + verify_write_data(ad, 1); + verify_write_data_block(ad, 1); + assertEqualInt(0, archive_write_finish(ad)); + +} From owner-svn-src-stable@FreeBSD.ORG Mon Feb 9 03:32:24 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 459BD1065676; Mon, 9 Feb 2009 03:32:24 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 327EE8FC1B; Mon, 9 Feb 2009 03:32:24 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n193WOK9043707; Mon, 9 Feb 2009 03:32:24 GMT (envelope-from yongari@svn.freebsd.org) Received: (from yongari@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n193WOPc043706; Mon, 9 Feb 2009 03:32:24 GMT (envelope-from yongari@svn.freebsd.org) Message-Id: <200902090332.n193WOPc043706@svn.freebsd.org> From: Pyun YongHyeon Date: Mon, 9 Feb 2009 03:32:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r188368 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb dev/fxp X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Feb 2009 03:32:25 -0000 Author: yongari Date: Mon Feb 9 03:32:23 2009 New Revision: 188368 URL: http://svn.freebsd.org/changeset/base/188368 Log: MFC r185273 Fix Tx/Rx checksum offload ioctl handling and make Rx handler honor checksum offload configuration. Now checksum offload can be controlled by ifconfig(8). While I'm here add an additional check for interface capabilities before applying user's request. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/dev/fxp/if_fxp.c Modified: stable/7/sys/dev/fxp/if_fxp.c ============================================================================== --- stable/7/sys/dev/fxp/if_fxp.c Mon Feb 9 03:31:53 2009 (r188367) +++ stable/7/sys/dev/fxp/if_fxp.c Mon Feb 9 03:32:23 2009 (r188368) @@ -1558,6 +1558,7 @@ fxp_intr_body(struct fxp_softc *sc, stru struct fxp_rfa *rfa; int rnr = (statack & FXP_SCB_STATACK_RNR) ? 1 : 0; int fxp_rc = 0; + uint16_t status; FXP_LOCK_ASSERT(sc, MA_OWNED); if (rnr) @@ -1635,7 +1636,8 @@ fxp_intr_body(struct fxp_softc *sc, stru } #endif /* DEVICE_POLLING */ - if ((le16toh(rfa->rfa_status) & FXP_RFA_STATUS_C) == 0) + status = le16toh(rfa->rfa_status); + if ((status & FXP_RFA_STATUS_C) == 0) break; /* @@ -1661,14 +1663,14 @@ fxp_intr_body(struct fxp_softc *sc, stru total_len = le16toh(rfa->actual_size) & 0x3fff; if (total_len < sizeof(struct ether_header) || total_len > MCLBYTES - RFA_ALIGNMENT_FUDGE - - sc->rfa_size || - le16toh(rfa->rfa_status) & FXP_RFA_STATUS_CRC) { + sc->rfa_size || status & FXP_RFA_STATUS_CRC) { m_freem(m); continue; } /* Do IP checksum checking. */ - if (le16toh(rfa->rfa_status) & FXP_RFA_STATUS_PARSE) { + if ((ifp->if_capenable & IFCAP_RXCSUM) != 0 && + (status & FXP_RFA_STATUS_PARSE)) { if (rfa->rfax_csum_sts & FXP_RFDX_CS_IP_CSUM_BIT_VALID) m->m_pkthdr.csum_flags |= @@ -2372,7 +2374,7 @@ fxp_ioctl(struct ifnet *ifp, u_long comm struct fxp_softc *sc = ifp->if_softc; struct ifreq *ifr = (struct ifreq *)data; struct mii_data *mii; - int flag, mask, error = 0; + int flag, mask, error = 0, reinit; switch (command) { case SIOCSIFFLAGS: @@ -2432,6 +2434,7 @@ fxp_ioctl(struct ifnet *ifp, u_long comm break; case SIOCSIFCAP: + reinit = 0; mask = ifp->if_capenable ^ ifr->ifr_reqcap; #ifdef DEVICE_POLLING if (mask & IFCAP_POLLING) { @@ -2454,8 +2457,20 @@ fxp_ioctl(struct ifnet *ifp, u_long comm } } #endif - if (mask & IFCAP_VLAN_MTU) { - FXP_LOCK(sc); + FXP_LOCK(sc); + if ((mask & IFCAP_TXCSUM) != 0 && + (ifp->if_capabilities & IFCAP_TXCSUM) != 0) { + ifp->if_capenable ^= IFCAP_TXCSUM; + if ((ifp->if_capenable & IFCAP_TXCSUM) != 0) + ifp->if_hwassist |= FXP_CSUM_FEATURES; + else + ifp->if_hwassist &= ~FXP_CSUM_FEATURES; + } + if ((mask & IFCAP_RXCSUM) != 0 && + (ifp->if_capabilities & IFCAP_RXCSUM) != 0) + ifp->if_capenable ^= IFCAP_RXCSUM; + if ((mask & IFCAP_VLAN_MTU) != 0 && + (ifp->if_capabilities & IFCAP_VLAN_MTU) != 0) { ifp->if_capenable ^= IFCAP_VLAN_MTU; if (sc->revision != FXP_REV_82557) flag = FXP_FLAG_LONG_PKT_EN; @@ -2463,9 +2478,11 @@ fxp_ioctl(struct ifnet *ifp, u_long comm flag = FXP_FLAG_SAVE_BAD; sc->flags ^= flag; if (ifp->if_flags & IFF_UP) - fxp_init_body(sc); - FXP_UNLOCK(sc); + reinit++; } + if (reinit > 0) + fxp_init_body(sc); + FXP_UNLOCK(sc); break; default: From owner-svn-src-stable@FreeBSD.ORG Mon Feb 9 03:34:36 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 421EB106570D; Mon, 9 Feb 2009 03:34:36 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 2EC1F8FC16; Mon, 9 Feb 2009 03:34:36 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n193YaJx043811; Mon, 9 Feb 2009 03:34:36 GMT (envelope-from yongari@svn.freebsd.org) Received: (from yongari@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n193Yakm043810; Mon, 9 Feb 2009 03:34:36 GMT (envelope-from yongari@svn.freebsd.org) Message-Id: <200902090334.n193Yakm043810@svn.freebsd.org> From: Pyun YongHyeon Date: Mon, 9 Feb 2009 03:34:36 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r188369 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb dev/fxp X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Feb 2009 03:34:38 -0000 Author: yongari Date: Mon Feb 9 03:34:35 2009 New Revision: 188369 URL: http://svn.freebsd.org/changeset/base/188369 Log: MFC r185276 Move unarming watchdog timer and pending multicast configuration check to fxp_txeof(). While I'm here unarm watchdog timer only if there are no pending queued Tx requests. Previously the watchdog timer was unarmed whenever Tx interrupt is raised. This could be resulted in hiding root cause of watchdog timeouts. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/dev/fxp/if_fxp.c Modified: stable/7/sys/dev/fxp/if_fxp.c ============================================================================== --- stable/7/sys/dev/fxp/if_fxp.c Mon Feb 9 03:32:23 2009 (r188368) +++ stable/7/sys/dev/fxp/if_fxp.c Mon Feb 9 03:34:35 2009 (r188369) @@ -1547,6 +1547,11 @@ fxp_txeof(struct fxp_softc *sc) } sc->fxp_desc.tx_first = txp; bus_dmamap_sync(sc->cbl_tag, sc->cbl_map, BUS_DMASYNC_PREWRITE); + if (sc->tx_queued == 0) { + sc->watchdog_timer = 0; + if (sc->need_mcsetup) + fxp_mc_setup(sc); + } } static void @@ -1587,11 +1592,6 @@ fxp_intr_body(struct fxp_softc *sc, stru if (statack & (FXP_SCB_STATACK_CXTNO | FXP_SCB_STATACK_CNA)) { fxp_txeof(sc); - sc->watchdog_timer = 0; - if (sc->tx_queued == 0) { - if (sc->need_mcsetup) - fxp_mc_setup(sc); - } /* * Try to start more packets transmitting. */ From owner-svn-src-stable@FreeBSD.ORG Mon Feb 9 03:38:01 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 75230106566C; Mon, 9 Feb 2009 03:38:01 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 615628FC16; Mon, 9 Feb 2009 03:38:01 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n193c1fh043923; Mon, 9 Feb 2009 03:38:01 GMT (envelope-from yongari@svn.freebsd.org) Received: (from yongari@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n193c1Ii043921; Mon, 9 Feb 2009 03:38:01 GMT (envelope-from yongari@svn.freebsd.org) Message-Id: <200902090338.n193c1Ii043921@svn.freebsd.org> From: Pyun YongHyeon Date: Mon, 9 Feb 2009 03:38:01 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r188370 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb dev/fxp X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Feb 2009 03:38:02 -0000 Author: yongari Date: Mon Feb 9 03:38:01 2009 New Revision: 188370 URL: http://svn.freebsd.org/changeset/base/188370 Log: MFC r185285: - Allow fxp_encap() enqueue failed transmissions and set IFF_DRV_OACTIVE to note resource shortage to upper stack. - Don't count number of mbuf chains. Default 32 DMA segments for a frame is enough for most cases. If bus_dmamap_mbuf_sg fails use m_collapse(9) to collapse the mbuf chain instead of relying on expensive m_defrag(9). - Move bpf handling to fxp_start_body() which is supposed to be more appropriate place. - Always arm watchdog timer whenever a new Tx request is made. Previously fxp(4) used to arm watchdog timer only when FXP_CXINT_THRESH-th Tx request is made. Because fxp(4) does not rely on Tx interrupt to reclaim transmitted mbufs it's better to arm watchdog timer to detect potential lockups. - Add more aggresive Tx buffer reclaiming in fxp_start_body to make room for new Tx requests. Since fxp(4) does not request Tx completion interrupt for every frames it's necessary to clean TXCBs in advance to saturate link. - Make fxp(4) try to start more packets transmitting regardless of interrupt type in fxp_intr_body. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/dev/fxp/if_fxp.c stable/7/sys/dev/fxp/if_fxpvar.h Modified: stable/7/sys/dev/fxp/if_fxp.c ============================================================================== --- stable/7/sys/dev/fxp/if_fxp.c Mon Feb 9 03:34:35 2009 (r188369) +++ stable/7/sys/dev/fxp/if_fxp.c Mon Feb 9 03:38:01 2009 (r188370) @@ -220,7 +220,8 @@ static void fxp_init_body(struct fxp_s static void fxp_tick(void *xsc); static void fxp_start(struct ifnet *ifp); static void fxp_start_body(struct ifnet *ifp); -static int fxp_encap(struct fxp_softc *sc, struct mbuf *m_head); +static int fxp_encap(struct fxp_softc *sc, struct mbuf **m_head); +static void fxp_txeof(struct fxp_softc *sc); static void fxp_stop(struct fxp_softc *sc); static void fxp_release(struct fxp_softc *sc); static int fxp_ioctl(struct ifnet *ifp, u_long command, @@ -1190,7 +1191,7 @@ fxp_start_body(struct ifnet *ifp) { struct fxp_softc *sc = ifp->if_softc; struct mbuf *mb_head; - int error, txqueued; + int txqueued; FXP_LOCK_ASSERT(sc, MA_OWNED); @@ -1202,6 +1203,8 @@ fxp_start_body(struct ifnet *ifp) if (sc->need_mcsetup) return; + if (sc->tx_queued > FXP_NTXCB_HIWAT) + fxp_txeof(sc); /* * We're finished if there is nothing more to add to the list or if * we're all filled up with buffers to transmit. @@ -1219,32 +1222,44 @@ fxp_start_body(struct ifnet *ifp) if (mb_head == NULL) break; - error = fxp_encap(sc, mb_head); - if (error) - break; - txqueued = 1; + if (fxp_encap(sc, &mb_head)) { + if (mb_head == NULL) + break; + IFQ_DRV_PREPEND(&ifp->if_snd, mb_head); + ifp->if_drv_flags |= IFF_DRV_OACTIVE; + } + txqueued++; + /* + * Pass packet to bpf if there is a listener. + */ + BPF_MTAP(ifp, mb_head); } - bus_dmamap_sync(sc->cbl_tag, sc->cbl_map, BUS_DMASYNC_PREWRITE); /* * We're finished. If we added to the list, issue a RESUME to get DMA * going again if suspended. */ - if (txqueued) { + if (txqueued > 0) { + bus_dmamap_sync(sc->cbl_tag, sc->cbl_map, BUS_DMASYNC_PREWRITE); fxp_scb_wait(sc); fxp_scb_cmd(sc, FXP_SCB_COMMAND_CU_RESUME); + /* + * Set a 5 second timer just in case we don't hear + * from the card again. + */ + sc->watchdog_timer = 5; } } static int -fxp_encap(struct fxp_softc *sc, struct mbuf *m_head) +fxp_encap(struct fxp_softc *sc, struct mbuf **m_head) { struct ifnet *ifp; struct mbuf *m; struct fxp_tx *txp; struct fxp_cb_tx *cbp; bus_dma_segment_t segs[FXP_NTXSEG]; - int chainlen, error, i, nseg; + int error, i, nseg; FXP_LOCK_ASSERT(sc, MA_OWNED); ifp = sc->ifp; @@ -1271,6 +1286,7 @@ fxp_encap(struct fxp_softc *sc, struct m txp->tx_cb->ipcb_ip_activation_high = FXP_IPCB_HARDWAREPARSING_ENABLE; + m = *m_head; /* * Deal with TCP/IP checksum offload. Note that * in order for TCP checksum offload to work, @@ -1279,11 +1295,11 @@ fxp_encap(struct fxp_softc *sc, struct m * in the TCP header. The stack should have * already done this for us. */ - if (m_head->m_pkthdr.csum_flags) { - if (m_head->m_pkthdr.csum_flags & CSUM_DELAY_DATA) { + if (m->m_pkthdr.csum_flags) { + if (m->m_pkthdr.csum_flags & CSUM_DELAY_DATA) { txp->tx_cb->ipcb_ip_schedule = FXP_IPCB_TCPUDP_CHECKSUM_ENABLE; - if (m_head->m_pkthdr.csum_flags & CSUM_TCP) + if (m->m_pkthdr.csum_flags & CSUM_TCP) txp->tx_cb->ipcb_ip_schedule |= FXP_IPCB_TCP_PACKET; } @@ -1311,13 +1327,13 @@ fxp_encap(struct fxp_softc *sc, struct m * the header sizes/offsets vary. */ - if (m_head->m_pkthdr.csum_flags & CSUM_IP) { - if (m_head->m_pkthdr.len < 38) { + if (m->m_pkthdr.csum_flags & CSUM_IP) { + if (m->m_pkthdr.len < 38) { struct ip *ip; - m_head->m_data += ETHER_HDR_LEN; - ip = mtod(m_head, struct ip *); - ip->ip_sum = in_cksum(m_head, ip->ip_hl << 2); - m_head->m_data -= ETHER_HDR_LEN; + m->m_data += ETHER_HDR_LEN; + ip = mtod(m, struct ip *); + ip->ip_sum = in_cksum(m, ip->ip_hl << 2); + m->m_data -= ETHER_HDR_LEN; } else { txp->tx_cb->ipcb_ip_activation_high = FXP_IPCB_HARDWAREPARSING_ENABLE; @@ -1328,40 +1344,33 @@ fxp_encap(struct fxp_softc *sc, struct m #endif } - chainlen = 0; - for (m = m_head; m != NULL && chainlen <= sc->maxtxseg; m = m->m_next) - chainlen++; - if (chainlen > sc->maxtxseg) { - struct mbuf *mn; - - /* - * We ran out of segments. We have to recopy this - * mbuf chain first. Bail out if we can't get the - * new buffers. - */ - mn = m_defrag(m_head, M_DONTWAIT); - if (mn == NULL) { - m_freem(m_head); - return (-1); - } else { - m_head = mn; + error = bus_dmamap_load_mbuf_sg(sc->fxp_mtag, txp->tx_map, *m_head, + segs, &nseg, 0); + if (error == EFBIG) { + m = m_collapse(*m_head, M_DONTWAIT, sc->maxtxseg); + if (m == NULL) { + m_freem(*m_head); + *m_head = NULL; + return (ENOMEM); + } + *m_head = m; + error = bus_dmamap_load_mbuf_sg(sc->fxp_mtag, txp->tx_map, + *m_head, segs, &nseg, 0); + if (error != 0) { + m_freem(*m_head); + *m_head = NULL; + return (ENOMEM); } - } - - /* - * Go through each of the mbufs in the chain and initialize - * the transmit buffer descriptors with the physical address - * and size of the mbuf. - */ - error = bus_dmamap_load_mbuf_sg(sc->fxp_mtag, txp->tx_map, - m_head, segs, &nseg, 0); - if (error) { - device_printf(sc->dev, "can't map mbuf (error %d)\n", error); - m_freem(m_head); - return (-1); + } else if (error != 0) + return (error); + if (nseg == 0) { + m_freem(*m_head); + *m_head = NULL; + return (EIO); } KASSERT(nseg <= sc->maxtxseg, ("too many DMA segments")); + bus_dmamap_sync(sc->fxp_mtag, txp->tx_map, BUS_DMASYNC_PREWRITE); cbp = txp->tx_cb; for (i = 0; i < nseg; i++) { @@ -1389,24 +1398,17 @@ fxp_encap(struct fxp_softc *sc, struct m } cbp->tbd_number = nseg; - bus_dmamap_sync(sc->fxp_mtag, txp->tx_map, BUS_DMASYNC_PREWRITE); - txp->tx_mbuf = m_head; + txp->tx_mbuf = m; txp->tx_cb->cb_status = 0; txp->tx_cb->byte_count = 0; - if (sc->tx_queued != FXP_CXINT_THRESH - 1) { + if (sc->tx_queued != FXP_CXINT_THRESH - 1) txp->tx_cb->cb_command = htole16(sc->tx_cmd | FXP_CB_COMMAND_SF | FXP_CB_COMMAND_S); - } else { + else txp->tx_cb->cb_command = htole16(sc->tx_cmd | FXP_CB_COMMAND_SF | FXP_CB_COMMAND_S | FXP_CB_COMMAND_I); - /* - * Set a 5 second timer just in case we don't hear - * from the card again. - */ - sc->watchdog_timer = 5; - } txp->tx_cb->tx_threshold = tx_threshold; /* @@ -1439,10 +1441,6 @@ fxp_encap(struct fxp_softc *sc, struct m sc->tx_queued++; - /* - * Pass packet to bpf if there is a listener. - */ - BPF_MTAP(ifp, m_head); return (0); } @@ -1528,8 +1526,10 @@ fxp_intr(void *xsc) static void fxp_txeof(struct fxp_softc *sc) { + struct ifnet *ifp; struct fxp_tx *txp; + ifp = sc->ifp; bus_dmamap_sync(sc->cbl_tag, sc->cbl_map, BUS_DMASYNC_PREREAD); for (txp = sc->fxp_desc.tx_first; sc->tx_queued && (le16toh(txp->tx_cb->cb_status) & FXP_CB_STATUS_C) != 0; @@ -1544,6 +1544,7 @@ fxp_txeof(struct fxp_softc *sc) txp->tx_cb->tbd[0].tb_addr = 0; } sc->tx_queued--; + ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; } sc->fxp_desc.tx_first = txp; bus_dmamap_sync(sc->cbl_tag, sc->cbl_map, BUS_DMASYNC_PREWRITE); @@ -1589,15 +1590,14 @@ fxp_intr_body(struct fxp_softc *sc, stru * packets go out onto the wire for about 5 to 10 seconds * after the interface is ifconfig'ed for the first time. */ - if (statack & (FXP_SCB_STATACK_CXTNO | FXP_SCB_STATACK_CNA)) { + if (statack & (FXP_SCB_STATACK_CXTNO | FXP_SCB_STATACK_CNA)) fxp_txeof(sc); - /* - * Try to start more packets transmitting. - */ - if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd)) - fxp_start_body(ifp); - } + /* + * Try to start more packets transmitting. + */ + if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd)) + fxp_start_body(ifp); /* * Just return if nothing happened on the receive side. Modified: stable/7/sys/dev/fxp/if_fxpvar.h ============================================================================== --- stable/7/sys/dev/fxp/if_fxpvar.h Mon Feb 9 03:34:35 2009 (r188369) +++ stable/7/sys/dev/fxp/if_fxpvar.h Mon Feb 9 03:38:01 2009 (r188370) @@ -38,6 +38,7 @@ * This must be a power of two. */ #define FXP_NTXCB 128 +#define FXP_NTXCB_HIWAT ((FXP_NTXCB * 7) / 10) /* * Size of the TxCB list. From owner-svn-src-stable@FreeBSD.ORG Mon Feb 9 03:40:52 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 300D810656E8; Mon, 9 Feb 2009 03:40:52 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 1D3088FC16; Mon, 9 Feb 2009 03:40:52 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n193eqRA044022; Mon, 9 Feb 2009 03:40:52 GMT (envelope-from yongari@svn.freebsd.org) Received: (from yongari@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n193eq9A044021; Mon, 9 Feb 2009 03:40:52 GMT (envelope-from yongari@svn.freebsd.org) Message-Id: <200902090340.n193eq9A044021@svn.freebsd.org> From: Pyun YongHyeon Date: Mon, 9 Feb 2009 03:40:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r188371 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb dev/fxp X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Feb 2009 03:40:53 -0000 Author: yongari Date: Mon Feb 9 03:40:51 2009 New Revision: 188371 URL: http://svn.freebsd.org/changeset/base/188371 Log: MFC r185286: Simplify Tx checksum offload configuration. Also clear CSUM_IP if we've computed IP checksum with software method. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/dev/fxp/if_fxp.c Modified: stable/7/sys/dev/fxp/if_fxp.c ============================================================================== --- stable/7/sys/dev/fxp/if_fxp.c Mon Feb 9 03:38:01 2009 (r188370) +++ stable/7/sys/dev/fxp/if_fxp.c Mon Feb 9 03:40:51 2009 (r188371) @@ -1295,14 +1295,10 @@ fxp_encap(struct fxp_softc *sc, struct m * in the TCP header. The stack should have * already done this for us. */ - if (m->m_pkthdr.csum_flags) { - if (m->m_pkthdr.csum_flags & CSUM_DELAY_DATA) { - txp->tx_cb->ipcb_ip_schedule = - FXP_IPCB_TCPUDP_CHECKSUM_ENABLE; - if (m->m_pkthdr.csum_flags & CSUM_TCP) - txp->tx_cb->ipcb_ip_schedule |= - FXP_IPCB_TCP_PACKET; - } + if (m->m_pkthdr.csum_flags & FXP_CSUM_FEATURES) { + txp->tx_cb->ipcb_ip_schedule = FXP_IPCB_TCPUDP_CHECKSUM_ENABLE; + if (m->m_pkthdr.csum_flags & CSUM_TCP) + txp->tx_cb->ipcb_ip_schedule |= FXP_IPCB_TCP_PACKET; #ifdef FXP_IP_CSUM_WAR /* @@ -1334,6 +1330,7 @@ fxp_encap(struct fxp_softc *sc, struct m ip = mtod(m, struct ip *); ip->ip_sum = in_cksum(m, ip->ip_hl << 2); m->m_data -= ETHER_HDR_LEN; + m->m_pkthdr.csum_flags &= ~CSUM_IP; } else { txp->tx_cb->ipcb_ip_activation_high = FXP_IPCB_HARDWAREPARSING_ENABLE; From owner-svn-src-stable@FreeBSD.ORG Mon Feb 9 03:43:47 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 30E3C106567F; Mon, 9 Feb 2009 03:43:47 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 1D7048FC1D; Mon, 9 Feb 2009 03:43:47 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n193hlqG044114; Mon, 9 Feb 2009 03:43:47 GMT (envelope-from yongari@svn.freebsd.org) Received: (from yongari@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n193hltc044113; Mon, 9 Feb 2009 03:43:47 GMT (envelope-from yongari@svn.freebsd.org) Message-Id: <200902090343.n193hltc044113@svn.freebsd.org> From: Pyun YongHyeon Date: Mon, 9 Feb 2009 03:43:46 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r188372 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb dev/fxp X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Feb 2009 03:43:47 -0000 Author: yongari Date: Mon Feb 9 03:43:46 2009 New Revision: 188372 URL: http://svn.freebsd.org/changeset/base/188372 Log: MFC r185328: o Introduce a new function, fxp_new_rfabuf which allocates a new Rx buffer and loads DMA map. Also add a function fxp_discard_rfabuf that handles reusing Rx buffer/DMA map. With this change fxp_add_rfabuf just handles appending a new RFA to existing chain. o Initialize mbuf length in fxp_new_rfabuf. o Don't reset rnr and have fxp(4) handle received frames even if it couldn't allocate new Rx buffer. This will make fxp(4) reload updated RFA under rnr case. The rnr would still be reset to 0 if polling is active and fxp(4) processed number of allowed Rx events. o Update if_iqdrops if fxp(4) couldn't allocate Rx buffer. Previously fxp(4) used to try to reuse Rx buffer when new buffer allocation is failed. But fxp(4) didn't take into account loaded DMA map such that the same DMA map was loaded again without unloading the map. There is no reason to unload the loaded map and reload the same map again, just reusing the map is enough. I believe the spare DMA map in softc was introduced to implement this behaviour. Also fxp(4) used to stop Rx processing if once Rx buffer allocation or DMA map load fails which in turn resulted in losing incoming frames under heavy network load. With this change fxp(4) should survive from resource shortage condition. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/dev/fxp/if_fxp.c Modified: stable/7/sys/dev/fxp/if_fxp.c ============================================================================== --- stable/7/sys/dev/fxp/if_fxp.c Mon Feb 9 03:40:51 2009 (r188371) +++ stable/7/sys/dev/fxp/if_fxp.c Mon Feb 9 03:43:46 2009 (r188372) @@ -227,8 +227,12 @@ static void fxp_release(struct fxp_sof static int fxp_ioctl(struct ifnet *ifp, u_long command, caddr_t data); static void fxp_watchdog(struct fxp_softc *sc); -static int fxp_add_rfabuf(struct fxp_softc *sc, - struct fxp_rx *rxp, struct mbuf *oldm); +static void fxp_add_rfabuf(struct fxp_softc *sc, + struct fxp_rx *rxp); +static void fxp_discard_rfabuf(struct fxp_softc *sc, + struct fxp_rx *rxp); +static int fxp_new_rfabuf(struct fxp_softc *sc, + struct fxp_rx *rxp); static int fxp_mc_addrs(struct fxp_softc *sc); static void fxp_mc_setup(struct fxp_softc *sc); static uint16_t fxp_eeprom_getword(struct fxp_softc *sc, int offset, @@ -712,10 +716,11 @@ fxp_attach(device_t dev) device_printf(dev, "can't create DMA map for RX\n"); goto fail; } - if (fxp_add_rfabuf(sc, rxp, NULL) != 0) { + if (fxp_new_rfabuf(sc, rxp) != 0) { error = ENOMEM; goto fail; } + fxp_add_rfabuf(sc, rxp); } /* @@ -1560,7 +1565,6 @@ fxp_intr_body(struct fxp_softc *sc, stru struct fxp_rx *rxp; struct fxp_rfa *rfa; int rnr = (statack & FXP_SCB_STATACK_RNR) ? 1 : 0; - int fxp_rc = 0; uint16_t status; FXP_LOCK_ASSERT(sc, MA_OWNED); @@ -1647,8 +1651,7 @@ fxp_intr_body(struct fxp_softc *sc, stru * If this fails, the old buffer is recycled * instead. */ - fxp_rc = fxp_add_rfabuf(sc, rxp, m); - if (fxp_rc == 0) { + if (fxp_new_rfabuf(sc, rxp) == 0) { int total_len; /* @@ -1700,10 +1703,12 @@ fxp_intr_body(struct fxp_softc *sc, stru FXP_UNLOCK(sc); (*ifp->if_input)(ifp, m); FXP_LOCK(sc); - } else if (fxp_rc == ENOBUFS) { - rnr = 0; - break; + } else { + /* Reuse RFA and loaded DMA map. */ + ifp->if_iqdrops++; + fxp_discard_rfabuf(sc, rxp); } + fxp_add_rfabuf(sc, rxp); } if (rnr) { fxp_scb_wait(sc); @@ -2234,32 +2239,21 @@ fxp_ifmedia_sts(struct ifnet *ifp, struc /* * Add a buffer to the end of the RFA buffer list. * Return 0 if successful, 1 for failure. A failure results in - * adding the 'oldm' (if non-NULL) on to the end of the list - - * tossing out its old contents and recycling it. + * reusing the RFA buffer. * The RFA struct is stuck at the beginning of mbuf cluster and the * data pointer is fixed up to point just past it. */ static int -fxp_add_rfabuf(struct fxp_softc *sc, struct fxp_rx *rxp, struct mbuf *oldm) +fxp_new_rfabuf(struct fxp_softc *sc, struct fxp_rx *rxp) { struct mbuf *m; - struct fxp_rfa *rfa, *p_rfa; - struct fxp_rx *p_rx; + struct fxp_rfa *rfa; bus_dmamap_t tmp_map; - int error, reused_mbuf=0; + int error; m = m_getcl(M_DONTWAIT, MT_DATA, M_PKTHDR); - if (m == NULL) { - if (oldm == NULL) - return ENOBUFS; - m = oldm; - m->m_data = m->m_ext.ext_buf; - /* - * return error so the receive loop will - * not pass the packet to upper layer - */ - reused_mbuf = EAGAIN; - } + if (m == NULL) + return (ENOBUFS); /* * Move the data pointer up so that the incoming data packet @@ -2278,6 +2272,8 @@ fxp_add_rfabuf(struct fxp_softc *sc, str rfa->rfa_status = 0; rfa->rfa_control = htole16(FXP_RFA_CONTROL_EL); rfa->actual_size = 0; + m->m_len = m->m_pkthdr.len = MCLBYTES - RFA_ALIGNMENT_FUDGE - + sc->rfa_size; /* * Initialize the rest of the RFA. Note that since the RFA @@ -2305,6 +2301,14 @@ fxp_add_rfabuf(struct fxp_softc *sc, str bus_dmamap_sync(sc->fxp_mtag, rxp->rx_map, BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE); + return (0); +} + +static void +fxp_add_rfabuf(struct fxp_softc *sc, struct fxp_rx *rxp) +{ + struct fxp_rfa *p_rfa; + struct fxp_rx *p_rx; /* * If there are other buffers already on the list, attach this @@ -2324,7 +2328,45 @@ fxp_add_rfabuf(struct fxp_softc *sc, str sc->fxp_desc.rx_head = rxp; } sc->fxp_desc.rx_tail = rxp; - return (reused_mbuf); +} + +static void +fxp_discard_rfabuf(struct fxp_softc *sc, struct fxp_rx *rxp) +{ + struct mbuf *m; + struct fxp_rfa *rfa; + + m = rxp->rx_mbuf; + m->m_data = m->m_ext.ext_buf; + /* + * Move the data pointer up so that the incoming data packet + * will be 32-bit aligned. + */ + m->m_data += RFA_ALIGNMENT_FUDGE; + + /* + * Get a pointer to the base of the mbuf cluster and move + * data start past it. + */ + rfa = mtod(m, struct fxp_rfa *); + m->m_data += sc->rfa_size; + rfa->size = htole16(MCLBYTES - sc->rfa_size - RFA_ALIGNMENT_FUDGE); + + rfa->rfa_status = 0; + rfa->rfa_control = htole16(FXP_RFA_CONTROL_EL); + rfa->actual_size = 0; + + /* + * Initialize the rest of the RFA. Note that since the RFA + * is misaligned, we cannot store values directly. We're thus + * using the le32enc() function which handles endianness and + * is also alignment-safe. + */ + le32enc(&rfa->link_addr, 0xffffffff); + le32enc(&rfa->rbd_addr, 0xffffffff); + + bus_dmamap_sync(sc->fxp_mtag, rxp->rx_map, + BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE); } static int From owner-svn-src-stable@FreeBSD.ORG Mon Feb 9 03:46:15 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 668511065670; Mon, 9 Feb 2009 03:46:15 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 52BC78FC14; Mon, 9 Feb 2009 03:46:15 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n193kFgJ044229; Mon, 9 Feb 2009 03:46:15 GMT (envelope-from yongari@svn.freebsd.org) Received: (from yongari@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n193kFN1044227; Mon, 9 Feb 2009 03:46:15 GMT (envelope-from yongari@svn.freebsd.org) Message-Id: <200902090346.n193kFN1044227@svn.freebsd.org> From: Pyun YongHyeon Date: Mon, 9 Feb 2009 03:46:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r188373 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb dev/fxp X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Feb 2009 03:46:16 -0000 Author: yongari Date: Mon Feb 9 03:46:15 2009 New Revision: 188373 URL: http://svn.freebsd.org/changeset/base/188373 Log: MFC r185329: Implement Rx checksum offload for 82559 or later controllers. 82559 or later controllers added simple checksum calculation logic in RU. For backward compatibility the computed checksum is appended at the end of the data posted to Rx buffer. This type of simple checksum calculation support had been used on several vendors such as Sun HME/GEM, SysKonnect GENESIS and Marvell Yukon controllers. Because this type of checksum offload support requires parsing of received frame and pseudo checksum calculation with software routine it still consumes more CPU cycles than that of full-fledged checksum offload controller. But it's still better than software checksum calculation. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/dev/fxp/if_fxp.c stable/7/sys/dev/fxp/if_fxpvar.h Modified: stable/7/sys/dev/fxp/if_fxp.c ============================================================================== --- stable/7/sys/dev/fxp/if_fxp.c Mon Feb 9 03:43:46 2009 (r188372) +++ stable/7/sys/dev/fxp/if_fxp.c Mon Feb 9 03:46:15 2009 (r188373) @@ -59,15 +59,15 @@ __FBSDID("$FreeBSD$"); #include #include -#include -#include - -#ifdef FXP_IP_CSUM_WAR #include #include #include +#include +#include + +#include #include -#endif +#include #include #include /* for PCIM_CMD_xxx */ @@ -213,6 +213,8 @@ static int fxp_suspend(device_t dev); static int fxp_resume(device_t dev); static void fxp_intr(void *xsc); +static void fxp_rxcsum(struct fxp_softc *sc, struct ifnet *ifp, + struct mbuf *m, uint16_t status, int pos); static void fxp_intr_body(struct fxp_softc *sc, struct ifnet *ifp, uint8_t statack, int count); static void fxp_init(void *xsc); @@ -591,6 +593,9 @@ fxp_attach(device_t dev) sc->flags |= FXP_FLAG_SAVE_BAD; } + /* For 82559 or later chips, Rx checksum offload is supported. */ + if (sc->revision >= FXP_REV_82559_A0) + sc->flags |= FXP_FLAG_82559_RXCSUM; /* * Enable use of extended RFDs and TCBs for 82550 * and later chips. Note: we need extended TXCB support @@ -603,6 +608,8 @@ fxp_attach(device_t dev) sc->rfa_size = sizeof (struct fxp_rfa); sc->tx_cmd = FXP_CB_COMMAND_IPCBXMIT; sc->flags |= FXP_FLAG_EXT_RFA; + /* Use extended RFA instead of 82559 checksum mode. */ + sc->flags &= ~FXP_FLAG_82559_RXCSUM; } else { sc->rfa_size = sizeof (struct fxp_rfa) - FXP_RFAX_LEN; sc->tx_cmd = FXP_CB_COMMAND_XMIT; @@ -780,6 +787,11 @@ fxp_attach(device_t dev) ifp->if_capenable |= IFCAP_HWCSUM; } + if (sc->flags & FXP_FLAG_82559_RXCSUM) { + ifp->if_capabilities |= IFCAP_RXCSUM; + ifp->if_capenable |= IFCAP_RXCSUM; + } + #ifdef DEVICE_POLLING /* Inform the world we support polling. */ ifp->if_capabilities |= IFCAP_POLLING; @@ -1558,6 +1570,84 @@ fxp_txeof(struct fxp_softc *sc) } static void +fxp_rxcsum(struct fxp_softc *sc, struct ifnet *ifp, struct mbuf *m, + uint16_t status, int pos) +{ + struct ether_header *eh; + struct ip *ip; + struct udphdr *uh; + int32_t hlen, len, pktlen, temp32; + uint16_t csum, *opts; + + if ((sc->flags & FXP_FLAG_82559_RXCSUM) == 0) { + if ((status & FXP_RFA_STATUS_PARSE) != 0) { + if (status & FXP_RFDX_CS_IP_CSUM_BIT_VALID) + m->m_pkthdr.csum_flags |= CSUM_IP_CHECKED; + if (status & FXP_RFDX_CS_IP_CSUM_VALID) + m->m_pkthdr.csum_flags |= CSUM_IP_VALID; + if ((status & FXP_RFDX_CS_TCPUDP_CSUM_BIT_VALID) && + (status & FXP_RFDX_CS_TCPUDP_CSUM_VALID)) { + m->m_pkthdr.csum_flags |= CSUM_DATA_VALID | + CSUM_PSEUDO_HDR; + m->m_pkthdr.csum_data = 0xffff; + } + } + return; + } + + pktlen = m->m_pkthdr.len; + if (pktlen < sizeof(struct ether_header) + sizeof(struct ip)) + return; + eh = mtod(m, struct ether_header *); + if (eh->ether_type != htons(ETHERTYPE_IP)) + return; + ip = (struct ip *)(eh + 1); + if (ip->ip_v != IPVERSION) + return; + + hlen = ip->ip_hl << 2; + pktlen -= sizeof(struct ether_header); + if (hlen < sizeof(struct ip)) + return; + if (ntohs(ip->ip_len) < hlen) + return; + if (ntohs(ip->ip_len) != pktlen) + return; + if (ip->ip_off & htons(IP_MF | IP_OFFMASK)) + return; /* can't handle fragmented packet */ + + switch (ip->ip_p) { + case IPPROTO_TCP: + if (pktlen < (hlen + sizeof(struct tcphdr))) + return; + break; + case IPPROTO_UDP: + if (pktlen < (hlen + sizeof(struct udphdr))) + return; + uh = (struct udphdr *)((caddr_t)ip + hlen); + if (uh->uh_sum == 0) + return; /* no checksum */ + break; + default: + return; + } + /* Extract computed checksum. */ + csum = be16dec(mtod(m, char *) + pos); + /* checksum fixup for IP options */ + len = hlen - sizeof(struct ip); + if (len > 0) { + opts = (uint16_t *)(ip + 1); + for (; len > 0; len -= sizeof(uint16_t), opts++) { + temp32 = csum - *opts; + temp32 = (temp32 >> 16) + (temp32 & 65535); + csum = temp32 & 65535; + } + } + m->m_pkthdr.csum_flags |= CSUM_DATA_VALID; + m->m_pkthdr.csum_data = csum; +} + +static void fxp_intr_body(struct fxp_softc *sc, struct ifnet *ifp, uint8_t statack, int count) { @@ -1661,6 +1751,11 @@ fxp_intr_body(struct fxp_softc *sc, stru * of bogus length or CRC errors. */ total_len = le16toh(rfa->actual_size) & 0x3fff; + if ((sc->flags & FXP_FLAG_82559_RXCSUM) != 0 && + (ifp->if_capenable & IFCAP_RXCSUM) != 0) { + /* Adjust for appended checksum bytes. */ + total_len -= 2; + } if (total_len < sizeof(struct ether_header) || total_len > MCLBYTES - RFA_ALIGNMENT_FUDGE - sc->rfa_size || status & FXP_RFA_STATUS_CRC) { @@ -1668,30 +1763,12 @@ fxp_intr_body(struct fxp_softc *sc, stru continue; } - /* Do IP checksum checking. */ - if ((ifp->if_capenable & IFCAP_RXCSUM) != 0 && - (status & FXP_RFA_STATUS_PARSE)) { - if (rfa->rfax_csum_sts & - FXP_RFDX_CS_IP_CSUM_BIT_VALID) - m->m_pkthdr.csum_flags |= - CSUM_IP_CHECKED; - if (rfa->rfax_csum_sts & - FXP_RFDX_CS_IP_CSUM_VALID) - m->m_pkthdr.csum_flags |= - CSUM_IP_VALID; - if ((rfa->rfax_csum_sts & - FXP_RFDX_CS_TCPUDP_CSUM_BIT_VALID) && - (rfa->rfax_csum_sts & - FXP_RFDX_CS_TCPUDP_CSUM_VALID)) { - m->m_pkthdr.csum_flags |= - CSUM_DATA_VALID|CSUM_PSEUDO_HDR; - m->m_pkthdr.csum_data = 0xffff; - } - } - m->m_pkthdr.len = m->m_len = total_len; m->m_pkthdr.rcvif = ifp; + /* Do IP checksum checking. */ + if ((ifp->if_capenable & IFCAP_RXCSUM) != 0) + fxp_rxcsum(sc, ifp, m, status, total_len); /* * Drop locks before calling if_input() since it * may re-enter fxp_start() in the netisr case. @@ -2024,7 +2101,8 @@ fxp_init_body(struct fxp_softc *sc) cbp->ext_rfa = sc->flags & FXP_FLAG_EXT_RFA ? 1 : 0; cbp->mediatype = sc->flags & FXP_FLAG_SERIAL_MEDIA ? 0 : 1; cbp->csma_dis = 0; /* (don't) disable link */ - cbp->tcp_udp_cksum = 0; /* (don't) enable checksum */ + cbp->tcp_udp_cksum = ((sc->flags & FXP_FLAG_82559_RXCSUM) != 0 && + (ifp->if_capenable & IFCAP_RXCSUM) != 0) ? 1 : 0; cbp->vlan_tco = 0; /* (don't) enable vlan wakeup */ cbp->link_wake_en = 0; /* (don't) assert PME# on link change */ cbp->arp_wake_en = 0; /* (don't) assert PME# on arp */ @@ -2506,8 +2584,11 @@ fxp_ioctl(struct ifnet *ifp, u_long comm ifp->if_hwassist &= ~FXP_CSUM_FEATURES; } if ((mask & IFCAP_RXCSUM) != 0 && - (ifp->if_capabilities & IFCAP_RXCSUM) != 0) + (ifp->if_capabilities & IFCAP_RXCSUM) != 0) { ifp->if_capenable ^= IFCAP_RXCSUM; + if ((sc->flags & FXP_FLAG_82559_RXCSUM) != 0) + reinit++; + } if ((mask & IFCAP_VLAN_MTU) != 0 && (ifp->if_capabilities & IFCAP_VLAN_MTU) != 0) { ifp->if_capenable ^= IFCAP_VLAN_MTU; Modified: stable/7/sys/dev/fxp/if_fxpvar.h ============================================================================== --- stable/7/sys/dev/fxp/if_fxpvar.h Mon Feb 9 03:43:46 2009 (r188372) +++ stable/7/sys/dev/fxp/if_fxpvar.h Mon Feb 9 03:46:15 2009 (r188373) @@ -194,6 +194,7 @@ struct fxp_softc { #define FXP_FLAG_DEFERRED_RNR 0x0200 /* DEVICE_POLLING deferred RNR */ #define FXP_FLAG_EXT_RFA 0x0400 /* extended RFDs for csum offload */ #define FXP_FLAG_SAVE_BAD 0x0800 /* save bad pkts: bad size, CRC, etc */ +#define FXP_FLAG_82559_RXCSUM 0x1000 /* 82559 compatible RX checksum */ /* Macros to ease CSR access. */ #define CSR_READ_1(sc, reg) bus_read_1(sc->fxp_res[0], reg) From owner-svn-src-stable@FreeBSD.ORG Mon Feb 9 03:48:49 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id DE7521065670; Mon, 9 Feb 2009 03:48:49 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id CA9B18FC12; Mon, 9 Feb 2009 03:48:49 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n193mnap044321; Mon, 9 Feb 2009 03:48:49 GMT (envelope-from yongari@svn.freebsd.org) Received: (from yongari@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n193mnDw044318; Mon, 9 Feb 2009 03:48:49 GMT (envelope-from yongari@svn.freebsd.org) Message-Id: <200902090348.n193mnDw044318@svn.freebsd.org> From: Pyun YongHyeon Date: Mon, 9 Feb 2009 03:48:49 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r188374 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb dev/fxp X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Feb 2009 03:48:50 -0000 Author: yongari Date: Mon Feb 9 03:48:49 2009 New Revision: 188374 URL: http://svn.freebsd.org/changeset/base/188374 Log: MFC r185330: Implement TSO for 82550/82551 controllers. o Configure controller to use dynamic TBD as TSO requires that operation mode. o Add a dummy TBD to tx_cb_u as TSO can access one more TBD in TSO operation. o Increase a DMA segment size to 4096 to hold a full IP segment with link layer header. o Unlike other TSO capable controllers, 82550/82551 does not modify the first IP packet in TSO operation so driver should create an IP packet with proper header. Subsequent IP packets are generated from the header information in the first IP packet header. Likewise pseudo checksum also should be computed by driver for the first packet. o TSO requires one more TBD to hold total TCP payload. To make code simple for TSO/non-TSO case, increase the index of the first available TBD array. o Remove KASSERT that checks the size of a DMA segment should be less than or equal to MCLBYTES as it's no longer valid in TSO. o Tx threshold and number of TBDs field is used to store MSS in TSO. So don't set the Tx threshold in TSO case. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/dev/fxp/if_fxp.c stable/7/sys/dev/fxp/if_fxpreg.h stable/7/sys/dev/fxp/if_fxpvar.h Modified: stable/7/sys/dev/fxp/if_fxp.c ============================================================================== --- stable/7/sys/dev/fxp/if_fxp.c Mon Feb 9 03:46:15 2009 (r188373) +++ stable/7/sys/dev/fxp/if_fxp.c Mon Feb 9 03:48:49 2009 (r188374) @@ -619,11 +619,15 @@ fxp_attach(device_t dev) * Allocate DMA tags and DMA safe memory. */ sc->maxtxseg = FXP_NTXSEG; - if (sc->flags & FXP_FLAG_EXT_RFA) + sc->maxsegsize = MCLBYTES; + if (sc->flags & FXP_FLAG_EXT_RFA) { sc->maxtxseg--; + sc->maxsegsize = FXP_TSO_SEGSIZE; + } error = bus_dma_tag_create(bus_get_dma_tag(dev), 2, 0, BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, - MCLBYTES * sc->maxtxseg, sc->maxtxseg, MCLBYTES, 0, + sc->maxsegsize * sc->maxtxseg + sizeof(struct ether_vlan_header), + sc->maxtxseg, sc->maxsegsize, 0, busdma_lock_mutex, &Giant, &sc->fxp_mtag); if (error) { device_printf(dev, "could not allocate dma tag\n"); @@ -780,11 +784,11 @@ fxp_attach(device_t dev) ifp->if_capabilities = ifp->if_capenable = 0; - /* Enable checksum offload for 82550 or better chips */ + /* Enable checksum offload/TSO for 82550 or better chips */ if (sc->flags & FXP_FLAG_EXT_RFA) { - ifp->if_hwassist = FXP_CSUM_FEATURES; - ifp->if_capabilities |= IFCAP_HWCSUM; - ifp->if_capenable |= IFCAP_HWCSUM; + ifp->if_hwassist = FXP_CSUM_FEATURES | CSUM_TSO; + ifp->if_capabilities |= IFCAP_HWCSUM | IFCAP_TSO4; + ifp->if_capenable |= IFCAP_HWCSUM | IFCAP_TSO4; } if (sc->flags & FXP_FLAG_82559_RXCSUM) { @@ -1275,12 +1279,15 @@ fxp_encap(struct fxp_softc *sc, struct m struct mbuf *m; struct fxp_tx *txp; struct fxp_cb_tx *cbp; + struct tcphdr *tcp; bus_dma_segment_t segs[FXP_NTXSEG]; - int error, i, nseg; + int error, i, nseg, tcp_payload; FXP_LOCK_ASSERT(sc, MA_OWNED); ifp = sc->ifp; + tcp_payload = 0; + tcp = NULL; /* * Get pointer to next available tx desc. */ @@ -1358,6 +1365,75 @@ fxp_encap(struct fxp_softc *sc, struct m #endif } + if (m->m_pkthdr.csum_flags & CSUM_TSO) { + /* + * 82550/82551 requires ethernet/IP/TCP headers must be + * contained in the first active transmit buffer. + */ + struct ether_header *eh; + struct ip *ip; + uint32_t ip_off, poff; + + if (M_WRITABLE(*m_head) == 0) { + /* Get a writable copy. */ + m = m_dup(*m_head, M_DONTWAIT); + m_freem(*m_head); + if (m == NULL) { + *m_head = NULL; + return (ENOBUFS); + } + *m_head = m; + } + ip_off = sizeof(struct ether_header); + m = m_pullup(*m_head, ip_off); + if (m == NULL) { + *m_head = NULL; + return (ENOBUFS); + } + eh = mtod(m, struct ether_header *); + /* Check the existence of VLAN tag. */ + if (eh->ether_type == htons(ETHERTYPE_VLAN)) { + ip_off = sizeof(struct ether_vlan_header); + m = m_pullup(m, ip_off); + if (m == NULL) { + *m_head = NULL; + return (ENOBUFS); + } + } + m = m_pullup(m, ip_off + sizeof(struct ip)); + if (m == NULL) { + *m_head = NULL; + return (ENOBUFS); + } + ip = (struct ip *)(mtod(m, char *) + ip_off); + poff = ip_off + (ip->ip_hl << 2); + m = m_pullup(m, poff + sizeof(struct tcphdr)); + if (m == NULL) { + *m_head = NULL; + return (ENOBUFS); + } + tcp = (struct tcphdr *)(mtod(m, char *) + poff); + m = m_pullup(m, poff + sizeof(struct tcphdr) + tcp->th_off); + if (m == NULL) { + *m_head = NULL; + return (ENOBUFS); + } + + /* + * Since 82550/82551 doesn't modify IP length and pseudo + * checksum in the first frame driver should compute it. + */ + ip->ip_sum = 0; + ip->ip_len = htons(ifp->if_mtu); + tcp->th_sum = in_pseudo(ip->ip_src.s_addr, ip->ip_dst.s_addr, + htons(IPPROTO_TCP + (tcp->th_off << 2) + + m->m_pkthdr.tso_segsz)); + /* Compute total TCP payload. */ + tcp_payload = m->m_pkthdr.len - ip_off - (ip->ip_hl << 2); + tcp_payload -= tcp->th_off << 2; + *m_head = m; + } + error = bus_dmamap_load_mbuf_sg(sc->fxp_mtag, txp->tx_map, *m_head, segs, &nseg, 0); if (error == EFBIG) { @@ -1388,7 +1464,6 @@ fxp_encap(struct fxp_softc *sc, struct m cbp = txp->tx_cb; for (i = 0; i < nseg; i++) { - KASSERT(segs[i].ds_len <= MCLBYTES, ("segment size too large")); /* * If this is an 82550/82551, then we're using extended * TxCBs _and_ we're using checksum offload. This means @@ -1403,14 +1478,28 @@ fxp_encap(struct fxp_softc *sc, struct m * the chip is an 82550/82551 or not. */ if (sc->flags & FXP_FLAG_EXT_RFA) { - cbp->tbd[i + 1].tb_addr = htole32(segs[i].ds_addr); - cbp->tbd[i + 1].tb_size = htole32(segs[i].ds_len); + cbp->tbd[i + 2].tb_addr = htole32(segs[i].ds_addr); + cbp->tbd[i + 2].tb_size = htole32(segs[i].ds_len); } else { cbp->tbd[i].tb_addr = htole32(segs[i].ds_addr); cbp->tbd[i].tb_size = htole32(segs[i].ds_len); } } - cbp->tbd_number = nseg; + if (sc->flags & FXP_FLAG_EXT_RFA) { + /* Configure dynamic TBD for 82550/82551. */ + cbp->tbd_number = 0xFF; + cbp->tbd[nseg + 1].tb_size |= htole32(0x8000); + } else + cbp->tbd_number = nseg; + /* Configure TSO. */ + if (m->m_pkthdr.csum_flags & CSUM_TSO) { + cbp->tbd[-1].tb_size = htole32(m->m_pkthdr.tso_segsz << 16); + cbp->tbd[1].tb_size = htole32(tcp_payload << 16); + cbp->ipcb_ip_schedule |= FXP_IPCB_LARGESEND_ENABLE | + FXP_IPCB_IP_CHECKSUM_ENABLE | + FXP_IPCB_TCP_PACKET | + FXP_IPCB_TCPUDP_CHECKSUM_ENABLE; + } txp->tx_mbuf = m; txp->tx_cb->cb_status = 0; @@ -1423,7 +1512,8 @@ fxp_encap(struct fxp_softc *sc, struct m txp->tx_cb->cb_command = htole16(sc->tx_cmd | FXP_CB_COMMAND_SF | FXP_CB_COMMAND_S | FXP_CB_COMMAND_I); - txp->tx_cb->tx_threshold = tx_threshold; + if ((m->m_pkthdr.csum_flags & CSUM_TSO) == 0) + txp->tx_cb->tx_threshold = tx_threshold; /* * Advance the end of list forward. @@ -2097,7 +2187,7 @@ fxp_init_body(struct fxp_softc *sc) cbp->disc_short_rx = !prm; /* discard short packets */ cbp->underrun_retry = 1; /* retry mode (once) on DMA underrun */ cbp->two_frames = 0; /* do not limit FIFO to 2 frames */ - cbp->dyn_tbd = 0; /* (no) dynamic TBD mode */ + cbp->dyn_tbd = sc->flags & FXP_FLAG_EXT_RFA ? 1 : 0; cbp->ext_rfa = sc->flags & FXP_FLAG_EXT_RFA ? 1 : 0; cbp->mediatype = sc->flags & FXP_FLAG_SERIAL_MEDIA ? 0 : 1; cbp->csma_dis = 0; /* (don't) disable link */ @@ -2589,6 +2679,14 @@ fxp_ioctl(struct ifnet *ifp, u_long comm if ((sc->flags & FXP_FLAG_82559_RXCSUM) != 0) reinit++; } + if ((mask & IFCAP_TSO4) != 0 && + (ifp->if_capabilities & IFCAP_TSO4) != 0) { + ifp->if_capenable ^= IFCAP_TSO4; + if ((ifp->if_capenable & IFCAP_TSO4) != 0) + ifp->if_hwassist |= CSUM_TSO; + else + ifp->if_hwassist &= ~CSUM_TSO; + } if ((mask & IFCAP_VLAN_MTU) != 0 && (ifp->if_capabilities & IFCAP_VLAN_MTU) != 0) { ifp->if_capenable ^= IFCAP_VLAN_MTU; Modified: stable/7/sys/dev/fxp/if_fxpreg.h ============================================================================== --- stable/7/sys/dev/fxp/if_fxpreg.h Mon Feb 9 03:46:15 2009 (r188373) +++ stable/7/sys/dev/fxp/if_fxpreg.h Mon Feb 9 03:48:49 2009 (r188374) @@ -292,7 +292,7 @@ struct fxp_cb_tx { */ union { struct fxp_ipcb ipcb; - struct fxp_tbd tbd[FXP_NTXSEG]; + struct fxp_tbd tbd[FXP_NTXSEG + 1]; } tx_cb_u; }; Modified: stable/7/sys/dev/fxp/if_fxpvar.h ============================================================================== --- stable/7/sys/dev/fxp/if_fxpvar.h Mon Feb 9 03:46:15 2009 (r188373) +++ stable/7/sys/dev/fxp/if_fxpvar.h Mon Feb 9 03:48:49 2009 (r188374) @@ -41,6 +41,11 @@ #define FXP_NTXCB_HIWAT ((FXP_NTXCB * 7) / 10) /* + * Maximum size of a DMA segment. + */ +#define FXP_TSO_SEGSIZE 4096 + +/* * Size of the TxCB list. */ #define FXP_TXCB_SZ (FXP_NTXCB * sizeof(struct fxp_cb_tx)) @@ -157,6 +162,7 @@ struct fxp_softc { bus_dmamap_t spare_map; /* spare DMA map */ struct fxp_desc_list fxp_desc; /* descriptors management struct */ int maxtxseg; /* maximum # of TX segments */ + int maxsegsize; /* maximum size of a TX segment */ int tx_queued; /* # of active TxCB's */ int need_mcsetup; /* multicast filter needs programming */ struct fxp_stats *fxp_stats; /* Pointer to interface stats */ From owner-svn-src-stable@FreeBSD.ORG Mon Feb 9 03:53:21 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id F0DF8106566B; Mon, 9 Feb 2009 03:53:20 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id DD3468FC08; Mon, 9 Feb 2009 03:53:20 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n193rKIH044454; Mon, 9 Feb 2009 03:53:20 GMT (envelope-from yongari@svn.freebsd.org) Received: (from yongari@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n193rKkw044451; Mon, 9 Feb 2009 03:53:20 GMT (envelope-from yongari@svn.freebsd.org) Message-Id: <200902090353.n193rKkw044451@svn.freebsd.org> From: Pyun YongHyeon Date: Mon, 9 Feb 2009 03:53:20 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r188375 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb dev/fxp X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Feb 2009 03:53:21 -0000 Author: yongari Date: Mon Feb 9 03:53:20 2009 New Revision: 188375 URL: http://svn.freebsd.org/changeset/base/188375 Log: MFC r185354,185538: r185354: Add basic WOL support for 82550/82551/82558 and 82559 based controllers. ICH based controllers are treated as 82559. 82557, earlier revision of 82558 and 82559ER have no WOL capability. o WOL support requires help of a firmware so add check whether hardware is capable of handling magic frames by reading EEPROM. o Enable accepting WOL frames only when hardware is about to suspend or shutdown. Previously fxp(4) used to allow receipt of magic frame under normal operation mode which could cause hardware hang if magic frame is received by hardware. Datasheet clearly states driver should not allow WOL frames under normal operation mode. o Disable WOL frame reception in device attach so have fxp(4) immunize against system hang which can be triggered by magic packets when the hardware is not in fully initialized state. o Don't reset all hardware configuration data in fxp_stop() otherwise important configuration data is lost and this would reset WOL configuration to default state which in turn cause hardware hang on receipt of magic frames. To fix the issue, preserve hardware configuration data by issuing a selective reset. o Explicitly disable interrupts after issuing selective reset as reset may unmask interrupts. r185538: Make sure to clear PMDR register by writing back power management events. Just reading PMDR register was not enough to have fxp(4) immuninize against received magic packets during system boot. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/dev/fxp/if_fxp.c stable/7/sys/dev/fxp/if_fxpreg.h stable/7/sys/dev/fxp/if_fxpvar.h Modified: stable/7/sys/dev/fxp/if_fxp.c ============================================================================== --- stable/7/sys/dev/fxp/if_fxp.c Mon Feb 9 03:48:49 2009 (r188374) +++ stable/7/sys/dev/fxp/if_fxp.c Mon Feb 9 03:53:20 2009 (r188375) @@ -405,7 +405,7 @@ fxp_attach(device_t dev) uint32_t val; uint16_t data, myea[ETHER_ADDR_LEN / 2]; u_char eaddr[ETHER_ADDR_LEN]; - int i, prefer_iomap; + int i, pmc, prefer_iomap; int error; error = 0; @@ -483,6 +483,17 @@ fxp_attach(device_t dev) sc->revision = pci_get_revid(dev); /* + * Check availability of WOL. 82559ER does not support WOL. + */ + if (sc->revision >= FXP_REV_82558_A4 && + sc->revision != FXP_REV_82559S_A) { + fxp_read_eeprom(sc, &data, 10, 1); + if ((data & 0x20) != 0 && + pci_find_extcap(sc->dev, PCIY_PMG, &pmc) == 0) + sc->flags |= FXP_FLAG_WOLCAP; + } + + /* * Determine whether we must use the 503 serial interface. */ fxp_read_eeprom(sc, &data, 6, 1); @@ -796,6 +807,11 @@ fxp_attach(device_t dev) ifp->if_capenable |= IFCAP_RXCSUM; } + if (sc->flags & FXP_FLAG_WOLCAP) { + ifp->if_capabilities |= IFCAP_WOL_MAGIC; + ifp->if_capenable |= IFCAP_WOL_MAGIC; + } + #ifdef DEVICE_POLLING /* Inform the world we support polling. */ ifp->if_capabilities |= IFCAP_POLLING; @@ -834,6 +850,19 @@ fxp_attach(device_t dev) goto fail; } + /* + * Configure hardware to reject magic frames otherwise + * system will hang on recipt of magic frames. + */ + if ((sc->flags & FXP_FLAG_WOLCAP) != 0) { + FXP_LOCK(sc); + /* Clear wakeup events. */ + CSR_WRITE_1(sc, FXP_CSR_PMDR, CSR_READ_1(sc, FXP_CSR_PMDR)); + fxp_init_body(sc); + fxp_stop(sc); + FXP_UNLOCK(sc); + } + fail: if (error) fxp_release(sc); @@ -956,17 +985,13 @@ fxp_detach(device_t dev) static int fxp_shutdown(device_t dev) { - struct fxp_softc *sc = device_get_softc(dev); /* * Make sure that DMA is disabled prior to reboot. Not doing * do could allow DMA to corrupt kernel memory during the * reboot before the driver initializes. */ - FXP_LOCK(sc); - fxp_stop(sc); - FXP_UNLOCK(sc); - return (0); + return (fxp_suspend(dev)); } /* @@ -978,9 +1003,25 @@ static int fxp_suspend(device_t dev) { struct fxp_softc *sc = device_get_softc(dev); + struct ifnet *ifp; + int pmc; + uint16_t pmstat; FXP_LOCK(sc); + ifp = sc->ifp; + if (pci_find_extcap(sc->dev, PCIY_PMG, &pmc) == 0) { + pmstat = pci_read_config(sc->dev, pmc + PCIR_POWER_STATUS, 2); + pmstat &= ~(PCIM_PSTAT_PME | PCIM_PSTAT_PMEENABLE); + if ((ifp->if_capenable & IFCAP_WOL_MAGIC) != 0) { + /* Request PME. */ + pmstat |= PCIM_PSTAT_PME | PCIM_PSTAT_PMEENABLE; + sc->flags |= FXP_FLAG_WOL; + /* Reconfigure hardware to accept magic frames. */ + fxp_init_body(sc); + } + pci_write_config(sc->dev, pmc + PCIR_POWER_STATUS, pmstat, 2); + } fxp_stop(sc); sc->suspended = 1; @@ -998,9 +1039,22 @@ fxp_resume(device_t dev) { struct fxp_softc *sc = device_get_softc(dev); struct ifnet *ifp = sc->ifp; + int pmc; + uint16_t pmstat; FXP_LOCK(sc); + if (pci_find_extcap(sc->dev, PCIY_PMG, &pmc) == 0) { + sc->flags &= ~FXP_FLAG_WOL; + pmstat = pci_read_config(sc->dev, pmc + PCIR_POWER_STATUS, 2); + /* Disable PME and clear PME status. */ + pmstat &= ~PCIM_PSTAT_PMEENABLE; + pci_write_config(sc->dev, pmc + PCIR_POWER_STATUS, pmstat, 2); + if ((sc->flags & FXP_FLAG_WOLCAP) != 0) + CSR_WRITE_1(sc, FXP_CSR_PMDR, + CSR_READ_1(sc, FXP_CSR_PMDR)); + } + CSR_WRITE_4(sc, FXP_CSR_PORT, FXP_PORT_SELECTIVE_RESET); DELAY(10); @@ -2015,11 +2069,13 @@ fxp_stop(struct fxp_softc *sc) callout_stop(&sc->stat_ch); /* - * Issue software reset, which also unloads the microcode. + * Preserve PCI configuration, configure, IA/multicast + * setup and put RU and CU into idle state. */ - sc->flags &= ~FXP_FLAG_UCODE; - CSR_WRITE_4(sc, FXP_CSR_PORT, FXP_PORT_SOFTWARE_RESET); + CSR_WRITE_4(sc, FXP_CSR_PORT, FXP_PORT_SELECTIVE_RESET); DELAY(50); + /* Disable interrupts. */ + CSR_WRITE_1(sc, FXP_CSR_SCB_INTRCNTL, FXP_SCB_INTR_DISABLE); /* * Release any xmit buffers. @@ -2099,6 +2155,13 @@ fxp_init_body(struct fxp_softc *sc) */ fxp_stop(sc); + /* + * Issue software reset, which also unloads the microcode. + */ + sc->flags &= ~FXP_FLAG_UCODE; + CSR_WRITE_4(sc, FXP_CSR_PORT, FXP_PORT_SOFTWARE_RESET); + DELAY(50); + prm = (ifp->if_flags & IFF_PROMISC) ? 1 : 0; /* @@ -2215,8 +2278,7 @@ fxp_init_body(struct fxp_softc *sc) cbp->rcv_crc_xfer = 0; /* (don't) xfer CRC to host */ cbp->long_rx_en = sc->flags & FXP_FLAG_LONG_PKT_EN ? 1 : 0; cbp->ia_wake_en = 0; /* (don't) wake up on address match */ - cbp->magic_pkt_dis = 0; /* (don't) disable magic packet */ - /* must set wake_en in PMCSR also */ + cbp->magic_pkt_dis = sc->flags & FXP_FLAG_WOL ? 0 : 1; cbp->force_fdx = 0; /* (don't) force full duplex */ cbp->fdx_pin_en = 1; /* (enable) FDX# pin */ cbp->multi_ia = 0; /* (don't) accept multiple IAs */ @@ -2687,6 +2749,9 @@ fxp_ioctl(struct ifnet *ifp, u_long comm else ifp->if_hwassist &= ~CSUM_TSO; } + if ((mask & IFCAP_WOL_MAGIC) != 0 && + (ifp->if_capabilities & IFCAP_WOL_MAGIC) != 0) + ifp->if_capenable ^= IFCAP_WOL_MAGIC; if ((mask & IFCAP_VLAN_MTU) != 0 && (ifp->if_capabilities & IFCAP_VLAN_MTU) != 0) { ifp->if_capenable ^= IFCAP_VLAN_MTU; Modified: stable/7/sys/dev/fxp/if_fxpreg.h ============================================================================== --- stable/7/sys/dev/fxp/if_fxpreg.h Mon Feb 9 03:48:49 2009 (r188374) +++ stable/7/sys/dev/fxp/if_fxpreg.h Mon Feb 9 03:53:20 2009 (r188375) @@ -46,6 +46,7 @@ #define FXP_CSR_EEPROMCONTROL 14 /* eeprom control (2 bytes) */ #define FXP_CSR_MDICONTROL 16 /* mdi control (4 bytes) */ #define FXP_CSR_FLOWCONTROL 0x19 /* flow control (2 bytes) */ +#define FXP_CSR_PMDR 0x1B /* power management driver (1 byte) */ #define FXP_CSR_GENCONTROL 0x1C /* general control (1 byte) */ /* Modified: stable/7/sys/dev/fxp/if_fxpvar.h ============================================================================== --- stable/7/sys/dev/fxp/if_fxpvar.h Mon Feb 9 03:48:49 2009 (r188374) +++ stable/7/sys/dev/fxp/if_fxpvar.h Mon Feb 9 03:53:20 2009 (r188375) @@ -201,6 +201,8 @@ struct fxp_softc { #define FXP_FLAG_EXT_RFA 0x0400 /* extended RFDs for csum offload */ #define FXP_FLAG_SAVE_BAD 0x0800 /* save bad pkts: bad size, CRC, etc */ #define FXP_FLAG_82559_RXCSUM 0x1000 /* 82559 compatible RX checksum */ +#define FXP_FLAG_WOLCAP 0x2000 /* WOL capability */ +#define FXP_FLAG_WOL 0x4000 /* WOL active */ /* Macros to ease CSR access. */ #define CSR_READ_1(sc, reg) bus_read_1(sc->fxp_res[0], reg) From owner-svn-src-stable@FreeBSD.ORG Mon Feb 9 03:55:51 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id CD161106564A; Mon, 9 Feb 2009 03:55:51 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id BA1E78FC0C; Mon, 9 Feb 2009 03:55:51 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n193tp0F044571; Mon, 9 Feb 2009 03:55:51 GMT (envelope-from yongari@svn.freebsd.org) Received: (from yongari@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n193tpNJ044569; Mon, 9 Feb 2009 03:55:51 GMT (envelope-from yongari@svn.freebsd.org) Message-Id: <200902090355.n193tpNJ044569@svn.freebsd.org> From: Pyun YongHyeon Date: Mon, 9 Feb 2009 03:55:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r188376 - in stable/7/sys: . contrib/pf dev/cxgb dev/fxp X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Feb 2009 03:55:52 -0000 Author: yongari Date: Mon Feb 9 03:55:51 2009 New Revision: 188376 URL: http://svn.freebsd.org/changeset/base/188376 Log: MFC r185540: Add VLAN hardware tag insertion/stripping support. Tx/Rx checksum offload for VLAN frames are also supported. The VLAN hardware assistance is available only on 82550/82551 based controllers. While I'm here change the confusing name of bit1 in byte 22 of configuration block to vlan_drop_en. The bit controls whether hardware strips VLAN tagged frame or not. Special thanks to wpaul who sent valuable VLAN related information to me. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/dev/fxp/if_fxp.c stable/7/sys/dev/fxp/if_fxpreg.h Modified: stable/7/sys/dev/fxp/if_fxp.c ============================================================================== --- stable/7/sys/dev/fxp/if_fxp.c Mon Feb 9 03:53:20 2009 (r188375) +++ stable/7/sys/dev/fxp/if_fxp.c Mon Feb 9 03:55:51 2009 (r188376) @@ -830,6 +830,12 @@ fxp_attach(device_t dev) ifp->if_data.ifi_hdrlen = sizeof(struct ether_vlan_header); ifp->if_capabilities |= IFCAP_VLAN_MTU; ifp->if_capenable |= IFCAP_VLAN_MTU; /* the hw bits already set */ + if ((sc->flags & FXP_FLAG_EXT_RFA) != 0) { + ifp->if_capabilities |= IFCAP_VLAN_HWTAGGING | + IFCAP_VLAN_HWCSUM; + ifp->if_capenable |= IFCAP_VLAN_HWTAGGING | + IFCAP_VLAN_HWCSUM; + } /* * Let the system queue as many packets as we have available @@ -1554,6 +1560,12 @@ fxp_encap(struct fxp_softc *sc, struct m FXP_IPCB_TCP_PACKET | FXP_IPCB_TCPUDP_CHECKSUM_ENABLE; } + /* Configure VLAN hardware tag insertion. */ + if ((m->m_flags & M_VLANTAG) != 0) { + cbp->ipcb_vlan_id = htons(m->m_pkthdr.ether_vtag); + txp->tx_cb->ipcb_ip_activation_high |= + FXP_IPCB_INSERTVLAN_ENABLE; + } txp->tx_mbuf = m; txp->tx_cb->cb_status = 0; @@ -1913,6 +1925,12 @@ fxp_intr_body(struct fxp_softc *sc, stru /* Do IP checksum checking. */ if ((ifp->if_capenable & IFCAP_RXCSUM) != 0) fxp_rxcsum(sc, ifp, m, status, total_len); + if ((ifp->if_capenable & IFCAP_VLAN_HWTAGGING) != 0 && + (status & FXP_RFA_STATUS_VLAN) != 0) { + m->m_pkthdr.ether_vtag = + ntohs(rfa->rfax_vlan_id); + m->m_flags |= M_VLANTAG; + } /* * Drop locks before calling if_input() since it * may re-enter fxp_start() in the netisr case. @@ -2284,6 +2302,8 @@ fxp_init_body(struct fxp_softc *sc) cbp->multi_ia = 0; /* (don't) accept multiple IAs */ cbp->mc_all = sc->flags & FXP_FLAG_ALL_MCAST ? 1 : 0; cbp->gamla_rx = sc->flags & FXP_FLAG_EXT_RFA ? 1 : 0; + cbp->vlan_strip_en = ((sc->flags & FXP_FLAG_EXT_RFA) != 0 && + (ifp->if_capenable & IFCAP_VLAN_HWTAGGING) != 0) ? 1 : 0; if (sc->tunable_noflow || sc->revision == FXP_REV_82557) { /* @@ -2763,9 +2783,15 @@ fxp_ioctl(struct ifnet *ifp, u_long comm if (ifp->if_flags & IFF_UP) reinit++; } - if (reinit > 0) + if ((mask & IFCAP_VLAN_HWTAGGING) != 0 && + (ifp->if_capabilities & IFCAP_VLAN_HWTAGGING) != 0) { + ifp->if_capenable ^= IFCAP_VLAN_HWTAGGING; + reinit++; + } + if (reinit > 0 && ifp->if_flags & IFF_UP) fxp_init_body(sc); FXP_UNLOCK(sc); + VLAN_CAPABILITIES(ifp); break; default: Modified: stable/7/sys/dev/fxp/if_fxpreg.h ============================================================================== --- stable/7/sys/dev/fxp/if_fxpreg.h Mon Feb 9 03:53:20 2009 (r188375) +++ stable/7/sys/dev/fxp/if_fxpreg.h Mon Feb 9 03:55:51 2009 (r188376) @@ -224,7 +224,7 @@ struct fxp_cb_config { /* Bytes 22 - 31 -- i82550 only */ u_int __FXP_BITFIELD3(gamla_rx:1, - vlan_drop_en:1, + vlan_strip_en:1, :6); uint8_t pad[9]; }; @@ -377,6 +377,7 @@ struct fxp_rfa { #define FXP_RFA_STATUS_RNR 0x0200 /* no resources */ #define FXP_RFA_STATUS_ALIGN 0x0400 /* alignment error */ #define FXP_RFA_STATUS_CRC 0x0800 /* CRC error */ +#define FXP_RFA_STATUS_VLAN 0x1000 /* VLAN tagged frame */ #define FXP_RFA_STATUS_OK 0x2000 /* packet received okay */ #define FXP_RFA_STATUS_C 0x8000 /* packet reception complete */ #define FXP_RFA_CONTROL_SF 0x08 /* simple/flexible memory mode */ From owner-svn-src-stable@FreeBSD.ORG Mon Feb 9 03:58:30 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 06B03106566B; Mon, 9 Feb 2009 03:58:30 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id E86AC8FC12; Mon, 9 Feb 2009 03:58:29 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n193wTdY044660; Mon, 9 Feb 2009 03:58:29 GMT (envelope-from yongari@svn.freebsd.org) Received: (from yongari@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n193wTZh044659; Mon, 9 Feb 2009 03:58:29 GMT (envelope-from yongari@svn.freebsd.org) Message-Id: <200902090358.n193wTZh044659@svn.freebsd.org> From: Pyun YongHyeon Date: Mon, 9 Feb 2009 03:58:29 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r188377 - in stable/7/sys: . contrib/pf dev/cxgb dev/fxp X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Feb 2009 03:58:30 -0000 Author: yongari Date: Mon Feb 9 03:58:29 2009 New Revision: 188377 URL: http://svn.freebsd.org/changeset/base/188377 Log: MFC r185758: mutex.h is needed here. It got it by namespace pollution. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/dev/fxp/if_fxp.c Modified: stable/7/sys/dev/fxp/if_fxp.c ============================================================================== --- stable/7/sys/dev/fxp/if_fxp.c Mon Feb 9 03:55:51 2009 (r188376) +++ stable/7/sys/dev/fxp/if_fxp.c Mon Feb 9 03:58:29 2009 (r188377) @@ -44,7 +44,9 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include +#include #include #include #include From owner-svn-src-stable@FreeBSD.ORG Mon Feb 9 04:00:55 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 43D821065673; Mon, 9 Feb 2009 04:00:55 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 3126E8FC1C; Mon, 9 Feb 2009 04:00:55 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n1940tNi044786; Mon, 9 Feb 2009 04:00:55 GMT (envelope-from yongari@svn.freebsd.org) Received: (from yongari@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n1940tvv044785; Mon, 9 Feb 2009 04:00:55 GMT (envelope-from yongari@svn.freebsd.org) Message-Id: <200902090400.n1940tvv044785@svn.freebsd.org> From: Pyun YongHyeon Date: Mon, 9 Feb 2009 04:00:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r188378 - in stable/7/sys: . contrib/pf dev/cxgb dev/fxp X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Feb 2009 04:00:56 -0000 Author: yongari Date: Mon Feb 9 04:00:54 2009 New Revision: 188378 URL: http://svn.freebsd.org/changeset/base/188378 Log: MFC r186262: It seems that we don't need to reserve a TBD to set total TCP payload length in TSO case. Leaving unused TBD also seem to cause SCB timeouts under certain conditions when TSO/non-TSO traffics are active at the same time. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/dev/fxp/if_fxp.c Modified: stable/7/sys/dev/fxp/if_fxp.c ============================================================================== --- stable/7/sys/dev/fxp/if_fxp.c Mon Feb 9 03:58:29 2009 (r188377) +++ stable/7/sys/dev/fxp/if_fxp.c Mon Feb 9 04:00:54 2009 (r188378) @@ -1540,8 +1540,8 @@ fxp_encap(struct fxp_softc *sc, struct m * the chip is an 82550/82551 or not. */ if (sc->flags & FXP_FLAG_EXT_RFA) { - cbp->tbd[i + 2].tb_addr = htole32(segs[i].ds_addr); - cbp->tbd[i + 2].tb_size = htole32(segs[i].ds_len); + cbp->tbd[i + 1].tb_addr = htole32(segs[i].ds_addr); + cbp->tbd[i + 1].tb_size = htole32(segs[i].ds_len); } else { cbp->tbd[i].tb_addr = htole32(segs[i].ds_addr); cbp->tbd[i].tb_size = htole32(segs[i].ds_len); @@ -1550,13 +1550,13 @@ fxp_encap(struct fxp_softc *sc, struct m if (sc->flags & FXP_FLAG_EXT_RFA) { /* Configure dynamic TBD for 82550/82551. */ cbp->tbd_number = 0xFF; - cbp->tbd[nseg + 1].tb_size |= htole32(0x8000); + cbp->tbd[nseg].tb_size |= htole32(0x8000); } else cbp->tbd_number = nseg; /* Configure TSO. */ if (m->m_pkthdr.csum_flags & CSUM_TSO) { cbp->tbd[-1].tb_size = htole32(m->m_pkthdr.tso_segsz << 16); - cbp->tbd[1].tb_size = htole32(tcp_payload << 16); + cbp->tbd[1].tb_size |= htole32(tcp_payload << 16); cbp->ipcb_ip_schedule |= FXP_IPCB_LARGESEND_ENABLE | FXP_IPCB_IP_CHECKSUM_ENABLE | FXP_IPCB_TCP_PACKET | From owner-svn-src-stable@FreeBSD.ORG Mon Feb 9 04:02:54 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0321E106568C; Mon, 9 Feb 2009 04:02:54 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id E42C88FC16; Mon, 9 Feb 2009 04:02:53 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n1942rXc044868; Mon, 9 Feb 2009 04:02:53 GMT (envelope-from yongari@svn.freebsd.org) Received: (from yongari@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n1942r56044867; Mon, 9 Feb 2009 04:02:53 GMT (envelope-from yongari@svn.freebsd.org) Message-Id: <200902090402.n1942r56044867@svn.freebsd.org> From: Pyun YongHyeon Date: Mon, 9 Feb 2009 04:02:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r188379 - in stable/7/sys: . contrib/pf dev/cxgb dev/fxp X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Feb 2009 04:02:55 -0000 Author: yongari Date: Mon Feb 9 04:02:53 2009 New Revision: 188379 URL: http://svn.freebsd.org/changeset/base/188379 Log: MFC r186884: Always check whether dma map is valid before unloading the map. When fxp(4) intializes Rx buffers for the first time, there is no loaded dma map so attempting to unload it is an invalid operation. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/dev/fxp/if_fxp.c Modified: stable/7/sys/dev/fxp/if_fxp.c ============================================================================== --- stable/7/sys/dev/fxp/if_fxp.c Mon Feb 9 04:00:54 2009 (r188378) +++ stable/7/sys/dev/fxp/if_fxp.c Mon Feb 9 04:02:53 2009 (r188379) @@ -2545,7 +2545,8 @@ fxp_new_rfabuf(struct fxp_softc *sc, str return (error); } - bus_dmamap_unload(sc->fxp_mtag, rxp->rx_map); + if (rxp->rx_mbuf != NULL) + bus_dmamap_unload(sc->fxp_mtag, rxp->rx_map); tmp_map = sc->spare_map; sc->spare_map = rxp->rx_map; rxp->rx_map = tmp_map; From owner-svn-src-stable@FreeBSD.ORG Mon Feb 9 10:28:17 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1DF1D106566B; Mon, 9 Feb 2009 10:28:17 +0000 (UTC) (envelope-from maxim@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 0BAD08FC1D; Mon, 9 Feb 2009 10:28:17 +0000 (UTC) (envelope-from maxim@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n19ASGZC052054; Mon, 9 Feb 2009 10:28:16 GMT (envelope-from maxim@svn.freebsd.org) Received: (from maxim@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n19ASGsJ052053; Mon, 9 Feb 2009 10:28:16 GMT (envelope-from maxim@svn.freebsd.org) Message-Id: <200902091028.n19ASGsJ052053@svn.freebsd.org> From: Maxim Konovalov Date: Mon, 9 Feb 2009 10:28:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r188384 - stable/7/libexec/ftpd X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Feb 2009 10:28:17 -0000 Author: maxim Date: Mon Feb 9 10:28:16 2009 New Revision: 188384 URL: http://svn.freebsd.org/changeset/base/188384 Log: MFC r187913: fix typo. Modified: stable/7/libexec/ftpd/ftpd.8 Modified: stable/7/libexec/ftpd/ftpd.8 ============================================================================== --- stable/7/libexec/ftpd/ftpd.8 Mon Feb 9 06:23:21 2009 (r188383) +++ stable/7/libexec/ftpd/ftpd.8 Mon Feb 9 10:28:16 2009 (r188384) @@ -205,7 +205,7 @@ for more information. Note that option is a virtual no-op in .Fx 5.0 and above; both port -ranges are indentical by default. +ranges are identical by default. .It Fl u The default file creation mode mask is set to .Ar umask , From owner-svn-src-stable@FreeBSD.ORG Mon Feb 9 12:22:49 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C7DBD106566C; Mon, 9 Feb 2009 12:22:49 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id B4FDD8FC0C; Mon, 9 Feb 2009 12:22:49 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n19CMnbR059847; Mon, 9 Feb 2009 12:22:49 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n19CMnfR059846; Mon, 9 Feb 2009 12:22:49 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <200902091222.n19CMnfR059846@svn.freebsd.org> From: Konstantin Belousov Date: Mon, 9 Feb 2009 12:22:49 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r188389 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb fs/fifofs X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Feb 2009 12:22:50 -0000 Author: kib Date: Mon Feb 9 12:22:49 2009 New Revision: 188389 URL: http://svn.freebsd.org/changeset/base/188389 Log: MFC r187715: The kernel may do unbalanced calls to fifo_close() for fifo vnode, without corresponding number of fifo_open(). This causes assertion failure in fifo_close() due to vp->v_fifoinfo being NULL for kernel with INVARIANTS, or NULL pointer dereference otherwise. In fact, we may ignore excess calls to fifo_close() without bad consequences. Turn KASSERT() into the return, and print warning for now. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/fs/fifofs/fifo_vnops.c Modified: stable/7/sys/fs/fifofs/fifo_vnops.c ============================================================================== --- stable/7/sys/fs/fifofs/fifo_vnops.c Mon Feb 9 11:42:23 2009 (r188388) +++ stable/7/sys/fs/fifofs/fifo_vnops.c Mon Feb 9 12:22:49 2009 (r188389) @@ -424,7 +424,10 @@ fifo_close(ap) struct fifoinfo *fip = vp->v_fifoinfo; ASSERT_VOP_LOCKED(vp, "fifo_close"); - KASSERT(fip != NULL, ("fifo_close: no v_fifoinfo")); + if (fip == NULL) { + printf("fifo_close: no v_fifoinfo %p\n", vp); + return (0); + } if (ap->a_fflag & FREAD) { fip->fi_readers--; if (fip->fi_readers == 0) From owner-svn-src-stable@FreeBSD.ORG Mon Feb 9 17:14:50 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 20BFE106566B; Mon, 9 Feb 2009 17:14:50 +0000 (UTC) (envelope-from emax@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 0E79F8FC19; Mon, 9 Feb 2009 17:14:50 +0000 (UTC) (envelope-from emax@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n19HEnqB066253; Mon, 9 Feb 2009 17:14:49 GMT (envelope-from emax@svn.freebsd.org) Received: (from emax@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n19HEndG066252; Mon, 9 Feb 2009 17:14:49 GMT (envelope-from emax@svn.freebsd.org) Message-Id: <200902091714.n19HEndG066252@svn.freebsd.org> From: Maksim Yevmenkin Date: Mon, 9 Feb 2009 17:14:49 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r188397 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb dev/kbdmux X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Feb 2009 17:14:51 -0000 Author: emax Date: Mon Feb 9 17:14:49 2009 New Revision: 188397 URL: http://svn.freebsd.org/changeset/base/188397 Log: MFC r188030 Properly retun error core from kbdmux_modevent() Reported by: Christoph Mallon < christoph -dot- mallon -at- gmx -dot- de > Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/dev/kbdmux/kbdmux.c Modified: stable/7/sys/dev/kbdmux/kbdmux.c ============================================================================== --- stable/7/sys/dev/kbdmux/kbdmux.c Mon Feb 9 17:07:29 2009 (r188396) +++ stable/7/sys/dev/kbdmux/kbdmux.c Mon Feb 9 17:14:49 2009 (r188397) @@ -1384,7 +1384,7 @@ kbdmux_modevent(module_t mod, int type, break; } - return (0); + return (error); } DEV_MODULE(kbdmux, kbdmux_modevent, NULL); From owner-svn-src-stable@FreeBSD.ORG Mon Feb 9 17:50:19 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7F785106566C; Mon, 9 Feb 2009 17:50:19 +0000 (UTC) (envelope-from emax@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 6C5CE8FC1B; Mon, 9 Feb 2009 17:50:19 +0000 (UTC) (envelope-from emax@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n19HoJXs066983; Mon, 9 Feb 2009 17:50:19 GMT (envelope-from emax@svn.freebsd.org) Received: (from emax@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n19HoJmJ066982; Mon, 9 Feb 2009 17:50:19 GMT (envelope-from emax@svn.freebsd.org) Message-Id: <200902091750.n19HoJmJ066982@svn.freebsd.org> From: Maksim Yevmenkin Date: Mon, 9 Feb 2009 17:50:19 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r188400 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb netgraph/bluetooth/l2cap X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Feb 2009 17:50:20 -0000 Author: emax Date: Mon Feb 9 17:50:19 2009 New Revision: 188400 URL: http://svn.freebsd.org/changeset/base/188400 Log: MFC r187454 Properly return error code to the caller. This should fix the following panic in ng_l2cap(4). panic: ng_l2cap_l2ca_con_req: ubt0l2cap - could not find connection! While i'm here get rid of few goto's. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/netgraph/bluetooth/l2cap/ng_l2cap_llpi.c Modified: stable/7/sys/netgraph/bluetooth/l2cap/ng_l2cap_llpi.c ============================================================================== --- stable/7/sys/netgraph/bluetooth/l2cap/ng_l2cap_llpi.c Mon Feb 9 17:38:16 2009 (r188399) +++ stable/7/sys/netgraph/bluetooth/l2cap/ng_l2cap_llpi.c Mon Feb 9 17:50:19 2009 (r188400) @@ -116,10 +116,14 @@ ng_l2cap_lp_con_req(ng_l2cap_p l2cap, bd NG_SEND_MSG_HOOK(error, l2cap->node, msg, l2cap->hci, 0); if (error != 0) { - if ((error = ng_l2cap_lp_untimeout(con)) != 0) - return (error); + if (ng_l2cap_lp_untimeout(con) == 0) + ng_l2cap_free_con(con); - ng_l2cap_free_con(con); + /* + * Do not free connection if ng_l2cap_lp_untimeout() failed + * let timeout handler deal with it. Always return error to + * the caller. + */ } return (error); @@ -213,8 +217,8 @@ ng_l2cap_lp_con_ind(ng_l2cap_p l2cap, st NG_L2CAP_ALERT( "%s: %s - invalid LP_ConnectInd message size\n", __func__, NG_NODE_NAME(l2cap->node)); - error = EMSGSIZE; - goto out; + + return (EMSGSIZE); } ep = (ng_hci_lp_con_ind_ep *) (msg->data); @@ -227,8 +231,8 @@ ng_l2cap_lp_con_ind(ng_l2cap_p l2cap, st "Connection already exists, state=%d, con_handle=%d\n", __func__, NG_NODE_NAME(l2cap->node), con->state, con->con_handle); - error = EEXIST; - goto out; + + return (EEXIST); } /* Check if lower layer protocol is still connected */ @@ -236,24 +240,22 @@ ng_l2cap_lp_con_ind(ng_l2cap_p l2cap, st NG_L2CAP_ERR( "%s: %s - hook \"%s\" is not connected or valid", __func__, NG_NODE_NAME(l2cap->node), NG_L2CAP_HOOK_HCI); - error = ENOTCONN; - goto out; + + return (ENOTCONN); } /* Create and intialize new connection descriptor */ con = ng_l2cap_new_con(l2cap, &ep->bdaddr); - if (con == NULL) { - error = ENOMEM; - goto out; - } + if (con == NULL) + return (ENOMEM); /* Create and send LP_ConnectRsp event */ NG_MKMESSAGE(rsp, NGM_HCI_COOKIE, NGM_HCI_LP_CON_RSP, sizeof(*rp), M_NOWAIT); if (rsp == NULL) { ng_l2cap_free_con(con); - error = ENOMEM; - goto out; + + return (ENOMEM); } rp = (ng_hci_lp_con_rsp_ep *)(rsp->data); @@ -266,14 +268,18 @@ ng_l2cap_lp_con_ind(ng_l2cap_p l2cap, st NG_SEND_MSG_HOOK(error, l2cap->node, rsp, l2cap->hci, 0); if (error != 0) { - if ((error = ng_l2cap_lp_untimeout(con)) != 0) - goto out; + if (ng_l2cap_lp_untimeout(con) == 0) + ng_l2cap_free_con(con); - ng_l2cap_free_con(con); + /* + * Do not free connection if ng_l2cap_lp_untimeout() failed + * let timeout handler deal with it. Always return error to + * the caller. + */ } -out: + return (error); -} /* ng_hci_lp_con_ind */ +} /* ng_l2cap_lp_con_ind */ /* * Process LP_DisconnectInd event from the lower layer protocol. We have been From owner-svn-src-stable@FreeBSD.ORG Mon Feb 9 17:53:45 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A2E231065674; Mon, 9 Feb 2009 17:53:45 +0000 (UTC) (envelope-from emax@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 905468FC23; Mon, 9 Feb 2009 17:53:45 +0000 (UTC) (envelope-from emax@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n19HrjHa067086; Mon, 9 Feb 2009 17:53:45 GMT (envelope-from emax@svn.freebsd.org) Received: (from emax@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n19HrjwG067085; Mon, 9 Feb 2009 17:53:45 GMT (envelope-from emax@svn.freebsd.org) Message-Id: <200902091753.n19HrjwG067085@svn.freebsd.org> From: Maksim Yevmenkin Date: Mon, 9 Feb 2009 17:53:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r188401 - in stable/7/sys: . contrib/pf dev/cxgb netgraph/bluetooth/hci X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Feb 2009 17:53:46 -0000 Author: emax Date: Mon Feb 9 17:53:45 2009 New Revision: 188401 URL: http://svn.freebsd.org/changeset/base/188401 Log: MFC r186466 Change message severity level from WARN to INFO. This should reduce amount of messages sent to syslog Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/netgraph/bluetooth/hci/ng_hci_main.c Modified: stable/7/sys/netgraph/bluetooth/hci/ng_hci_main.c ============================================================================== --- stable/7/sys/netgraph/bluetooth/hci/ng_hci_main.c Mon Feb 9 17:50:19 2009 (r188400) +++ stable/7/sys/netgraph/bluetooth/hci/ng_hci_main.c Mon Feb 9 17:53:45 2009 (r188401) @@ -728,7 +728,7 @@ ng_hci_drv_rcvdata(hook_p hook, item_p i if ((unit->state & NG_HCI_UNIT_READY) != NG_HCI_UNIT_READY || unit->sco == NULL || NG_HOOK_NOT_VALID(unit->sco)) { - NG_HCI_WARN( + NG_HCI_INFO( "%s: %s - could not forward HCI SCO data packet, state=%#x, hook=%p\n", __func__, NG_NODE_NAME(unit->node), unit->state, unit->sco); From owner-svn-src-stable@FreeBSD.ORG Mon Feb 9 22:21:39 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 12DA410656BF; Mon, 9 Feb 2009 22:21:39 +0000 (UTC) (envelope-from cognet@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id F39CA8FC26; Mon, 9 Feb 2009 22:21:38 +0000 (UTC) (envelope-from cognet@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n19MLcjF073260; Mon, 9 Feb 2009 22:21:38 GMT (envelope-from cognet@svn.freebsd.org) Received: (from cognet@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n19MLcHb073259; Mon, 9 Feb 2009 22:21:38 GMT (envelope-from cognet@svn.freebsd.org) Message-Id: <200902092221.n19MLcHb073259@svn.freebsd.org> From: Olivier Houchard Date: Mon, 9 Feb 2009 22:21:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r188420 - stable/7/sys/arm/arm X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Feb 2009 22:21:40 -0000 Author: cognet Date: Mon Feb 9 22:21:38 2009 New Revision: 188420 URL: http://svn.freebsd.org/changeset/base/188420 Log: MFC r188112 r188112 | cognet | 2009-02-04 02:14:06 +0100 (Wed, 04 Feb 2009) | 8 lines Erm... Report the buffer as being bounced even when it's the entire buffer, or we would end up invalidating the cache line for what we just copied... Modified: stable/7/sys/arm/arm/busdma_machdep.c Modified: stable/7/sys/arm/arm/busdma_machdep.c ============================================================================== --- stable/7/sys/arm/arm/busdma_machdep.c Mon Feb 9 22:18:11 2009 (r188419) +++ stable/7/sys/arm/arm/busdma_machdep.c Mon Feb 9 22:21:38 2009 (r188420) @@ -1164,7 +1164,7 @@ _bus_dma_buf_is_in_bp(bus_dmamap_t map, STAILQ_FOREACH(bpage, &map->bpages, links) { if ((vm_offset_t)buf >= bpage->datavaddr && - (vm_offset_t)buf + len < bpage->datavaddr + + (vm_offset_t)buf + len <= bpage->datavaddr + bpage->datacount) return (1); } From owner-svn-src-stable@FreeBSD.ORG Mon Feb 9 22:22:10 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 16D5D1065706; Mon, 9 Feb 2009 22:22:10 +0000 (UTC) (envelope-from cognet@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 034868FC31; Mon, 9 Feb 2009 22:22:10 +0000 (UTC) (envelope-from cognet@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n19MM9X8073321; Mon, 9 Feb 2009 22:22:09 GMT (envelope-from cognet@svn.freebsd.org) Received: (from cognet@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n19MM9lA073320; Mon, 9 Feb 2009 22:22:09 GMT (envelope-from cognet@svn.freebsd.org) Message-Id: <200902092222.n19MM9lA073320@svn.freebsd.org> From: Olivier Houchard Date: Mon, 9 Feb 2009 22:22:09 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-6@freebsd.org X-SVN-Group: stable-6 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r188421 - stable/6/sys/arm/arm X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Feb 2009 22:22:11 -0000 Author: cognet Date: Mon Feb 9 22:22:09 2009 New Revision: 188421 URL: http://svn.freebsd.org/changeset/base/188421 Log: MFC r188112 r188112 | cognet | 2009-02-04 02:14:06 +0100 (Wed, 04 Feb 2009) | 8 lines Erm... Report the buffer as being bounced even when it's the entire buffer, or we would end up invalidating the cache line for what we just copied... Modified: stable/6/sys/arm/arm/busdma_machdep.c Modified: stable/6/sys/arm/arm/busdma_machdep.c ============================================================================== --- stable/6/sys/arm/arm/busdma_machdep.c Mon Feb 9 22:21:38 2009 (r188420) +++ stable/6/sys/arm/arm/busdma_machdep.c Mon Feb 9 22:22:09 2009 (r188421) @@ -1146,7 +1146,7 @@ _bus_dma_buf_is_in_bp(bus_dmamap_t map, STAILQ_FOREACH(bpage, &map->bpages, links) { if ((vm_offset_t)buf >= bpage->datavaddr && - (vm_offset_t)buf + len < bpage->datavaddr + + (vm_offset_t)buf + len <= bpage->datavaddr + bpage->datacount) return (1); } From owner-svn-src-stable@FreeBSD.ORG Mon Feb 9 23:00:56 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1B8B010656CD; Mon, 9 Feb 2009 23:00:56 +0000 (UTC) (envelope-from bms@FreeBSD.org) Received: from out1.smtp.messagingengine.com (out1.smtp.messagingengine.com [66.111.4.25]) by mx1.freebsd.org (Postfix) with ESMTP id DF1E28FC21; Mon, 9 Feb 2009 23:00:55 +0000 (UTC) (envelope-from bms@FreeBSD.org) Received: from compute1.internal (compute1.internal [10.202.2.41]) by out1.messagingengine.com (Postfix) with ESMTP id 8B0982900BB; Mon, 9 Feb 2009 17:45:18 -0500 (EST) Received: from heartbeat1.messagingengine.com ([10.202.2.160]) by compute1.internal (MEProxy); Mon, 09 Feb 2009 17:45:18 -0500 X-Sasl-enc: 14HDvqIFWLi1ADXzEyiY6A2boxsf+01p5hGAh/scOqxE 1234219518 Received: from empiric.lon.incunabulum.net (82-35-112-254.cable.ubr07.dals.blueyonder.co.uk [82.35.112.254]) by mail.messagingengine.com (Postfix) with ESMTPSA id F26272A003; Mon, 9 Feb 2009 17:45:15 -0500 (EST) Message-ID: <4990B1F9.7020009@FreeBSD.org> Date: Mon, 09 Feb 2009 22:45:13 +0000 From: "Bruce M. Simpson" User-Agent: Thunderbird 2.0.0.19 (X11/20090126) MIME-Version: 1.0 To: Pyun YongHyeon References: <200902090353.n193rKkw044451@svn.freebsd.org> In-Reply-To: <200902090353.n193rKkw044451@svn.freebsd.org> X-Enigmail-Version: 0.95.6 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: svn-src-stable@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, svn-src-stable-7@freebsd.org Subject: Re: svn commit: r188375 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb dev/fxp X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Feb 2009 23:00:58 -0000 This looks really cool and I look forward to trying WOL once I have the right combo of cards/machines which should really sleep here. I would ask though: I managed to get WOL working on Linux, but only if the parent ACPI devices have been explicitly activated for wakeup. I wonder if we've addressed that yet? On Linux it's necessary to use acpitool -W to fully enable the WOL capable device to bring the system out of sleep, it seems. From owner-svn-src-stable@FreeBSD.ORG Mon Feb 9 23:23:00 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 740EA10656DA; Mon, 9 Feb 2009 23:23:00 +0000 (UTC) (envelope-from rwatson@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 60F088FC1B; Mon, 9 Feb 2009 23:23:00 +0000 (UTC) (envelope-from rwatson@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n19NN0O7074634; Mon, 9 Feb 2009 23:23:00 GMT (envelope-from rwatson@svn.freebsd.org) Received: (from rwatson@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n19NN0QL074633; Mon, 9 Feb 2009 23:23:00 GMT (envelope-from rwatson@svn.freebsd.org) Message-Id: <200902092323.n19NN0QL074633@svn.freebsd.org> From: Robert Watson Date: Mon, 9 Feb 2009 23:23:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-6@freebsd.org X-SVN-Group: stable-6 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r188425 - stable/6/sys/kern X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Feb 2009 23:23:02 -0000 Author: rwatson Date: Mon Feb 9 23:23:00 2009 New Revision: 188425 URL: http://svn.freebsd.org/changeset/base/188425 Log: In unp_connect(), don't unlock the global UNIX domain socket lock when UNP_CONNECTING is set, as the caller will do that. (Due to significantly different locking in 7.0 and later, this fix applies only to stable/7). PR: kern/128974 Submitted by: Larry Baird Modified: stable/6/sys/kern/uipc_usrreq.c Modified: stable/6/sys/kern/uipc_usrreq.c ============================================================================== --- stable/6/sys/kern/uipc_usrreq.c Mon Feb 9 22:59:22 2009 (r188424) +++ stable/6/sys/kern/uipc_usrreq.c Mon Feb 9 23:23:00 2009 (r188425) @@ -1027,10 +1027,8 @@ unp_connect(struct socket *so, struct so if (len <= 0) return (EINVAL); strlcpy(buf, soun->sun_path, len + 1); - if (unp->unp_flags & UNP_CONNECTING) { - UNP_UNLOCK(); + if (unp->unp_flags & UNP_CONNECTING) return (EALREADY); - } unp->unp_flags |= UNP_CONNECTING; UNP_UNLOCK(); sa = malloc(sizeof(struct sockaddr_un), M_SONAME, M_WAITOK); From owner-svn-src-stable@FreeBSD.ORG Tue Feb 10 01:28:42 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 83094106564A for ; Tue, 10 Feb 2009 01:28:42 +0000 (UTC) (envelope-from pyunyh@gmail.com) Received: from yx-out-2324.google.com (yx-out-2324.google.com [74.125.44.29]) by mx1.freebsd.org (Postfix) with ESMTP id 374608FC13 for ; Tue, 10 Feb 2009 01:28:42 +0000 (UTC) (envelope-from pyunyh@gmail.com) Received: by yx-out-2324.google.com with SMTP id 31so150985yxl.13 for ; Mon, 09 Feb 2009 17:28:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:received:from:date:to:cc :subject:message-id:reply-to:references:mime-version:content-type :content-disposition:in-reply-to:user-agent; bh=gBcTu1TENaX0GhKlqrjiAXcQy6r+KLSqWyOIjxf40yA=; b=pYlQHgZcZ1p3kDE6BXObMftXDNvcJKV5bH8HqeZOD2e6+mdpifihw4xE38pUUgMQlj aKaoepe4DazWH9gAhrRH50cqYrOK/2rFsYpBmMmml0thHDo/IzJznnjrQcqFNt8uybVG 7lL6B1DKIS87j0vnJ9WkUJaVSuUgxsmpkPGdU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:date:to:cc:subject:message-id:reply-to:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; b=b43wO/npztl8LPgiXjf9FIVTfyuVF0D3zCjNnMZbURKjha56+KT8/jcbBFfs7TNOSL BKTaY36WED56JUz4eSJa9gx5J7zGzeM+QSkRadLe8onvx1RcpT7fXFs9OGzyySpe2VfT ylT+2+BopjuROaAMKYWGjPX25sIMCaZUbM8u8= Received: by 10.150.52.10 with SMTP id z10mr434536ybz.169.1234227441825; Mon, 09 Feb 2009 16:57:21 -0800 (PST) Received: from michelle.cdnetworks.co.kr ([114.111.62.249]) by mx.google.com with ESMTPS id m30sm13762272elf.12.2009.02.09.16.57.18 (version=SSLv3 cipher=RC4-MD5); Mon, 09 Feb 2009 16:57:20 -0800 (PST) Received: by michelle.cdnetworks.co.kr (sSMTP sendmail emulation); Tue, 10 Feb 2009 09:59:28 +0900 From: Pyun YongHyeon Date: Tue, 10 Feb 2009 09:59:28 +0900 To: "Bruce M. Simpson" Message-ID: <20090210005928.GE98095@michelle.cdnetworks.co.kr> References: <200902090353.n193rKkw044451@svn.freebsd.org> <4990B1F9.7020009@FreeBSD.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4990B1F9.7020009@FreeBSD.org> User-Agent: Mutt/1.4.2.3i Cc: svn-src-stable@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, svn-src-stable-7@freebsd.org, Pyun YongHyeon Subject: Re: svn commit: r188375 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb dev/fxp X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: pyunyh@gmail.com List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 10 Feb 2009 01:28:42 -0000 On Mon, Feb 09, 2009 at 10:45:13PM +0000, Bruce M. Simpson wrote: > This looks really cool and I look forward to trying WOL once I have the > right combo of cards/machines which should really sleep here. > > I would ask though: I managed to get WOL working on Linux, but only if > the parent ACPI devices have been explicitly activated for wakeup. I > wonder if we've addressed that yet? > If you mean suspend/resume support on amd64 I don't know. > On Linux it's necessary to use acpitool -W > to fully enable the WOL capable > device to bring the system out of sleep, it seems. I don't use Linux at all except comparing driver performance so I have no idea how Linux WOL works. Resuming with WOL was tested on FreeBSD i386 box and display was not restored to previous state on my box, except that system worked as normal. From owner-svn-src-stable@FreeBSD.ORG Tue Feb 10 11:36:38 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D3F26106564A; Tue, 10 Feb 2009 11:36:38 +0000 (UTC) (envelope-from rwatson@FreeBSD.org) Received: from cyrus.watson.org (cyrus.watson.org [65.122.17.42]) by mx1.freebsd.org (Postfix) with ESMTP id AEB008FC2C; Tue, 10 Feb 2009 11:36:38 +0000 (UTC) (envelope-from rwatson@FreeBSD.org) Received: from fledge.watson.org (fledge.watson.org [65.122.17.41]) by cyrus.watson.org (Postfix) with ESMTPS id 4EEA846B42; Tue, 10 Feb 2009 06:36:38 -0500 (EST) Date: Tue, 10 Feb 2009 11:36:38 +0000 (GMT) From: Robert Watson X-X-Sender: robert@fledge.watson.org To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-6@freebsd.org In-Reply-To: <200902092323.n19NN0QL074633@svn.freebsd.org> Message-ID: References: <200902092323.n19NN0QL074633@svn.freebsd.org> User-Agent: Alpine 2.00 (BSF 1167 2008-08-23) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: Subject: Re: svn commit: r188425 - stable/6/sys/kern X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 10 Feb 2009 11:36:41 -0000 On Mon, 9 Feb 2009, Robert Watson wrote: > Author: rwatson > Date: Mon Feb 9 23:23:00 2009 > New Revision: 188425 > URL: http://svn.freebsd.org/changeset/base/188425 > > Log: > In unp_connect(), don't unlock the global UNIX domain socket lock when > UNP_CONNECTING is set, as the caller will do that. > > (Due to significantly different locking in 7.0 and later, this fix > applies only to stable/7). This should have read "stable/6" -- the bug in question isn't present in the finer-grained UNIX domain socket locking introduced in the 7.x series. Robert N M Watson Computer Laboratory University of Cambridge From owner-svn-src-stable@FreeBSD.ORG Tue Feb 10 17:43:48 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4482B1065672; Tue, 10 Feb 2009 17:43:48 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 27A328FC0C; Tue, 10 Feb 2009 17:43:48 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n1AHhmjL099859; Tue, 10 Feb 2009 17:43:48 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n1AHhmhA099857; Tue, 10 Feb 2009 17:43:48 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <200902101743.n1AHhmhA099857@svn.freebsd.org> From: Konstantin Belousov Date: Tue, 10 Feb 2009 17:43:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r188441 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb kern ufs/ffs X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 10 Feb 2009 17:43:50 -0000 Author: kib Date: Tue Feb 10 17:43:47 2009 New Revision: 188441 URL: http://svn.freebsd.org/changeset/base/188441 Log: MFC r187467: Change vinvalbuf() to not remove any pages from the object when V_NORMAL or V_ALT are specified. Instead, the only in-tree caller in ffs_inode.c:ffs_truncate() that specifies V_ALT explicitely removes the corresponding page range. The V_NORMAL caller does vnode_pager_setsize(vp, 0) immediately after the call to vinvalbuf(V_NORMAL) already. MFC r187490: The r187467 should remove all pages for V_NORMAL case too, because indirect block pages are not removed by the mentioned invocation of the vnode_pager_setsize(). Put a common code into the helper function ffs_pages_remove(). Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/kern/vfs_subr.c stable/7/sys/ufs/ffs/ffs_inode.c Modified: stable/7/sys/kern/vfs_subr.c ============================================================================== --- stable/7/sys/kern/vfs_subr.c Tue Feb 10 15:50:19 2009 (r188440) +++ stable/7/sys/kern/vfs_subr.c Tue Feb 10 17:43:47 2009 (r188441) @@ -1103,7 +1103,7 @@ bufobj_invalbuf(struct bufobj *bo, int f /* * Destroy the copy in the VM cache, too. */ - if (bo->bo_object != NULL) { + if (bo->bo_object != NULL && (flags & (V_ALT | V_NORMAL)) == 0) { VM_OBJECT_LOCK(bo->bo_object); vm_object_page_remove(bo->bo_object, 0, 0, (flags & V_SAVE) ? TRUE : FALSE); Modified: stable/7/sys/ufs/ffs/ffs_inode.c ============================================================================== --- stable/7/sys/ufs/ffs/ffs_inode.c Tue Feb 10 15:50:19 2009 (r188440) +++ stable/7/sys/ufs/ffs/ffs_inode.c Tue Feb 10 17:43:47 2009 (r188441) @@ -48,6 +48,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include @@ -128,6 +129,18 @@ ffs_update(vp, waitfor) } } +static void +ffs_pages_remove(struct vnode *vp, vm_pindex_t start, vm_pindex_t end) +{ + vm_object_t object; + + if ((object = vp->v_object) == NULL) + return; + VM_OBJECT_LOCK(object); + vm_object_page_remove(object, start, end, FALSE); + VM_OBJECT_UNLOCK(object); +} + #define SINGLE 0 /* index of single indirect block */ #define DOUBLE 1 /* index of double indirect block */ #define TRIPLE 2 /* index of triple indirect block */ @@ -203,6 +216,8 @@ ffs_truncate(vp, length, flags, cred, td (void) chkdq(ip, -extblocks, NOCRED, 0); #endif vinvalbuf(vp, V_ALT, td, 0, 0); + ffs_pages_remove(vp, + OFF_TO_IDX(lblktosize(fs, -extblocks)), 0); ip->i_din2->di_extsize = 0; for (i = 0; i < NXADDR; i++) { oldblks[i] = ip->i_din2->di_extb[i]; @@ -279,6 +294,9 @@ ffs_truncate(vp, length, flags, cred, td IO_EXT | IO_NORMAL : IO_NORMAL); ASSERT_VOP_LOCKED(vp, "ffs_truncate1"); vinvalbuf(vp, needextclean ? 0 : V_NORMAL, td, 0, 0); + if (!needextclean) + ffs_pages_remove(vp, 0, + OFF_TO_IDX(lblktosize(fs, -extblocks))); vnode_pager_setsize(vp, 0); ip->i_flag |= IN_CHANGE | IN_UPDATE; return (ffs_update(vp, 0)); From owner-svn-src-stable@FreeBSD.ORG Tue Feb 10 17:47:36 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2237F106564A; Tue, 10 Feb 2009 17:47:36 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 0F37F8FC12; Tue, 10 Feb 2009 17:47:36 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n1AHlZVS099982; Tue, 10 Feb 2009 17:47:35 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n1AHlZMK099980; Tue, 10 Feb 2009 17:47:35 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <200902101747.n1AHlZMK099980@svn.freebsd.org> From: Konstantin Belousov Date: Tue, 10 Feb 2009 17:47:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r188442 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb ufs/ffs X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 10 Feb 2009 17:47:37 -0000 Author: kib Date: Tue Feb 10 17:47:35 2009 New Revision: 188442 URL: http://svn.freebsd.org/changeset/base/188442 Log: MFC r187468: Revert vnode_pager_setsize() back when UFS_BALLOC() failed, for ffs_truncate() and ffs_write(). Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/ufs/ffs/ffs_inode.c stable/7/sys/ufs/ffs/ffs_vnops.c Modified: stable/7/sys/ufs/ffs/ffs_inode.c ============================================================================== --- stable/7/sys/ufs/ffs/ffs_inode.c Tue Feb 10 17:43:47 2009 (r188441) +++ stable/7/sys/ufs/ffs/ffs_inode.c Tue Feb 10 17:47:35 2009 (r188442) @@ -312,8 +312,10 @@ ffs_truncate(vp, length, flags, cred, td vnode_pager_setsize(vp, length); flags |= BA_CLRBUF; error = UFS_BALLOC(vp, length - 1, 1, cred, flags, &bp); - if (error) + if (error) { + vnode_pager_setsize(vp, osize); return (error); + } ip->i_size = length; DIP_SET(ip, i_size, length); if (bp->b_bufsize == fs->fs_bsize) Modified: stable/7/sys/ufs/ffs/ffs_vnops.c ============================================================================== --- stable/7/sys/ufs/ffs/ffs_vnops.c Tue Feb 10 17:43:47 2009 (r188441) +++ stable/7/sys/ufs/ffs/ffs_vnops.c Tue Feb 10 17:47:35 2009 (r188442) @@ -723,8 +723,10 @@ ffs_write(ap) /* XXX is uio->uio_offset the right thing here? */ error = UFS_BALLOC(vp, uio->uio_offset, xfersize, ap->a_cred, flags, &bp); - if (error != 0) + if (error != 0) { + vnode_pager_setsize(vp, ip->i_size); break; + } /* * If the buffer is not valid we have to clear out any * garbage data from the pages instantiated for the buffer. From owner-svn-src-stable@FreeBSD.ORG Tue Feb 10 17:50:04 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 31CB81065670; Tue, 10 Feb 2009 17:50:04 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id D7A418FC1A; Tue, 10 Feb 2009 17:50:03 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n1AHo3tU000177; Tue, 10 Feb 2009 17:50:03 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n1AHo3WQ000176; Tue, 10 Feb 2009 17:50:03 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <200902101750.n1AHo3WQ000176@svn.freebsd.org> From: Konstantin Belousov Date: Tue, 10 Feb 2009 17:50:03 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r188443 - in stable/7/sys: . amd64/amd64 contrib/pf dev/ath/ath_hal dev/cxgb X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 10 Feb 2009 17:50:06 -0000 Author: kib Date: Tue Feb 10 17:50:03 2009 New Revision: 188443 URL: http://svn.freebsd.org/changeset/base/188443 Log: MFC r187470: Unconditionally reload fsbase when switching to 32bit binary. Modified: stable/7/sys/ (props changed) stable/7/sys/amd64/amd64/cpu_switch.S stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) Modified: stable/7/sys/amd64/amd64/cpu_switch.S ============================================================================== --- stable/7/sys/amd64/amd64/cpu_switch.S Tue Feb 10 17:47:35 2009 (r188442) +++ stable/7/sys/amd64/amd64/cpu_switch.S Tue Feb 10 17:50:03 2009 (r188443) @@ -199,6 +199,7 @@ done_load_seg: cmpq PCB_FSBASE(%r8),%r9 jz 1f /* Restore userland %fs */ +restore_fsbase: movl $MSR_FSBASE,%ecx movl PCB_FSBASE(%r8),%eax movl PCB_FSBASE+4(%r8),%edx @@ -281,7 +282,7 @@ load_seg: movl PCB_DS(%r8),%ds movl PCB_ES(%r8),%es movl PCB_FS(%r8),%fs - jmp done_load_seg + jmp restore_fsbase /* Restore userland %gs while preserving kernel gsbase */ 2: movq PCPU(GS32P),%rax movq PCB_GS32SD(%r8),%rcx From owner-svn-src-stable@FreeBSD.ORG Tue Feb 10 20:03:27 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 08947106564A; Tue, 10 Feb 2009 20:03:27 +0000 (UTC) (envelope-from emax@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id E990E8FC17; Tue, 10 Feb 2009 20:03:26 +0000 (UTC) (envelope-from emax@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n1AK3QVj002939; Tue, 10 Feb 2009 20:03:26 GMT (envelope-from emax@svn.freebsd.org) Received: (from emax@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n1AK3QQD002938; Tue, 10 Feb 2009 20:03:26 GMT (envelope-from emax@svn.freebsd.org) Message-Id: <200902102003.n1AK3QQD002938@svn.freebsd.org> From: Maksim Yevmenkin Date: Tue, 10 Feb 2009 20:03:26 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r188449 - stable/7/share/man/man4 X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 10 Feb 2009 20:03:27 -0000 Author: emax Date: Tue Feb 10 20:03:26 2009 New Revision: 188449 URL: http://svn.freebsd.org/changeset/base/188449 Log: MFC r182881 Document TAPGIFNAME, TAPSIFINFO and TAPGIFINFO tap(4) character device ioctl's. Modified: stable/7/share/man/man4/ (props changed) stable/7/share/man/man4/igb.4 (props changed) stable/7/share/man/man4/tap.4 Modified: stable/7/share/man/man4/tap.4 ============================================================================== --- stable/7/share/man/man4/tap.4 Tue Feb 10 19:37:38 2009 (r188448) +++ stable/7/share/man/man4/tap.4 Tue Feb 10 20:03:26 2009 (r188449) @@ -1,7 +1,7 @@ .\" $FreeBSD$ .\" Based on PR#2411 .\" -.Dd March 19, 2007 +.Dd September 8, 2008 .Os .Dt TAP 4 .Sh NAME @@ -163,6 +163,14 @@ calls are supported (defined in .In net/if_tap.h ) : .Bl -tag -width VMIO_SIOCSETMACADDR +.It Dv TAPSIFINFO +Set network interface information (line speed, MTU and type). +The argument should be a pointer to a +.Va struct tapinfo . +.It Dv TAPGIFINFO +Retrieve network interface information (line speed, MTU and type). +The argument should be a pointer to a +.Va struct tapinfo . .It Dv TAPSDEBUG The argument should be a pointer to an .Va int ; @@ -174,6 +182,13 @@ code. The argument should be a pointer to an .Va int ; this stores the internal debugging variable's value into it. +.It Dv TAPGIFNAME +Retrieve network interface name. +The argument should be a pointer to a +.Va struct ifreq . +The interface name will be returned in the +.Va ifr_name +field. .It Dv FIONBIO Turn non-blocking I/O for reads off or on, according as the argument .Va int Ns 's From owner-svn-src-stable@FreeBSD.ORG Tue Feb 10 20:04:22 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 27C18106564A; Tue, 10 Feb 2009 20:04:22 +0000 (UTC) (envelope-from emax@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 13F2D8FC0C; Tue, 10 Feb 2009 20:04:22 +0000 (UTC) (envelope-from emax@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n1AK4Ls3002996; Tue, 10 Feb 2009 20:04:21 GMT (envelope-from emax@svn.freebsd.org) Received: (from emax@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n1AK4KgW002994; Tue, 10 Feb 2009 20:04:20 GMT (envelope-from emax@svn.freebsd.org) Message-Id: <200902102004.n1AK4KgW002994@svn.freebsd.org> From: Maksim Yevmenkin Date: Tue, 10 Feb 2009 20:04:20 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r188450 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb net X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 10 Feb 2009 20:04:23 -0000 Author: emax Date: Tue Feb 10 20:04:20 2009 New Revision: 188450 URL: http://svn.freebsd.org/changeset/base/188450 Log: MFC r182880$$ Add new TAPGIFNAME tap(4) character device ioctl. This is a convenient shortcut to obtain network interface name using file descriptor for character device. Obtained from: NetBSD Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/net/if_tap.c stable/7/sys/net/if_tap.h Modified: stable/7/sys/net/if_tap.c ============================================================================== --- stable/7/sys/net/if_tap.c Tue Feb 10 20:03:26 2009 (r188449) +++ stable/7/sys/net/if_tap.c Tue Feb 10 20:04:20 2009 (r188450) @@ -745,6 +745,12 @@ tapioctl(struct cdev *dev, u_long cmd, c *(int *)data = tapdebug; break; + case TAPGIFNAME: { + struct ifreq *ifr = (struct ifreq *) data; + + strlcpy(ifr->ifr_name, ifp->if_xname, IFNAMSIZ); + } break; + case FIONBIO: break; Modified: stable/7/sys/net/if_tap.h ============================================================================== --- stable/7/sys/net/if_tap.h Tue Feb 10 20:03:26 2009 (r188449) +++ stable/7/sys/net/if_tap.h Tue Feb 10 20:04:20 2009 (r188450) @@ -55,6 +55,7 @@ struct tapinfo { #define TAPGDEBUG _IOR('t', 89, int) #define TAPSIFINFO _IOW('t', 91, struct tapinfo) #define TAPGIFINFO _IOR('t', 92, struct tapinfo) +#define TAPGIFNAME _IOR('t', 93, struct ifreq) /* VMware ioctl's */ #define VMIO_SIOCSIFFLAGS _IOWINT('V', 0) From owner-svn-src-stable@FreeBSD.ORG Tue Feb 10 20:08:03 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id CBB291065686; Tue, 10 Feb 2009 20:08:03 +0000 (UTC) (envelope-from emax@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 9E23D8FC21; Tue, 10 Feb 2009 20:08:03 +0000 (UTC) (envelope-from emax@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n1AK83TV003104; Tue, 10 Feb 2009 20:08:03 GMT (envelope-from emax@svn.freebsd.org) Received: (from emax@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n1AK83fs003103; Tue, 10 Feb 2009 20:08:03 GMT (envelope-from emax@svn.freebsd.org) Message-Id: <200902102008.n1AK83fs003103@svn.freebsd.org> From: Maksim Yevmenkin Date: Tue, 10 Feb 2009 20:08:03 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r188451 - stable/7/usr.sbin/bluetooth/sdpd X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 10 Feb 2009 20:08:05 -0000 Author: emax Date: Tue Feb 10 20:08:03 2009 New Revision: 188451 URL: http://svn.freebsd.org/changeset/base/188451 Log: MFC r185320 Straighten out those pesky SDP records for the Bluetooth Service Discovery Application Profile. Discussed with: Iain Hibbert of NetBSD plunky at rya dash online dot net Modified: stable/7/usr.sbin/bluetooth/sdpd/ (props changed) stable/7/usr.sbin/bluetooth/sdpd/sd.c Modified: stable/7/usr.sbin/bluetooth/sdpd/sd.c ============================================================================== --- stable/7/usr.sbin/bluetooth/sdpd/sd.c Tue Feb 10 20:04:20 2009 (r188450) +++ stable/7/usr.sbin/bluetooth/sdpd/sd.c Tue Feb 10 20:08:03 2009 (r188451) @@ -52,6 +52,22 @@ sd_profile_create_service_class_id_list( } static int32_t +sd_profile_create_bluetooth_profile_descriptor_list( + uint8_t *buf, uint8_t const * const eob, + uint8_t const *data, uint32_t datalen) +{ + static uint16_t profile_descriptor_list[] = { + SDP_SERVICE_CLASS_SERVICE_DISCOVERY_SERVER, + 0x0100 + }; + + return (common_profile_create_bluetooth_profile_descriptor_list( + buf, eob, + (uint8_t const *) profile_descriptor_list, + sizeof(profile_descriptor_list))); +} + +static int32_t sd_profile_create_service_id( uint8_t *buf, uint8_t const * const eob, uint8_t const *data, uint32_t datalen) @@ -89,25 +105,23 @@ sd_profile_create_protocol_descriptor_li uint8_t *buf, uint8_t const * const eob, uint8_t const *data, uint32_t datalen) { - if (buf + 13 > eob) + if (buf + 12 > eob) return (-1); SDP_PUT8(SDP_DATA_SEQ8, buf); - SDP_PUT8(11, buf); + SDP_PUT8(10, buf); SDP_PUT8(SDP_DATA_SEQ8, buf); - SDP_PUT8(9, buf); - + SDP_PUT8(3, buf); SDP_PUT8(SDP_DATA_UUID16, buf); SDP_PUT16(SDP_UUID_PROTOCOL_L2CAP, buf); - SDP_PUT8(SDP_DATA_UINT16, buf); - SDP_PUT16(NG_L2CAP_PSM_SDP, buf); - - SDP_PUT8(SDP_DATA_UINT16, buf); - SDP_PUT16(1, buf); /* version */ + SDP_PUT8(SDP_DATA_SEQ8, buf); + SDP_PUT8(3, buf); + SDP_PUT8(SDP_DATA_UUID16, buf); + SDP_PUT16(SDP_UUID_PROTOCOL_SDP, buf); - return (13); + return (12); } static int32_t @@ -182,6 +196,8 @@ static attr_t sd_profile_attrs[] = { common_profile_create_service_record_handle }, { SDP_ATTR_SERVICE_CLASS_ID_LIST, sd_profile_create_service_class_id_list }, + { SDP_ATTR_BLUETOOTH_PROFILE_DESCRIPTOR_LIST, + sd_profile_create_bluetooth_profile_descriptor_list }, { SDP_ATTR_SERVICE_ID, sd_profile_create_service_id }, { SDP_ATTR_LANGUAGE_BASE_ATTRIBUTE_ID_LIST, From owner-svn-src-stable@FreeBSD.ORG Tue Feb 10 21:09:54 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 995EC1065670; Tue, 10 Feb 2009 21:09:54 +0000 (UTC) (envelope-from emax@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 853AF8FC14; Tue, 10 Feb 2009 21:09:54 +0000 (UTC) (envelope-from emax@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n1AL9sof004416; Tue, 10 Feb 2009 21:09:54 GMT (envelope-from emax@svn.freebsd.org) Received: (from emax@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n1AL9s3j004415; Tue, 10 Feb 2009 21:09:54 GMT (envelope-from emax@svn.freebsd.org) Message-Id: <200902102109.n1AL9s3j004415@svn.freebsd.org> From: Maksim Yevmenkin Date: Tue, 10 Feb 2009 21:09:54 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r188454 - in stable/7/lib/libc: . string uuid X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 10 Feb 2009 21:09:55 -0000 Author: emax Date: Tue Feb 10 21:09:54 2009 New Revision: 188454 URL: http://svn.freebsd.org/changeset/base/188454 Log: MFC r183058 Add uuid_enc,dec_le,be() functions to Symbol.map Pointy hat goes to me. MFC r183192 Move uuid_enc_le, uuid_dec_le, uuid_enc_be and uuid_dec_be symbols into FBSD_1.1 section where they should be (as Pointed out by: kib, deischen) Modified: stable/7/lib/libc/ (props changed) stable/7/lib/libc/string/ffsll.c (props changed) stable/7/lib/libc/string/flsll.c (props changed) stable/7/lib/libc/uuid/Symbol.map Modified: stable/7/lib/libc/uuid/Symbol.map ============================================================================== --- stable/7/lib/libc/uuid/Symbol.map Tue Feb 10 20:29:57 2009 (r188453) +++ stable/7/lib/libc/uuid/Symbol.map Tue Feb 10 21:09:54 2009 (r188454) @@ -12,3 +12,10 @@ FBSD_1.0 { uuid_create; uuid_compare; }; + +FBSD_1.1 { + uuid_enc_le; + uuid_dec_le; + uuid_enc_be; + uuid_dec_be; +}; From owner-svn-src-stable@FreeBSD.ORG Wed Feb 11 10:28:56 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4ABCC1065670; Wed, 11 Feb 2009 10:28:56 +0000 (UTC) (envelope-from maxim@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 1CBC78FC17; Wed, 11 Feb 2009 10:28:56 +0000 (UTC) (envelope-from maxim@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n1BASuAF020670; Wed, 11 Feb 2009 10:28:56 GMT (envelope-from maxim@svn.freebsd.org) Received: (from maxim@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n1BAStLU020668; Wed, 11 Feb 2009 10:28:55 GMT (envelope-from maxim@svn.freebsd.org) Message-Id: <200902111028.n1BAStLU020668@svn.freebsd.org> From: Maxim Konovalov Date: Wed, 11 Feb 2009 10:28:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r188479 - stable/7/usr.bin/netstat X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Feb 2009 10:28:57 -0000 Author: maxim Date: Wed Feb 11 10:28:55 2009 New Revision: 188479 URL: http://svn.freebsd.org/changeset/base/188479 Log: MFC r186644: show unix sockets listen queues stats with -L flag. Modified: stable/7/usr.bin/netstat/ (props changed) stable/7/usr.bin/netstat/main.c stable/7/usr.bin/netstat/unix.c Modified: stable/7/usr.bin/netstat/main.c ============================================================================== --- stable/7/usr.bin/netstat/main.c Wed Feb 11 09:18:09 2009 (r188478) +++ stable/7/usr.bin/netstat/main.c Wed Feb 11 10:28:55 2009 (r188479) @@ -589,7 +589,7 @@ main(int argc, char *argv[]) for (tp = netgraphprotox; tp->pr_name; tp++) printproto(tp, tp->pr_name); #endif /* NETGRAPH */ - if ((af == AF_UNIX || af == AF_UNSPEC) && !Lflag && !sflag) + if ((af == AF_UNIX || af == AF_UNSPEC) && !sflag) unixpr(nl[N_UNP_COUNT].n_value, nl[N_UNP_GENCNT].n_value, nl[N_UNP_DHEAD].n_value, nl[N_UNP_SHEAD].n_value); exit(0); Modified: stable/7/usr.bin/netstat/unix.c ============================================================================== --- stable/7/usr.bin/netstat/unix.c Wed Feb 11 09:18:09 2009 (r188478) +++ stable/7/usr.bin/netstat/unix.c Wed Feb 11 10:28:55 2009 (r188479) @@ -247,6 +247,7 @@ unixdomainpr(struct xunpcb *xunp, struct struct unpcb *unp; struct sockaddr_un *sa; static int first = 1; + char buf1[15]; unp = &xunp->xu_unp; if (unp->unp_addr) @@ -254,7 +255,7 @@ unixdomainpr(struct xunpcb *xunp, struct else sa = (struct sockaddr_un *)0; - if (first) { + if (first && !Lflag) { printf("Active UNIX domain sockets\n"); printf( "%-8.8s %-6.6s %-6.6s %-6.6s %8.8s %8.8s %8.8s %8.8s Addr\n", @@ -262,11 +263,21 @@ unixdomainpr(struct xunpcb *xunp, struct "Inode", "Conn", "Refs", "Nextref"); first = 0; } - printf("%8lx %-6.6s %6u %6u %8lx %8lx %8lx %8lx", - (long)so->so_pcb, socktype[so->so_type], so->so_rcv.sb_cc, - so->so_snd.sb_cc, - (long)unp->unp_vnode, (long)unp->unp_conn, - (long)LIST_FIRST(&unp->unp_refs), (long)LIST_NEXT(unp, unp_reflink)); + + if (Lflag && so->so_qlimit == 0) + return; + + if (Lflag) { + snprintf(buf1, 15, "%d/%d/%d", so->so_qlen, + so->so_incqlen, so->so_qlimit); + printf("unix %-14.14s", buf1); + } else { + printf("%8lx %-6.6s %6u %6u %8lx %8lx %8lx %8lx", + (long)so->so_pcb, socktype[so->so_type], so->so_rcv.sb_cc, + so->so_snd.sb_cc, (long)unp->unp_vnode, (long)unp->unp_conn, + (long)LIST_FIRST(&unp->unp_refs), + (long)LIST_NEXT(unp, unp_reflink)); + } if (sa) printf(" %.*s", (int)(sa->sun_len - offsetof(struct sockaddr_un, sun_path)), From owner-svn-src-stable@FreeBSD.ORG Thu Feb 12 14:37:59 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id DB27210656D8; Thu, 12 Feb 2009 14:37:58 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id C7CFF8FC20; Thu, 12 Feb 2009 14:37:58 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n1CEbwK8058326; Thu, 12 Feb 2009 14:37:58 GMT (envelope-from jhb@svn.freebsd.org) Received: (from jhb@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n1CEbwUe058325; Thu, 12 Feb 2009 14:37:58 GMT (envelope-from jhb@svn.freebsd.org) Message-Id: <200902121437.n1CEbwUe058325@svn.freebsd.org> From: John Baldwin Date: Thu, 12 Feb 2009 14:37:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r188514 - in stable/7/sys: . contrib/pf dev/cxgb libkern X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Feb 2009 14:38:00 -0000 Author: jhb Date: Thu Feb 12 14:37:58 2009 New Revision: 188514 URL: http://svn.freebsd.org/changeset/base/188514 Log: MFC: Add simple locking for the in-kernel iconv code. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/libkern/iconv.c Modified: stable/7/sys/libkern/iconv.c ============================================================================== --- stable/7/sys/libkern/iconv.c Thu Feb 12 13:49:51 2009 (r188513) +++ stable/7/sys/libkern/iconv.c Thu Feb 12 14:37:58 2009 (r188514) @@ -39,6 +39,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include "iconv_converter_if.h" @@ -52,6 +53,8 @@ MALLOC_DEFINE(M_ICONVDATA, "iconv_data", MODULE_VERSION(libiconv, 2); +static struct sx iconv_lock; + #ifdef notnow /* * iconv converter instance @@ -86,11 +89,16 @@ iconv_mod_unload(void) { struct iconv_cspair *csp; + sx_xlock(&iconv_lock); while ((csp = TAILQ_FIRST(&iconv_cslist)) != NULL) { if (csp->cp_refcount) return EBUSY; - iconv_unregister_cspair(csp); } + + while ((csp = TAILQ_FIRST(&iconv_cslist)) != NULL) + iconv_unregister_cspair(csp); + sx_xunlock(&iconv_lock); + sx_destroy(&iconv_lock); return 0; } @@ -102,6 +110,7 @@ iconv_mod_handler(module_t mod, int type switch (type) { case MOD_LOAD: error = 0; + sx_init(&iconv_lock, "iconv"); break; case MOD_UNLOAD: error = iconv_mod_unload(); @@ -311,7 +320,7 @@ iconv_sysctl_drvlist(SYSCTL_HANDLER_ARGS int error; error = 0; - + sx_slock(&iconv_lock); TAILQ_FOREACH(dcp, &iconv_converters, cc_link) { name = ICONV_CONVERTER_NAME(dcp); if (name == NULL) @@ -320,6 +329,7 @@ iconv_sysctl_drvlist(SYSCTL_HANDLER_ARGS if (error) break; } + sx_sunlock(&iconv_lock); if (error) return error; spc = 0; @@ -343,7 +353,7 @@ iconv_sysctl_cslist(SYSCTL_HANDLER_ARGS) error = 0; bzero(&csi, sizeof(csi)); csi.cs_version = ICONV_CSPAIR_INFO_VER; - + sx_slock(&iconv_lock); TAILQ_FOREACH(csp, &iconv_cslist, cp_link) { csi.cs_id = csp->cp_id; csi.cs_refcount = csp->cp_refcount; @@ -354,6 +364,7 @@ iconv_sysctl_cslist(SYSCTL_HANDLER_ARGS) if (error) break; } + sx_sunlock(&iconv_lock); return error; } @@ -387,9 +398,12 @@ iconv_sysctl_add(SYSCTL_HANDLER_ARGS) return EINVAL; if (iconv_lookupconv(din.ia_converter, &dcp) != 0) return EINVAL; + sx_xlock(&iconv_lock); error = iconv_register_cspair(din.ia_to, din.ia_from, dcp, NULL, &csp); - if (error) + if (error) { + sx_xunlock(&iconv_lock); return error; + } if (din.ia_datalen) { csp->cp_data = malloc(din.ia_datalen, M_ICONVDATA, M_WAITOK); error = copyin(din.ia_data, csp->cp_data, din.ia_datalen); @@ -400,10 +414,12 @@ iconv_sysctl_add(SYSCTL_HANDLER_ARGS) error = SYSCTL_OUT(req, &dout, sizeof(dout)); if (error) goto bad; + sx_xunlock(&iconv_lock); ICDEBUG("%s => %s, %d bytes\n",din.ia_from, din.ia_to, din.ia_datalen); return 0; bad: iconv_unregister_cspair(csp); + sx_xunlock(&iconv_lock); return error; } @@ -433,16 +449,22 @@ iconv_converter_handler(module_t mod, in switch (type) { case MOD_LOAD: + sx_xlock(&iconv_lock); error = iconv_register_converter(dcp); - if (error) + if (error) { + sx_xunlock(&iconv_lock); break; + } error = ICONV_CONVERTER_INIT(dcp); if (error) iconv_unregister_converter(dcp); + sx_xunlock(&iconv_lock); break; case MOD_UNLOAD: + sx_xlock(&iconv_lock); ICONV_CONVERTER_DONE(dcp); error = iconv_unregister_converter(dcp); + sx_xunlock(&iconv_lock); break; default: error = EINVAL; From owner-svn-src-stable@FreeBSD.ORG Thu Feb 12 14:41:23 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9251810657D3; Thu, 12 Feb 2009 14:41:23 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 7BF8E8FC14; Thu, 12 Feb 2009 14:41:23 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n1CEfNM9058449; Thu, 12 Feb 2009 14:41:23 GMT (envelope-from jhb@svn.freebsd.org) Received: (from jhb@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n1CEfNM5058448; Thu, 12 Feb 2009 14:41:23 GMT (envelope-from jhb@svn.freebsd.org) Message-Id: <200902121441.n1CEfNM5058448@svn.freebsd.org> From: John Baldwin Date: Thu, 12 Feb 2009 14:41:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r188515 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb kern X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Feb 2009 14:41:26 -0000 Author: jhb Date: Thu Feb 12 14:41:23 2009 New Revision: 188515 URL: http://svn.freebsd.org/changeset/base/188515 Log: MFC: Drop the kernel linker lock while running SYSUNINIT routines and removing sysctls during a linker file unload. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/kern/kern_linker.c Modified: stable/7/sys/kern/kern_linker.c ============================================================================== --- stable/7/sys/kern/kern_linker.c Thu Feb 12 14:37:58 2009 (r188514) +++ stable/7/sys/kern/kern_linker.c Thu Feb 12 14:41:23 2009 (r188515) @@ -642,8 +642,11 @@ linker_file_unload(linker_file_t file, i * link error. */ if (file->flags & LINKER_FILE_LINKED) { + file->flags &= ~LINKER_FILE_LINKED; + KLD_UNLOCK(); linker_file_sysuninit(file); linker_file_unregister_sysctls(file); + KLD_LOCK(); } TAILQ_REMOVE(&linker_files, file, link); From owner-svn-src-stable@FreeBSD.ORG Thu Feb 12 14:49:21 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3AB5B106568A; Thu, 12 Feb 2009 14:49:21 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 0B9CE8FC14; Thu, 12 Feb 2009 14:49:21 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n1CEnKup058701; Thu, 12 Feb 2009 14:49:20 GMT (envelope-from jhb@svn.freebsd.org) Received: (from jhb@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n1CEnKFK058700; Thu, 12 Feb 2009 14:49:20 GMT (envelope-from jhb@svn.freebsd.org) Message-Id: <200902121449.n1CEnKFK058700@svn.freebsd.org> From: John Baldwin Date: Thu, 12 Feb 2009 14:49:20 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-6@freebsd.org X-SVN-Group: stable-6 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r188517 - in stable/6/sys: . boot/i386/libi386 contrib/pf dev/cxgb X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Feb 2009 14:49:24 -0000 Author: jhb Date: Thu Feb 12 14:49:20 2009 New Revision: 188517 URL: http://svn.freebsd.org/changeset/base/188517 Log: MFC: Use CPUID to see if the current CPU supports long mode when attemping to boot an amd64 kernel. Modified: stable/6/sys/ (props changed) stable/6/sys/boot/i386/libi386/bootinfo64.c stable/6/sys/contrib/pf/ (props changed) stable/6/sys/dev/cxgb/ (props changed) Modified: stable/6/sys/boot/i386/libi386/bootinfo64.c ============================================================================== --- stable/6/sys/boot/i386/libi386/bootinfo64.c Thu Feb 12 14:44:15 2009 (r188516) +++ stable/6/sys/boot/i386/libi386/bootinfo64.c Thu Feb 12 14:49:20 2009 (r188517) @@ -32,6 +32,9 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include +#include +#include #include "bootstrap.h" #include "libi386.h" #include "btxv86.h" @@ -124,7 +127,45 @@ bi_copymodules64(vm_offset_t addr) } /* - * Load the information expected by an i386 kernel. + * Check to see if this CPU supports long mode. + */ +static int +bi_checkcpu(void) +{ + char *cpu_vendor; + int vendor[3]; + int eflags, regs[4]; + + /* Check for presence of "cpuid". */ + eflags = read_eflags(); + write_eflags(eflags ^ PSL_ID); + if (!((eflags ^ read_eflags()) & PSL_ID)) + return (0); + + /* Fetch the vendor string. */ + do_cpuid(0, regs); + vendor[0] = regs[1]; + vendor[1] = regs[3]; + vendor[2] = regs[2]; + cpu_vendor = (char *)vendor; + + /* Check for vendors that support AMD features. */ + if (strncmp(cpu_vendor, "GenuineIntel", 12) != 0 && + strncmp(cpu_vendor, "AuthenticAMD", 12) != 0) + return (0); + + /* Has to support AMD features. */ + do_cpuid(0x80000000, regs); + if (!(regs[0] >= 0x80000001)) + return (0); + + /* Check for long mode. */ + do_cpuid(0x80000001, regs); + return (regs[3] & AMDID_LM); +} + +/* + * Load the information expected by an amd64 kernel. * * - The 'boothowto' argument is constructed * - The 'bootdev' argument is constructed @@ -147,6 +188,11 @@ bi_load64(char *args, vm_offset_t *modul char *kernelname; const char *kernelpath; + if (!bi_checkcpu()) { + printf("CPU doesn't support long mode\n"); + return (EINVAL); + } + howto = bi_getboothowto(args); /* From owner-svn-src-stable@FreeBSD.ORG Thu Feb 12 15:26:00 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id BAED0106567A; Thu, 12 Feb 2009 15:26:00 +0000 (UTC) (envelope-from cognet@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id A832A8FC0C; Thu, 12 Feb 2009 15:26:00 +0000 (UTC) (envelope-from cognet@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n1CFQ0Dj059452; Thu, 12 Feb 2009 15:26:00 GMT (envelope-from cognet@svn.freebsd.org) Received: (from cognet@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n1CFQ0Ic059451; Thu, 12 Feb 2009 15:26:00 GMT (envelope-from cognet@svn.freebsd.org) Message-Id: <200902121526.n1CFQ0Ic059451@svn.freebsd.org> From: Olivier Houchard Date: Thu, 12 Feb 2009 15:26:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r188518 - stable/7/sys/dev/sound/pci X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Feb 2009 15:26:01 -0000 Author: cognet Date: Thu Feb 12 15:26:00 2009 New Revision: 188518 URL: http://svn.freebsd.org/changeset/base/188518 Log: MFC: r188424 | cognet | 2009-02-09 23:59:22 +0100 (Mon, 09 Feb 2009) | 6 lines Hmm... "base? base : 0" and "base" should be equivalent. Modified: stable/7/sys/dev/sound/pci/ds1.c Modified: stable/7/sys/dev/sound/pci/ds1.c ============================================================================== --- stable/7/sys/dev/sound/pci/ds1.c Thu Feb 12 14:49:20 2009 (r188517) +++ stable/7/sys/dev/sound/pci/ds1.c Thu Feb 12 15:26:00 2009 (r188518) @@ -396,7 +396,7 @@ ds_initpbank(volatile struct pbank *pb, pb->Format |= b16? 0 : 0x80000000; pb->Format |= (stereo && (ch == 2 || ch == 4))? 0x00000001 : 0; pb->LoopDefault = 0; - pb->PgBase = base? base : 0; + pb->PgBase = base; pb->PgLoop = 0; pb->PgLoopEnd = len >> ss; pb->PgLoopFrac = 0; From owner-svn-src-stable@FreeBSD.ORG Thu Feb 12 15:26:29 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 555A91065674; Thu, 12 Feb 2009 15:26:28 +0000 (UTC) (envelope-from cognet@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 467AE8FC1A; Thu, 12 Feb 2009 15:26:28 +0000 (UTC) (envelope-from cognet@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n1CFQSTs059497; Thu, 12 Feb 2009 15:26:28 GMT (envelope-from cognet@svn.freebsd.org) Received: (from cognet@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n1CFQS2M059496; Thu, 12 Feb 2009 15:26:28 GMT (envelope-from cognet@svn.freebsd.org) Message-Id: <200902121526.n1CFQS2M059496@svn.freebsd.org> From: Olivier Houchard Date: Thu, 12 Feb 2009 15:26:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-6@freebsd.org X-SVN-Group: stable-6 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r188519 - stable/6/sys/dev/sound/pci X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Feb 2009 15:26:30 -0000 Author: cognet Date: Thu Feb 12 15:26:27 2009 New Revision: 188519 URL: http://svn.freebsd.org/changeset/base/188519 Log: MFC: r188424 | cognet | 2009-02-09 23:59:22 +0100 (Mon, 09 Feb 2009) | 6 lines Hmm... "base? base : 0" and "base" should be equivalent. Modified: stable/6/sys/dev/sound/pci/ds1.c Modified: stable/6/sys/dev/sound/pci/ds1.c ============================================================================== --- stable/6/sys/dev/sound/pci/ds1.c Thu Feb 12 15:26:00 2009 (r188518) +++ stable/6/sys/dev/sound/pci/ds1.c Thu Feb 12 15:26:27 2009 (r188519) @@ -396,7 +396,7 @@ ds_initpbank(volatile struct pbank *pb, pb->Format |= b16? 0 : 0x80000000; pb->Format |= (stereo && (ch == 2 || ch == 4))? 0x00000001 : 0; pb->LoopDefault = 0; - pb->PgBase = base? base : 0; + pb->PgBase = base; pb->PgLoop = 0; pb->PgLoopEnd = len >> ss; pb->PgLoopFrac = 0; From owner-svn-src-stable@FreeBSD.ORG Thu Feb 12 16:40:48 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 764DE10656C1; Thu, 12 Feb 2009 16:40:48 +0000 (UTC) (envelope-from rrs@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 6498A8FC15; Thu, 12 Feb 2009 16:40:48 +0000 (UTC) (envelope-from rrs@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n1CGem6M061022; Thu, 12 Feb 2009 16:40:48 GMT (envelope-from rrs@svn.freebsd.org) Received: (from rrs@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n1CGemoZ061021; Thu, 12 Feb 2009 16:40:48 GMT (envelope-from rrs@svn.freebsd.org) Message-Id: <200902121640.n1CGemoZ061021@svn.freebsd.org> From: Randall Stewart Date: Thu, 12 Feb 2009 16:40:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r188521 - in stable/7/sys: . netinet X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Feb 2009 16:40:49 -0000 Author: rrs Date: Thu Feb 12 16:40:48 2009 New Revision: 188521 URL: http://svn.freebsd.org/changeset/base/188521 Log: Merges in 182268 from head close bug where we failed to NULL the sctp_socket. Modified: stable/7/sys/ (props changed) stable/7/sys/netinet/sctp_pcb.c Modified: stable/7/sys/netinet/sctp_pcb.c ============================================================================== --- stable/7/sys/netinet/sctp_pcb.c Thu Feb 12 15:28:15 2009 (r188520) +++ stable/7/sys/netinet/sctp_pcb.c Thu Feb 12 16:40:48 2009 (r188521) @@ -3270,6 +3270,7 @@ sctp_inpcb_free(struct sctp_inpcb *inp, #ifdef SCTP_LOG_CLOSING sctp_log_closing(inp, NULL, 2); #endif + inp->sctp_socket = NULL; return; } } From owner-svn-src-stable@FreeBSD.ORG Thu Feb 12 17:26:17 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 003F3106564A; Thu, 12 Feb 2009 17:26:16 +0000 (UTC) (envelope-from rrs@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id E285F8FC1C; Thu, 12 Feb 2009 17:26:16 +0000 (UTC) (envelope-from rrs@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n1CHQG7d061987; Thu, 12 Feb 2009 17:26:16 GMT (envelope-from rrs@svn.freebsd.org) Received: (from rrs@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n1CHQGgR061986; Thu, 12 Feb 2009 17:26:16 GMT (envelope-from rrs@svn.freebsd.org) Message-Id: <200902121726.n1CHQGgR061986@svn.freebsd.org> From: Randall Stewart Date: Thu, 12 Feb 2009 17:26:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r188522 - in stable/7/sys: . netinet X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Feb 2009 17:26:17 -0000 Author: rrs Date: Thu Feb 12 17:26:16 2009 New Revision: 188522 URL: http://svn.freebsd.org/changeset/base/188522 Log: MFC of 184030 - socket accept inherit bug. Basically accepted sockets were not inheriting the proper sock buf size. Modified: stable/7/sys/ (props changed) stable/7/sys/netinet/sctp_usrreq.c Modified: stable/7/sys/netinet/sctp_usrreq.c ============================================================================== --- stable/7/sys/netinet/sctp_usrreq.c Thu Feb 12 16:40:48 2009 (r188521) +++ stable/7/sys/netinet/sctp_usrreq.c Thu Feb 12 17:26:16 2009 (r188522) @@ -516,9 +516,11 @@ sctp_attach(struct socket *so, int proto SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL); return EINVAL; } - error = SCTP_SORESERVE(so, SCTP_BASE_SYSCTL(sctp_sendspace), SCTP_BASE_SYSCTL(sctp_recvspace)); - if (error) { - return error; + if (so->so_snd.sb_hiwat == 0 || so->so_rcv.sb_hiwat == 0) { + error = SCTP_SORESERVE(so, SCTP_BASE_SYSCTL(sctp_sendspace), SCTP_BASE_SYSCTL(sctp_recvspace)); + if (error) { + return error; + } } error = sctp_inpcb_alloc(so, vrf_id); if (error) { From owner-svn-src-stable@FreeBSD.ORG Thu Feb 12 17:31:39 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C58EB1065674; Thu, 12 Feb 2009 17:31:39 +0000 (UTC) (envelope-from rrs@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 992F78FC08; Thu, 12 Feb 2009 17:31:39 +0000 (UTC) (envelope-from rrs@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n1CHVdaD062201; Thu, 12 Feb 2009 17:31:39 GMT (envelope-from rrs@svn.freebsd.org) Received: (from rrs@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n1CHVdD4062199; Thu, 12 Feb 2009 17:31:39 GMT (envelope-from rrs@svn.freebsd.org) Message-Id: <200902121731.n1CHVdD4062199@svn.freebsd.org> From: Randall Stewart Date: Thu, 12 Feb 2009 17:31:39 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r188523 - in stable/7/sys: . netinet X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Feb 2009 17:31:41 -0000 Author: rrs Date: Thu Feb 12 17:31:39 2009 New Revision: 188523 URL: http://svn.freebsd.org/changeset/base/188523 Log: MFC of 184336: Two inter-related bugs. - If we send EXACTLY the size left in the send buffer and then send again, we end up with exactly 0 bytes and don't hit the pre-block code to wait for more space. - If we fall into the loop with our max_len == 0 (the bug above) we then call in to copy out the data, setup the length of the waiting to transmit data to 0 and call the mbuf copy routine which 0 indicates copy all the data to the mbuf chain.. which it does. This then leaves a "stuck" message on the stream queue with its size exactly 0 bytes but all the data there and thus nothing left in the uio structure. We then reach a stuck forever state never being able to send data. Modified: stable/7/sys/ (props changed) stable/7/sys/netinet/sctp_output.c Modified: stable/7/sys/netinet/sctp_output.c ============================================================================== --- stable/7/sys/netinet/sctp_output.c Thu Feb 12 17:26:16 2009 (r188522) +++ stable/7/sys/netinet/sctp_output.c Thu Feb 12 17:31:39 2009 (r188523) @@ -11686,7 +11686,12 @@ sctp_copy_it_in(struct sctp_tcb *stcb, sp->put_last_out = 0; resv_in_first = sizeof(struct sctp_data_chunk); sp->data = sp->tail_mbuf = NULL; + if (sp->length == 0) { + *error = 0; + goto skip_copy; + } *error = sctp_copy_one(sp, uio, resv_in_first); +skip_copy: if (*error) { sctp_free_a_strmoq(stcb, sp); sp = NULL; @@ -12448,7 +12453,8 @@ sctp_lower_sosend(struct socket *so, goto skip_preblock; } if (((max_len <= local_add_more) && - (SCTP_SB_LIMIT_SND(so) > local_add_more)) || + (SCTP_SB_LIMIT_SND(so) >= local_add_more)) || + (max_len == 0) || ((stcb->asoc.chunks_on_out_queue + stcb->asoc.stream_queue_cnt) >= SCTP_BASE_SYSCTL(sctp_max_chunks_on_queue))) { /* if */ /* No room right now ! */ SOCKBUF_LOCK(&so->so_snd); @@ -13063,7 +13069,7 @@ skip_out_eof: (void)sctp_med_chunk_output(inp, stcb, &stcb->asoc, &num_out, &reason, 1, &cwnd_full, 1, &now, &now_filled, frag_point, SCTP_SO_LOCKED); } - SCTPDBG(SCTP_DEBUG_OUTPUT1, "USR Send complete qo:%d prw:%d unsent:%d tf:%d cooq:%d toqs:%d err:%d", + SCTPDBG(SCTP_DEBUG_OUTPUT1, "USR Send complete qo:%d prw:%d unsent:%d tf:%d cooq:%d toqs:%d err:%d\n", queue_only, stcb->asoc.peers_rwnd, un_sent, stcb->asoc.total_flight, stcb->asoc.chunks_on_out_queue, stcb->asoc.total_output_queue_size, error); From owner-svn-src-stable@FreeBSD.ORG Thu Feb 12 17:57:29 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 37A67106572B; Thu, 12 Feb 2009 17:57:29 +0000 (UTC) (envelope-from rrs@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 248DD8FC0A; Thu, 12 Feb 2009 17:57:29 +0000 (UTC) (envelope-from rrs@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n1CHvTmG062791; Thu, 12 Feb 2009 17:57:29 GMT (envelope-from rrs@svn.freebsd.org) Received: (from rrs@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n1CHvSVo062783; Thu, 12 Feb 2009 17:57:28 GMT (envelope-from rrs@svn.freebsd.org) Message-Id: <200902121757.n1CHvSVo062783@svn.freebsd.org> From: Randall Stewart Date: Thu, 12 Feb 2009 17:57:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r188524 - in stable/7/sys: . netinet X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Feb 2009 17:57:30 -0000 Author: rrs Date: Thu Feb 12 17:57:28 2009 New Revision: 188524 URL: http://svn.freebsd.org/changeset/base/188524 Log: MFC of 182367 and 182403 - Make strict-sacks be the default. - Change it so that without INVARIANTs there are no panics in SCTP. - sctp_timer changes so that we have a recovery mechanism when the sent list is out of order. Fixes compile error when INVARIANTs is on. Adds an empty goto to keep the compiler happy. Modified: stable/7/sys/ (props changed) stable/7/sys/netinet/sctp_indata.c stable/7/sys/netinet/sctp_lock_bsd.h stable/7/sys/netinet/sctp_output.c stable/7/sys/netinet/sctp_sysctl.h stable/7/sys/netinet/sctp_timer.c stable/7/sys/netinet/sctp_timer.h stable/7/sys/netinet/sctp_var.h stable/7/sys/netinet/sctputil.c Modified: stable/7/sys/netinet/sctp_indata.c ============================================================================== --- stable/7/sys/netinet/sctp_indata.c Thu Feb 12 17:31:39 2009 (r188523) +++ stable/7/sys/netinet/sctp_indata.c Thu Feb 12 17:57:28 2009 (r188524) @@ -386,12 +386,21 @@ abandon: if (stcb->asoc.state & SCTP_STATE_ABOUT_TO_BE_FREED) { goto abandon; } else { +#ifdef INVARIANTS if ((stcb->asoc.control_pdapi == NULL) || (stcb->asoc.control_pdapi->tail_mbuf == NULL)) { panic("This should not happen control_pdapi NULL?"); } /* if we did not panic, it was a EOM */ panic("Bad chunking ??"); - return; +#else + if ((stcb->asoc.control_pdapi == NULL) || (stcb->asoc.control_pdapi->tail_mbuf == NULL)) { + SCTP_PRINTF("This should not happen control_pdapi NULL?\n"); + } + SCTP_PRINTF("Bad chunking ??\n"); + SCTP_PRINTF("Dumping re-assembly queue this will probably hose the association\n"); + +#endif + goto abandon; } } cntDel++; Modified: stable/7/sys/netinet/sctp_lock_bsd.h ============================================================================== --- stable/7/sys/netinet/sctp_lock_bsd.h Thu Feb 12 17:31:39 2009 (r188523) +++ stable/7/sys/netinet/sctp_lock_bsd.h Thu Feb 12 17:57:28 2009 (r188524) @@ -365,14 +365,20 @@ extern int sctp_logoff_stuff; do { \ atomic_add_int(&SCTP_BASE_INFO(ipi_count_chunk), 1); \ } while (0) - +#ifdef INVARIANTS #define SCTP_DECR_CHK_COUNT() \ do { \ if(SCTP_BASE_INFO(ipi_count_chunk) == 0) \ panic("chunk count to 0?"); \ atomic_subtract_int(&SCTP_BASE_INFO(ipi_count_chunk), 1); \ } while (0) - +#else +#define SCTP_DECR_CHK_COUNT() \ + do { \ + if(SCTP_BASE_INFO(ipi_count_chunk) != 0) \ + atomic_subtract_int(&SCTP_BASE_INFO(ipi_count_chunk), 1); \ + } while (0) +#endif #define SCTP_INCR_READQ_COUNT() \ do { \ atomic_add_int(&SCTP_BASE_INFO(ipi_count_readq),1); \ Modified: stable/7/sys/netinet/sctp_output.c ============================================================================== --- stable/7/sys/netinet/sctp_output.c Thu Feb 12 17:31:39 2009 (r188523) +++ stable/7/sys/netinet/sctp_output.c Thu Feb 12 17:57:28 2009 (r188524) @@ -11381,6 +11381,7 @@ sctp_send_operr_to(struct mbuf *m, int i struct ip *iph; struct udphdr *udp = NULL; struct mbuf *mout; + #ifdef INET6 #ifdef SCTP_DEBUG struct sockaddr_in6 lsa6, fsa6; Modified: stable/7/sys/netinet/sctp_sysctl.h ============================================================================== --- stable/7/sys/netinet/sctp_sysctl.h Thu Feb 12 17:31:39 2009 (r188523) +++ stable/7/sys/netinet/sctp_sysctl.h Thu Feb 12 17:57:28 2009 (r188524) @@ -152,7 +152,7 @@ struct sctp_sysctl { #define SCTPCTL_STRICT_SACKS_DESC "Enable SCTP Strict SACK checking" #define SCTPCTL_STRICT_SACKS_MIN 0 #define SCTPCTL_STRICT_SACKS_MAX 1 -#define SCTPCTL_STRICT_SACKS_DEFAULT 0 +#define SCTPCTL_STRICT_SACKS_DEFAULT 1 /* loopback_nocsum: Enable NO Csum on packets sent on loopback */ #define SCTPCTL_LOOPBACK_NOCSUM_DESC "Enable NO Csum on packets sent on loopback" Modified: stable/7/sys/netinet/sctp_timer.c ============================================================================== --- stable/7/sys/netinet/sctp_timer.c Thu Feb 12 17:31:39 2009 (r188523) +++ stable/7/sys/netinet/sctp_timer.c Thu Feb 12 17:57:28 2009 (r188524) @@ -561,6 +561,49 @@ sctp_backoff_on_timeout(struct sctp_tcb } } +void +sctp_recover_sent_list(struct sctp_tcb *stcb) +{ + struct sctp_tmit_chunk *chk, *tp2; + struct sctp_association *asoc; + + asoc = &stcb->asoc; + chk = TAILQ_FIRST(&stcb->asoc.sent_queue); + for (; chk != NULL; chk = tp2) { + tp2 = TAILQ_NEXT(chk, sctp_next); + if ((compare_with_wrap(stcb->asoc.last_acked_seq, + chk->rec.data.TSN_seq, + MAX_TSN)) || + (stcb->asoc.last_acked_seq == chk->rec.data.TSN_seq)) { + + SCTP_PRINTF("Found chk:%p tsn:%x <= last_acked_seq:%x\n", + chk, chk->rec.data.TSN_seq, stcb->asoc.last_acked_seq); + TAILQ_REMOVE(&asoc->sent_queue, chk, sctp_next); + if (chk->pr_sctp_on) { + if (asoc->pr_sctp_cnt != 0) + asoc->pr_sctp_cnt--; + } + if (chk->data) { + /* sa_ignore NO_NULL_CHK */ + sctp_free_bufspace(stcb, asoc, chk, 1); + sctp_m_freem(chk->data); + if (PR_SCTP_BUF_ENABLED(chk->flags)) { + asoc->sent_queue_cnt_removeable--; + } + } + chk->data = NULL; + asoc->sent_queue_cnt--; + sctp_free_a_chunk(stcb, chk); + } + } + SCTP_PRINTF("after recover order is as follows\n"); + chk = TAILQ_FIRST(&stcb->asoc.sent_queue); + for (; chk != NULL; chk = tp2) { + tp2 = TAILQ_NEXT(chk, sctp_next); + SCTP_PRINTF("chk:%p TSN:%x\n", chk, chk->rec.data.TSN_seq); + } +} + static int sctp_mark_all_for_resend(struct sctp_tcb *stcb, struct sctp_nets *net, @@ -583,6 +626,7 @@ sctp_mark_all_for_resend(struct sctp_tcb unsigned int cnt_mk; uint32_t orig_flight, orig_tf; uint32_t tsnlast, tsnfirst; + int recovery_cnt = 0; /* none in flight now */ @@ -635,6 +679,7 @@ sctp_mark_all_for_resend(struct sctp_tcb /* Now on to each chunk */ num_mk = cnt_mk = 0; tsnfirst = tsnlast = 0; +start_again: chk = TAILQ_FIRST(&stcb->asoc.sent_queue); for (; chk != NULL; chk = tp2) { tp2 = TAILQ_NEXT(chk, sctp_next); @@ -643,8 +688,22 @@ sctp_mark_all_for_resend(struct sctp_tcb MAX_TSN)) || (stcb->asoc.last_acked_seq == chk->rec.data.TSN_seq)) { /* Strange case our list got out of order? */ - SCTP_PRINTF("Our list is out of order?\n"); - panic("Out of order list"); + SCTP_PRINTF("Our list is out of order? last_acked:%x chk:%x", + (unsigned int)stcb->asoc.last_acked_seq, (unsigned int)chk->rec.data.TSN_seq); + recovery_cnt++; +#ifdef INVARIANTS + panic("last acked >= chk on sent-Q"); + /* to keep compiler happy */ + goto start_again; +#else + SCTP_PRINTF("Recover attempts a restart cnt:%d\n", recovery_cnt); + sctp_recover_sent_list(stcb); + if (recovery_cnt < 10) { + goto start_again; + } else { + SCTP_PRINTF("Recovery fails %d times??\n", recovery_cnt); + } +#endif } if ((chk->whoTo == net) && (chk->sent < SCTP_DATAGRAM_ACKED)) { /* Modified: stable/7/sys/netinet/sctp_timer.h ============================================================================== --- stable/7/sys/netinet/sctp_timer.h Thu Feb 12 17:31:39 2009 (r188523) +++ stable/7/sys/netinet/sctp_timer.h Thu Feb 12 17:57:28 2009 (r188524) @@ -99,6 +99,8 @@ void sctp_audit_retranmission_queue(stru void sctp_iterator_timer(struct sctp_iterator *it); +void sctp_recover_sent_list(struct sctp_tcb *stcb); + #endif #endif Modified: stable/7/sys/netinet/sctp_var.h ============================================================================== --- stable/7/sys/netinet/sctp_var.h Thu Feb 12 17:31:39 2009 (r188523) +++ stable/7/sys/netinet/sctp_var.h Thu Feb 12 17:57:28 2009 (r188524) @@ -160,6 +160,9 @@ extern struct pr_usrreqs sctp_usrreqs; } \ } +#ifdef INVARIANTS + + #define sctp_sbfree(ctl, stcb, sb, m) { \ uint32_t val; \ val = atomic_fetchadd_int(&(sb)->sb_cc,-(SCTP_BUF_LEN((m)))); \ @@ -186,6 +189,35 @@ extern struct pr_usrreqs sctp_usrreqs; } +#else + +#define sctp_sbfree(ctl, stcb, sb, m) { \ + uint32_t val; \ + val = atomic_fetchadd_int(&(sb)->sb_cc,-(SCTP_BUF_LEN((m)))); \ + if (val < SCTP_BUF_LEN((m))) { \ + (sb)->sb_cc = 0;\ + } \ + val = atomic_fetchadd_int(&(sb)->sb_mbcnt,-(MSIZE)); \ + if (val < MSIZE) { \ + (sb)->sb_mbcnt = 0; \ + } \ + if (((ctl)->do_not_ref_stcb == 0) && stcb) {\ + val = atomic_fetchadd_int(&(stcb)->asoc.sb_cc,-(SCTP_BUF_LEN((m)))); \ + if (val < SCTP_BUF_LEN((m))) {\ + (stcb)->asoc.sb_cc = 0; \ + } \ + val = atomic_fetchadd_int(&(stcb)->asoc.my_rwnd_control_len,-(MSIZE)); \ + if (val < MSIZE) { \ + (stcb)->asoc.my_rwnd_control_len = 0; \ + } \ + } \ + if (SCTP_BUF_TYPE(m) != MT_DATA && SCTP_BUF_TYPE(m) != MT_HEADER && \ + SCTP_BUF_TYPE(m) != MT_OOBDATA) \ + atomic_subtract_int(&(sb)->sb_ctl,SCTP_BUF_LEN((m))); \ +} + +#endif + #define sctp_sballoc(stcb, sb, m) { \ atomic_add_int(&(sb)->sb_cc,SCTP_BUF_LEN((m))); \ atomic_add_int(&(sb)->sb_mbcnt, MSIZE); \ Modified: stable/7/sys/netinet/sctputil.c ============================================================================== --- stable/7/sys/netinet/sctputil.c Thu Feb 12 17:31:39 2009 (r188523) +++ stable/7/sys/netinet/sctputil.c Thu Feb 12 17:57:28 2009 (r188524) @@ -922,7 +922,9 @@ sctp_init_asoc(struct sctp_inpcb *m, str asoc->my_vtag = override_tag; } else { SCTP_LTRACE_ERR_RET(NULL, stcb, NULL, SCTP_FROM_SCTPUTIL, ENOMEM); +#ifdef INVARIANTS panic("Huh is_in_timewait fails"); +#endif return (ENOMEM); } @@ -4848,6 +4850,7 @@ sctp_find_ifa_by_addr(struct sockaddr *a vrf = sctp_find_vrf(vrf_id); if (vrf == NULL) { +stage_right: if (holds_lock == 0) SCTP_IPI_ADDR_RUNLOCK(); return (NULL); @@ -4868,7 +4871,13 @@ sctp_find_ifa_by_addr(struct sockaddr *a } LIST_FOREACH(sctp_ifap, hash_head, next_bucket) { if (sctp_ifap == NULL) { +#ifdef INVARIANTS panic("Huh LIST_FOREACH corrupt"); + goto stage_right; +#else + SCTP_PRINTF("LIST corrupt of sctp_ifap's?\n"); + goto stage_right; +#endif } if (addr->sa_family != sctp_ifap->address.sa.sa_family) continue; @@ -5918,7 +5927,12 @@ out: * the atomic add to the refcnt. */ if (stcb == NULL) { +#ifdef INVARIANTS panic("stcb for refcnt has gone NULL?"); + goto stage_left; +#else + goto stage_left; +#endif } atomic_add_int(&stcb->asoc.refcnt, -1); freecnt_applied = 0; @@ -5940,6 +5954,7 @@ out: so->so_rcv.sb_cc); } } +stage_left: if (wakeup_read_socket) { sctp_sorwakeup(inp, so); } From owner-svn-src-stable@FreeBSD.ORG Thu Feb 12 18:02:47 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2E7FD106566C; Thu, 12 Feb 2009 18:02:47 +0000 (UTC) (envelope-from rrs@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 1C8C28FC17; Thu, 12 Feb 2009 18:02:47 +0000 (UTC) (envelope-from rrs@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n1CI2li0063040; Thu, 12 Feb 2009 18:02:47 GMT (envelope-from rrs@svn.freebsd.org) Received: (from rrs@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n1CI2ktB063039; Thu, 12 Feb 2009 18:02:46 GMT (envelope-from rrs@svn.freebsd.org) Message-Id: <200902121802.n1CI2ktB063039@svn.freebsd.org> From: Randall Stewart Date: Thu, 12 Feb 2009 18:02:46 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r188525 - in stable/7/sys: . netinet X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Feb 2009 18:02:48 -0000 Author: rrs Date: Thu Feb 12 18:02:46 2009 New Revision: 188525 URL: http://svn.freebsd.org/changeset/base/188525 Log: MFC of 184027: Reported by Yehuda Weinraub (yehudasa@gamil.com) - CRC32C algorithm uses incorrect init_bytes value. It SHOULD have the number of bytes to get to a 4 byte boundary. PR: 128134 Modified: stable/7/sys/ (props changed) stable/7/sys/netinet/sctp_crc32.c Modified: stable/7/sys/netinet/sctp_crc32.c ============================================================================== --- stable/7/sys/netinet/sctp_crc32.c Thu Feb 12 17:57:28 2009 (r188524) +++ stable/7/sys/netinet/sctp_crc32.c Thu Feb 12 18:02:46 2009 (r188525) @@ -583,13 +583,13 @@ update_crc32(uint32_t crc32c, unsigned char *buffer, unsigned int length) { - uint32_t offset; + uint32_t to_even_word; if (length == 0) { return (crc32c); } - offset = ((uintptr_t) buffer) & 0x3; - return (sctp_crc32c_sb8_64_bit(crc32c, buffer, length, offset)); + to_even_word = (4 - (((uintptr_t) buffer) & 0x3)); + return (sctp_crc32c_sb8_64_bit(crc32c, buffer, length, to_even_word)); } uint32_t sctp_crc_c[256] = { From owner-svn-src-stable@FreeBSD.ORG Thu Feb 12 18:22:11 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7E22B1065676; Thu, 12 Feb 2009 18:22:11 +0000 (UTC) (envelope-from rrs@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 6BF998FC19; Thu, 12 Feb 2009 18:22:11 +0000 (UTC) (envelope-from rrs@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n1CIMBrt063466; Thu, 12 Feb 2009 18:22:11 GMT (envelope-from rrs@svn.freebsd.org) Received: (from rrs@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n1CIMB9s063465; Thu, 12 Feb 2009 18:22:11 GMT (envelope-from rrs@svn.freebsd.org) Message-Id: <200902121822.n1CIMB9s063465@svn.freebsd.org> From: Randall Stewart Date: Thu, 12 Feb 2009 18:22:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r188526 - in stable/7/sys: . netinet X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Feb 2009 18:22:12 -0000 Author: rrs Date: Thu Feb 12 18:22:11 2009 New Revision: 188526 URL: http://svn.freebsd.org/changeset/base/188526 Log: MFC of 184031: The flags value was not always being copied out in the recv routine like it should be. Obtained from: Michael Tuexen Modified: stable/7/sys/ (props changed) stable/7/sys/netinet/sctputil.c Modified: stable/7/sys/netinet/sctputil.c ============================================================================== --- stable/7/sys/netinet/sctputil.c Thu Feb 12 18:02:46 2009 (r188525) +++ stable/7/sys/netinet/sctputil.c Thu Feb 12 18:22:11 2009 (r188526) @@ -5896,9 +5896,10 @@ release_unlocked: (no_rcv_needed == 0)) sctp_user_rcvd(stcb, &freed_so_far, hold_rlock, rwnd_req); } - if (msg_flags) - *msg_flags = out_flags; out: + if (msg_flags) { + *msg_flags = out_flags; + } if (((out_flags & MSG_EOR) == 0) && ((in_flags & MSG_PEEK) == 0) && (sinfo) && From owner-svn-src-stable@FreeBSD.ORG Thu Feb 12 18:24:54 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id DEE1B106564A; Thu, 12 Feb 2009 18:24:54 +0000 (UTC) (envelope-from rrs@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id CCD6A8FC18; Thu, 12 Feb 2009 18:24:54 +0000 (UTC) (envelope-from rrs@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n1CIOs4j063578; Thu, 12 Feb 2009 18:24:54 GMT (envelope-from rrs@svn.freebsd.org) Received: (from rrs@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n1CIOsTm063576; Thu, 12 Feb 2009 18:24:54 GMT (envelope-from rrs@svn.freebsd.org) Message-Id: <200902121824.n1CIOsTm063576@svn.freebsd.org> From: Randall Stewart Date: Thu, 12 Feb 2009 18:24:54 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r188527 - in stable/7/sys: . netinet X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Feb 2009 18:24:55 -0000 Author: rrs Date: Thu Feb 12 18:24:54 2009 New Revision: 188527 URL: http://svn.freebsd.org/changeset/base/188527 Log: MFC 184333 Invariants changes that make more sense. Modified: stable/7/sys/ (props changed) stable/7/sys/netinet/sctp_timer.c stable/7/sys/netinet/sctp_timer.h Modified: stable/7/sys/netinet/sctp_timer.c ============================================================================== --- stable/7/sys/netinet/sctp_timer.c Thu Feb 12 18:22:11 2009 (r188526) +++ stable/7/sys/netinet/sctp_timer.c Thu Feb 12 18:24:54 2009 (r188527) @@ -561,7 +561,8 @@ sctp_backoff_on_timeout(struct sctp_tcb } } -void +#ifndef INVARIANTS +static void sctp_recover_sent_list(struct sctp_tcb *stcb) { struct sctp_tmit_chunk *chk, *tp2; @@ -604,6 +605,8 @@ sctp_recover_sent_list(struct sctp_tcb * } } +#endif + static int sctp_mark_all_for_resend(struct sctp_tcb *stcb, struct sctp_nets *net, @@ -679,7 +682,9 @@ sctp_mark_all_for_resend(struct sctp_tcb /* Now on to each chunk */ num_mk = cnt_mk = 0; tsnfirst = tsnlast = 0; +#ifndef INVARIANTS start_again: +#endif chk = TAILQ_FIRST(&stcb->asoc.sent_queue); for (; chk != NULL; chk = tp2) { tp2 = TAILQ_NEXT(chk, sctp_next); @@ -693,8 +698,6 @@ start_again: recovery_cnt++; #ifdef INVARIANTS panic("last acked >= chk on sent-Q"); - /* to keep compiler happy */ - goto start_again; #else SCTP_PRINTF("Recover attempts a restart cnt:%d\n", recovery_cnt); sctp_recover_sent_list(stcb); Modified: stable/7/sys/netinet/sctp_timer.h ============================================================================== --- stable/7/sys/netinet/sctp_timer.h Thu Feb 12 18:22:11 2009 (r188526) +++ stable/7/sys/netinet/sctp_timer.h Thu Feb 12 18:24:54 2009 (r188527) @@ -99,8 +99,6 @@ void sctp_audit_retranmission_queue(stru void sctp_iterator_timer(struct sctp_iterator *it); -void sctp_recover_sent_list(struct sctp_tcb *stcb); - #endif #endif From owner-svn-src-stable@FreeBSD.ORG Thu Feb 12 18:28:43 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6953F106566B; Thu, 12 Feb 2009 18:28:43 +0000 (UTC) (envelope-from rrs@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 3CCB38FC18; Thu, 12 Feb 2009 18:28:43 +0000 (UTC) (envelope-from rrs@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n1CISh4I063772; Thu, 12 Feb 2009 18:28:43 GMT (envelope-from rrs@svn.freebsd.org) Received: (from rrs@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n1CISh44063767; Thu, 12 Feb 2009 18:28:43 GMT (envelope-from rrs@svn.freebsd.org) Message-Id: <200902121828.n1CISh44063767@svn.freebsd.org> From: Randall Stewart Date: Thu, 12 Feb 2009 18:28:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r188528 - in stable/7/sys: . netinet X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Feb 2009 18:28:44 -0000 Author: rrs Date: Thu Feb 12 18:28:42 2009 New Revision: 188528 URL: http://svn.freebsd.org/changeset/base/188528 Log: MFC of 184340 More issues with pre-blocking: a) Need for EEOR mode to take the min of the socket buffer size and the add more threshold, otherwise if you are so silly as to set a send buf size less than the add-more you could block forever in eeor mode. b) We were incorrectly using the sysctl vs the calculated value. This causes us to block forever if the addmore theshold is larger than then the socket buffer size. Modified: stable/7/sys/ (props changed) stable/7/sys/netinet/sctp_output.c Modified: stable/7/sys/netinet/sctp_output.c ============================================================================== --- stable/7/sys/netinet/sctp_output.c Thu Feb 12 18:24:54 2009 (r188527) +++ stable/7/sys/netinet/sctp_output.c Thu Feb 12 18:28:42 2009 (r188528) @@ -12441,7 +12441,7 @@ sctp_lower_sosend(struct socket *so, goto out_unlocked; } if (user_marks_eor) { - local_add_more = SCTP_BASE_SYSCTL(sctp_add_more_threshold); + local_add_more = min(SCTP_SB_LIMIT_SND(so), SCTP_BASE_SYSCTL(sctp_add_more_threshold)); } else { /*- * For non-eeor the whole message must fit in @@ -12460,9 +12460,15 @@ sctp_lower_sosend(struct socket *so, /* No room right now ! */ SOCKBUF_LOCK(&so->so_snd); inqueue_bytes = stcb->asoc.total_output_queue_size - (stcb->asoc.chunks_on_out_queue * sizeof(struct sctp_data_chunk)); - while ((SCTP_SB_LIMIT_SND(so) < (inqueue_bytes + SCTP_BASE_SYSCTL(sctp_add_more_threshold))) || - ((stcb->asoc.stream_queue_cnt + stcb->asoc.chunks_on_out_queue) >= SCTP_BASE_SYSCTL(sctp_max_chunks_on_queue) /* while */ )) { - + while ((SCTP_SB_LIMIT_SND(so) < (inqueue_bytes + local_add_more)) || + ((stcb->asoc.stream_queue_cnt + stcb->asoc.chunks_on_out_queue) >= SCTP_BASE_SYSCTL(sctp_max_chunks_on_queue)) /* while */ ) { + SCTPDBG(SCTP_DEBUG_OUTPUT1, "pre_block limit:%d <(inq:%d + %d) || (%d+%d > %d)\n", + SCTP_SB_LIMIT_SND(so), + inqueue_bytes, + local_add_more, + stcb->asoc.stream_queue_cnt, + stcb->asoc.chunks_on_out_queue, + SCTP_BASE_SYSCTL(sctp_max_chunks_on_queue)); if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_BLK_LOGGING_ENABLE) { sctp_log_block(SCTP_BLOCK_LOG_INTO_BLKA, so, asoc, sndlen); From owner-svn-src-stable@FreeBSD.ORG Thu Feb 12 18:33:27 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5EC29106571E; Thu, 12 Feb 2009 18:33:27 +0000 (UTC) (envelope-from rrs@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 4BC1D8FC1F; Thu, 12 Feb 2009 18:33:27 +0000 (UTC) (envelope-from rrs@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n1CIXRN4063985; Thu, 12 Feb 2009 18:33:27 GMT (envelope-from rrs@svn.freebsd.org) Received: (from rrs@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n1CIXQ8o063979; Thu, 12 Feb 2009 18:33:26 GMT (envelope-from rrs@svn.freebsd.org) Message-Id: <200902121833.n1CIXQ8o063979@svn.freebsd.org> From: Randall Stewart Date: Thu, 12 Feb 2009 18:33:26 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r188530 - in stable/7/sys: . netinet X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Feb 2009 18:33:28 -0000 Author: rrs Date: Thu Feb 12 18:33:26 2009 New Revision: 188530 URL: http://svn.freebsd.org/changeset/base/188530 Log: MFC 184883 - a pack of bug fixes and misc adjustments: -Improvement: Add '\n' on debug output in sctp_lower_sosend(). -Improvement: panic() on INVARIANTS kernels if memory allocation fails for a tagblock in sctp_add_vtag_to_timewait(). -Bugfix: Protect code in sctp_is_in_timewait() by SCTP_INP_INFO_WLOCK/SCTP_INP_INFO_WUNLOCK. -Cleanup: Get rid of unused variable now in sctp_init_asoc(). -Bugfix: Reuse the correct vtag in sctp_add_vtag_to_timewait(). -Cleanup: Get rid of unused constant SCTP_TIME_WAIT_SHORT in sctp_constants.h. -Improvement: Use all hash buckets of the vtag hash table. -Cleanup: Get rid of then unused constant SCTP_STACK_VTAG_HASH_SIZE_A. -Bugfix: Handle SHUTDOWN;SACK packet correctly. -Bugfix: Last TSN in a gap ack block was not being "ack'd" in the internal scoreboard. Obtained from: (with help from Michael Tuexen) Modified: stable/7/sys/ (props changed) stable/7/sys/netinet/sctp_constants.h stable/7/sys/netinet/sctp_indata.c stable/7/sys/netinet/sctp_input.c stable/7/sys/netinet/sctp_pcb.c stable/7/sys/netinet/sctp_pcb.h stable/7/sys/netinet/sctputil.c Modified: stable/7/sys/netinet/sctp_constants.h ============================================================================== --- stable/7/sys/netinet/sctp_constants.h Thu Feb 12 18:33:13 2009 (r188529) +++ stable/7/sys/netinet/sctp_constants.h Thu Feb 12 18:33:26 2009 (r188530) @@ -1001,8 +1001,7 @@ __FBSDID("$FreeBSD$"); * entries must be searched to see if the tag is in timed wait. If so we * reject it. */ -#define SCTP_STACK_VTAG_HASH_SIZE 31 -#define SCTP_STACK_VTAG_HASH_SIZE_A 32 +#define SCTP_STACK_VTAG_HASH_SIZE 32 /* @@ -1016,12 +1015,6 @@ __FBSDID("$FreeBSD$"); */ #define SCTP_TIME_WAIT 60 -/* This time wait is the same as the default cookie life - * since we now enter a tag in every time we send a cookie. - * We want this shorter to avoid vtag depletion. - */ -#define SCTP_TIME_WAIT_SHORT 60 - /* The system retains a cache of free chunks such to * cut down on calls the memory allocation system. There * is a per association limit of free items and a overall Modified: stable/7/sys/netinet/sctp_indata.c ============================================================================== --- stable/7/sys/netinet/sctp_indata.c Thu Feb 12 18:33:13 2009 (r188529) +++ stable/7/sys/netinet/sctp_indata.c Thu Feb 12 18:33:26 2009 (r188530) @@ -2766,8 +2766,8 @@ sctp_handle_segments(struct mbuf *m, int struct sctp_sack *sack; struct sctp_gap_ack_block *frag, block; struct sctp_tmit_chunk *tp1; - int i; - unsigned int j; + int i, j; + unsigned int theTSN; int num_frs = 0; uint16_t frag_strt, frag_end, primary_flag_set; @@ -2835,7 +2835,8 @@ sctp_handle_segments(struct mbuf *m, int } last_frag_high = frag_end + last_tsn; } - for (j = frag_strt + last_tsn; (compare_with_wrap((frag_end + last_tsn), j, MAX_TSN)); j++) { + for (j = frag_strt; j <= frag_end; j++) { + theTSN = j + last_tsn; while (tp1) { if (tp1->rec.data.doing_fast_retransmit) num_frs++; @@ -2858,7 +2859,7 @@ sctp_handle_segments(struct mbuf *m, int tp1->whoTo->rtx_pseudo_cumack = tp1->rec.data.TSN_seq; tp1->whoTo->find_rtx_pseudo_cumack = 0; } - if (tp1->rec.data.TSN_seq == j) { + if (tp1->rec.data.TSN_seq == theTSN) { if (tp1->sent != SCTP_DATAGRAM_UNSENT) { /* * must be held until @@ -3030,8 +3031,8 @@ sctp_handle_segments(struct mbuf *m, int } } break; - } /* if (tp1->TSN_seq == j) */ - if (compare_with_wrap(tp1->rec.data.TSN_seq, j, + } /* if (tp1->TSN_seq == theTSN) */ + if (compare_with_wrap(tp1->rec.data.TSN_seq, theTSN, MAX_TSN)) break; Modified: stable/7/sys/netinet/sctp_input.c ============================================================================== --- stable/7/sys/netinet/sctp_input.c Thu Feb 12 18:33:13 2009 (r188529) +++ stable/7/sys/netinet/sctp_input.c Thu Feb 12 18:33:26 2009 (r188530) @@ -4280,7 +4280,6 @@ process_control_chunks: if ((stcb == NULL) || (chk_length < sizeof(struct sctp_sack_chunk))) { SCTPDBG(SCTP_DEBUG_INDATA1, "Bad size on sack chunk, too small\n"); - ignore_sack: *offset = length; if (locked_tcb) { SCTP_TCB_UNLOCK(locked_tcb); @@ -4293,7 +4292,7 @@ process_control_chunks: * attention to a sack sent in to us since * we don't care anymore. */ - goto ignore_sack; + break; } sack = (struct sctp_sack_chunk *)ch; nonce_sum_flag = ch->chunk_flags & SCTP_SACK_NONCE_SUM; Modified: stable/7/sys/netinet/sctp_pcb.c ============================================================================== --- stable/7/sys/netinet/sctp_pcb.c Thu Feb 12 18:33:13 2009 (r188529) +++ stable/7/sys/netinet/sctp_pcb.c Thu Feb 12 18:33:26 2009 (r188530) @@ -4191,6 +4191,7 @@ sctp_is_in_timewait(uint32_t tag) int found = 0; int i; + SCTP_INP_INFO_WLOCK(); chain = &SCTP_BASE_INFO(vtag_timewait)[(tag % SCTP_STACK_VTAG_HASH_SIZE)]; if (!SCTP_LIST_EMPTY(chain)) { LIST_FOREACH(twait_block, chain, sctp_nxt_tagblock) { @@ -4204,6 +4205,7 @@ sctp_is_in_timewait(uint32_t tag) break; } } + SCTP_INP_INFO_WUNLOCK(); return (found); } @@ -4236,8 +4238,8 @@ sctp_add_vtag_to_timewait(uint32_t tag, twait_block->vtag_block[i].v_tag = 0; if (set == 0) { /* Reuse it for my new tag */ - twait_block->vtag_block[0].tv_sec_at_expire = now.tv_sec + time; - twait_block->vtag_block[0].v_tag = tag; + twait_block->vtag_block[i].tv_sec_at_expire = now.tv_sec + time; + twait_block->vtag_block[i].v_tag = tag; set = 1; } } @@ -4256,6 +4258,9 @@ sctp_add_vtag_to_timewait(uint32_t tag, SCTP_MALLOC(twait_block, struct sctp_tagblock *, sizeof(struct sctp_tagblock), SCTP_M_TIMW); if (twait_block == NULL) { +#ifdef INVARIANTS + panic("Can not alloc tagblock"); +#endif return; } memset(twait_block, 0, sizeof(struct sctp_tagblock)); @@ -5392,7 +5397,7 @@ sctp_pcb_init() SCTP_OS_TIMER_INIT(&SCTP_BASE_INFO(addr_wq_timer.timer)); /* Init the TIMEWAIT list */ - for (i = 0; i < SCTP_STACK_VTAG_HASH_SIZE_A; i++) { + for (i = 0; i < SCTP_STACK_VTAG_HASH_SIZE; i++) { LIST_INIT(&SCTP_BASE_INFO(vtag_timewait[i])); } @@ -5462,7 +5467,7 @@ sctp_pcb_finish(void) * free the TIMEWAIT list elements malloc'd in the function * sctp_add_vtag_to_timewait()... */ - for (i = 0; i < SCTP_STACK_VTAG_HASH_SIZE_A; i++) { + for (i = 0; i < SCTP_STACK_VTAG_HASH_SIZE; i++) { chain = &SCTP_BASE_INFO(vtag_timewait)[i]; if (!SCTP_LIST_EMPTY(chain)) { prev_twait_block = NULL; Modified: stable/7/sys/netinet/sctp_pcb.h ============================================================================== --- stable/7/sys/netinet/sctp_pcb.h Thu Feb 12 18:33:13 2009 (r188529) +++ stable/7/sys/netinet/sctp_pcb.h Thu Feb 12 18:33:26 2009 (r188530) @@ -228,7 +228,7 @@ struct sctp_epinfo { uint32_t ipi_free_strmoq; - struct sctpvtaghead vtag_timewait[SCTP_STACK_VTAG_HASH_SIZE_A]; + struct sctpvtaghead vtag_timewait[SCTP_STACK_VTAG_HASH_SIZE]; /* address work queue handling */ #if defined(SCTP_USE_THREAD_BASED_ITERATOR) Modified: stable/7/sys/netinet/sctputil.c ============================================================================== --- stable/7/sys/netinet/sctputil.c Thu Feb 12 18:33:13 2009 (r188529) +++ stable/7/sys/netinet/sctputil.c Thu Feb 12 18:33:26 2009 (r188530) @@ -910,9 +910,6 @@ sctp_init_asoc(struct sctp_inpcb *m, str #endif asoc->sb_send_resv = 0; if (override_tag) { - struct timeval now; - - (void)SCTP_GETTIME_TIMEVAL(&now); if (sctp_is_in_timewait(override_tag)) { /* * It must be in the time-wait hash, we put it there @@ -1466,6 +1463,9 @@ sctp_timeout_handler(void *t) SCTP_INP_INCR_REF(inp); if ((inp->sctp_socket == 0) && ((tmr->type != SCTP_TIMER_TYPE_INPKILL) && + (tmr->type != SCTP_TIMER_TYPE_SEND) && + (tmr->type != SCTP_TIMER_TYPE_RECV) && + (tmr->type != SCTP_TIMER_TYPE_HEARTBEAT) && (tmr->type != SCTP_TIMER_TYPE_SHUTDOWN) && (tmr->type != SCTP_TIMER_TYPE_SHUTDOWNACK) && (tmr->type != SCTP_TIMER_TYPE_SHUTDOWNGUARD) && From owner-svn-src-stable@FreeBSD.ORG Thu Feb 12 18:50:27 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A02661065698; Thu, 12 Feb 2009 18:50:27 +0000 (UTC) (envelope-from rrs@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 8C2AC8FC14; Thu, 12 Feb 2009 18:50:27 +0000 (UTC) (envelope-from rrs@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n1CIoRfe064406; Thu, 12 Feb 2009 18:50:27 GMT (envelope-from rrs@svn.freebsd.org) Received: (from rrs@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n1CIoRMp064401; Thu, 12 Feb 2009 18:50:27 GMT (envelope-from rrs@svn.freebsd.org) Message-Id: <200902121850.n1CIoRMp064401@svn.freebsd.org> From: Randall Stewart Date: Thu, 12 Feb 2009 18:50:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r188532 - in stable/7/sys: . netinet netinet6 X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Feb 2009 18:50:28 -0000 Author: rrs Date: Thu Feb 12 18:50:27 2009 New Revision: 188532 URL: http://svn.freebsd.org/changeset/base/188532 Log: MFC of 185694 - The IETF hack session: Code from the hack-session known as the IETF (and a bit of debugging afterwards): - Fix protection code for notification generation. - Decouple associd from vtag - Allow vtags to have less strigent requirements in non-uniqueness. o don't pre-hash them when you issue one in a cookie. o Allow duplicates and use addresses and ports to discriminate amongst the duplicates during lookup. - Add support for the NAT draft draft-ietf-behave-sctpnat-00, this is still experimental and needs more extensive testing with the Jason Butt ipfw changes. - Support for the SENDER_DRY event to get DTLS in OpenSSL working with a set of patches from Michael Tuexen (hopefully heading to OpenSSL soon). - Update the support of SCTP-AUTH by Peter Lei. - Use macros for refcounting. - Fix MTU for UDP encapsulation. - Fix reporting back of unsent data. - Update assoc send counter handling to be consistent with endpoint sent counter. - Fix a bug in PR-SCTP. - Fix so we only send another FWD-TSN when a SACK arrives IF and only if the adv-peer-ack point progressed. However we still make sure a timer is running if we do have an adv_peer_ack point. - Fix PR-SCTP bug where chunks were retransmitted if they are sent unreliable but not abandoned yet. With the help of: Michael Teuxen and Peter Lei :-) Modified: stable/7/sys/ (props changed) stable/7/sys/netinet/sctp.h stable/7/sys/netinet/sctp_asconf.c stable/7/sys/netinet/sctp_asconf.h stable/7/sys/netinet/sctp_auth.c stable/7/sys/netinet/sctp_auth.h stable/7/sys/netinet/sctp_constants.h stable/7/sys/netinet/sctp_header.h stable/7/sys/netinet/sctp_indata.c stable/7/sys/netinet/sctp_indata.h stable/7/sys/netinet/sctp_input.c stable/7/sys/netinet/sctp_os_bsd.h stable/7/sys/netinet/sctp_output.c stable/7/sys/netinet/sctp_output.h stable/7/sys/netinet/sctp_pcb.c stable/7/sys/netinet/sctp_pcb.h stable/7/sys/netinet/sctp_structs.h stable/7/sys/netinet/sctp_sysctl.c stable/7/sys/netinet/sctp_sysctl.h stable/7/sys/netinet/sctp_timer.c stable/7/sys/netinet/sctp_uio.h stable/7/sys/netinet/sctp_usrreq.c stable/7/sys/netinet/sctp_var.h stable/7/sys/netinet/sctputil.c stable/7/sys/netinet/sctputil.h stable/7/sys/netinet6/sctp6_usrreq.c Modified: stable/7/sys/netinet/sctp.h ============================================================================== --- stable/7/sys/netinet/sctp.h Thu Feb 12 18:33:56 2009 (r188531) +++ stable/7/sys/netinet/sctp.h Thu Feb 12 18:50:27 2009 (r188532) @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2001-2007, by Cisco Systems, Inc. All rights reserved. + * Copyright (c) 2001-2008, by Cisco Systems, 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: @@ -111,6 +111,7 @@ struct sctp_paramhdr { /* explict EOR signalling */ #define SCTP_EXPLICIT_EOR 0x0000001b #define SCTP_REUSE_PORT 0x0000001c /* rw */ +#define SCTP_AUTH_DEACTIVATE_KEY 0x0000001d /* * read-only options @@ -154,6 +155,8 @@ struct sctp_paramhdr { /* CMT ON/OFF socket option */ #define SCTP_CMT_ON_OFF 0x00001200 #define SCTP_CMT_USE_DAC 0x00001201 +/* EY - NR_SACK on/off socket option */ +#define SCTP_NR_SACK_ON_OFF 0x00001300 /* JRS - Pluggable Congestion Control Socket option */ #define SCTP_PLUGGABLE_CC 0x00001202 @@ -293,11 +296,15 @@ struct sctp_paramhdr { #define SCTP_CAUSE_PROTOCOL_VIOLATION 0x000d /* Error causes from RFC5061 */ -#define SCTP_CAUSE_DELETING_LAST_ADDR 0xa0 -#define SCTP_CAUSE_RESOURCE_SHORTAGE 0xa1 -#define SCTP_CAUSE_DELETING_SRC_ADDR 0xa2 -#define SCTP_CAUSE_ILLEGAL_ASCONF_ACK 0xa3 -#define SCTP_CAUSE_REQUEST_REFUSED 0xa4 +#define SCTP_CAUSE_DELETING_LAST_ADDR 0x00a0 +#define SCTP_CAUSE_RESOURCE_SHORTAGE 0x00a1 +#define SCTP_CAUSE_DELETING_SRC_ADDR 0x00a2 +#define SCTP_CAUSE_ILLEGAL_ASCONF_ACK 0x00a3 +#define SCTP_CAUSE_REQUEST_REFUSED 0x00a4 + +/* Error causes from nat-draft */ +#define SCTP_CAUSE_NAT_COLLIDING_STATE 0x00b0 +#define SCTP_CAUSE_NAT_MISSING_STATE 0x00b1 /* Error causes from RFC4895 */ #define SCTP_CAUSE_UNSUPPORTED_HMACID 0x0105 @@ -364,6 +371,8 @@ struct sctp_error_unrecognized_chunk { #define SCTP_SHUTDOWN_COMPLETE 0x0e /* RFC4895 */ #define SCTP_AUTHENTICATION 0x0f +/* EY nr_sack chunk id*/ +#define SCTP_NR_SELECTIVE_ACK 0x10 /************0x40 series ***********/ /************0x80 series ***********/ /* RFC5061 */ @@ -406,6 +415,9 @@ struct sctp_error_unrecognized_chunk { /* ECN Nonce: SACK Chunk Specific Flags */ #define SCTP_SACK_NONCE_SUM 0x01 +/* EY nr_sack all bit - All bit is the 2nd LSB of nr_sack chunk flags*/ +/* if All bit is set in an nr-sack chunk, then all nr gap acks gap acks*/ +#define SCTP_NR_SACK_ALL_BIT 0x02 /* CMT DAC algorithm SACK flag */ #define SCTP_SACK_CMT_DAC 0x80 @@ -467,6 +479,7 @@ struct sctp_error_unrecognized_chunk { #define SCTP_PCB_FLAGS_NEEDS_MAPPED_V4 0x00800000 #define SCTP_PCB_FLAGS_MULTIPLE_ASCONFS 0x01000000 #define SCTP_PCB_FLAGS_PORTREUSE 0x02000000 +#define SCTP_PCB_FLAGS_DRYEVNT 0x04000000 /*- * mobility_features parameters (by micchie).Note * these features are applied against the Modified: stable/7/sys/netinet/sctp_asconf.c ============================================================================== --- stable/7/sys/netinet/sctp_asconf.c Thu Feb 12 18:33:56 2009 (r188531) +++ stable/7/sys/netinet/sctp_asconf.c Thu Feb 12 18:50:27 2009 (r188532) @@ -761,6 +761,9 @@ sctp_handle_asconf(struct mbuf *m, unsig m_result = sctp_process_asconf_set_primary(m, aph, stcb, error); break; + case SCTP_NAT_VTAGS: + SCTPDBG(SCTP_DEBUG_ASCONF1, "handle_asconf: sees a NAT VTAG state parameter\n"); + break; case SCTP_SUCCESS_REPORT: /* not valid in an ASCONF chunk */ break; @@ -1349,6 +1352,7 @@ sctp_asconf_queue_mgmt(struct sctp_tcb * SCTPDBG(SCTP_DEBUG_ASCONF1, "asconf_queue_mgmt: failed to get memory!\n"); return (-1); } + aa->special_del = 0; /* fill in asconf address parameter fields */ /* top level elements are "networked" during send */ aa->ap.aph.ph.param_type = type; @@ -1555,6 +1559,7 @@ sctp_asconf_queue_sa_delete(struct sctp_ "sctp_asconf_queue_sa_delete: failed to get memory!\n"); return (-1); } + aa->special_del = 0; /* fill in asconf address parameter fields */ /* top level elements are "networked" during send */ aa->ap.aph.ph.param_type = SCTP_DEL_IP_ADDRESS; @@ -2691,6 +2696,7 @@ sctp_compose_asconf(struct sctp_tcb *stc * case) */ if (lookup_used == 0 && + (aa->special_del == 0) && aa->ap.aph.ph.param_type == SCTP_DEL_IP_ADDRESS) { struct sctp_ipv6addr_param *lookup; uint16_t p_size, addr_size; @@ -3234,3 +3240,195 @@ sctp_addr_mgmt_ep_sa(struct sctp_inpcb * } return (0); } + +void +sctp_asconf_send_nat_state_update(struct sctp_tcb *stcb, + struct sctp_nets *net) +{ + struct sctp_asconf_addr *aa; + struct sctp_ifa *sctp_ifap; + struct sctp_asconf_tag_param *vtag; + struct sockaddr_in *to; + +#ifdef INET6 + struct sockaddr_in6 *to6; + +#endif + if (net == NULL) { + SCTPDBG(SCTP_DEBUG_ASCONF1, "sctp_asconf_send_nat_state_update: Missing net\n"); + return; + } + if (stcb == NULL) { + SCTPDBG(SCTP_DEBUG_ASCONF1, "sctp_asconf_send_nat_state_update: Missing stcb\n"); + return; + } + /* + * Need to have in the asconf: - vtagparam(my_vtag/peer_vtag) - + * add(0.0.0.0) - del(0.0.0.0) - Any global addresses add(addr) + */ + SCTP_MALLOC(aa, struct sctp_asconf_addr *, sizeof(*aa), + SCTP_M_ASC_ADDR); + if (aa == NULL) { + /* didn't get memory */ + SCTPDBG(SCTP_DEBUG_ASCONF1, + "sctp_asconf_send_nat_state_update: failed to get memory!\n"); + return; + } + aa->special_del = 0; + /* fill in asconf address parameter fields */ + /* top level elements are "networked" during send */ + aa->ifa = NULL; + aa->sent = 0; /* clear sent flag */ + vtag = (struct sctp_asconf_tag_param *)&aa->ap.aph; + vtag->aph.ph.param_type = SCTP_NAT_VTAGS; + vtag->aph.ph.param_length = sizeof(struct sctp_asconf_tag_param); + vtag->local_vtag = htonl(stcb->asoc.my_vtag); + vtag->remote_vtag = htonl(stcb->asoc.peer_vtag); + TAILQ_INSERT_TAIL(&stcb->asoc.asconf_queue, aa, next); + + SCTP_MALLOC(aa, struct sctp_asconf_addr *, sizeof(*aa), + SCTP_M_ASC_ADDR); + if (aa == NULL) { + /* didn't get memory */ + SCTPDBG(SCTP_DEBUG_ASCONF1, + "sctp_asconf_send_nat_state_update: failed to get memory!\n"); + return; + } + memset(aa, 0, sizeof(struct sctp_asconf_addr)); + /* fill in asconf address parameter fields */ + /* ADD(0.0.0.0) */ + if (net->ro._l_addr.sa.sa_family == AF_INET) { + aa->ap.aph.ph.param_type = SCTP_ADD_IP_ADDRESS; + aa->ap.aph.ph.param_length = sizeof(struct sctp_asconf_addrv4_param); + aa->ap.addrp.ph.param_type = SCTP_IPV4_ADDRESS; + aa->ap.addrp.ph.param_length = sizeof(struct sctp_ipv4addr_param); + /* No need to add an address, we are using 0.0.0.0 */ + TAILQ_INSERT_TAIL(&stcb->asoc.asconf_queue, aa, next); + } +#ifdef INET6 + else if (net->ro._l_addr.sa.sa_family == AF_INET6) { + aa->ap.aph.ph.param_type = SCTP_ADD_IP_ADDRESS; + aa->ap.aph.ph.param_length = sizeof(struct sctp_asconf_addr_param); + aa->ap.addrp.ph.param_type = SCTP_IPV6_ADDRESS; + aa->ap.addrp.ph.param_length = sizeof(struct sctp_ipv6addr_param); + /* No need to add an address, we are using 0.0.0.0 */ + TAILQ_INSERT_TAIL(&stcb->asoc.asconf_queue, aa, next); + } +#endif /* INET6 */ + SCTP_MALLOC(aa, struct sctp_asconf_addr *, sizeof(*aa), + SCTP_M_ASC_ADDR); + if (aa == NULL) { + /* didn't get memory */ + SCTPDBG(SCTP_DEBUG_ASCONF1, + "sctp_asconf_send_nat_state_update: failed to get memory!\n"); + return; + } + memset(aa, 0, sizeof(struct sctp_asconf_addr)); + /* fill in asconf address parameter fields */ + /* ADD(0.0.0.0) */ + if (net->ro._l_addr.sa.sa_family == AF_INET) { + aa->ap.aph.ph.param_type = SCTP_ADD_IP_ADDRESS; + aa->ap.aph.ph.param_length = sizeof(struct sctp_asconf_addrv4_param); + aa->ap.addrp.ph.param_type = SCTP_IPV4_ADDRESS; + aa->ap.addrp.ph.param_length = sizeof(struct sctp_ipv4addr_param); + /* No need to add an address, we are using 0.0.0.0 */ + TAILQ_INSERT_TAIL(&stcb->asoc.asconf_queue, aa, next); + } +#ifdef INET6 + else if (net->ro._l_addr.sa.sa_family == AF_INET6) { + aa->ap.aph.ph.param_type = SCTP_DEL_IP_ADDRESS; + aa->ap.aph.ph.param_length = sizeof(struct sctp_asconf_addr_param); + aa->ap.addrp.ph.param_type = SCTP_IPV6_ADDRESS; + aa->ap.addrp.ph.param_length = sizeof(struct sctp_ipv6addr_param); + /* No need to add an address, we are using 0.0.0.0 */ + TAILQ_INSERT_TAIL(&stcb->asoc.asconf_queue, aa, next); + } +#endif /* INET6 */ + /* Now we must hunt the addresses and add all global addresses */ + if (stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_BOUNDALL) { + struct sctp_vrf *vrf = NULL; + struct sctp_ifn *sctp_ifnp; + uint32_t vrf_id; + + vrf_id = stcb->sctp_ep->def_vrf_id; + vrf = sctp_find_vrf(vrf_id); + if (vrf == NULL) { + goto skip_rest; + } + SCTP_IPI_ADDR_RLOCK(); + LIST_FOREACH(sctp_ifnp, &vrf->ifnlist, next_ifn) { + LIST_FOREACH(sctp_ifap, &sctp_ifnp->ifalist, next_ifa) { + if (sctp_ifap->address.sa.sa_family == AF_INET) { + to = &sctp_ifap->address.sin; + + if (IN4_ISPRIVATE_ADDRESS(&to->sin_addr)) { + continue; + } + if (IN4_ISLOOPBACK_ADDRESS(&to->sin_addr)) { + continue; + } + } +#ifdef INET6 + else if (sctp_ifap->address.sa.sa_family == AF_INET6) { + to6 = &sctp_ifap->address.sin6; + if (IN6_IS_ADDR_LOOPBACK(&to6->sin6_addr)) { + continue; + } + if (IN6_IS_ADDR_LINKLOCAL(&to6->sin6_addr)) { + continue; + } + } +#endif + sctp_asconf_queue_mgmt(stcb, sctp_ifap, SCTP_ADD_IP_ADDRESS); + } + } + SCTP_IPI_ADDR_RUNLOCK(); + } else { + struct sctp_laddr *laddr; + + LIST_FOREACH(laddr, &stcb->sctp_ep->sctp_addr_list, sctp_nxt_addr) { + if (laddr->ifa == NULL) { + continue; + } + if (laddr->ifa->localifa_flags & SCTP_BEING_DELETED) + /* + * Address being deleted by the system, dont + * list. + */ + continue; + if (laddr->action == SCTP_DEL_IP_ADDRESS) { + /* + * Address being deleted on this ep don't + * list. + */ + continue; + } + sctp_ifap = laddr->ifa; + if (sctp_ifap->address.sa.sa_family == AF_INET) { + to = &sctp_ifap->address.sin; + + if (IN4_ISPRIVATE_ADDRESS(&to->sin_addr)) { + continue; + } + if (IN4_ISLOOPBACK_ADDRESS(&to->sin_addr)) { + continue; + } + } +#ifdef INET6 + else if (sctp_ifap->address.sa.sa_family == AF_INET6) { + to6 = &sctp_ifap->address.sin6; + if (IN6_IS_ADDR_LOOPBACK(&to6->sin6_addr)) { + continue; + } + if (IN6_IS_ADDR_LINKLOCAL(&to6->sin6_addr)) { + continue; + } + } +#endif + sctp_asconf_queue_mgmt(stcb, sctp_ifap, SCTP_ADD_IP_ADDRESS); + } + } +skip_rest: + /* Now we must send the asconf into the queue */ + sctp_send_asconf(stcb, net, 0); +} Modified: stable/7/sys/netinet/sctp_asconf.h ============================================================================== --- stable/7/sys/netinet/sctp_asconf.h Thu Feb 12 18:33:56 2009 (r188531) +++ stable/7/sys/netinet/sctp_asconf.h Thu Feb 12 18:50:27 2009 (r188532) @@ -86,6 +86,10 @@ extern void extern void sctp_net_immediate_retrans(struct sctp_tcb *, struct sctp_nets *); +extern void +sctp_asconf_send_nat_state_update(struct sctp_tcb *stcb, + struct sctp_nets *net); + extern int sctp_is_addr_pending(struct sctp_tcb *, struct sctp_ifa *); Modified: stable/7/sys/netinet/sctp_auth.c ============================================================================== --- stable/7/sys/netinet/sctp_auth.c Thu Feb 12 18:33:56 2009 (r188531) +++ stable/7/sys/netinet/sctp_auth.c Thu Feb 12 18:50:27 2009 (r188532) @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2001-2007, by Cisco Systems, Inc. All rights reserved. + * Copyright (c) 2001-2008, by Cisco Systems, 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: @@ -359,9 +359,11 @@ sctp_set_key(uint8_t * key, uint32_t key return (new_key); } -/* +/*- * given two keys of variable size, compute which key is "larger/smaller" - * returns: 1 if key1 > key2 -1 if key1 < key2 0 if key1 = key2 + * returns: 1 if key1 > key2 + * -1 if key1 < key2 + * 0 if key1 = key2 */ static int sctp_compare_key(sctp_key_t * key1, sctp_key_t * key2) @@ -531,13 +533,18 @@ sctp_alloc_sharedkey(void) } new_key->keyid = 0; new_key->key = NULL; + new_key->refcount = 1; + new_key->deactivated = 0; return (new_key); } void sctp_free_sharedkey(sctp_sharedkey_t * skey) { - if (skey != NULL) { + if (skey == NULL) + return; + + if (SCTP_DECREMENT_AND_CHECK_REFCOUNT(&skey->refcount)) { if (skey->key != NULL) sctp_free_key(skey->key); SCTP_FREE(skey, SCTP_M_AUTH_KY); @@ -556,40 +563,93 @@ sctp_find_sharedkey(struct sctp_keyhead return (NULL); } -void +int sctp_insert_sharedkey(struct sctp_keyhead *shared_keys, sctp_sharedkey_t * new_skey) { sctp_sharedkey_t *skey; if ((shared_keys == NULL) || (new_skey == NULL)) - return; + return (EINVAL); /* insert into an empty list? */ if (SCTP_LIST_EMPTY(shared_keys)) { LIST_INSERT_HEAD(shared_keys, new_skey, next); - return; + return (0); } /* insert into the existing list, ordered by key id */ LIST_FOREACH(skey, shared_keys, next) { if (new_skey->keyid < skey->keyid) { /* insert it before here */ LIST_INSERT_BEFORE(skey, new_skey, next); - return; + return (0); } else if (new_skey->keyid == skey->keyid) { /* replace the existing key */ + /* verify this key *can* be replaced */ + if ((skey->deactivated) && (skey->refcount > 1)) { + SCTPDBG(SCTP_DEBUG_AUTH1, + "can't replace shared key id %u\n", + new_skey->keyid); + return (EBUSY); + } SCTPDBG(SCTP_DEBUG_AUTH1, "replacing shared key id %u\n", new_skey->keyid); LIST_INSERT_BEFORE(skey, new_skey, next); LIST_REMOVE(skey, next); sctp_free_sharedkey(skey); - return; + return (0); } if (LIST_NEXT(skey, next) == NULL) { /* belongs at the end of the list */ LIST_INSERT_AFTER(skey, new_skey, next); - return; + return (0); + } + } + /* shouldn't reach here */ + return (0); +} + +void +sctp_auth_key_acquire(struct sctp_tcb *stcb, uint16_t key_id) +{ + sctp_sharedkey_t *skey; + + /* find the shared key */ + skey = sctp_find_sharedkey(&stcb->asoc.shared_keys, key_id); + + /* bump the ref count */ + if (skey) { + atomic_add_int(&skey->refcount, 1); + SCTPDBG(SCTP_DEBUG_AUTH2, + "%s: stcb %p key %u refcount acquire to %d\n", + __FUNCTION__, stcb, key_id, skey->refcount); + } +} + +void +sctp_auth_key_release(struct sctp_tcb *stcb, uint16_t key_id) +{ + sctp_sharedkey_t *skey; + + /* find the shared key */ + skey = sctp_find_sharedkey(&stcb->asoc.shared_keys, key_id); + + /* decrement the ref count */ + if (skey) { + sctp_free_sharedkey(skey); + SCTPDBG(SCTP_DEBUG_AUTH2, + "%s: stcb %p key %u refcount release to %d\n", + __FUNCTION__, stcb, key_id, skey->refcount); + + /* see if a notification should be generated */ + if ((skey->refcount <= 1) && (skey->deactivated)) { + /* notify ULP that key is no longer used */ + sctp_ulp_notify(SCTP_NOTIFY_AUTH_FREE_KEY, stcb, + key_id, 0, SCTP_SO_NOT_LOCKED); + SCTPDBG(SCTP_DEBUG_AUTH2, + "%s: stcb %p key %u no longer used, %d\n", + __FUNCTION__, stcb, key_id, skey->refcount); } } } @@ -623,7 +683,7 @@ sctp_copy_skeylist(const struct sctp_key LIST_FOREACH(skey, src, next) { new_skey = sctp_copy_sharedkey(skey); if (new_skey != NULL) { - sctp_insert_sharedkey(dest, new_skey); + (void)sctp_insert_sharedkey(dest, new_skey); count++; } } @@ -727,9 +787,9 @@ sctp_default_supported_hmaclist(void) return (new_list); } -/* - * HMAC algos are listed in priority/preference order find the best HMAC id - * to use for the peer based on local support +/*- + * HMAC algos are listed in priority/preference order + * find the best HMAC id to use for the peer based on local support */ uint16_t sctp_negotiate_hmacid(sctp_hmaclist_t * peer, sctp_hmaclist_t * local) @@ -760,9 +820,9 @@ sctp_negotiate_hmacid(sctp_hmaclist_t * return (SCTP_AUTH_HMAC_ID_RSVD); } -/* - * serialize the HMAC algo list and return space used caller must guarantee - * ptr has appropriate space +/*- + * serialize the HMAC algo list and return space used + * caller must guarantee ptr has appropriate space */ int sctp_serialize_hmaclist(sctp_hmaclist_t * list, uint8_t * ptr) @@ -994,7 +1054,7 @@ sctp_hmac_final(uint16_t hmac_algo, sctp } /* end switch */ } -/* +/*- * Keyed-Hashing for Message Authentication: FIPS 198 (RFC 2104) * * Compute the HMAC digest using the desired hash key, text, and HMAC @@ -1142,9 +1202,10 @@ sctp_hmac_m(uint16_t hmac_algo, uint8_t return (digestlen); } -/* +/*- * verify the HMAC digest using the desired hash key, text, and HMAC - * algorithm. Returns -1 on error, 0 on success. + * algorithm. + * Returns -1 on error, 0 on success. */ int sctp_verify_hmac(uint16_t hmac_algo, uint8_t * key, uint32_t keylen, @@ -1263,10 +1324,10 @@ sctp_auth_is_supported_hmac(sctp_hmaclis } -/* - * clear any cached key(s) if they match the given key id on an association - * the cached key(s) will be recomputed and re-cached at next use. ASSUMES - * TCB_LOCK is already held +/*- + * clear any cached key(s) if they match the given key id on an association. + * the cached key(s) will be recomputed and re-cached at next use. + * ASSUMES TCB_LOCK is already held */ void sctp_clear_cachedkeys(struct sctp_tcb *stcb, uint16_t keyid) @@ -1284,9 +1345,10 @@ sctp_clear_cachedkeys(struct sctp_tcb *s } } -/* +/*- * clear any cached key(s) if they match the given key id for all assocs on - * an association ASSUMES INP_WLOCK is already held + * an endpoint. + * ASSUMES INP_WLOCK is already held */ void sctp_clear_cachedkeys_ep(struct sctp_inpcb *inp, uint16_t keyid) @@ -1304,8 +1366,9 @@ sctp_clear_cachedkeys_ep(struct sctp_inp } } -/* - * delete a shared key from an association ASSUMES TCB_LOCK is already held +/*- + * delete a shared key from an association + * ASSUMES TCB_LOCK is already held */ int sctp_delete_sharedkey(struct sctp_tcb *stcb, uint16_t keyid) @@ -1316,7 +1379,7 @@ sctp_delete_sharedkey(struct sctp_tcb *s return (-1); /* is the keyid the assoc active sending key */ - if (keyid == stcb->asoc.authinfo.assoc_keyid) + if (keyid == stcb->asoc.authinfo.active_keyid) return (-1); /* does the key exist? */ @@ -1324,6 +1387,10 @@ sctp_delete_sharedkey(struct sctp_tcb *s if (skey == NULL) return (-1); + /* are there other refcount holders on the key? */ + if (skey->refcount > 1) + return (-1); + /* remove it */ LIST_REMOVE(skey, next); sctp_free_sharedkey(skey); /* frees skey->key as well */ @@ -1333,35 +1400,29 @@ sctp_delete_sharedkey(struct sctp_tcb *s return (0); } -/* - * deletes a shared key from the endpoint ASSUMES INP_WLOCK is already held +/*- + * deletes a shared key from the endpoint + * ASSUMES INP_WLOCK is already held */ int sctp_delete_sharedkey_ep(struct sctp_inpcb *inp, uint16_t keyid) { sctp_sharedkey_t *skey; - struct sctp_tcb *stcb; if (inp == NULL) return (-1); - /* is the keyid the active sending key on the endpoint or any assoc */ + /* is the keyid the active sending key on the endpoint */ if (keyid == inp->sctp_ep.default_keyid) return (-1); - LIST_FOREACH(stcb, &inp->sctp_asoc_list, sctp_tcblist) { - SCTP_TCB_LOCK(stcb); - if (keyid == stcb->asoc.authinfo.assoc_keyid) { - SCTP_TCB_UNLOCK(stcb); - return (-1); - } - SCTP_TCB_UNLOCK(stcb); - } /* does the key exist? */ skey = sctp_find_sharedkey(&inp->sctp_ep.shared_keys, keyid); if (skey == NULL) return (-1); + /* endpoint keys are not refcounted */ + /* remove it */ LIST_REMOVE(skey, next); sctp_free_sharedkey(skey); /* frees skey->key as well */ @@ -1371,60 +1432,36 @@ sctp_delete_sharedkey_ep(struct sctp_inp return (0); } -/* - * set the active key on an association ASSUME TCB_LOCK is already held +/*- + * set the active key on an association + * ASSUMES TCB_LOCK is already held */ int sctp_auth_setactivekey(struct sctp_tcb *stcb, uint16_t keyid) { sctp_sharedkey_t *skey = NULL; - sctp_key_t *key = NULL; - int using_ep_key = 0; /* find the key on the assoc */ skey = sctp_find_sharedkey(&stcb->asoc.shared_keys, keyid); if (skey == NULL) { - /* if not on the assoc, find the key on the endpoint */ - atomic_add_int(&stcb->asoc.refcnt, 1); - SCTP_TCB_UNLOCK(stcb); - SCTP_INP_RLOCK(stcb->sctp_ep); - SCTP_TCB_LOCK(stcb); - atomic_add_int(&stcb->asoc.refcnt, -1); - skey = sctp_find_sharedkey(&stcb->sctp_ep->sctp_ep.shared_keys, - keyid); - using_ep_key = 1; - } - if (skey == NULL) { /* that key doesn't exist */ - if (using_ep_key) { - SCTP_INP_RUNLOCK(stcb->sctp_ep); - } return (-1); } - /* get the shared key text */ - key = skey->key; - - /* free any existing cached key */ - if (stcb->asoc.authinfo.assoc_key != NULL) - sctp_free_key(stcb->asoc.authinfo.assoc_key); - /* compute a new assoc key and cache it */ - stcb->asoc.authinfo.assoc_key = - sctp_compute_hashkey(stcb->asoc.authinfo.random, - stcb->asoc.authinfo.peer_random, key); - stcb->asoc.authinfo.assoc_keyid = keyid; -#ifdef SCTP_DEBUG - if (SCTP_AUTH_DEBUG) - sctp_print_key(stcb->asoc.authinfo.assoc_key, "Assoc Key"); -#endif - - if (using_ep_key) { - SCTP_INP_RUNLOCK(stcb->sctp_ep); + if ((skey->deactivated) && (skey->refcount > 1)) { + /* can't reactivate a deactivated key with other refcounts */ + return (-1); } + /* set the (new) active key */ + stcb->asoc.authinfo.active_keyid = keyid; + /* reset the deactivated flag */ + skey->deactivated = 0; + return (0); } -/* - * set the active key on an endpoint ASSUMES INP_WLOCK is already held +/*- + * set the active key on an endpoint + * ASSUMES INP_WLOCK is already held */ int sctp_auth_setactivekey_ep(struct sctp_inpcb *inp, uint16_t keyid) @@ -1441,6 +1478,69 @@ sctp_auth_setactivekey_ep(struct sctp_in return (0); } +/*- + * deactivates a shared key from the association + * ASSUMES INP_WLOCK is already held + */ +int +sctp_deact_sharedkey(struct sctp_tcb *stcb, uint16_t keyid) +{ + sctp_sharedkey_t *skey; + + if (stcb == NULL) + return (-1); + + /* is the keyid the assoc active sending key */ + if (keyid == stcb->asoc.authinfo.active_keyid) + return (-1); + + /* does the key exist? */ + skey = sctp_find_sharedkey(&stcb->asoc.shared_keys, keyid); + if (skey == NULL) + return (-1); + + /* are there other refcount holders on the key? */ + if (skey->refcount == 1) { + /* no other users, send a notification for this key */ + sctp_ulp_notify(SCTP_NOTIFY_AUTH_FREE_KEY, stcb, keyid, 0, + SCTP_SO_LOCKED); + } + /* mark the key as deactivated */ + skey->deactivated = 1; + + return (0); +} + +/*- + * deactivates a shared key from the endpoint + * ASSUMES INP_WLOCK is already held + */ +int +sctp_deact_sharedkey_ep(struct sctp_inpcb *inp, uint16_t keyid) +{ + sctp_sharedkey_t *skey; + + if (inp == NULL) + return (-1); + + /* is the keyid the active sending key on the endpoint */ + if (keyid == inp->sctp_ep.default_keyid) + return (-1); + + /* does the key exist? */ + skey = sctp_find_sharedkey(&inp->sctp_ep.shared_keys, keyid); + if (skey == NULL) + return (-1); + + /* endpoint keys are not refcounted */ + + /* remove it */ + LIST_REMOVE(skey, next); + sctp_free_sharedkey(skey); /* frees skey->key as well */ + + return (0); +} + /* * get local authentication parameters from cookie (from INIT-ACK) */ @@ -1581,9 +1681,13 @@ sctp_auth_get_cookie_params(struct sctp_ /* negotiate what HMAC to use for the peer */ stcb->asoc.peer_hmac_id = sctp_negotiate_hmacid(stcb->asoc.peer_hmacs, stcb->asoc.local_hmacs); + /* copy defaults from the endpoint */ /* FIX ME: put in cookie? */ - stcb->asoc.authinfo.assoc_keyid = stcb->sctp_ep->sctp_ep.default_keyid; + stcb->asoc.authinfo.active_keyid = stcb->sctp_ep->sctp_ep.default_keyid; + /* copy out the shared key list (by reference) from the endpoint */ + (void)sctp_copy_skeylist(&stcb->sctp_ep->sctp_ep.shared_keys, + &stcb->asoc.shared_keys); } /* @@ -1591,7 +1695,7 @@ sctp_auth_get_cookie_params(struct sctp_ */ void sctp_fill_hmac_digest_m(struct mbuf *m, uint32_t auth_offset, - struct sctp_auth_chunk *auth, struct sctp_tcb *stcb) + struct sctp_auth_chunk *auth, struct sctp_tcb *stcb, uint16_t keyid) { uint32_t digestlen; sctp_sharedkey_t *skey; @@ -1603,15 +1707,15 @@ sctp_fill_hmac_digest_m(struct mbuf *m, /* zero the digest + chunk padding */ digestlen = sctp_get_hmac_digest_len(stcb->asoc.peer_hmac_id); bzero(auth->hmac, SCTP_SIZE32(digestlen)); - /* is an assoc key cached? */ - if (stcb->asoc.authinfo.assoc_key == NULL) { - skey = sctp_find_sharedkey(&stcb->asoc.shared_keys, - stcb->asoc.authinfo.assoc_keyid); - if (skey == NULL) { - /* not in the assoc list, so check the endpoint list */ - skey = sctp_find_sharedkey(&stcb->sctp_ep->sctp_ep.shared_keys, - stcb->asoc.authinfo.assoc_keyid); + + /* is the desired key cached? */ + if ((keyid != stcb->asoc.authinfo.assoc_keyid) || + (stcb->asoc.authinfo.assoc_key == NULL)) { + if (stcb->asoc.authinfo.assoc_key != NULL) { + /* free the old cached key */ + sctp_free_key(stcb->asoc.authinfo.assoc_key); } + skey = sctp_find_sharedkey(&stcb->asoc.shared_keys, keyid); /* the only way skey is NULL is if null key id 0 is used */ if (skey != NULL) key = skey->key; @@ -1621,6 +1725,7 @@ sctp_fill_hmac_digest_m(struct mbuf *m, stcb->asoc.authinfo.assoc_key = sctp_compute_hashkey(stcb->asoc.authinfo.random, stcb->asoc.authinfo.peer_random, key); + stcb->asoc.authinfo.assoc_keyid = keyid; SCTPDBG(SCTP_DEBUG_AUTH1, "caching key id %u\n", stcb->asoc.authinfo.assoc_keyid); #ifdef SCTP_DEBUG @@ -1630,11 +1735,10 @@ sctp_fill_hmac_digest_m(struct mbuf *m, #endif } /* set in the active key id */ - auth->shared_key_id = htons(stcb->asoc.authinfo.assoc_keyid); + auth->shared_key_id = htons(keyid); /* compute and fill in the digest */ - (void)sctp_compute_hmac_m(stcb->asoc.peer_hmac_id, - stcb->asoc.authinfo.assoc_key, + (void)sctp_compute_hmac_m(stcb->asoc.peer_hmac_id, stcb->asoc.authinfo.assoc_key, m, auth_offset, auth->hmac); } @@ -1671,9 +1775,11 @@ sctp_bzero_m(struct mbuf *m, uint32_t m_ } } -/* - * process the incoming Authentication chunk return codes: -1 on any - * authentication error 0 on authentication verification +/*- + * process the incoming Authentication chunk + * return codes: + * -1 on any authentication error + * 0 on authentication verification */ int sctp_handle_auth(struct sctp_tcb *stcb, struct sctp_auth_chunk *auth, @@ -1736,12 +1842,8 @@ sctp_handle_auth(struct sctp_tcb *stcb, if ((stcb->asoc.authinfo.recv_key == NULL) || (stcb->asoc.authinfo.recv_keyid != shared_key_id)) { /* find the shared key on the assoc first */ - skey = sctp_find_sharedkey(&stcb->asoc.shared_keys, shared_key_id); - if (skey == NULL) { - /* if not on the assoc, find it on the endpoint */ - skey = sctp_find_sharedkey(&stcb->sctp_ep->sctp_ep.shared_keys, - shared_key_id); - } + skey = sctp_find_sharedkey(&stcb->asoc.shared_keys, + shared_key_id); /* if the shared key isn't found, discard the chunk */ if (skey == NULL) { SCTP_STAT_INCR(sctps_recvivalkeyid); @@ -1758,7 +1860,8 @@ sctp_handle_auth(struct sctp_tcb *stcb, * *)stcb->asoc.authinfo.recv_keyid); */ sctp_notify_authentication(stcb, SCTP_AUTH_NEWKEY, - shared_key_id, stcb->asoc.authinfo.recv_keyid); + shared_key_id, stcb->asoc.authinfo.recv_keyid, + SCTP_SO_NOT_LOCKED); /* compute a new recv assoc key and cache it */ if (stcb->asoc.authinfo.recv_key != NULL) sctp_free_key(stcb->asoc.authinfo.recv_key); @@ -1801,7 +1904,11 @@ sctp_handle_auth(struct sctp_tcb *stcb, */ void sctp_notify_authentication(struct sctp_tcb *stcb, uint32_t indication, - uint16_t keyid, uint16_t alt_keyid) + uint16_t keyid, uint16_t alt_keyid, int so_locked +#if !defined(__APPLE__) && !defined(SCTP_SO_LOCK_TESTING) + SCTP_UNUSED +#endif +) { struct mbuf *m_notify; struct sctp_authkey_event *auth; @@ -1851,11 +1958,11 @@ sctp_notify_authentication(struct sctp_t /* not that we need this */ control->tail_mbuf = m_notify; sctp_add_to_readq(stcb->sctp_ep, stcb, control, - &stcb->sctp_socket->so_rcv, 1, SCTP_SO_NOT_LOCKED); + &stcb->sctp_socket->so_rcv, 1, so_locked); } -/* +/*- * validates the AUTHentication related parameters in an INIT/INIT-ACK * Note: currently only used for INIT as INIT-ACK is handled inline * with sctp_load_addresses_from_init() @@ -2027,7 +2134,11 @@ sctp_initialize_auth_params(struct sctp_ } } /* copy defaults from the endpoint */ - stcb->asoc.authinfo.assoc_keyid = inp->sctp_ep.default_keyid; + stcb->asoc.authinfo.active_keyid = inp->sctp_ep.default_keyid; + + /* copy out the shared key list (by reference) from the endpoint */ + (void)sctp_copy_skeylist(&inp->sctp_ep.shared_keys, + &stcb->asoc.shared_keys); /* now set the concatenated key (random + chunks + hmacs) */ #ifdef SCTP_AUTH_DRAFT_04 @@ -2135,11 +2246,13 @@ sctp_test_hmac_sha1(void) uint32_t digestlen = 20; int failed = 0; - /* - * test_case = 1 key = - * 0x0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b key_len = 20 - * data = "Hi There" data_len = 8 digest = - * 0xb617318655057264e28bc0b6fb378c8ef146be00 + /*- + * test_case = 1 + * key = 0x0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b + * key_len = 20 + * data = "Hi There" + * data_len = 8 + * digest = 0xb617318655057264e28bc0b6fb378c8ef146be00 */ keylen = 20; memset(key, 0x0b, keylen); @@ -2150,10 +2263,13 @@ sctp_test_hmac_sha1(void) text, textlen, digest, digestlen) < 0) failed++; - /* - * test_case = 2 key = "Jefe" key_len = 4 data = - * "what do ya want for nothing?" data_len = 28 digest = - * 0xeffcdf6ae5eb2fa2d27416d5f184df9c259a7c79 + /*- + * test_case = 2 + * key = "Jefe" + * key_len = 4 + * data = "what do ya want for nothing?" + * data_len = 28 + * digest = 0xeffcdf6ae5eb2fa2d27416d5f184df9c259a7c79 */ keylen = 4; strcpy(key, "Jefe"); @@ -2164,11 +2280,13 @@ sctp_test_hmac_sha1(void) text, textlen, digest, digestlen) < 0) failed++; - /* - * test_case = 3 key = - * 0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa key_len = 20 - * data = 0xdd repeated 50 times data_len = 50 digest - * = 0x125d7342b9ac11cd91a39af48aa17b4f63f175d3 + /*- + * test_case = 3 + * key = 0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + * key_len = 20 + * data = 0xdd repeated 50 times + * data_len = 50 + * digest = 0x125d7342b9ac11cd91a39af48aa17b4f63f175d3 */ keylen = 20; memset(key, 0xaa, keylen); @@ -2179,11 +2297,13 @@ sctp_test_hmac_sha1(void) text, textlen, digest, digestlen) < 0) failed++; - /* - * test_case = 4 key = - * 0x0102030405060708090a0b0c0d0e0f10111213141516171819 key_len = 25 - * data = 0xcd repeated 50 times data_len = 50 digest - * = 0x4c9007f4026250c6bc8414f9bf50c86c2d7235da + /*- + * test_case = 4 + * key = 0x0102030405060708090a0b0c0d0e0f10111213141516171819 + * key_len = 25 + * data = 0xcd repeated 50 times + * data_len = 50 + * digest = 0x4c9007f4026250c6bc8414f9bf50c86c2d7235da */ keylen = 25; memcpy(key, "\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19", keylen); @@ -2194,12 +2314,14 @@ sctp_test_hmac_sha1(void) text, textlen, digest, digestlen) < 0) failed++; - /* - * test_case = 5 key = - * 0x0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c key_len = 20 - * data = "Test With Truncation" data_len = 20 digest - * = 0x4c1a03424b55e07fe7f27be1d58bb9324a9a5a04 digest-96 = *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-stable@FreeBSD.ORG Fri Feb 13 01:14:00 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 839D71065674; Fri, 13 Feb 2009 01:14:00 +0000 (UTC) (envelope-from emax@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 5624F8FC1E; Fri, 13 Feb 2009 01:14:00 +0000 (UTC) (envelope-from emax@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n1D1E0c6072050; Fri, 13 Feb 2009 01:14:00 GMT (envelope-from emax@svn.freebsd.org) Received: (from emax@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n1D1E0Pu072049; Fri, 13 Feb 2009 01:14:00 GMT (envelope-from emax@svn.freebsd.org) Message-Id: <200902130114.n1D1E0Pu072049@svn.freebsd.org> From: Maksim Yevmenkin Date: Fri, 13 Feb 2009 01:14:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r188547 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb netgraph/bluetooth/socket X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 Feb 2009 01:14:01 -0000 Author: emax Date: Fri Feb 13 01:14:00 2009 New Revision: 188547 URL: http://svn.freebsd.org/changeset/base/188547 Log: MFC r188452 Update comment. soalloc() is no longer performing M_WAITOK memory allocations. Submitted by: ru Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/netgraph/bluetooth/socket/ng_btsocket_rfcomm.c Modified: stable/7/sys/netgraph/bluetooth/socket/ng_btsocket_rfcomm.c ============================================================================== --- stable/7/sys/netgraph/bluetooth/socket/ng_btsocket_rfcomm.c Fri Feb 13 00:01:11 2009 (r188546) +++ stable/7/sys/netgraph/bluetooth/socket/ng_btsocket_rfcomm.c Fri Feb 13 01:14:00 2009 (r188547) @@ -518,13 +518,9 @@ ng_btsocket_rfcomm_connect(struct socket return (EDESTADDRREQ); /* - * XXX FIXME - This is FUBAR. socreate() will call soalloc(1), i.e. - * soalloc() is allowed to sleep in MALLOC. This creates "could sleep" - * WITNESS warnings. To work around this problem we will create L2CAP - * socket first and then check if we actually need it. Note that we - * will not check for errors in socreate() because if we failed to - * create L2CAP socket at this point we still might have already open - * session. + * Note that we will not check for errors in socreate() because + * if we failed to create L2CAP socket at this point we still + * might have already open session. */ error = socreate(PF_BLUETOOTH, &l2so, SOCK_SEQPACKET, @@ -857,13 +853,9 @@ ng_btsocket_rfcomm_listen(struct socket mtx_unlock(&pcb->pcb_mtx); /* - * XXX FIXME - This is FUBAR. socreate() will call soalloc(1), i.e. - * soalloc() is allowed to sleep in MALLOC. This creates "could sleep" - * WITNESS warnings. To work around this problem we will create L2CAP - * socket first and then check if we actually need it. Note that we - * will not check for errors in socreate() because if we failed to - * create L2CAP socket at this point we still might have already open - * session. + * Note that we will not check for errors in socreate() because + * if we failed to create L2CAP socket at this point we still + * might have already open session. */ socreate_error = socreate(PF_BLUETOOTH, &l2so, SOCK_SEQPACKET, From owner-svn-src-stable@FreeBSD.ORG Fri Feb 13 02:41:16 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 47B76106566C; Fri, 13 Feb 2009 02:41:16 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 351CB8FC13; Fri, 13 Feb 2009 02:41:16 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n1D2fF6c073861; Fri, 13 Feb 2009 02:41:15 GMT (envelope-from yongari@svn.freebsd.org) Received: (from yongari@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n1D2fF5i073860; Fri, 13 Feb 2009 02:41:15 GMT (envelope-from yongari@svn.freebsd.org) Message-Id: <200902130241.n1D2fF5i073860@svn.freebsd.org> From: Pyun YongHyeon Date: Fri, 13 Feb 2009 02:41:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r188551 - stable/7/share/man/man4 X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 Feb 2009 02:41:17 -0000 Author: yongari Date: Fri Feb 13 02:41:15 2009 New Revision: 188551 URL: http://svn.freebsd.org/changeset/base/188551 Log: MFC r186126: Elaborate on the hardware features fxp(4) supports. Modified: stable/7/share/man/man4/ (props changed) stable/7/share/man/man4/fxp.4 stable/7/share/man/man4/igb.4 (props changed) Modified: stable/7/share/man/man4/fxp.4 ============================================================================== --- stable/7/share/man/man4/fxp.4 Fri Feb 13 02:08:20 2009 (r188550) +++ stable/7/share/man/man4/fxp.4 Fri Feb 13 02:41:15 2009 (r188551) @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd January 7, 2007 +.Dd December 15, 2008 .Dt FXP 4 .Os .Sh NAME @@ -51,6 +51,13 @@ The .Nm driver provides support for Ethernet adapters based on the Intel i82557, i82558, i82559, i82550, and i82562 chips. +The driver supports TCP/UDP/IP checksum offload for both transmit +and receive on i82550 and i82551. +On i82559 only TCP/UDP checksum offload for receive is supported. +TCP segmentation offload (TSO) for IPv4 as well as VLAN hardware +tag insertion/stripping is supported on i82550 and i82551. +Wake On Lan (WOL) support is provided on all controllers +except i82557, i82259ER and early i82558 revisions. .Pp The .Nm From owner-svn-src-stable@FreeBSD.ORG Fri Feb 13 12:15:46 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3DC2F106564A; Fri, 13 Feb 2009 12:15:46 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 29D238FC1F; Fri, 13 Feb 2009 12:15:46 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n1DCFjOO088382; Fri, 13 Feb 2009 12:15:45 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n1DCFj2V088381; Fri, 13 Feb 2009 12:15:45 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <200902131215.n1DCFj2V088381@svn.freebsd.org> From: Konstantin Belousov Date: Fri, 13 Feb 2009 12:15:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r188574 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb kern X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 Feb 2009 12:15:47 -0000 Author: kib Date: Fri Feb 13 12:15:45 2009 New Revision: 188574 URL: http://svn.freebsd.org/changeset/base/188574 Log: MFC r187223: Redo the locking of the semaphores lifetime cycle. MFC r187298: Lock the semaphore identifier lock during semaphore initialization. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/kern/sysv_sem.c Modified: stable/7/sys/kern/sysv_sem.c ============================================================================== --- stable/7/sys/kern/sysv_sem.c Fri Feb 13 12:07:45 2009 (r188573) +++ stable/7/sys/kern/sysv_sem.c Fri Feb 13 12:15:45 2009 (r188574) @@ -88,7 +88,7 @@ int semop(struct thread *td, struct semo static struct sem_undo *semu_alloc(struct thread *td); static int semundo_adjust(struct thread *td, struct sem_undo **supptr, - int semid, int semnum, int adjval); + int semid, int semseq, int semnum, int adjval); static void semundo_clear(int semid, int semnum); /* XXX casting to (sy_call_t *) is bogus, as usual. */ @@ -98,15 +98,17 @@ static sy_call_t *semcalls[] = { }; static struct mtx sem_mtx; /* semaphore global lock */ +static struct mtx sem_undo_mtx; static int semtot = 0; static struct semid_kernel *sema; /* semaphore id pool */ static struct mtx *sema_mtx; /* semaphore id pool mutexes*/ static struct sem *sem; /* semaphore pool */ -SLIST_HEAD(, sem_undo) semu_list; /* list of active undo structures */ +LIST_HEAD(, sem_undo) semu_list; /* list of active undo structures */ +LIST_HEAD(, sem_undo) semu_free_list; /* list of free undo structures */ static int *semu; /* undo structure pool */ static eventhandler_tag semexit_tag; -#define SEMUNDO_MTX sem_mtx +#define SEMUNDO_MTX sem_undo_mtx #define SEMUNDO_LOCK() mtx_lock(&SEMUNDO_MTX); #define SEMUNDO_UNLOCK() mtx_unlock(&SEMUNDO_MTX); #define SEMUNDO_LOCKASSERT(how) mtx_assert(&SEMUNDO_MTX, (how)); @@ -122,13 +124,14 @@ struct sem { * Undo structure (one per process) */ struct sem_undo { - SLIST_ENTRY(sem_undo) un_next; /* ptr to next active undo structure */ + LIST_ENTRY(sem_undo) un_next; /* ptr to next active undo structure */ struct proc *un_proc; /* owner of this structure */ short un_cnt; /* # of active entries */ struct undo { short un_adjval; /* adjust on exit values */ short un_num; /* semaphore # */ int un_id; /* semid */ + unsigned short un_seq; } un_ent[1]; /* undo entries */ }; @@ -250,12 +253,15 @@ seminit(void) } for (i = 0; i < seminfo.semmni; i++) mtx_init(&sema_mtx[i], "semid", NULL, MTX_DEF); + LIST_INIT(&semu_free_list); for (i = 0; i < seminfo.semmnu; i++) { struct sem_undo *suptr = SEMU(i); suptr->un_proc = NULL; + LIST_INSERT_HEAD(&semu_free_list, suptr, un_next); } - SLIST_INIT(&semu_list); + LIST_INIT(&semu_list); mtx_init(&sem_mtx, "sem", NULL, MTX_DEF); + mtx_init(&sem_undo_mtx, "semu", NULL, MTX_DEF); semexit_tag = EVENTHANDLER_REGISTER(process_exit, semexit_myhook, NULL, EVENTHANDLER_PRI_ANY); } @@ -265,6 +271,7 @@ semunload(void) { int i; + /* XXXKIB */ if (semtot != 0) return (EBUSY); @@ -279,6 +286,7 @@ semunload(void) for (i = 0; i < seminfo.semmni; i++) mtx_destroy(&sema_mtx[i]); mtx_destroy(&sem_mtx); + mtx_destroy(&sem_undo_mtx); return (0); } @@ -350,69 +358,31 @@ semsys(td, uap) */ static struct sem_undo * -semu_alloc(td) - struct thread *td; +semu_alloc(struct thread *td) { - int i; struct sem_undo *suptr; - struct sem_undo **supptr; - int attempt; SEMUNDO_LOCKASSERT(MA_OWNED); - /* - * Try twice to allocate something. - * (we'll purge an empty structure after the first pass so - * two passes are always enough) - */ - - for (attempt = 0; attempt < 2; attempt++) { - /* - * Look for a free structure. - * Fill it in and return it if we find one. - */ - - for (i = 0; i < seminfo.semmnu; i++) { - suptr = SEMU(i); - if (suptr->un_proc == NULL) { - SLIST_INSERT_HEAD(&semu_list, suptr, un_next); - suptr->un_cnt = 0; - suptr->un_proc = td->td_proc; - return(suptr); - } - } + if ((suptr = LIST_FIRST(&semu_free_list)) == NULL) + return (NULL); + LIST_REMOVE(suptr, un_next); + LIST_INSERT_HEAD(&semu_list, suptr, un_next); + suptr->un_cnt = 0; + suptr->un_proc = td->td_proc; + return (suptr); +} - /* - * We didn't find a free one, if this is the first attempt - * then try to free a structure. - */ +static int +semu_try_free(struct sem_undo *suptr) +{ - if (attempt == 0) { - /* All the structures are in use - try to free one */ - int did_something = 0; - - SLIST_FOREACH_PREVPTR(suptr, supptr, &semu_list, - un_next) { - if (suptr->un_cnt == 0) { - suptr->un_proc = NULL; - did_something = 1; - *supptr = SLIST_NEXT(suptr, un_next); - break; - } - } + SEMUNDO_LOCKASSERT(MA_OWNED); - /* If we didn't free anything then just give-up */ - if (!did_something) - return(NULL); - } else { - /* - * The second pass failed even though we freed - * something after the first pass! - * This is IMPOSSIBLE! - */ - panic("semu_alloc - second attempt failed"); - } - } - return (NULL); + if (suptr->un_cnt != 0) + return (0); + LIST_REMOVE(suptr, un_next); + LIST_INSERT_HEAD(&semu_free_list, suptr, un_next); + return (1); } /* @@ -420,11 +390,8 @@ semu_alloc(td) */ static int -semundo_adjust(td, supptr, semid, semnum, adjval) - struct thread *td; - struct sem_undo **supptr; - int semid, semnum; - int adjval; +semundo_adjust(struct thread *td, struct sem_undo **supptr, int semid, + int semseq, int semnum, int adjval) { struct proc *p = td->td_proc; struct sem_undo *suptr; @@ -437,7 +404,7 @@ semundo_adjust(td, supptr, semid, semnum suptr = *supptr; if (suptr == NULL) { - SLIST_FOREACH(suptr, &semu_list, un_next) { + LIST_FOREACH(suptr, &semu_list, un_next) { if (suptr->un_proc == p) { *supptr = suptr; break; @@ -448,7 +415,7 @@ semundo_adjust(td, supptr, semid, semnum return(0); suptr = semu_alloc(td); if (suptr == NULL) - return(ENOSPC); + return (ENOSPC); *supptr = suptr; } } @@ -472,58 +439,59 @@ semundo_adjust(td, supptr, semid, semnum if (i < suptr->un_cnt) suptr->un_ent[i] = suptr->un_ent[suptr->un_cnt]; + if (suptr->un_cnt == 0) + semu_try_free(suptr); } - return(0); + return (0); } /* Didn't find the right entry - create it */ if (adjval == 0) - return(0); + return (0); if (adjval > seminfo.semaem || adjval < -seminfo.semaem) return (ERANGE); if (suptr->un_cnt != seminfo.semume) { sunptr = &suptr->un_ent[suptr->un_cnt]; suptr->un_cnt++; sunptr->un_adjval = adjval; - sunptr->un_id = semid; sunptr->un_num = semnum; + sunptr->un_id = semid; + sunptr->un_num = semnum; + sunptr->un_seq = semseq; } else - return(EINVAL); - return(0); + return (EINVAL); + return (0); } static void -semundo_clear(semid, semnum) - int semid, semnum; +semundo_clear(int semid, int semnum) { - struct sem_undo *suptr; + struct sem_undo *suptr, *suptr1; + struct undo *sunptr; + int i; SEMUNDO_LOCKASSERT(MA_OWNED); - SLIST_FOREACH(suptr, &semu_list, un_next) { - struct undo *sunptr = &suptr->un_ent[0]; - int i = 0; - - while (i < suptr->un_cnt) { - if (sunptr->un_id == semid) { - if (semnum == -1 || sunptr->un_num == semnum) { - suptr->un_cnt--; - if (i < suptr->un_cnt) { - suptr->un_ent[i] = - suptr->un_ent[suptr->un_cnt]; - continue; - } + LIST_FOREACH_SAFE(suptr, &semu_list, un_next, suptr1) { + sunptr = &suptr->un_ent[0]; + for (i = 0; i < suptr->un_cnt; i++, sunptr++) { + if (sunptr->un_id != semid) + continue; + if (semnum == -1 || sunptr->un_num == semnum) { + suptr->un_cnt--; + if (i < suptr->un_cnt) { + suptr->un_ent[i] = + suptr->un_ent[suptr->un_cnt]; + continue; } - if (semnum != -1) - break; + semu_try_free(suptr); } - i++, sunptr++; + if (semnum != -1) + break; } } } static int -semvalid(semid, semakptr) - int semid; - struct semid_kernel *semakptr; +semvalid(int semid, struct semid_kernel *semakptr) { return ((semakptr->u.sem_perm.mode & SEM_ALLOC) == 0 || @@ -542,9 +510,7 @@ struct __semctl_args { }; #endif int -__semctl(td, uap) - struct thread *td; - struct __semctl_args *uap; +__semctl(struct thread *td, struct __semctl_args *uap) { struct semid_ds dsbuf; union semun arg, semun; @@ -655,6 +621,8 @@ kern_semctl(struct thread *td, int semid semakptr = &sema[semidx]; sema_mtxp = &sema_mtx[semidx]; + if (cmd == IPC_RMID) + mtx_lock(&sem_mtx); mtx_lock(sema_mtxp); #ifdef MAC error = mac_check_sysv_semctl(cred, semakptr, cmd); @@ -673,22 +641,29 @@ kern_semctl(struct thread *td, int semid goto done2; semakptr->u.sem_perm.cuid = cred->cr_uid; semakptr->u.sem_perm.uid = cred->cr_uid; - semtot -= semakptr->u.sem_nsems; + semakptr->u.sem_perm.mode = 0; + SEMUNDO_LOCK(); + semundo_clear(semidx, -1); + SEMUNDO_UNLOCK(); +#ifdef MAC + mac_cleanup_sysv_sem(semakptr); +#endif + wakeup(semakptr); + for (i = 0; i < seminfo.semmni; i++) { + if ((sema[i].u.sem_perm.mode & SEM_ALLOC) && + sema[i].u.sem_base > semakptr->u.sem_base) + mtx_lock_flags(&sema_mtx[i], LOP_DUPOK); + } for (i = semakptr->u.sem_base - sem; i < semtot; i++) sem[i] = sem[i + semakptr->u.sem_nsems]; for (i = 0; i < seminfo.semmni; i++) { if ((sema[i].u.sem_perm.mode & SEM_ALLOC) && - sema[i].u.sem_base > semakptr->u.sem_base) + sema[i].u.sem_base > semakptr->u.sem_base) { sema[i].u.sem_base -= semakptr->u.sem_nsems; + mtx_unlock(&sema_mtx[i]); + } } - semakptr->u.sem_perm.mode = 0; -#ifdef MAC - mac_cleanup_sysv_sem(semakptr); -#endif - SEMUNDO_LOCK(); - semundo_clear(semidx, -1); - SEMUNDO_UNLOCK(); - wakeup(semakptr); + semtot -= semakptr->u.sem_nsems; break; case IPC_SET: @@ -855,6 +830,8 @@ kern_semctl(struct thread *td, int semid done2: mtx_unlock(sema_mtxp); + if (cmd == IPC_RMID) + mtx_unlock(&sem_mtx); if (array != NULL) free(array, M_TEMP); return(error); @@ -868,9 +845,7 @@ struct semget_args { }; #endif int -semget(td, uap) - struct thread *td; - struct semget_args *uap; +semget(struct thread *td, struct semget_args *uap) { int semid, error = 0; int key = uap->key; @@ -882,7 +857,7 @@ semget(td, uap) if (!jail_sysvipc_allowed && jailed(td->td_ucred)) return (ENOSYS); - mtx_lock(&Giant); + mtx_lock(&sem_mtx); if (key != IPC_PRIVATE) { for (semid = 0; semid < seminfo.semmni; semid++) { if ((sema[semid].u.sem_perm.mode & SEM_ALLOC) && @@ -939,6 +914,9 @@ semget(td, uap) goto done2; } DPRINTF(("semid %d is available\n", semid)); + mtx_lock(&sema_mtx[semid]); + KASSERT((sema[semid].u.sem_perm.mode & SEM_ALLOC) == 0, + ("Lost semaphore %d", semid)); sema[semid].u.sem_perm.key = key; sema[semid].u.sem_perm.cuid = cred->cr_uid; sema[semid].u.sem_perm.uid = cred->cr_uid; @@ -957,6 +935,7 @@ semget(td, uap) #ifdef MAC mac_create_sysv_sem(cred, &sema[semid]); #endif + mtx_unlock(&sema_mtx[semid]); DPRINTF(("sembase = %p, next = %p\n", sema[semid].u.sem_base, &sem[semtot])); } else { @@ -968,7 +947,7 @@ semget(td, uap) found: td->td_retval[0] = IXSEQ_TO_IPCID(semid, sema[semid].u.sem_perm); done2: - mtx_unlock(&Giant); + mtx_unlock(&sem_mtx); return (error); } @@ -980,9 +959,7 @@ struct semop_args { }; #endif int -semop(td, uap) - struct thread *td; - struct semop_args *uap; +semop(struct thread *td, struct semop_args *uap) { #define SMALL_SOPS 8 struct sembuf small_sops[SMALL_SOPS]; @@ -997,6 +974,7 @@ semop(td, uap) size_t i, j, k; int error; int do_wakeup, do_undos; + unsigned short seq; #ifdef SEM_DEBUG sops = NULL; @@ -1036,7 +1014,8 @@ semop(td, uap) error = EINVAL; goto done2; } - if (semakptr->u.sem_perm.seq != IPCID_TO_SEQ(uap->semid)) { + seq = semakptr->u.sem_perm.seq; + if (seq != IPCID_TO_SEQ(uap->semid)) { error = EINVAL; goto done2; } @@ -1160,8 +1139,9 @@ semop(td, uap) /* * Make sure that the semaphore still exists */ + seq = semakptr->u.sem_perm.seq; if ((semakptr->u.sem_perm.mode & SEM_ALLOC) == 0 || - semakptr->u.sem_perm.seq != IPCID_TO_SEQ(uap->semid)) { + seq != IPCID_TO_SEQ(uap->semid)) { error = EIDRM; goto done2; } @@ -1213,7 +1193,7 @@ done: adjval = sops[i].sem_op; if (adjval == 0) continue; - error = semundo_adjust(td, &suptr, semid, + error = semundo_adjust(td, &suptr, semid, seq, sops[i].sem_num, -adjval); if (error == 0) continue; @@ -1234,7 +1214,7 @@ done: adjval = sops[k].sem_op; if (adjval == 0) continue; - if (semundo_adjust(td, &suptr, semid, + if (semundo_adjust(td, &suptr, semid, seq, sops[k].sem_num, adjval) != 0) panic("semop - can't undo undos"); } @@ -1281,28 +1261,28 @@ done2: * semaphores. */ static void -semexit_myhook(arg, p) - void *arg; - struct proc *p; +semexit_myhook(void *arg, struct proc *p) { struct sem_undo *suptr; - struct sem_undo **supptr; + struct semid_kernel *semakptr; + struct mtx *sema_mtxp; + int semid, semnum, adjval, ix; + unsigned short seq; /* * Go through the chain of undo vectors looking for one * associated with this process. */ SEMUNDO_LOCK(); - SLIST_FOREACH_PREVPTR(suptr, supptr, &semu_list, un_next) { - if (suptr->un_proc == p) { - *supptr = SLIST_NEXT(suptr, un_next); + LIST_FOREACH(suptr, &semu_list, un_next) { + if (suptr->un_proc == p) break; - } } - SEMUNDO_UNLOCK(); - - if (suptr == NULL) + if (suptr == NULL) { + SEMUNDO_UNLOCK(); return; + } + LIST_REMOVE(suptr, un_next); DPRINTF(("proc @%p has undo structure with %d entries\n", p, suptr->un_cnt)); @@ -1311,21 +1291,21 @@ semexit_myhook(arg, p) * If there are any active undo elements then process them. */ if (suptr->un_cnt > 0) { - int ix; - + SEMUNDO_UNLOCK(); for (ix = 0; ix < suptr->un_cnt; ix++) { - int semid = suptr->un_ent[ix].un_id; - int semnum = suptr->un_ent[ix].un_num; - int adjval = suptr->un_ent[ix].un_adjval; - struct semid_kernel *semakptr; - struct mtx *sema_mtxp; - + semid = suptr->un_ent[ix].un_id; + semnum = suptr->un_ent[ix].un_num; + adjval = suptr->un_ent[ix].un_adjval; + seq = suptr->un_ent[ix].un_seq; semakptr = &sema[semid]; sema_mtxp = &sema_mtx[semid]; + mtx_lock(sema_mtxp); - SEMUNDO_LOCK(); - if ((semakptr->u.sem_perm.mode & SEM_ALLOC) == 0) - panic("semexit - semid not allocated"); + if ((semakptr->u.sem_perm.mode & SEM_ALLOC) == 0 || + (semakptr->u.sem_perm.seq != seq)) { + mtx_unlock(sema_mtxp); + continue; + } if (semnum >= semakptr->u.sem_nsems) panic("semexit - semnum out of range"); @@ -1336,29 +1316,26 @@ semexit_myhook(arg, p) suptr->un_ent[ix].un_adjval, semakptr->u.sem_base[semnum].semval)); - if (adjval < 0) { - if (semakptr->u.sem_base[semnum].semval < - -adjval) - semakptr->u.sem_base[semnum].semval = 0; - else - semakptr->u.sem_base[semnum].semval += - adjval; - } else + if (adjval < 0 && semakptr->u.sem_base[semnum].semval < + -adjval) + semakptr->u.sem_base[semnum].semval = 0; + else semakptr->u.sem_base[semnum].semval += adjval; wakeup(semakptr); DPRINTF(("semexit: back from wakeup\n")); mtx_unlock(sema_mtxp); - SEMUNDO_UNLOCK(); } + SEMUNDO_LOCK(); } /* * Deallocate the undo vector. */ DPRINTF(("removing vector\n")); - SEMUNDO_LOCK(); suptr->un_proc = NULL; + suptr->un_cnt = 0; + LIST_INSERT_HEAD(&semu_free_list, suptr, un_next); SEMUNDO_UNLOCK(); } From owner-svn-src-stable@FreeBSD.ORG Fri Feb 13 13:35:41 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id AFEE21065698; Fri, 13 Feb 2009 13:35:41 +0000 (UTC) (envelope-from luigi@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 8077F8FC1C; Fri, 13 Feb 2009 13:35:41 +0000 (UTC) (envelope-from luigi@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n1DDZfwB089895; Fri, 13 Feb 2009 13:35:41 GMT (envelope-from luigi@svn.freebsd.org) Received: (from luigi@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n1DDZffx089893; Fri, 13 Feb 2009 13:35:41 GMT (envelope-from luigi@svn.freebsd.org) Message-Id: <200902131335.n1DDZffx089893@svn.freebsd.org> From: Luigi Rizzo Date: Fri, 13 Feb 2009 13:35:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r188576 - stable/7/sys/netinet X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 Feb 2009 13:35:45 -0000 Author: luigi Date: Fri Feb 13 13:35:41 2009 New Revision: 188576 URL: http://svn.freebsd.org/changeset/base/188576 Log: remove some unnecessary #include The change is not directly applicable to HEAD because there a lot of headers are already included by vnet.h Modified: stable/7/sys/netinet/ip_dummynet.c stable/7/sys/netinet/ip_fw2.c Modified: stable/7/sys/netinet/ip_dummynet.c ============================================================================== --- stable/7/sys/netinet/ip_dummynet.c Fri Feb 13 12:59:54 2009 (r188575) +++ stable/7/sys/netinet/ip_dummynet.c Fri Feb 13 13:35:41 2009 (r188576) @@ -72,7 +72,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #include #include #include @@ -81,7 +80,7 @@ __FBSDID("$FreeBSD$"); #include #include -#include /* for struct arpcom */ +#include /* various ether_* routines */ #include /* for ip6_input, ip6_output prototypes */ #include Modified: stable/7/sys/netinet/ip_fw2.c ============================================================================== --- stable/7/sys/netinet/ip_fw2.c Fri Feb 13 12:59:54 2009 (r188575) +++ stable/7/sys/netinet/ip_fw2.c Fri Feb 13 13:35:41 2009 (r188576) @@ -83,17 +83,12 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include -#include #include -#include #include #include #include #include -#include - #include #include #ifdef INET6 @@ -104,7 +99,9 @@ __FBSDID("$FreeBSD$"); #include /* XXX for in_cksum */ +#ifdef MAC #include +#endif /* * set_disable contains one bit per set value (0..31). From owner-svn-src-stable@FreeBSD.ORG Fri Feb 13 18:04:56 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3C884106564A; Fri, 13 Feb 2009 18:04:56 +0000 (UTC) (envelope-from luigi@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 2A0448FC13; Fri, 13 Feb 2009 18:04:56 +0000 (UTC) (envelope-from luigi@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n1DI4u1e095331; Fri, 13 Feb 2009 18:04:56 GMT (envelope-from luigi@svn.freebsd.org) Received: (from luigi@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n1DI4uWN095330; Fri, 13 Feb 2009 18:04:56 GMT (envelope-from luigi@svn.freebsd.org) Message-Id: <200902131804.n1DI4uWN095330@svn.freebsd.org> From: Luigi Rizzo Date: Fri, 13 Feb 2009 18:04:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r188586 - stable/7/sys/netinet X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 Feb 2009 18:04:57 -0000 Author: luigi Date: Fri Feb 13 18:04:55 2009 New Revision: 188586 URL: http://svn.freebsd.org/changeset/base/188586 Log: document why certain headers are required. Modified: stable/7/sys/netinet/ip_dummynet.c Modified: stable/7/sys/netinet/ip_dummynet.c ============================================================================== --- stable/7/sys/netinet/ip_dummynet.c Fri Feb 13 17:45:09 2009 (r188585) +++ stable/7/sys/netinet/ip_dummynet.c Fri Feb 13 18:04:55 2009 (r188586) @@ -70,15 +70,14 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include +#include /* IFNAMSIZ, struct ifaddr, ifq head, lock.h mutex.h */ #include #include -#include -#include -#include +#include /* n_long, SYSCTL_DECL(_net) */ +#include /* ip_len, ip_off */ #include #include -#include +#include /* ip_output(), IP_FORWARDING */ #include /* various ether_* routines */ @@ -154,6 +153,9 @@ static struct callout dn_timeout; extern void (*bridge_dn_p)(struct mbuf *, struct ifnet *); #ifdef SYSCTL_NODE +SYSCTL_DECL(_net_inet); +SYSCTL_DECL(_net_inet_ip); + SYSCTL_NODE(_net_inet_ip, OID_AUTO, dummynet, CTLFLAG_RW, 0, "Dummynet"); SYSCTL_INT(_net_inet_ip_dummynet, OID_AUTO, hash_size, CTLFLAG_RW, &dn_hash_size, 0, "Default hash table size"); @@ -889,7 +891,7 @@ dummynet_send(struct mbuf *m) case DN_TO_IP_OUT: ip_output(m, NULL, NULL, IP_FORWARDING, NULL, NULL); break ; - case DN_TO_IP_IN : + case DN_TO_IP_IN : ip = mtod(m, struct ip *); ip->ip_len = htons(ip->ip_len); ip->ip_off = htons(ip->ip_off); From owner-svn-src-stable@FreeBSD.ORG Fri Feb 13 18:09:38 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id AA007106564A; Fri, 13 Feb 2009 18:09:38 +0000 (UTC) (envelope-from luigi@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 8DACF8FC13; Fri, 13 Feb 2009 18:09:38 +0000 (UTC) (envelope-from luigi@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n1DI9cDn095464; Fri, 13 Feb 2009 18:09:38 GMT (envelope-from luigi@svn.freebsd.org) Received: (from luigi@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n1DI9cXb095457; Fri, 13 Feb 2009 18:09:38 GMT (envelope-from luigi@svn.freebsd.org) Message-Id: <200902131809.n1DI9cXb095457@svn.freebsd.org> From: Luigi Rizzo Date: Fri, 13 Feb 2009 18:09:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r188587 - stable/7/sys/netinet X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 Feb 2009 18:09:39 -0000 Author: luigi Date: Fri Feb 13 18:09:38 2009 New Revision: 188587 URL: http://svn.freebsd.org/changeset/base/188587 Log: MFC - replace usage of n_* types with uint*_t , to help removing unnecessary dependencies on in_systm.h Modified: stable/7/sys/netinet/in_systm.h stable/7/sys/netinet/ip.h stable/7/sys/netinet/ip_icmp.c stable/7/sys/netinet/ip_icmp.h stable/7/sys/netinet/ip_options.c stable/7/sys/netinet/tcp_debug.h stable/7/sys/netinet/tcp_subr.c Modified: stable/7/sys/netinet/in_systm.h ============================================================================== --- stable/7/sys/netinet/in_systm.h Fri Feb 13 18:04:55 2009 (r188586) +++ stable/7/sys/netinet/in_systm.h Fri Feb 13 18:09:38 2009 (r188587) @@ -52,7 +52,7 @@ typedef u_int32_t n_long; /* long as re typedef u_int32_t n_time; /* ms since 00:00 GMT, byte rev */ #ifdef _KERNEL -n_time iptime(void); +uint32_t iptime(void); #endif #endif Modified: stable/7/sys/netinet/ip.h ============================================================================== --- stable/7/sys/netinet/ip.h Fri Feb 13 18:04:55 2009 (r188586) +++ stable/7/sys/netinet/ip.h Fri Feb 13 18:09:38 2009 (r188587) @@ -159,10 +159,10 @@ struct ip_timestamp { ipt_flg:4; /* flags, see below */ #endif union ipt_timestamp { - n_long ipt_time[1]; + uint32_t ipt_time[1]; /* network format */ struct ipt_ta { struct in_addr ipt_addr; - n_long ipt_time; + uint32_t ipt_time; /* network format */ } ipt_ta[1]; } ipt_timestamp; }; Modified: stable/7/sys/netinet/ip_icmp.c ============================================================================== --- stable/7/sys/netinet/ip_icmp.c Fri Feb 13 18:04:55 2009 (r188586) +++ stable/7/sys/netinet/ip_icmp.c Fri Feb 13 18:09:38 2009 (r188587) @@ -141,7 +141,7 @@ extern struct protosw inetsw[]; * in response to bad packet ip. */ void -icmp_error(struct mbuf *n, int type, int code, n_long dest, int mtu) +icmp_error(struct mbuf *n, int type, int code, uint32_t dest, int mtu) { register struct ip *oip = mtod(n, struct ip *), *nip; register unsigned oiphlen = oip->ip_hl << 2; @@ -825,7 +825,10 @@ icmp_send(struct mbuf *m, struct mbuf *o (void) ip_output(m, opts, NULL, 0, NULL, NULL); } -n_time +/* + * Return milliseconds since 00:00 GMT in network format. + */ +uint32_t iptime(void) { struct timeval atv; Modified: stable/7/sys/netinet/ip_icmp.h ============================================================================== --- stable/7/sys/netinet/ip_icmp.h Fri Feb 13 18:04:55 2009 (r188586) +++ stable/7/sys/netinet/ip_icmp.h Fri Feb 13 18:09:38 2009 (r188587) @@ -68,15 +68,15 @@ struct icmp { u_char ih_pptr; /* ICMP_PARAMPROB */ struct in_addr ih_gwaddr; /* ICMP_REDIRECT */ struct ih_idseq { - n_short icd_id; - n_short icd_seq; + uint16_t icd_id; /* network format */ + uint16_t icd_seq; /* network format */ } ih_idseq; int ih_void; /* ICMP_UNREACH_NEEDFRAG -- Path MTU Discovery (RFC1191) */ struct ih_pmtu { - n_short ipm_void; - n_short ipm_nextmtu; + uint16_t ipm_void; /* network format */ + uint16_t ipm_nextmtu; /* network format */ } ih_pmtu; struct ih_rtradv { @@ -97,9 +97,13 @@ struct icmp { #define icmp_lifetime icmp_hun.ih_rtradv.irt_lifetime union { struct id_ts { /* ICMP Timestamp */ - n_time its_otime; /* Originate */ - n_time its_rtime; /* Receive */ - n_time its_ttime; /* Transmit */ + /* + * The next 3 fields are in network format, + * milliseconds since 00:00 GMT + */ + uint32_t its_otime; /* Originate */ + uint32_t its_rtime; /* Receive */ + uint32_t its_ttime; /* Transmit */ } id_ts; struct id_ip { struct ip idi_ip; @@ -127,7 +131,7 @@ struct icmp { * ip header length. */ #define ICMP_MINLEN 8 /* abs minimum */ -#define ICMP_TSLEN (8 + 3 * sizeof (n_time)) /* timestamp */ +#define ICMP_TSLEN (8 + 3 * sizeof (uint32_t)) /* timestamp */ #define ICMP_MASKLEN 12 /* address mask */ #define ICMP_ADVLENMIN (8 + sizeof (struct ip) + 8) /* min */ #define ICMP_ADVLEN(p) (8 + ((p)->icmp_ip.ip_hl << 2) + 8) @@ -202,7 +206,7 @@ struct icmp { (type) == ICMP_MASKREQ || (type) == ICMP_MASKREPLY) #ifdef _KERNEL -void icmp_error(struct mbuf *, int, int, n_long, int); +void icmp_error(struct mbuf *, int, int, uint32_t, int); void icmp_input(struct mbuf *, int); int ip_next_mtu(int, int); #endif Modified: stable/7/sys/netinet/ip_options.c ============================================================================== --- stable/7/sys/netinet/ip_options.c Fri Feb 13 18:04:55 2009 (r188586) +++ stable/7/sys/netinet/ip_options.c Fri Feb 13 18:09:38 2009 (r188587) @@ -102,7 +102,7 @@ ip_dooptions(struct mbuf *m, int pass) struct in_ifaddr *ia; int opt, optlen, cnt, off, code, type = ICMP_PARAMPROB, forward = 0; struct in_addr *sin, dst; - n_time ntime; + uint32_t ntime; struct sockaddr_in ipaddr = { sizeof(ipaddr), AF_INET }; /* Ignore or reject packets with IP options. */ @@ -317,7 +317,7 @@ dropit: break; case IPOPT_TS_TSANDADDR: - if (off + sizeof(n_time) + + if (off + sizeof(uint32_t) + sizeof(struct in_addr) > optlen) { code = &cp[IPOPT_OFFSET] - (u_char *)ip; goto bad; @@ -334,7 +334,7 @@ dropit: break; case IPOPT_TS_PRESPEC: - if (off + sizeof(n_time) + + if (off + sizeof(uint32_t) + sizeof(struct in_addr) > optlen) { code = &cp[IPOPT_OFFSET] - (u_char *)ip; goto bad; @@ -352,8 +352,8 @@ dropit: goto bad; } ntime = iptime(); - (void)memcpy(cp + off, &ntime, sizeof(n_time)); - cp[IPOPT_OFFSET] += sizeof(n_time); + (void)memcpy(cp + off, &ntime, sizeof(uint32_t)); + cp[IPOPT_OFFSET] += sizeof(uint32_t); } } if (forward && ipforwarding) { Modified: stable/7/sys/netinet/tcp_debug.h ============================================================================== --- stable/7/sys/netinet/tcp_debug.h Fri Feb 13 18:04:55 2009 (r188586) +++ stable/7/sys/netinet/tcp_debug.h Fri Feb 13 18:09:38 2009 (r188587) @@ -34,7 +34,7 @@ #define _NETINET_TCP_DEBUG_H_ struct tcp_debug { - n_time td_time; + uint32_t td_time; /* network format */ short td_act; short td_ostate; caddr_t td_tcb; Modified: stable/7/sys/netinet/tcp_subr.c ============================================================================== --- stable/7/sys/netinet/tcp_subr.c Fri Feb 13 18:04:55 2009 (r188586) +++ stable/7/sys/netinet/tcp_subr.c Fri Feb 13 18:09:38 2009 (r188587) @@ -484,7 +484,7 @@ tcp_respond(struct tcpcb *tp, void *ipge } else #endif /* INET6 */ { - xchg(ip->ip_dst.s_addr, ip->ip_src.s_addr, n_long); + xchg(ip->ip_dst.s_addr, ip->ip_src.s_addr, uint32_t); nth = (struct tcphdr *)(ip + 1); } if (th != nth) { @@ -496,7 +496,7 @@ tcp_respond(struct tcpcb *tp, void *ipge nth->th_sport = th->th_sport; nth->th_dport = th->th_dport; } - xchg(nth->th_dport, nth->th_sport, n_short); + xchg(nth->th_dport, nth->th_sport, uint16_t); #undef xchg } #ifdef INET6 From owner-svn-src-stable@FreeBSD.ORG Fri Feb 13 18:31:35 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id CE8BE106566C; Fri, 13 Feb 2009 18:31:35 +0000 (UTC) (envelope-from luigi@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id A18028FC13; Fri, 13 Feb 2009 18:31:35 +0000 (UTC) (envelope-from luigi@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n1DIVZmL095945; Fri, 13 Feb 2009 18:31:35 GMT (envelope-from luigi@svn.freebsd.org) Received: (from luigi@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n1DIVZpj095941; Fri, 13 Feb 2009 18:31:35 GMT (envelope-from luigi@svn.freebsd.org) Message-Id: <200902131831.n1DIVZpj095941@svn.freebsd.org> From: Luigi Rizzo Date: Fri, 13 Feb 2009 18:31:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r188589 - stable/7/sys/netinet X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 Feb 2009 18:31:36 -0000 Author: luigi Date: Fri Feb 13 18:31:35 2009 New Revision: 188589 URL: http://svn.freebsd.org/changeset/base/188589 Log: remove some unnecessary #include Again, this change is not directly applicable to HEAD due to the presence of vnet.h and vinet.h which bring in almost every network-related header. Modified: stable/7/sys/netinet/ip_dummynet.c stable/7/sys/netinet/ip_fw2.c stable/7/sys/netinet/ip_fw_pfil.c stable/7/sys/netinet/ip_input.c Modified: stable/7/sys/netinet/ip_dummynet.c ============================================================================== --- stable/7/sys/netinet/ip_dummynet.c Fri Feb 13 18:18:14 2009 (r188588) +++ stable/7/sys/netinet/ip_dummynet.c Fri Feb 13 18:31:35 2009 (r188589) @@ -73,7 +73,6 @@ __FBSDID("$FreeBSD$"); #include /* IFNAMSIZ, struct ifaddr, ifq head, lock.h mutex.h */ #include #include -#include /* n_long, SYSCTL_DECL(_net) */ #include /* ip_len, ip_off */ #include #include Modified: stable/7/sys/netinet/ip_fw2.c ============================================================================== --- stable/7/sys/netinet/ip_fw2.c Fri Feb 13 18:18:14 2009 (r188588) +++ stable/7/sys/netinet/ip_fw2.c Fri Feb 13 18:31:35 2009 (r188589) @@ -72,7 +72,6 @@ __FBSDID("$FreeBSD$"); #define IPFW_INTERNAL /* Access to protected data structures in ip_fw.h. */ #include -#include #include #include #include Modified: stable/7/sys/netinet/ip_fw_pfil.c ============================================================================== --- stable/7/sys/netinet/ip_fw_pfil.c Fri Feb 13 18:18:14 2009 (r188588) +++ stable/7/sys/netinet/ip_fw_pfil.c Fri Feb 13 18:31:35 2009 (r188589) @@ -46,15 +46,11 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #include -#include #include #include -#include -#include #include #include #include Modified: stable/7/sys/netinet/ip_input.c ============================================================================== --- stable/7/sys/netinet/ip_input.c Fri Feb 13 18:18:14 2009 (r188588) +++ stable/7/sys/netinet/ip_input.c Fri Feb 13 18:31:35 2009 (r188589) @@ -61,7 +61,6 @@ __FBSDID("$FreeBSD$"); #include #include -#include #include #include #include From owner-svn-src-stable@FreeBSD.ORG Fri Feb 13 18:54:37 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E9923106567A; Fri, 13 Feb 2009 18:54:37 +0000 (UTC) (envelope-from rwatson@FreeBSD.org) Received: from cyrus.watson.org (cyrus.watson.org [65.122.17.42]) by mx1.freebsd.org (Postfix) with ESMTP id 93EC78FC17; Fri, 13 Feb 2009 18:54:37 +0000 (UTC) (envelope-from rwatson@FreeBSD.org) Received: from fledge.watson.org (fledge.watson.org [65.122.17.41]) by cyrus.watson.org (Postfix) with ESMTPS id 465B246B0C; Fri, 13 Feb 2009 13:54:37 -0500 (EST) Date: Fri, 13 Feb 2009 18:54:37 +0000 (GMT) From: Robert Watson X-X-Sender: robert@fledge.watson.org To: Luigi Rizzo In-Reply-To: <200902131809.n1DI9cXb095457@svn.freebsd.org> Message-ID: References: <200902131809.n1DI9cXb095457@svn.freebsd.org> User-Agent: Alpine 2.00 (BSF 1167 2008-08-23) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: svn-src-stable@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, svn-src-stable-7@freebsd.org Subject: Re: svn commit: r188587 - stable/7/sys/netinet X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 Feb 2009 18:54:38 -0000 On Fri, 13 Feb 2009, Luigi Rizzo wrote: > Author: luigi > Date: Fri Feb 13 18:09:38 2009 > New Revision: 188587 > URL: http://svn.freebsd.org/changeset/base/188587 > > Log: > MFC - replace usage of n_* types with uint*_t , to help removing > unnecessary dependencies on in_systm.h As harmless as these changes may seem, insta-MFCs often come with unexpected side effects. A three day MFC wait will also never hurt for what are definitely not critical bug fixes :-). Robert N M Watson Computer Laboratory University of Cambridge > > Modified: > stable/7/sys/netinet/in_systm.h > stable/7/sys/netinet/ip.h > stable/7/sys/netinet/ip_icmp.c > stable/7/sys/netinet/ip_icmp.h > stable/7/sys/netinet/ip_options.c > stable/7/sys/netinet/tcp_debug.h > stable/7/sys/netinet/tcp_subr.c > > Modified: stable/7/sys/netinet/in_systm.h > ============================================================================== > --- stable/7/sys/netinet/in_systm.h Fri Feb 13 18:04:55 2009 (r188586) > +++ stable/7/sys/netinet/in_systm.h Fri Feb 13 18:09:38 2009 (r188587) > @@ -52,7 +52,7 @@ typedef u_int32_t n_long; /* long as re > typedef u_int32_t n_time; /* ms since 00:00 GMT, byte rev */ > > #ifdef _KERNEL > -n_time iptime(void); > +uint32_t iptime(void); > #endif > > #endif > > Modified: stable/7/sys/netinet/ip.h > ============================================================================== > --- stable/7/sys/netinet/ip.h Fri Feb 13 18:04:55 2009 (r188586) > +++ stable/7/sys/netinet/ip.h Fri Feb 13 18:09:38 2009 (r188587) > @@ -159,10 +159,10 @@ struct ip_timestamp { > ipt_flg:4; /* flags, see below */ > #endif > union ipt_timestamp { > - n_long ipt_time[1]; > + uint32_t ipt_time[1]; /* network format */ > struct ipt_ta { > struct in_addr ipt_addr; > - n_long ipt_time; > + uint32_t ipt_time; /* network format */ > } ipt_ta[1]; > } ipt_timestamp; > }; > > Modified: stable/7/sys/netinet/ip_icmp.c > ============================================================================== > --- stable/7/sys/netinet/ip_icmp.c Fri Feb 13 18:04:55 2009 (r188586) > +++ stable/7/sys/netinet/ip_icmp.c Fri Feb 13 18:09:38 2009 (r188587) > @@ -141,7 +141,7 @@ extern struct protosw inetsw[]; > * in response to bad packet ip. > */ > void > -icmp_error(struct mbuf *n, int type, int code, n_long dest, int mtu) > +icmp_error(struct mbuf *n, int type, int code, uint32_t dest, int mtu) > { > register struct ip *oip = mtod(n, struct ip *), *nip; > register unsigned oiphlen = oip->ip_hl << 2; > @@ -825,7 +825,10 @@ icmp_send(struct mbuf *m, struct mbuf *o > (void) ip_output(m, opts, NULL, 0, NULL, NULL); > } > > -n_time > +/* > + * Return milliseconds since 00:00 GMT in network format. > + */ > +uint32_t > iptime(void) > { > struct timeval atv; > > Modified: stable/7/sys/netinet/ip_icmp.h > ============================================================================== > --- stable/7/sys/netinet/ip_icmp.h Fri Feb 13 18:04:55 2009 (r188586) > +++ stable/7/sys/netinet/ip_icmp.h Fri Feb 13 18:09:38 2009 (r188587) > @@ -68,15 +68,15 @@ struct icmp { > u_char ih_pptr; /* ICMP_PARAMPROB */ > struct in_addr ih_gwaddr; /* ICMP_REDIRECT */ > struct ih_idseq { > - n_short icd_id; > - n_short icd_seq; > + uint16_t icd_id; /* network format */ > + uint16_t icd_seq; /* network format */ > } ih_idseq; > int ih_void; > > /* ICMP_UNREACH_NEEDFRAG -- Path MTU Discovery (RFC1191) */ > struct ih_pmtu { > - n_short ipm_void; > - n_short ipm_nextmtu; > + uint16_t ipm_void; /* network format */ > + uint16_t ipm_nextmtu; /* network format */ > } ih_pmtu; > > struct ih_rtradv { > @@ -97,9 +97,13 @@ struct icmp { > #define icmp_lifetime icmp_hun.ih_rtradv.irt_lifetime > union { > struct id_ts { /* ICMP Timestamp */ > - n_time its_otime; /* Originate */ > - n_time its_rtime; /* Receive */ > - n_time its_ttime; /* Transmit */ > + /* > + * The next 3 fields are in network format, > + * milliseconds since 00:00 GMT > + */ > + uint32_t its_otime; /* Originate */ > + uint32_t its_rtime; /* Receive */ > + uint32_t its_ttime; /* Transmit */ > } id_ts; > struct id_ip { > struct ip idi_ip; > @@ -127,7 +131,7 @@ struct icmp { > * ip header length. > */ > #define ICMP_MINLEN 8 /* abs minimum */ > -#define ICMP_TSLEN (8 + 3 * sizeof (n_time)) /* timestamp */ > +#define ICMP_TSLEN (8 + 3 * sizeof (uint32_t)) /* timestamp */ > #define ICMP_MASKLEN 12 /* address mask */ > #define ICMP_ADVLENMIN (8 + sizeof (struct ip) + 8) /* min */ > #define ICMP_ADVLEN(p) (8 + ((p)->icmp_ip.ip_hl << 2) + 8) > @@ -202,7 +206,7 @@ struct icmp { > (type) == ICMP_MASKREQ || (type) == ICMP_MASKREPLY) > > #ifdef _KERNEL > -void icmp_error(struct mbuf *, int, int, n_long, int); > +void icmp_error(struct mbuf *, int, int, uint32_t, int); > void icmp_input(struct mbuf *, int); > int ip_next_mtu(int, int); > #endif > > Modified: stable/7/sys/netinet/ip_options.c > ============================================================================== > --- stable/7/sys/netinet/ip_options.c Fri Feb 13 18:04:55 2009 (r188586) > +++ stable/7/sys/netinet/ip_options.c Fri Feb 13 18:09:38 2009 (r188587) > @@ -102,7 +102,7 @@ ip_dooptions(struct mbuf *m, int pass) > struct in_ifaddr *ia; > int opt, optlen, cnt, off, code, type = ICMP_PARAMPROB, forward = 0; > struct in_addr *sin, dst; > - n_time ntime; > + uint32_t ntime; > struct sockaddr_in ipaddr = { sizeof(ipaddr), AF_INET }; > > /* Ignore or reject packets with IP options. */ > @@ -317,7 +317,7 @@ dropit: > break; > > case IPOPT_TS_TSANDADDR: > - if (off + sizeof(n_time) + > + if (off + sizeof(uint32_t) + > sizeof(struct in_addr) > optlen) { > code = &cp[IPOPT_OFFSET] - (u_char *)ip; > goto bad; > @@ -334,7 +334,7 @@ dropit: > break; > > case IPOPT_TS_PRESPEC: > - if (off + sizeof(n_time) + > + if (off + sizeof(uint32_t) + > sizeof(struct in_addr) > optlen) { > code = &cp[IPOPT_OFFSET] - (u_char *)ip; > goto bad; > @@ -352,8 +352,8 @@ dropit: > goto bad; > } > ntime = iptime(); > - (void)memcpy(cp + off, &ntime, sizeof(n_time)); > - cp[IPOPT_OFFSET] += sizeof(n_time); > + (void)memcpy(cp + off, &ntime, sizeof(uint32_t)); > + cp[IPOPT_OFFSET] += sizeof(uint32_t); > } > } > if (forward && ipforwarding) { > > Modified: stable/7/sys/netinet/tcp_debug.h > ============================================================================== > --- stable/7/sys/netinet/tcp_debug.h Fri Feb 13 18:04:55 2009 (r188586) > +++ stable/7/sys/netinet/tcp_debug.h Fri Feb 13 18:09:38 2009 (r188587) > @@ -34,7 +34,7 @@ > #define _NETINET_TCP_DEBUG_H_ > > struct tcp_debug { > - n_time td_time; > + uint32_t td_time; /* network format */ > short td_act; > short td_ostate; > caddr_t td_tcb; > > Modified: stable/7/sys/netinet/tcp_subr.c > ============================================================================== > --- stable/7/sys/netinet/tcp_subr.c Fri Feb 13 18:04:55 2009 (r188586) > +++ stable/7/sys/netinet/tcp_subr.c Fri Feb 13 18:09:38 2009 (r188587) > @@ -484,7 +484,7 @@ tcp_respond(struct tcpcb *tp, void *ipge > } else > #endif /* INET6 */ > { > - xchg(ip->ip_dst.s_addr, ip->ip_src.s_addr, n_long); > + xchg(ip->ip_dst.s_addr, ip->ip_src.s_addr, uint32_t); > nth = (struct tcphdr *)(ip + 1); > } > if (th != nth) { > @@ -496,7 +496,7 @@ tcp_respond(struct tcpcb *tp, void *ipge > nth->th_sport = th->th_sport; > nth->th_dport = th->th_dport; > } > - xchg(nth->th_dport, nth->th_sport, n_short); > + xchg(nth->th_dport, nth->th_sport, uint16_t); > #undef xchg > } > #ifdef INET6 > From owner-svn-src-stable@FreeBSD.ORG Fri Feb 13 19:16:16 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0D03B106566B; Fri, 13 Feb 2009 19:16:16 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id D43178FC0C; Fri, 13 Feb 2009 19:16:15 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n1DJGFtb096989; Fri, 13 Feb 2009 19:16:15 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n1DJGFtg096988; Fri, 13 Feb 2009 19:16:15 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <200902131916.n1DJGFtg096988@svn.freebsd.org> From: Alexander Motin Date: Fri, 13 Feb 2009 19:16:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r188593 - stable/7/sbin/route X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 Feb 2009 19:16:17 -0000 Author: mav Date: Fri Feb 13 19:16:15 2009 New Revision: 188593 URL: http://svn.freebsd.org/changeset/base/188593 Log: MFC rev. 187384 Fix regression introduced at rev. 173124: 0.0.0.0/1 is not the same as 0.0.0.0/0. Modified: stable/7/sbin/route/ (props changed) stable/7/sbin/route/route.c Modified: stable/7/sbin/route/route.c ============================================================================== --- stable/7/sbin/route/route.c Fri Feb 13 18:51:39 2009 (r188592) +++ stable/7/sbin/route/route.c Fri Feb 13 19:16:15 2009 (r188593) @@ -797,33 +797,34 @@ inet_makenetandmask(net, sin, bits) char *cp; rtm_addrs |= RTA_NETMASK; - if (net == 0) - mask = addr = 0; - else { - if (net <= 0xff) - addr = net << IN_CLASSA_NSHIFT; - else if (net <= 0xffff) - addr = net << IN_CLASSB_NSHIFT; - else if (net <= 0xffffff) - addr = net << IN_CLASSC_NSHIFT; - else - addr = net; + /* + * XXX: This approach unable to handle 0.0.0.1/32 correctly + * as inet_network() converts 0.0.0.1 and 1 equally. + */ + if (net <= 0xff) + addr = net << IN_CLASSA_NSHIFT; + else if (net <= 0xffff) + addr = net << IN_CLASSB_NSHIFT; + else if (net <= 0xffffff) + addr = net << IN_CLASSC_NSHIFT; + else + addr = net; + + if (bits != 0) + mask = 0xffffffff << (32 - bits); + else if (net == 0) + mask = 0; + else if (IN_CLASSA(addr)) + mask = IN_CLASSA_NET; + else if (IN_CLASSB(addr)) + mask = IN_CLASSB_NET; + else if (IN_CLASSC(addr)) + mask = IN_CLASSC_NET; + else if (IN_MULTICAST(addr)) + mask = IN_CLASSD_NET; + else + mask = 0xffffffff; - if (bits != 0) - mask = 0xffffffff << (32 - bits); - else { - if (IN_CLASSA(addr)) - mask = IN_CLASSA_NET; - else if (IN_CLASSB(addr)) - mask = IN_CLASSB_NET; - else if (IN_CLASSC(addr)) - mask = IN_CLASSC_NET; - else if (IN_MULTICAST(addr)) - mask = IN_CLASSD_NET; - else - mask = 0xffffffff; - } - } sin->sin_addr.s_addr = htonl(addr); sin = &so_mask.sin; sin->sin_addr.s_addr = htonl(mask); From owner-svn-src-stable@FreeBSD.ORG Fri Feb 13 19:49:35 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B19D41065674; Fri, 13 Feb 2009 19:49:35 +0000 (UTC) (envelope-from lulf@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 9E8E08FC17; Fri, 13 Feb 2009 19:49:35 +0000 (UTC) (envelope-from lulf@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n1DJnZRQ097706; Fri, 13 Feb 2009 19:49:35 GMT (envelope-from lulf@svn.freebsd.org) Received: (from lulf@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n1DJnZLj097705; Fri, 13 Feb 2009 19:49:35 GMT (envelope-from lulf@svn.freebsd.org) Message-Id: <200902131949.n1DJnZLj097705@svn.freebsd.org> From: Ulf Lilleengen Date: Fri, 13 Feb 2009 19:49:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r188596 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb geom/label X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 Feb 2009 19:49:36 -0000 Author: lulf Date: Fri Feb 13 19:49:35 2009 New Revision: 188596 URL: http://svn.freebsd.org/changeset/base/188596 Log: MFC r188492: - Use the correct argument when determining the buffer size. PR: kern/131575 Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/geom/label/g_label_msdosfs.c Modified: stable/7/sys/geom/label/g_label_msdosfs.c ============================================================================== --- stable/7/sys/geom/label/g_label_msdosfs.c Fri Feb 13 19:25:35 2009 (r188595) +++ stable/7/sys/geom/label/g_label_msdosfs.c Fri Feb 13 19:49:35 2009 (r188596) @@ -186,7 +186,7 @@ g_label_msdosfs_taste(struct g_consumer FAT_DES_ATTR_VOLUME_ID) { strlcpy(label, pfat_entry->DIR_Name, MIN(size, - sizeof(pfat_bsbpb->BS_VolLab) + 1)); + sizeof(pfat_entry->DIR_Name) + 1)); goto endofchecks; } } while((uint8_t *)(++pfat_entry) < From owner-svn-src-stable@FreeBSD.ORG Fri Feb 13 23:04:31 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 01EA71065674; Fri, 13 Feb 2009 23:04:31 +0000 (UTC) (envelope-from luigi@onelab2.iet.unipi.it) Received: from onelab2.iet.unipi.it (onelab2.iet.unipi.it [131.114.9.129]) by mx1.freebsd.org (Postfix) with ESMTP id B71358FC16; Fri, 13 Feb 2009 23:04:30 +0000 (UTC) (envelope-from luigi@onelab2.iet.unipi.it) Received: by onelab2.iet.unipi.it (Postfix, from userid 275) id C29E073098; Fri, 13 Feb 2009 23:54:27 +0100 (CET) Date: Fri, 13 Feb 2009 23:54:27 +0100 From: Luigi Rizzo To: Robert Watson Message-ID: <20090213225427.GA69192@onelab2.iet.unipi.it> References: <200902131809.n1DI9cXb095457@svn.freebsd.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4.2.3i Cc: svn-src-stable@freebsd.org, Luigi Rizzo , src-committers@freebsd.org, svn-src-stable-7@freebsd.org, svn-src-all@freebsd.org Subject: Re: svn commit: r188587 - stable/7/sys/netinet X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 Feb 2009 23:04:31 -0000 On Fri, Feb 13, 2009 at 06:54:37PM +0000, Robert Watson wrote: > > On Fri, 13 Feb 2009, Luigi Rizzo wrote: > > >Author: luigi > >Date: Fri Feb 13 18:09:38 2009 > >New Revision: 188587 > >URL: http://svn.freebsd.org/changeset/base/188587 > > > >Log: > > MFC - replace usage of n_* types with uint*_t , to help removing > > unnecessary dependencies on in_systm.h > > As harmless as these changes may seem, insta-MFCs often come with > unexpected side effects. A three day MFC wait will also never hurt for > what are definitely not critical bug fixes :-). To put this commit in the right context: I know the recommendation on MFC. But this is actually not an MFC but an MFStable as I will explain below. I started this work to remove useless header dependencies from ipfw and dummynet (and, as a side effect, the network stack as well). You may have seen userland changes being committed 1-2 weeks ago, in that case only in HEAD because that's was the appropriate approach in that context. But the kernel side is different. As I mentioned in some other commits today, HEAD and RELENG_7 are largely different in this respect after the VIMAGE import: in HEAD, several netinet/ files #include vnet.h and vinet.h which in turn bring in almost everything related to networking: if.h, route.h, <*_var.h> for the stats records, locks and so on. As a result, the cleanup work needs to be done differently in the two branches. In fact, the real reference is RELENG_7 which is clean from nested #include's: it's there that I can find out which headers are not necessary, and then I use the information to drive the changes to HEAD keeping in mind that eventually vinet.h should be cleaned up as well. That's why I say that these changes are closer to Merge >From Stable than to MFC. The n_* cleanup just happens to be part of both changesets, but that's only a minor part. cheers luigi From owner-svn-src-stable@FreeBSD.ORG Sat Feb 14 20:42:54 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9E1431065675; Sat, 14 Feb 2009 20:42:54 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 817D48FC14; Sat, 14 Feb 2009 20:42:54 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n1EKgsYr029817; Sat, 14 Feb 2009 20:42:54 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n1EKgsDR029815; Sat, 14 Feb 2009 20:42:54 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <200902142042.n1EKgsDR029815@svn.freebsd.org> From: Konstantin Belousov Date: Sat, 14 Feb 2009 20:42:54 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r188610 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb kern sys X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Feb 2009 20:42:55 -0000 Author: kib Date: Sat Feb 14 20:42:54 2009 New Revision: 188610 URL: http://svn.freebsd.org/changeset/base/188610 Log: MFC r182364: Introduce the VV_FORCEINSMQ vnode flag. It instructs the insmnque() function to ignore the unmounting and forces insertion of the vnode into the mount vnode list. Change insmntque() to fail when forced unmount is in progress and VV_FORCEINSMQ is not specified. Add an assertion to the insmntque(), requiring the vnode to be exclusively locked for mp-safe filesystems. MFC note: because zfs in stable/7 does not follow the insmntque() protocol, the assertion is commented out. Use the VV_FORCEINSMQ for the creation of the syncvnode. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/kern/vfs_subr.c stable/7/sys/sys/vnode.h Modified: stable/7/sys/kern/vfs_subr.c ============================================================================== --- stable/7/sys/kern/vfs_subr.c Sat Feb 14 19:46:28 2009 (r188609) +++ stable/7/sys/kern/vfs_subr.c Sat Feb 14 20:42:54 2009 (r188610) @@ -1007,17 +1007,30 @@ int insmntque1(struct vnode *vp, struct mount *mp, void (*dtr)(struct vnode *, void *), void *dtr_arg) { + int locked; KASSERT(vp->v_mount == NULL, ("insmntque: vnode already on per mount vnode list")); VNASSERT(mp != NULL, vp, ("Don't call insmntque(foo, NULL)")); +#if 0 +#ifdef DEBUG_VFS_LOCKS + if (!VFS_NEEDSGIANT(mp)) + ASSERT_VOP_ELOCKED(vp, + "insmntque: mp-safe fs and non-locked vp"); +#endif +#endif MNT_ILOCK(mp); if ((mp->mnt_kern_flag & MNTK_NOINSMNTQ) != 0 && - mp->mnt_nvnodelistsize == 0) { - MNT_IUNLOCK(mp); - if (dtr != NULL) - dtr(vp, dtr_arg); - return (EBUSY); + ((mp->mnt_kern_flag & MNTK_UNMOUNTF) != 0 || + mp->mnt_nvnodelistsize == 0)) { + locked = VOP_ISLOCKED(vp, curthread); + if (!locked || (locked == LK_EXCLUSIVE && + (vp->v_vflag & VV_FORCEINSMQ) == 0)) { + MNT_IUNLOCK(mp); + if (dtr != NULL) + dtr(vp, dtr_arg); + return (EBUSY); + } } vp->v_mount = mp; MNT_REF(mp); @@ -3140,9 +3153,13 @@ vfs_allocate_syncvnode(struct mount *mp) return (error); } vp->v_type = VNON; + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, curthread); + vp->v_vflag |= VV_FORCEINSMQ; error = insmntque(vp, mp); if (error != 0) panic("vfs_allocate_syncvnode: insmntque failed"); + vp->v_vflag &= ~VV_FORCEINSMQ; + VOP_UNLOCK(vp, 0, curthread); /* * Place the vnode onto the syncer worklist. We attempt to * scatter them about on the list so that they will go off Modified: stable/7/sys/sys/vnode.h ============================================================================== --- stable/7/sys/sys/vnode.h Sat Feb 14 19:46:28 2009 (r188609) +++ stable/7/sys/sys/vnode.h Sat Feb 14 20:42:54 2009 (r188610) @@ -251,6 +251,7 @@ struct xvnode { #define VV_NOKNOTE 0x0200 /* don't activate knotes on this vnode */ #define VV_DELETED 0x0400 /* should be removed */ #define VV_MD 0x0800 /* vnode backs the md device */ +#define VV_FORCEINSMQ 0x1000 /* force the insmntque to succeed */ /* * Vnode attributes. A field value of VNOVAL represents a field whose value From owner-svn-src-stable@FreeBSD.ORG Sat Feb 14 20:59:50 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E4B9E10656CC; Sat, 14 Feb 2009 20:59:50 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id CFEDB8FC0C; Sat, 14 Feb 2009 20:59:50 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n1EKxovr030149; Sat, 14 Feb 2009 20:59:50 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n1EKxo5F030146; Sat, 14 Feb 2009 20:59:50 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <200902142059.n1EKxo5F030146@svn.freebsd.org> From: Konstantin Belousov Date: Sat, 14 Feb 2009 20:59:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r188611 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb ufs/ffs X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Feb 2009 20:59:52 -0000 Author: kib Date: Sat Feb 14 20:59:50 2009 New Revision: 188611 URL: http://svn.freebsd.org/changeset/base/188611 Log: MFC r182365: Softdep code may need to instantiate vnode when processing dependencies. In particular, it may need this while syncing filesystem being unmounted. Since during unmount MNTK_NOINSMNTQUE flag is set, that could sometimes disallow insertion of the vnode into the vnode mount list, softdep code needs to overwrite the MNTK_NOINSMNTQUE flag. Create the ffs_vgetf() function that sets the VV_FORCEINSMQ flag for new vnode and use it consistently from the softdep code instead of ffs_vget(). Add the retry logic to the softdep_flushfiles() to flush the vnodes that could be instantiated while flushing softdep dependencies. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/ufs/ffs/ffs_extern.h stable/7/sys/ufs/ffs/ffs_softdep.c stable/7/sys/ufs/ffs/ffs_vfsops.c Modified: stable/7/sys/ufs/ffs/ffs_extern.h ============================================================================== --- stable/7/sys/ufs/ffs/ffs_extern.h Sat Feb 14 20:42:54 2009 (r188610) +++ stable/7/sys/ufs/ffs/ffs_extern.h Sat Feb 14 20:59:50 2009 (r188611) @@ -87,6 +87,9 @@ int ffs_valloc(struct vnode *, int, stru int ffs_vfree(struct vnode *, ino_t, int); vfs_vget_t ffs_vget; +int ffs_vgetf(struct mount *, ino_t, int, struct vnode **, int); + +#define FFSV_FORCEINSMQ 0x0001 extern struct vop_vector ffs_vnodeops1; extern struct vop_vector ffs_fifoops1; Modified: stable/7/sys/ufs/ffs/ffs_softdep.c ============================================================================== --- stable/7/sys/ufs/ffs/ffs_softdep.c Sat Feb 14 20:42:54 2009 (r188610) +++ stable/7/sys/ufs/ffs/ffs_softdep.c Sat Feb 14 20:59:50 2009 (r188611) @@ -921,8 +921,8 @@ process_worklist_item(mp, flags) wk->wk_state |= INPROGRESS; ump->softdep_on_worklist_inprogress++; FREE_LOCK(&lk); - ffs_vget(mp, WK_DIRREM(wk)->dm_oldinum, - LK_NOWAIT | LK_EXCLUSIVE, &vp); + ffs_vgetf(mp, WK_DIRREM(wk)->dm_oldinum, + LK_NOWAIT | LK_EXCLUSIVE, &vp, FFSV_FORCEINSMQ); ACQUIRE_LOCK(&lk); wk->wk_state &= ~INPROGRESS; ump->softdep_on_worklist_inprogress--; @@ -1076,8 +1076,11 @@ softdep_flushfiles(oldmnt, flags, td) int flags; struct thread *td; { - int error, count, loopcnt; + int error, depcount, loopcnt, retry_flush_count, retry; + loopcnt = 10; + retry_flush_count = 3; +retry_flush: error = 0; /* @@ -1086,15 +1089,15 @@ softdep_flushfiles(oldmnt, flags, td) * creates. In theory, this loop can happen at most twice, * but we give it a few extra just to be sure. */ - for (loopcnt = 10; loopcnt > 0; loopcnt--) { + for (; loopcnt > 0; loopcnt--) { /* * Do another flush in case any vnodes were brought in * as part of the cleanup operations. */ if ((error = ffs_flushfiles(oldmnt, flags, td)) != 0) break; - if ((error = softdep_flushworklist(oldmnt, &count, td)) != 0 || - count == 0) + if ((error = softdep_flushworklist(oldmnt, &depcount, td)) != 0 || + depcount == 0) break; } /* @@ -1109,6 +1112,24 @@ softdep_flushfiles(oldmnt, flags, td) } if (!error) error = softdep_waitidle(oldmnt); + if (!error) { + if (oldmnt->mnt_kern_flag & MNTK_UNMOUNT) { + retry = 0; + MNT_ILOCK(oldmnt); + KASSERT((oldmnt->mnt_kern_flag & MNTK_NOINSMNTQ) != 0, + ("softdep_flushfiles: !MNTK_NOINSMNTQ")); + if (oldmnt->mnt_nvnodelistsize > 0) { + if (--retry_flush_count > 0) { + retry = 1; + loopcnt = 3; + } else + error = EBUSY; + } + MNT_IUNLOCK(oldmnt); + if (retry) + goto retry_flush; + } + } return (error); } @@ -2777,8 +2798,9 @@ handle_workitem_freeblocks(freeblks, fla */ if (freeblks->fb_chkcnt != blocksreleased && (fs->fs_flags & FS_UNCLEAN) != 0 && - ffs_vget(freeblks->fb_list.wk_mp, freeblks->fb_previousinum, - (flags & LK_NOWAIT) | LK_EXCLUSIVE, &vp) == 0) { + ffs_vgetf(freeblks->fb_list.wk_mp, freeblks->fb_previousinum, + (flags & LK_NOWAIT) | LK_EXCLUSIVE, &vp, FFSV_FORCEINSMQ) + == 0) { ip = VTOI(vp); DIP_SET(ip, i_blocks, DIP(ip, i_blocks) + \ freeblks->fb_chkcnt - blocksreleased); @@ -3565,8 +3587,8 @@ handle_workitem_remove(dirrem, xp) int error; if ((vp = xp) == NULL && - (error = ffs_vget(dirrem->dm_list.wk_mp, - dirrem->dm_oldinum, LK_EXCLUSIVE, &vp)) != 0) { + (error = ffs_vgetf(dirrem->dm_list.wk_mp, + dirrem->dm_oldinum, LK_EXCLUSIVE, &vp, FFSV_FORCEINSMQ)) != 0) { softdep_error("handle_workitem_remove: vget", error); return; } @@ -5081,9 +5103,11 @@ softdep_fsync(vp) * for details on possible races. */ FREE_LOCK(&lk); - if (ffs_vget(mp, parentino, LK_NOWAIT | LK_EXCLUSIVE, &pvp)) { + if (ffs_vgetf(mp, parentino, LK_NOWAIT | LK_EXCLUSIVE, &pvp, + FFSV_FORCEINSMQ)) { VOP_UNLOCK(vp, 0, td); - error = ffs_vget(mp, parentino, LK_EXCLUSIVE, &pvp); + error = ffs_vgetf(mp, parentino, LK_EXCLUSIVE, + &pvp, FFSV_FORCEINSMQ); vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); if (error != 0) return (error); @@ -5583,7 +5607,8 @@ flush_pagedep_deps(pvp, mp, diraddhdp) inum = dap->da_newinum; if (dap->da_state & MKDIR_BODY) { FREE_LOCK(&lk); - if ((error = ffs_vget(mp, inum, LK_EXCLUSIVE, &vp))) + if ((error = ffs_vgetf(mp, inum, LK_EXCLUSIVE, &vp, + FFSV_FORCEINSMQ))) break; if ((error=ffs_syncvnode(vp, MNT_NOWAIT)) || (error=ffs_syncvnode(vp, MNT_NOWAIT))) { @@ -5921,7 +5946,8 @@ clear_remove(td) if (vn_start_write(NULL, &mp, V_NOWAIT) != 0) continue; FREE_LOCK(&lk); - if ((error = ffs_vget(mp, ino, LK_EXCLUSIVE, &vp))) { + if ((error = ffs_vgetf(mp, ino, LK_EXCLUSIVE, &vp, + FFSV_FORCEINSMQ))) { softdep_error("clear_remove: vget", error); vn_finished_write(mp); ACQUIRE_LOCK(&lk); @@ -5992,7 +6018,8 @@ clear_inodedeps(td) if (vn_start_write(NULL, &mp, V_NOWAIT) != 0) continue; FREE_LOCK(&lk); - if ((error = ffs_vget(mp, ino, LK_EXCLUSIVE, &vp)) != 0) { + if ((error = ffs_vgetf(mp, ino, LK_EXCLUSIVE, &vp, + FFSV_FORCEINSMQ)) != 0) { softdep_error("clear_inodedeps: vget", error); vn_finished_write(mp); ACQUIRE_LOCK(&lk); Modified: stable/7/sys/ufs/ffs/ffs_vfsops.c ============================================================================== --- stable/7/sys/ufs/ffs/ffs_vfsops.c Sat Feb 14 20:42:54 2009 (r188610) +++ stable/7/sys/ufs/ffs/ffs_vfsops.c Sat Feb 14 20:59:50 2009 (r188611) @@ -1295,6 +1295,17 @@ ffs_vget(mp, ino, flags, vpp) int flags; struct vnode **vpp; { + return (ffs_vgetf(mp, ino, flags, vpp, 0)); +} + +int +ffs_vgetf(mp, ino, flags, vpp, ffs_flags) + struct mount *mp; + ino_t ino; + int flags; + struct vnode **vpp; + int ffs_flags; +{ struct fs *fs; struct inode *ip; struct ufsmount *ump; @@ -1369,13 +1380,16 @@ ffs_vget(mp, ino, flags, vpp) td = curthread; lockmgr(vp->v_vnlock, LK_EXCLUSIVE, NULL, td); + if (ffs_flags & FFSV_FORCEINSMQ) + vp->v_vflag |= VV_FORCEINSMQ; error = insmntque(vp, mp); if (error != 0) { uma_zfree(uma_inode, ip); *vpp = NULL; return (error); } - error = vfs_hash_insert(vp, ino, flags, td, vpp, NULL, NULL); + vp->v_vflag &= ~VV_FORCEINSMQ; + error = vfs_hash_insert(vp, ino, flags, curthread, vpp, NULL, NULL); if (error || *vpp != NULL) return (error); From owner-svn-src-stable@FreeBSD.ORG Sat Feb 14 21:08:42 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6A043106564A; Sat, 14 Feb 2009 21:08:42 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 56DC18FC08; Sat, 14 Feb 2009 21:08:42 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n1EL8gs8030350; Sat, 14 Feb 2009 21:08:42 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n1EL8gQT030349; Sat, 14 Feb 2009 21:08:42 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <200902142108.n1EL8gQT030349@svn.freebsd.org> From: Konstantin Belousov Date: Sat, 14 Feb 2009 21:08:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r188612 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb ufs/ffs X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Feb 2009 21:08:43 -0000 Author: kib Date: Sat Feb 14 21:08:40 2009 New Revision: 188612 URL: http://svn.freebsd.org/changeset/base/188612 Log: MFC r182366: In ffs_valloc(), ffs_vget() may fail because insmntque() refused to insert new vnode into the mount vnode list. Then, for the SU-enabled mount, ffs_vfree could create freefile dependency. This dependency can hang around forever since inode is not marked as IN_MODIFIED and correspondingly inodeblock may be not marked as dirty. After ffs_vget() fails, retry with FFSV_FORCEINSMQ, mark the inode as modified, and vput() it immediately. Take care of the dup alloc. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/ufs/ffs/ffs_alloc.c Modified: stable/7/sys/ufs/ffs/ffs_alloc.c ============================================================================== --- stable/7/sys/ufs/ffs/ffs_alloc.c Sat Feb 14 20:59:50 2009 (r188611) +++ stable/7/sys/ufs/ffs/ffs_alloc.c Sat Feb 14 21:08:40 2009 (r188612) @@ -930,7 +930,7 @@ ffs_valloc(pvp, mode, cred, vpp) struct timespec ts; struct ufsmount *ump; ino_t ino, ipref; - int cg, error; + int cg, error, error1; static struct timeval lastfail; static int curfail; @@ -967,11 +967,21 @@ ffs_valloc(pvp, mode, cred, vpp) goto noinodes; error = ffs_vget(pvp->v_mount, ino, LK_EXCLUSIVE, vpp); if (error) { + error1 = ffs_vgetf(pvp->v_mount, ino, LK_EXCLUSIVE, vpp, + FFSV_FORCEINSMQ); ffs_vfree(pvp, ino, mode); + if (error1 == 0) { + ip = VTOI(*vpp); + if (ip->i_mode) + goto dup_alloc; + ip->i_flag |= IN_MODIFIED; + vput(*vpp); + } return (error); } ip = VTOI(*vpp); if (ip->i_mode) { +dup_alloc: printf("mode = 0%o, inum = %lu, fs = %s\n", ip->i_mode, (u_long)ip->i_number, fs->fs_fsmnt); panic("ffs_valloc: dup alloc"); From owner-svn-src-stable@FreeBSD.ORG Sat Feb 14 21:12:59 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7E05A106564A; Sat, 14 Feb 2009 21:12:59 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 6A7AD8FC20; Sat, 14 Feb 2009 21:12:59 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n1ELCxvY030524; Sat, 14 Feb 2009 21:12:59 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n1ELCx2H030518; Sat, 14 Feb 2009 21:12:59 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <200902142112.n1ELCx2H030518@svn.freebsd.org> From: Konstantin Belousov Date: Sat, 14 Feb 2009 21:12:59 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r188614 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb ufs/ffs ufs/ufs X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Feb 2009 21:13:00 -0000 Author: kib Date: Sat Feb 14 21:12:58 2009 New Revision: 188614 URL: http://svn.freebsd.org/changeset/base/188614 Log: MFC r183070: When downgrading the read-write mount to read-only, do_unmount() sets MNT_RDONLY flag before the VFS_MOUNT() is called. In ufs_inactive() and ufs_itimes_locked(), UFS verifies whether the fs is read-only by checking MNT_RDONLY, but this may cause loss of the IN_MODIFIED flag for inode on the fs being remounted rw->ro. Introduce UFS_RDONLY() struct ufsmount' method that reports the value of the fs_ronly. The later is set to 1 only after the remount is finished. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/ufs/ffs/ffs_extern.h stable/7/sys/ufs/ffs/ffs_inode.c stable/7/sys/ufs/ffs/ffs_vfsops.c stable/7/sys/ufs/ufs/ufs_inode.c stable/7/sys/ufs/ufs/ufs_vnops.c stable/7/sys/ufs/ufs/ufsmount.h Modified: stable/7/sys/ufs/ffs/ffs_extern.h ============================================================================== --- stable/7/sys/ufs/ffs/ffs_extern.h Sat Feb 14 21:12:24 2009 (r188613) +++ stable/7/sys/ufs/ffs/ffs_extern.h Sat Feb 14 21:12:58 2009 (r188614) @@ -131,4 +131,6 @@ int softdep_process_worklist(struct int softdep_fsync(struct vnode *); int softdep_waitidle(struct mount *); +int ffs_rdonly(struct inode *); + #endif /* !_UFS_FFS_EXTERN_H */ Modified: stable/7/sys/ufs/ffs/ffs_inode.c ============================================================================== --- stable/7/sys/ufs/ffs/ffs_inode.c Sat Feb 14 21:12:24 2009 (r188613) +++ stable/7/sys/ufs/ffs/ffs_inode.c Sat Feb 14 21:12:58 2009 (r188614) @@ -665,3 +665,11 @@ ffs_indirtrunc(ip, lbn, dbn, lastbn, lev *countp = blocksreleased; return (allerror); } + +int +ffs_rdonly(struct inode *ip) +{ + + return (ip->i_ump->um_fs->fs_ronly != 0); +} + Modified: stable/7/sys/ufs/ffs/ffs_vfsops.c ============================================================================== --- stable/7/sys/ufs/ffs/ffs_vfsops.c Sat Feb 14 21:12:24 2009 (r188613) +++ stable/7/sys/ufs/ffs/ffs_vfsops.c Sat Feb 14 21:12:58 2009 (r188614) @@ -734,6 +734,7 @@ ffs_mountfs(devvp, mp, td) ump->um_valloc = ffs_valloc; ump->um_vfree = ffs_vfree; ump->um_ifree = ffs_ifree; + ump->um_rdonly = ffs_rdonly; mtx_init(UFS_MTX(ump), "FFS", "FFS Lock", MTX_DEF); bcopy(bp->b_data, ump->um_fs, (u_int)fs->fs_sbsize); if (fs->fs_sbsize < SBLOCKSIZE) Modified: stable/7/sys/ufs/ufs/ufs_inode.c ============================================================================== --- stable/7/sys/ufs/ufs/ufs_inode.c Sat Feb 14 21:12:24 2009 (r188613) +++ stable/7/sys/ufs/ufs/ufs_inode.c Sat Feb 14 21:12:58 2009 (r188614) @@ -90,8 +90,7 @@ ufs_inactive(ap) ufs_gjournal_close(vp); #endif if ((ip->i_effnlink == 0 && DOINGSOFTDEP(vp)) || - (ip->i_nlink <= 0 && - (vp->v_mount->mnt_flag & MNT_RDONLY) == 0)) { + (ip->i_nlink <= 0 && !UFS_RDONLY(ip))) { loop: if (vn_start_secondary_write(vp, &mp, V_NOWAIT) != 0) { /* Cannot delete file while file system is suspended */ @@ -121,7 +120,7 @@ ufs_inactive(ap) } if (ip->i_effnlink == 0 && DOINGSOFTDEP(vp)) softdep_releasefile(ip); - if (ip->i_nlink <= 0 && (vp->v_mount->mnt_flag & MNT_RDONLY) == 0) { + if (ip->i_nlink <= 0 && !UFS_RDONLY(ip)) { #ifdef QUOTA if (!getinoquota(ip)) (void)chkiq(ip, -1, NOCRED, FORCE); Modified: stable/7/sys/ufs/ufs/ufs_vnops.c ============================================================================== --- stable/7/sys/ufs/ufs/ufs_vnops.c Sat Feb 14 21:12:24 2009 (r188613) +++ stable/7/sys/ufs/ufs/ufs_vnops.c Sat Feb 14 21:12:58 2009 (r188614) @@ -135,7 +135,7 @@ ufs_itimes_locked(struct vnode *vp) ASSERT_VI_LOCKED(vp, __func__); ip = VTOI(vp); - if ((vp->v_mount->mnt_flag & MNT_RDONLY) != 0) + if (UFS_RDONLY(ip)) goto out; if ((ip->i_flag & (IN_ACCESS | IN_CHANGE | IN_UPDATE)) == 0) return; Modified: stable/7/sys/ufs/ufs/ufsmount.h ============================================================================== --- stable/7/sys/ufs/ufs/ufsmount.h Sat Feb 14 21:12:24 2009 (r188613) +++ stable/7/sys/ufs/ufs/ufsmount.h Sat Feb 14 21:12:58 2009 (r188614) @@ -93,6 +93,7 @@ struct ufsmount { int (*um_valloc)(struct vnode *, int, struct ucred *, struct vnode **); int (*um_vfree)(struct vnode *, ino_t, int); void (*um_ifree)(struct ufsmount *, struct inode *); + int (*um_rdonly)(struct inode *); }; #define UFS_BALLOC(aa, bb, cc, dd, ee, ff) VFSTOUFS((aa)->v_mount)->um_balloc(aa, bb, cc, dd, ee, ff) @@ -102,6 +103,7 @@ struct ufsmount { #define UFS_VALLOC(aa, bb, cc, dd) VFSTOUFS((aa)->v_mount)->um_valloc(aa, bb, cc, dd) #define UFS_VFREE(aa, bb, cc) VFSTOUFS((aa)->v_mount)->um_vfree(aa, bb, cc) #define UFS_IFREE(aa, bb) ((aa)->um_ifree(aa, bb)) +#define UFS_RDONLY(aa) ((aa)->i_ump->um_rdonly(aa)) #define UFS_LOCK(aa) mtx_lock(&(aa)->um_lock) #define UFS_UNLOCK(aa) mtx_unlock(&(aa)->um_lock) From owner-svn-src-stable@FreeBSD.ORG Sat Feb 14 22:24:05 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E09AF1065678; Sat, 14 Feb 2009 22:24:04 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id C52258FC17; Sat, 14 Feb 2009 22:24:04 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n1EMO4Fq031960; Sat, 14 Feb 2009 22:24:04 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n1EMO4j9031957; Sat, 14 Feb 2009 22:24:04 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <200902142224.n1EMO4j9031957@svn.freebsd.org> From: Konstantin Belousov Date: Sat, 14 Feb 2009 22:24:04 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r188618 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb kern ufs/ffs X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Feb 2009 22:24:05 -0000 Author: kib Date: Sat Feb 14 22:24:04 2009 New Revision: 188618 URL: http://svn.freebsd.org/changeset/base/188618 Log: MFC r183072: Add the ffs structures introspection functions for ddb. Show the b_dep value for the buffer in the show buffer command. Add a comand to dump the dirty/clean buffer list for vnode. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/kern/vfs_bio.c stable/7/sys/ufs/ffs/ffs_softdep.c stable/7/sys/ufs/ffs/ffs_vfsops.c Modified: stable/7/sys/kern/vfs_bio.c ============================================================================== --- stable/7/sys/kern/vfs_bio.c Sat Feb 14 22:07:22 2009 (r188617) +++ stable/7/sys/kern/vfs_bio.c Sat Feb 14 22:24:04 2009 (r188618) @@ -3920,9 +3920,10 @@ DB_SHOW_COMMAND(buffer, db_show_buffer) db_printf("b_flags = 0x%b\n", (u_int)bp->b_flags, PRINT_BUF_FLAGS); db_printf( "b_error = %d, b_bufsize = %ld, b_bcount = %ld, b_resid = %ld\n" - "b_bufobj = (%p), b_data = %p, b_blkno = %jd\n", + "b_bufobj = (%p), b_data = %p, b_blkno = %jd, b_dep = %p\n", bp->b_error, bp->b_bufsize, bp->b_bcount, bp->b_resid, - bp->b_bufobj, bp->b_data, (intmax_t)bp->b_blkno); + bp->b_bufobj, bp->b_data, (intmax_t)bp->b_blkno, + bp->b_dep.lh_first); if (bp->b_npages) { int i; db_printf("b_npages = %d, pages(OBJ, IDX, PA): ", bp->b_npages); @@ -3952,4 +3953,26 @@ DB_SHOW_COMMAND(lockedbufs, lockedbufs) } } } + +DB_SHOW_COMMAND(vnodebufs, db_show_vnodebufs) +{ + struct vnode *vp; + struct buf *bp; + + if (!have_addr) { + db_printf("usage: show vnodebufs \n"); + return; + } + vp = (struct vnode *)addr; + db_printf("Clean buffers:\n"); + TAILQ_FOREACH(bp, &vp->v_bufobj.bo_clean.bv_hd, b_bobufs) { + db_show_buffer((uintptr_t)bp, 1, 0, NULL); + db_printf("\n"); + } + db_printf("Dirty buffers:\n"); + TAILQ_FOREACH(bp, &vp->v_bufobj.bo_dirty.bv_hd, b_bobufs) { + db_show_buffer((uintptr_t)bp, 1, 0, NULL); + db_printf("\n"); + } +} #endif /* DDB */ Modified: stable/7/sys/ufs/ffs/ffs_softdep.c ============================================================================== --- stable/7/sys/ufs/ffs/ffs_softdep.c Sat Feb 14 22:07:22 2009 (r188617) +++ stable/7/sys/ufs/ffs/ffs_softdep.c Sat Feb 14 22:24:04 2009 (r188618) @@ -41,6 +41,9 @@ #include __FBSDID("$FreeBSD$"); +#include "opt_ffs.h" +#include "opt_ddb.h" + /* * For now we want the safety net that DEBUG flags provide. */ @@ -77,7 +80,7 @@ __FBSDID("$FreeBSD$"); #include -#include "opt_ffs.h" +#include #include "opt_quota.h" #ifndef SOFTUPDATES @@ -6336,4 +6339,30 @@ softdep_error(func, error) printf("%s: got error %d while accessing filesystem\n", func, error); } +#ifdef DDB + +DB_SHOW_COMMAND(inodedeps, db_show_inodedeps) +{ + struct inodedep_hashhead *inodedephd; + struct inodedep *inodedep; + struct fs *fs; + int cnt; + + fs = have_addr ? (struct fs *)addr : NULL; + for (cnt = 0; cnt < inodedep_hash; cnt++) { + inodedephd = &inodedep_hashtbl[cnt]; + LIST_FOREACH(inodedep, inodedephd, id_hash) { + if (fs != NULL && fs != inodedep->id_fs) + continue; + db_printf("%p fs %p st %x ino %jd inoblk %jd\n", + inodedep, inodedep->id_fs, inodedep->id_state, + (intmax_t)inodedep->id_ino, + (intmax_t)fsbtodb(inodedep->id_fs, + ino_to_fsba(inodedep->id_fs, inodedep->id_ino))); + } + } +} + +#endif /* DDB */ + #endif /* SOFTUPDATES */ Modified: stable/7/sys/ufs/ffs/ffs_vfsops.c ============================================================================== --- stable/7/sys/ufs/ffs/ffs_vfsops.c Sat Feb 14 22:07:22 2009 (r188617) +++ stable/7/sys/ufs/ffs/ffs_vfsops.c Sat Feb 14 22:24:04 2009 (r188618) @@ -36,6 +36,7 @@ __FBSDID("$FreeBSD$"); #include "opt_quota.h" #include "opt_ufs.h" #include "opt_ffs.h" +#include "opt_ddb.h" #include #include @@ -71,6 +72,8 @@ __FBSDID("$FreeBSD$"); #include #include +#include + static uma_zone_t uma_inode, uma_ufs1, uma_ufs2; static int ffs_reload(struct mount *, struct thread *); @@ -1864,3 +1867,35 @@ ffs_geom_strategy(struct bufobj *bo, str } g_vfs_strategy(bo, bp); } + +#ifdef DDB + +static void +db_print_ffs(struct ufsmount *ump) +{ + db_printf("mp %p %s devvp %p fs %p su_wl %d su_wl_in %d su_deps %d " + "su_req %d\n", + ump->um_mountp, ump->um_mountp->mnt_stat.f_mntonname, + ump->um_devvp, ump->um_fs, ump->softdep_on_worklist, + ump->softdep_on_worklist_inprogress, ump->softdep_deps, + ump->softdep_req); +} + +DB_SHOW_COMMAND(ffs, db_show_ffs) +{ + struct mount *mp; + struct ufsmount *ump; + + if (have_addr) { + ump = VFSTOUFS((struct mount *)addr); + db_print_ffs(ump); + return; + } + + TAILQ_FOREACH(mp, &mountlist, mnt_list) { + if (!strcmp(mp->mnt_stat.f_fstypename, ufs_vfsconf.vfc_name)) + db_print_ffs(VFSTOUFS(mp)); + } +} + +#endif /* DDB */ From owner-svn-src-stable@FreeBSD.ORG Sat Feb 14 23:02:21 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9B21A106566C; Sat, 14 Feb 2009 23:02:21 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 870D88FC08; Sat, 14 Feb 2009 23:02:21 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n1EN2LQ8032793; Sat, 14 Feb 2009 23:02:21 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n1EN2LPM032787; Sat, 14 Feb 2009 23:02:21 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <200902142302.n1EN2LPM032787@svn.freebsd.org> From: Konstantin Belousov Date: Sat, 14 Feb 2009 23:02:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r188620 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb kern sys ufs/ffs X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Feb 2009 23:02:22 -0000 Author: kib Date: Sat Feb 14 23:02:21 2009 New Revision: 188620 URL: http://svn.freebsd.org/changeset/base/188620 Log: MFC r183073: When attempt is made to suspend a filesystem that is already syspended, wait until the current suspension is lifted instead of silently returning success immediately. The consequences of calling vfs_write() resume when not owning the suspension are not well-defined at best. Add the vfs_susp_clean() mount method to be called from vfs_write_resume(). Set it to process_deferred_inactive() for ffs, and stop calling it manually. Add the thread flag TDP_IGNSUSP that allows to bypass the suspension point in the vn_start_write. It is intended for use by VFS in the situations where the suspender want to do some i/o requiring calls to vn_start_write(), and this i/o cannot be done later. Note that addition of the mount method and new struct mount field change the KBI. This was approved by re and no objections on stable@ were raised. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/kern/vfs_vnops.c stable/7/sys/sys/mount.h stable/7/sys/sys/proc.h stable/7/sys/ufs/ffs/ffs_extern.h stable/7/sys/ufs/ffs/ffs_snapshot.c stable/7/sys/ufs/ffs/ffs_vfsops.c Modified: stable/7/sys/kern/vfs_vnops.c ============================================================================== --- stable/7/sys/kern/vfs_vnops.c Sat Feb 14 22:29:54 2009 (r188619) +++ stable/7/sys/kern/vfs_vnops.c Sat Feb 14 23:02:21 2009 (r188620) @@ -916,15 +916,18 @@ vn_start_write(vp, mpp, flags) /* * Check on status of suspension. */ - while ((mp->mnt_kern_flag & MNTK_SUSPEND) != 0) { - if (flags & V_NOWAIT) { - error = EWOULDBLOCK; - goto unlock; + if ((curthread->td_pflags & TDP_IGNSUSP) == 0 || + mp->mnt_susp_owner != curthread) { + while ((mp->mnt_kern_flag & MNTK_SUSPEND) != 0) { + if (flags & V_NOWAIT) { + error = EWOULDBLOCK; + goto unlock; + } + error = msleep(&mp->mnt_flag, MNT_MTX(mp), + (PUSER - 1) | (flags & PCATCH), "suspfs", 0); + if (error) + goto unlock; } - error = msleep(&mp->mnt_flag, MNT_MTX(mp), - (PUSER - 1) | (flags & PCATCH), "suspfs", 0); - if (error) - goto unlock; } if (flags & V_XSLEEP) goto unlock; @@ -1048,11 +1051,14 @@ vfs_write_suspend(mp) int error; MNT_ILOCK(mp); - if (mp->mnt_kern_flag & MNTK_SUSPEND) { + if (mp->mnt_susp_owner == curthread) { MNT_IUNLOCK(mp); - return (0); + return (EALREADY); } + while (mp->mnt_kern_flag & MNTK_SUSPEND) + msleep(&mp->mnt_flag, MNT_MTX(mp), PUSER - 1, "wsuspfs", 0); mp->mnt_kern_flag |= MNTK_SUSPEND; + mp->mnt_susp_owner = curthread; if (mp->mnt_writeopcount > 0) (void) msleep(&mp->mnt_writeopcount, MNT_MTX(mp), (PUSER - 1)|PDROP, "suspwt", 0); @@ -1073,12 +1079,17 @@ vfs_write_resume(mp) MNT_ILOCK(mp); if ((mp->mnt_kern_flag & MNTK_SUSPEND) != 0) { + KASSERT(mp->mnt_susp_owner == curthread, ("mnt_susp_owner")); mp->mnt_kern_flag &= ~(MNTK_SUSPEND | MNTK_SUSPEND2 | MNTK_SUSPENDED); + mp->mnt_susp_owner = NULL; wakeup(&mp->mnt_writeopcount); wakeup(&mp->mnt_flag); - } - MNT_IUNLOCK(mp); + curthread->td_pflags &= ~TDP_IGNSUSP; + MNT_IUNLOCK(mp); + VFS_SUSP_CLEAN(mp); + } else + MNT_IUNLOCK(mp); } /* Modified: stable/7/sys/sys/mount.h ============================================================================== --- stable/7/sys/sys/mount.h Sat Feb 14 22:29:54 2009 (r188619) +++ stable/7/sys/sys/mount.h Sat Feb 14 23:02:21 2009 (r188620) @@ -175,6 +175,7 @@ struct mount { int mnt_holdcntwaiters; /* waits on hold count */ int mnt_secondary_writes; /* (i) # of secondary writes */ int mnt_secondary_accwrites;/* (i) secondary wr. starts */ + struct thread *mnt_susp_owner; /* (i) thread owning suspension */ #define mnt_endzero mnt_gjprovider char *mnt_gjprovider; /* gjournal provider name */ struct lock mnt_explock; /* vfs_export walkers lock */ @@ -539,6 +540,7 @@ typedef int vfs_extattrctl_t(struct moun typedef int vfs_mount_t(struct mount *mp, struct thread *td); typedef int vfs_sysctl_t(struct mount *mp, fsctlop_t op, struct sysctl_req *req); +typedef void vfs_susp_clean_t(struct mount *mp); struct vfsops { vfs_mount_t *vfs_mount; @@ -555,6 +557,7 @@ struct vfsops { vfs_uninit_t *vfs_uninit; vfs_extattrctl_t *vfs_extattrctl; vfs_sysctl_t *vfs_sysctl; + vfs_susp_clean_t *vfs_susp_clean; }; vfs_statfs_t __vfs_statfs; @@ -576,6 +579,9 @@ vfs_statfs_t __vfs_statfs; (*(MP)->mnt_op->vfs_extattrctl)(MP, C, FN, NS, N, P) #define VFS_SYSCTL(MP, OP, REQ) \ (*(MP)->mnt_op->vfs_sysctl)(MP, OP, REQ) +#define VFS_SUSP_CLEAN(MP) \ + ({if (*(MP)->mnt_op->vfs_susp_clean != NULL) \ + (*(MP)->mnt_op->vfs_susp_clean)(MP); }) extern int mpsafe_vfs; Modified: stable/7/sys/sys/proc.h ============================================================================== --- stable/7/sys/sys/proc.h Sat Feb 14 22:29:54 2009 (r188619) +++ stable/7/sys/sys/proc.h Sat Feb 14 23:02:21 2009 (r188620) @@ -378,6 +378,7 @@ do { \ #define TDP_NORUNNINGBUF 0x00040000 /* Ignore runningbufspace check */ #define TDP_WAKEUP 0x00080000 /* Don't sleep in umtx cond_wait */ #define TDP_INBDFLUSH 0x00100000 /* Already in BO_BDFLUSH, do not recurse */ +#define TDP_IGNSUSP 0x00800000 /* Permission to ignore the MNTK_SUSPEND* */ /* * Reasons that the current thread can not be run yet. Modified: stable/7/sys/ufs/ffs/ffs_extern.h ============================================================================== --- stable/7/sys/ufs/ffs/ffs_extern.h Sat Feb 14 22:29:54 2009 (r188619) +++ stable/7/sys/ufs/ffs/ffs_extern.h Sat Feb 14 23:02:21 2009 (r188620) @@ -80,6 +80,7 @@ void ffs_snapremove(struct vnode *vp); int ffs_snapshot(struct mount *mp, char *snapfile); void ffs_snapshot_mount(struct mount *mp); void ffs_snapshot_unmount(struct mount *mp); +void process_deferred_inactive(struct mount *mp); int ffs_syncvnode(struct vnode *vp, int waitfor); int ffs_truncate(struct vnode *, off_t, int, struct ucred *, struct thread *); int ffs_update(struct vnode *, int); Modified: stable/7/sys/ufs/ffs/ffs_snapshot.c ============================================================================== --- stable/7/sys/ufs/ffs/ffs_snapshot.c Sat Feb 14 22:29:54 2009 (r188619) +++ stable/7/sys/ufs/ffs/ffs_snapshot.c Sat Feb 14 23:02:21 2009 (r188620) @@ -161,7 +161,6 @@ static int snapacct_ufs2(struct vnode *, static int mapacct_ufs2(struct vnode *, ufs2_daddr_t *, ufs2_daddr_t *, struct fs *, ufs_lbn_t, int); static int readblock(struct vnode *vp, struct buf *, ufs2_daddr_t); -static void process_deferred_inactive(struct mount *); static void try_free_snapdata(struct vnode *devvp, struct thread *td); static int ffs_bp_snapblk(struct vnode *, struct buf *); @@ -2429,12 +2428,14 @@ readblock(vp, bp, lbn) return (bp->b_error); } +#endif + /* * Process file deletes that were deferred by ufs_inactive() due to * the file system being suspended. Transfer IN_LAZYACCESS into * IN_MODIFIED for vnodes that were accessed during suspension. */ -static void +void process_deferred_inactive(struct mount *mp) { struct vnode *vp, *mvp; @@ -2507,6 +2508,8 @@ process_deferred_inactive(struct mount * vn_finished_secondary_write(mp); } +#ifndef NO_FFS_SNAPSHOT + /* Try to free snapdata associated with devvp */ static void try_free_snapdata(struct vnode *devvp, Modified: stable/7/sys/ufs/ffs/ffs_vfsops.c ============================================================================== --- stable/7/sys/ufs/ffs/ffs_vfsops.c Sat Feb 14 22:29:54 2009 (r188619) +++ stable/7/sys/ufs/ffs/ffs_vfsops.c Sat Feb 14 23:02:21 2009 (r188620) @@ -105,6 +105,7 @@ static struct vfsops ufs_vfsops = { .vfs_uninit = ffs_uninit, .vfs_unmount = ffs_unmount, .vfs_vget = ffs_vget, + .vfs_susp_clean = process_deferred_inactive, }; VFS_SET(ufs_vfsops, ufs, 0); From owner-svn-src-stable@FreeBSD.ORG Sat Feb 14 23:22:38 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5A3BD10656C7; Sat, 14 Feb 2009 23:22:38 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 4666B8FC1C; Sat, 14 Feb 2009 23:22:38 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n1ENMcrY033269; Sat, 14 Feb 2009 23:22:38 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n1ENMcpo033268; Sat, 14 Feb 2009 23:22:38 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <200902142322.n1ENMcpo033268@svn.freebsd.org> From: Konstantin Belousov Date: Sat, 14 Feb 2009 23:22:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r188623 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb ufs/ffs X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Feb 2009 23:22:40 -0000 Author: kib Date: Sat Feb 14 23:22:37 2009 New Revision: 188623 URL: http://svn.freebsd.org/changeset/base/188623 Log: MFC r183074: Suspend the write operations on the UFS filesystem being unmounted or remounted from rw to ro. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/ufs/ffs/ffs_vfsops.c Modified: stable/7/sys/ufs/ffs/ffs_vfsops.c ============================================================================== --- stable/7/sys/ufs/ffs/ffs_vfsops.c Sat Feb 14 23:20:00 2009 (r188622) +++ stable/7/sys/ufs/ffs/ffs_vfsops.c Sat Feb 14 23:22:37 2009 (r188623) @@ -189,14 +189,35 @@ ffs_mount(struct mount *mp, struct threa devvp = ump->um_devvp; if (fs->fs_ronly == 0 && vfs_flagopt(mp->mnt_optnew, "ro", NULL, 0)) { - if ((error = vn_start_write(NULL, &mp, V_WAIT)) != 0) - return (error); /* - * Flush any dirty data. + * Flush any dirty data and suspend filesystem. */ - if ((error = ffs_sync(mp, MNT_WAIT, td)) != 0) { - vn_finished_write(mp); + if ((error = vn_start_write(NULL, &mp, V_WAIT)) != 0) return (error); + for (;;) { + vn_finished_write(mp); + if ((error = vfs_write_suspend(mp)) != 0) + return (error); + MNT_ILOCK(mp); + if (mp->mnt_kern_flag & MNTK_SUSPENDED) { + /* + * Allow the secondary writes + * to proceed. + */ + mp->mnt_kern_flag &= ~(MNTK_SUSPENDED | + MNTK_SUSPEND2); + wakeup(&mp->mnt_flag); + MNT_IUNLOCK(mp); + /* + * Allow the curthread to + * ignore the suspension to + * synchronize on-disk state. + */ + curthread->td_pflags |= TDP_IGNSUSP; + break; + } + MNT_IUNLOCK(mp); + vn_start_write(NULL, &mp, V_WAIT); } /* * Check for and optionally get rid of files open @@ -211,7 +232,7 @@ ffs_mount(struct mount *mp, struct threa error = ffs_flushfiles(mp, flags, td); } if (error) { - vn_finished_write(mp); + vfs_write_resume(mp); return (error); } if (fs->fs_pendingblocks != 0 || @@ -228,10 +249,9 @@ ffs_mount(struct mount *mp, struct threa if ((error = ffs_sbupdate(ump, MNT_WAIT, 0)) != 0) { fs->fs_ronly = 0; fs->fs_clean = 0; - vn_finished_write(mp); + vfs_write_resume(mp); return (error); } - vn_finished_write(mp); DROP_GIANT(); g_topology_lock(); g_access(ump->um_cp, 0, -1, 0); @@ -241,6 +261,11 @@ ffs_mount(struct mount *mp, struct threa MNT_ILOCK(mp); mp->mnt_flag |= MNT_RDONLY; MNT_IUNLOCK(mp); + /* + * Allow the writers to note that filesystem + * is ro now. + */ + vfs_write_resume(mp); } if ((mp->mnt_flag & MNT_RELOAD) && (error = ffs_reload(mp, td)) != 0) @@ -1004,12 +1029,15 @@ ffs_unmount(mp, mntflags, td) { struct ufsmount *ump = VFSTOUFS(mp); struct fs *fs; - int error, flags; + int error, flags, susp; flags = 0; + fs = ump->um_fs; if (mntflags & MNT_FORCE) { flags |= FORCECLOSE; - } + susp = fs->fs_ronly != 0; + } else + susp = 0; #ifdef UFS_EXTATTR if ((error = ufs_extattr_stop(mp, td))) { if (error != EOPNOTSUPP) @@ -1019,14 +1047,34 @@ ffs_unmount(mp, mntflags, td) ufs_extattr_uepm_destroy(&ump->um_extattr); } #endif + if (susp) { + /* + * dounmount already called vn_start_write(). + */ + for (;;) { + vn_finished_write(mp); + if ((error = vfs_write_suspend(mp)) != 0) + return (error); + MNT_ILOCK(mp); + if (mp->mnt_kern_flag & MNTK_SUSPENDED) { + mp->mnt_kern_flag &= ~(MNTK_SUSPENDED | + MNTK_SUSPEND2); + wakeup(&mp->mnt_flag); + MNT_IUNLOCK(mp); + curthread->td_pflags |= TDP_IGNSUSP; + break; + } + MNT_IUNLOCK(mp); + vn_start_write(NULL, &mp, V_WAIT); + } + } if (mp->mnt_flag & MNT_SOFTDEP) { if ((error = softdep_flushfiles(mp, flags, td)) != 0) - return (error); + goto fail; } else { if ((error = ffs_flushfiles(mp, flags, td)) != 0) - return (error); + goto fail; } - fs = ump->um_fs; UFS_LOCK(ump); if (fs->fs_pendingblocks != 0 || fs->fs_pendinginodes != 0) { printf("%s: unmount pending error: blocks %jd files %d\n", @@ -1041,9 +1089,13 @@ ffs_unmount(mp, mntflags, td) error = ffs_sbupdate(ump, MNT_WAIT, 0); if (error) { fs->fs_clean = 0; - return (error); + goto fail; } } + if (susp) { + vfs_write_resume(mp); + vn_start_write(NULL, &mp, V_WAIT); + } DROP_GIANT(); g_topology_lock(); g_vfs_close(ump->um_cp, td); @@ -1063,6 +1115,13 @@ ffs_unmount(mp, mntflags, td) mp->mnt_flag &= ~MNT_LOCAL; MNT_IUNLOCK(mp); return (error); + +fail: + if (susp) { + vfs_write_resume(mp); + vn_start_write(NULL, &mp, V_WAIT); + } + return (error); } /* From owner-svn-src-stable@FreeBSD.ORG Sat Feb 14 23:45:24 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 70651106566C; Sat, 14 Feb 2009 23:45:24 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 5CF258FC1A; Sat, 14 Feb 2009 23:45:24 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n1ENjOBA033695; Sat, 14 Feb 2009 23:45:24 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n1ENjO96033694; Sat, 14 Feb 2009 23:45:24 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <200902142345.n1ENjO96033694@svn.freebsd.org> From: Konstantin Belousov Date: Sat, 14 Feb 2009 23:45:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r188624 - in stable/7/sys: . contrib/pf dev/cxgb ufs/ffs X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Feb 2009 23:45:25 -0000 Author: kib Date: Sat Feb 14 23:45:24 2009 New Revision: 188624 URL: http://svn.freebsd.org/changeset/base/188624 Log: MFC r186897: If unmount of the ffs mp failed, reinitialize the extended attributes for the mp, and restart them if autostart is enabled. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/ufs/ffs/ffs_vfsops.c Modified: stable/7/sys/ufs/ffs/ffs_vfsops.c ============================================================================== --- stable/7/sys/ufs/ffs/ffs_vfsops.c Sat Feb 14 23:22:37 2009 (r188623) +++ stable/7/sys/ufs/ffs/ffs_vfsops.c Sat Feb 14 23:45:24 2009 (r188624) @@ -1030,6 +1030,9 @@ ffs_unmount(mp, mntflags, td) struct ufsmount *ump = VFSTOUFS(mp); struct fs *fs; int error, flags, susp; +#ifdef UFS_EXTATTR + int e_restart; +#endif flags = 0; fs = ump->um_fs; @@ -1043,8 +1046,10 @@ ffs_unmount(mp, mntflags, td) if (error != EOPNOTSUPP) printf("ffs_unmount: ufs_extattr_stop returned %d\n", error); + e_restart = 0; } else { ufs_extattr_uepm_destroy(&ump->um_extattr); + e_restart = 1; } #endif if (susp) { @@ -1121,6 +1126,15 @@ fail: vfs_write_resume(mp); vn_start_write(NULL, &mp, V_WAIT); } +#ifdef UFS_EXTATTR + if (e_restart) { + ufs_extattr_uepm_init(&ump->um_extattr); +#ifdef UFS_EXTATTR_AUTOSTART + (void) ufs_extattr_autostart(mp, td); +#endif + } +#endif + return (error); } From owner-svn-src-stable@FreeBSD.ORG Sat Feb 14 23:48:26 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7D5CD106564A; Sat, 14 Feb 2009 23:48:26 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 6B3CC8FC1E; Sat, 14 Feb 2009 23:48:26 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n1ENmQPo033779; Sat, 14 Feb 2009 23:48:26 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n1ENmQ89033778; Sat, 14 Feb 2009 23:48:26 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <200902142348.n1ENmQ89033778@svn.freebsd.org> From: Konstantin Belousov Date: Sat, 14 Feb 2009 23:48:26 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r188625 - stable/7/sys/sys X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Feb 2009 23:48:27 -0000 Author: kib Date: Sat Feb 14 23:48:26 2009 New Revision: 188625 URL: http://svn.freebsd.org/changeset/base/188625 Log: Bump __FreeBSD_version after the r188620, that changed struct mount and struct vfsops. Modified: stable/7/sys/sys/param.h Modified: stable/7/sys/sys/param.h ============================================================================== --- stable/7/sys/sys/param.h Sat Feb 14 23:45:24 2009 (r188624) +++ stable/7/sys/sys/param.h Sat Feb 14 23:48:26 2009 (r188625) @@ -57,7 +57,7 @@ * is created, otherwise 1. */ #undef __FreeBSD_version -#define __FreeBSD_version 701103 /* Master, propagated to newvers */ +#define __FreeBSD_version 701104 /* Master, propagated to newvers */ #ifndef LOCORE #include